/*
To be called by the forked process to load the generated links and Hadoop
configuration properties to automatically inject.

@param props The Azkaban properties
433465
public static void injectResources(Props props) {
    // Add mapred, yarn and hdfs site configs (in addition to core-site, which
    // is automatically added) as default resources before we add the injected
    // configuration. This will cause the injected properties to override the
    // default site properties (instead of vice-versa). This is safe to do,
    // even when these site files don't exist for your Hadoop installation.
    if (props.getBoolean("azkaban.inject.hadoop-site.configs", true)) {
      Configuration.addDefaultResource("mapred-default.xml");
      Configuration.addDefaultResource("mapred-site.xml");
      Configuration.addDefaultResource("yarn-default.xml");
      Configuration.addDefaultResource("yarn-site.xml");
      Configuration.addDefaultResource("hdfs-default.xml");
      Configuration.addDefaultResource("hdfs-site.xml");
    }
    Configuration.addDefaultResource(INJECT_FILE);
  }
925275
public void createTaskFieldMap(Props props)
   {
      byte[] fieldMapData = null;
      for (Integer key : TASK_KEYS)
      {
         fieldMapData = props.getByteArray(key);
         if (fieldMapData != null)
         {
            break;
         }
      }

      if (fieldMapData == null)
      {
         populateDefaultData(getDefaultTaskData());
      }
      else
      {
         createFieldMap(fieldMapData);
      }
   }
754322
public void createResourceFieldMap(Props props)
   {
      byte[] fieldMapData = null;
      for (Integer key : RESOURCE_KEYS)
      {
         fieldMapData = props.getByteArray(key);
         if (fieldMapData != null)
         {
            break;
         }
      }

      if (fieldMapData == null)
      {
         populateDefaultData(getDefaultResourceData());
      }
      else
      {
         createFieldMap(fieldMapData);
      }
   }
915772
@Override
	protected void loadConfig(Properties props, String path, InputStream is) {
		try {

			// load properties into a Properties object
			String jsonContent = IOUtils.toString(is);
			// create an ObjectMapper instance.
			ObjectMapper mapper = new ObjectMapper();
			mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES,
					true);

			// use the ObjectMapper to read the json string and create a tree
			JsonNode node = mapper.readTree(jsonContent);
			generateProperties(node, null, props);
		} catch (JsonParseException e) {

			throw new BundlingProcessException(
					"jawr configuration could not be loaded at " + path
							+ FIELD_NAME_SEPARATOR, e);
		} catch (IOException e) {
			throw new BundlingProcessException(
					"jawr configuration could not be loaded at " + path
							+ FIELD_NAME_SEPARATOR, e);
		}
	}
116875
protected void loadFromUrl(Properties props, URL url) {
		InputStream is = null;
		try {
			is = url.openStream();
			props.load(is);
		} catch (IOException ex) {
			if (log.isLoggable(Level.WARNING)) {
				log.log(Level.WARNING, ex.getMessage(), ex);
			}
		} finally {
			try { if (is != null) is.close(); } catch (IOException ignore) {}
		}
	}
989320
public void createAssignmentFieldMap(Props props)
   {
      //System.out.println("ASSIGN");
      byte[] fieldMapData = null;
      for (Integer key : ASSIGNMENT_KEYS)
      {
         fieldMapData = props.getByteArray(key);
         if (fieldMapData != null)
         {
            break;
         }
      }

      if (fieldMapData == null)
      {
         populateDefaultData(getDefaultAssignmentData());
      }
      else
      {
         createFieldMap(fieldMapData);
      }
   }
271588
public void addAllToProperties(Properties props) {
		synchronized (this.confData) {
			for (Map.Entry<String, Object> entry : this.confData.entrySet()) {
				props.put(entry.getKey(), entry.getValue());
			}
		}
	}
1238122
private void parseJITOnlyReads(Map<Object, Object> props) {
        Object value = props.get(HttpConfigConstants.PROPNAME_JIT_ONLY_READS);
        if (null != value) {
            this.bJITOnlyReads = convertBoolean(value);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Config: JIT only reads is " + isJITOnlyReads());
            }
        }
    }
137609
public KafkaClient setConsumerProperties(Properties props) {
        if (props == null) {
            consumerProperties = null;
        } else {
            consumerProperties = new Properties();
            consumerProperties.putAll(props);
        }
        return this;
    }
1017801
public void loadFromJson(final Properties props, final Reader rd) throws IOException {
		try {
			((PrefixedProperties) props).loadFromJSON(rd);
		} catch (final NoSuchMethodError err) {
			throw new IOException(
					"Cannot load properties JSON file - not using PrefixedProperties: " + err.getMessage());
		}
	}
414579
public static void fillBeanProperties(Object bean, Map<String, Object> props) {
        fillBeanProperties(bean, props, EMPTY_MAP);
    }
889889
public static synchronized final void init ( Properties props ) throws CIFSException {
        if ( INSTANCE != null ) {
            throw new CIFSException("Singleton context is already initialized");
        }
        Properties p = new Properties();
        try {
            String filename = System.getProperty("jcifs.properties");
            if ( filename != null && filename.length() > 1 ) {

                try ( FileInputStream in = new FileInputStream(filename) ) {
                    p.load(in);
                }
            }

        }
        catch ( IOException ioe ) {
            log.error("Failed to load config", ioe); //$NON-NLS-1$
        }
        p.putAll(System.getProperties());
        if ( props != null ) {
            p.putAll(props);
        }
        INSTANCE = new SingletonContext(p);
    }
1017358
public static ConfigurationLoader from(final Properties props) throws IOException {
        return new ConfigurationLoader(new Function<String, String>() {
            public String apply(String from) {
                return props.getProperty(from);
            }
        });
    }
1041878
public void init(final Map<String, Map<String, DataSourceConfiguration>> dataSourceConfigurationMap,
                     final Map<String, RuleConfiguration> schemaRuleMap, final Authentication authentication, final Properties props) {
        for (Entry<String, Map<String, DataSourceConfiguration>> entry : dataSourceConfigurationMap.entrySet()) {
            configService.persistConfiguration(entry.getKey(), dataSourceConfigurationMap.get(entry.getKey()), schemaRuleMap.get(entry.getKey()), authentication, props, isOverwrite);
        }
        stateService.persistInstanceOnline();
        stateService.persistDataSourcesNode();
        listenerManager.initListeners();
    }
416130
private void parseAllowRetries(Map<Object, Object> props) {
        Object value = props.get(HttpConfigConstants.PROPNAME_ALLOW_RETRIES);
        if (null != value) {
            this.bAllowRetries = convertBoolean(value);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Config: allow retries is " + allowsRetries());
            }
        }
    }
540076
@SuppressWarnings("rawtypes")
   public static HikariConfig loadConfiguration(Map props)
   {
      Properties hikariProps = new Properties();
      copyProperty(AvailableSettings.ISOLATION, props, "transactionIsolation", hikariProps);
      copyProperty(AvailableSettings.AUTOCOMMIT, props, "autoCommit", hikariProps);
      copyProperty(AvailableSettings.DRIVER, props, "driverClassName", hikariProps);
      copyProperty(AvailableSettings.URL, props, "jdbcUrl", hikariProps);
      copyProperty(AvailableSettings.USER, props, "username", hikariProps);
      copyProperty(AvailableSettings.PASS, props, "password", hikariProps);

      for (Object keyo : props.keySet()) {
         String key = (String) keyo;
         if (key.startsWith(CONFIG_PREFIX)) {
            hikariProps.setProperty(key.substring(CONFIG_PREFIX.length()), (String) props.get(key));
         }
      }

      return new HikariConfig(hikariProps);
   }
525354
public void processConfig(Dictionary<?, ?> props) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Session manager configuration updated");
        }
        this.myConfig.updated(props);

        String value = (String) props.get("purge.interval");
        if (null != value) {
            try {
                // convert the configuration in seconds to runtime milliseconds
                this.purgeInterval = Long.parseLong(value.trim());
            } catch (NumberFormatException nfe) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                    Tr.event(tc, "Ignoring incorrect purge interval [" + value + "]", nfe.getMessage());
                }
            }
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Config: purge interval [" + this.purgeInterval + "]");
        }
    }