Translate storm config to heron config for components
@param stormConfig the storm config
@return a heron config
481791
@SuppressWarnings({"rawtypes", "unchecked"})
  public static Config translateComponentConfig(Map stormConfig) {
    Config heronConfig;
    if (stormConfig != null) {
      heronConfig = new Config((Map<String, Object>) stormConfig);
    } else {
      heronConfig = new Config();
    }

    doStormTranslation(heronConfig);

    return heronConfig;
  }
22997
public static Map<String, Object> getInnerLayerConfigFromConfig(Map<String, Object> layerConfig, KerasLayerConfiguration conf)
            throws InvalidKerasConfigurationException {
        if (!layerConfig.containsKey(conf.getLAYER_FIELD_CONFIG()))
            throw new InvalidKerasConfigurationException("Field "
                    + conf.getLAYER_FIELD_CONFIG() + " missing from layer config");
        return (Map<String, Object>) layerConfig.get(conf.getLAYER_FIELD_CONFIG());
    }
531113
public Protos.TaskInfo constructMesosTaskInfo(Config heronConfig, Config heronRuntime) {
    //String taskIdStr, BaseContainer task, Offer offer
    String taskIdStr = this.taskId;

    Protos.TaskID mesosTaskID = Protos.TaskID.newBuilder().setValue(taskIdStr).build();
    Protos.TaskInfo.Builder taskInfo = Protos.TaskInfo.newBuilder()
        .setName(baseContainer.name)
        .setTaskId(mesosTaskID);
    Protos.Environment.Builder environment = Protos.Environment.newBuilder();

    // If the job defines custom environment variables, add them to the builder
    // Don't add them if they already exist to prevent overwriting the defaults
    Set<String> builtinEnvNames = new HashSet<>();
    for (Protos.Environment.Variable variable : environment.getVariablesList()) {
      builtinEnvNames.add(variable.getName());
    }

    for (BaseContainer.EnvironmentVariable ev : baseContainer.environmentVariables) {
      environment.addVariables(
          Protos.Environment.Variable.newBuilder().setName(ev.name).setValue(ev.value));
    }

    taskInfo
        .addResources(scalarResource(TaskResources.CPUS_RESOURCE_NAME, baseContainer.cpu))
        .addResources(scalarResource(TaskResources.MEM_RESOURCE_NAME, baseContainer.memInMB))
        .addResources(scalarResource(TaskResources.DISK_RESOURCE_NAME, baseContainer.diskInMB))
        .addResources(rangeResource(TaskResources.PORT_RESOURCE_NAME,
            this.freePorts.get(0), this.freePorts.get(this.freePorts.size() - 1))).
        setSlaveId(this.offer.getSlaveId());

    int containerIndex = TaskUtils.getContainerIndexForTaskId(taskIdStr);
    String commandStr = executorCommand(heronConfig, heronRuntime, containerIndex);

    Protos.CommandInfo.Builder command = Protos.CommandInfo.newBuilder();

    List<Protos.CommandInfo.URI> uriProtos = new ArrayList<>();
    for (String uri : baseContainer.dependencies) {
      uriProtos.add(Protos.CommandInfo.URI.newBuilder()
          .setValue(uri)
          .setExtract(true)
          .build());
    }

    command.setValue(commandStr)
        .setShell(baseContainer.shell)
        .setEnvironment(environment)
        .addAllUris(uriProtos);

    if (!baseContainer.runAsUser.isEmpty()) {
      command.setUser(baseContainer.runAsUser);
    }
    taskInfo.setCommand(command);

    return taskInfo.build();
  }
1003276
public static ConfigBuilder configBuilder() {
    return new ConfigBuilder(new StringReader(""), new StringWriter(),
        EMPTY_CONNECTION_FACTORY, EMPTY_COMMAND_HANDLER,
        EMPTY_PROPERTY_HANDLER, EMPTY_ENV, DEFAULT_MAX_STACK_LENGTH);
  }
974039
public static ValidatedConformanceConfig create(ConformanceConfig config) {
    ImmutableList.Builder<RuleWithWhitelists> rulesBuilder = new ImmutableList.Builder<>();
    for (Requirement requirement : config.getRequirementList()) {
      Preconditions.checkArgument(
          !requirement.getErrorMessage().isEmpty(), "requirement missing error message");
      Preconditions.checkArgument(
          requirement.getRequirementTypeCase() != RequirementTypeCase.REQUIREMENTTYPE_NOT_SET,
          "requirement missing type");
      Rule<? extends Node> rule = forRequirement(requirement);
      ImmutableList<String> whitelists = ImmutableList.copyOf(requirement.getWhitelistList());
      ImmutableList<String> onlyApplyToPaths =
          ImmutableList.copyOf(requirement.getOnlyApplyToList());
      rulesBuilder.add(RuleWithWhitelists.create(rule, whitelists, onlyApplyToPaths));
    }
    return new ValidatedConformanceConfig(rulesBuilder.build());
  }
797422
@SuppressWarnings({ "rawtypes", "unchecked" })
	public Map getMap(NodeConfig nodeConfig) {
		Map map = new HashMap();
		List<AttributeConfig> attributes = nodeConfig.getAttribute();
		map.putAll(getAttribute(attributes));

		List<NodeConfig> childrenNodes = nodeConfig.getChildrenNodes();
		if (childrenNodes != null && childrenNodes.size() > 0) {
			for (NodeConfig childNode : childrenNodes) {
				String name = childNode.getName();
				Object value = childNode.getValue();

				if (childNode.hasChildren()) {
					Map childNodeMap = getMap(childNode);
					map.put(name, addToList(map.get(name), childNodeMap));
				} else {
					if (childNode.hasAttributes()) {
						Map attributeMap = new HashMap();
						attributeMap = getAttribute(childNode.getAttribute());
						if (attributeMap.size() > 0) {
							if (value != null && value instanceof String) {
								attributeMap.put("nodeValue", value);
							}
							value = attributeMap;
						}
					}
				}

				if (value != null) {
					map.put(name, addToList(map.get(name), value));
				}
			}
		}
		if (nodeConfig.getName() != null && nodeConfig.getValue() != null) {
			map.put(nodeConfig.getName(), nodeConfig.getValue());
		}
		return map;
	}
320261
public HadoopJarStepConfig toHadoopJarStepConfig() {
    List<String> args = new ArrayList<String>();

    if (reducer == null) {
      hadoopConfig.put("mapred.reduce.tasks", "0");
    }

    for (Map.Entry<String, String> entry : hadoopConfig.entrySet()) {
      args.add("-D");
      args.add(entry.getKey() + "=" + entry.getValue());
    }

    for (String input : inputs) {
      args.add("-input");
      args.add(input);
    }

    if (output != null) {
      args.add("-output");
      args.add(output);
    }

    if (mapper != null) {
      args.add("-mapper");
      args.add(mapper);
    }

    if (reducer != null) {
      args.add("-reducer");
      args.add(reducer);
    }

    return new HadoopJarStepConfig()
      .withJar("/home/hadoop/contrib/streaming/hadoop-streaming.jar")
      .withArgs(args);
  }
1286355
public static DynamicConfigGenerator createDynamicConfigGenerator(Config config) {
    String dynamicConfigGeneratorClassName =
        ConfigUtils.getString(config, ConfigurationKeys.DYNAMIC_CONFIG_GENERATOR_CLASS_KEY,
            ConfigurationKeys.DEFAULT_DYNAMIC_CONFIG_GENERATOR_CLASS_KEY);

    try {
      ClassAliasResolver<DynamicConfigGenerator> aliasResolver =
          new ClassAliasResolver<>(DynamicConfigGenerator.class);
      return aliasResolver.resolveClass(dynamicConfigGeneratorClassName).newInstance();
    } catch (ReflectiveOperationException e) {
      throw new RuntimeException("Could not construct DynamicConfigGenerator " +
          dynamicConfigGeneratorClassName, e);
    }
  }
1291178
public static EbeanParsedConfig parseFromConfig(Config config) {
        Config playEbeanConfig = config.getConfig("play.ebean");
        String defaultDatasource = playEbeanConfig.getString("defaultDatasource");
        String ebeanConfigKey = playEbeanConfig.getString("config");

        Map<String, List<String>> datasourceModels = new HashMap<>();

        if (config.hasPath(ebeanConfigKey)) {
            Config ebeanConfig = config.getConfig(ebeanConfigKey);
            ebeanConfig.root().forEach((key, raw) -> {
                List<String> models;
                if (raw.valueType() == ConfigValueType.STRING) {
                    // Support legacy comma separated string
                    models = Arrays.asList(((String) raw.unwrapped()).split(","));
                } else {
                    models = ebeanConfig.getStringList(key);
                }

                datasourceModels.put(key, models);
            });
        }
        return new EbeanParsedConfig(defaultDatasource, datasourceModels);
    }
529391
public static RedissonRxClient createRx(Config config) {
        RedissonRx react = new RedissonRx(config);
        if (config.isReferenceEnabled()) {
            react.enableRedissonReferenceSupport();
        }
        return react;
    }
768378
public static FailoverStrategy.Factory loadFailoverStrategy(Configuration config, @Nullable Logger logger) {
		final String strategyParam = config.getString(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY);

		if (StringUtils.isNullOrWhitespaceOnly(strategyParam)) {
			if (logger != null) {
				logger.warn("Null config value for {} ; using default failover strategy (full restarts).",
						JobManagerOptions.EXECUTION_FAILOVER_STRATEGY.key());
			}

			return new RestartAllStrategy.Factory();
		}
		else {
			switch (strategyParam.toLowerCase()) {
				case FULL_RESTART_STRATEGY_NAME:
					return new RestartAllStrategy.Factory();

				case PIPELINED_REGION_RESTART_STRATEGY_NAME:
					return new RestartPipelinedRegionStrategy.Factory();

				case INDIVIDUAL_RESTART_STRATEGY_NAME:
					return new RestartIndividualStrategy.Factory();

				default:
					// we could interpret the parameter as a factory class name and instantiate that
					// for now we simply do not support this
					throw new IllegalConfigurationException("Unknown failover strategy: " + strategyParam);
			}
		}
	}
1146813
public static IPrincipalToLocal GetPrincipalToLocalPlugin(Map storm_conf) {
        IPrincipalToLocal ptol = null;
        try {
            String ptol_klassName = (String) storm_conf.get(Config.STORM_PRINCIPAL_TO_LOCAL_PLUGIN);
            Class klass = Class.forName(ptol_klassName);
            ptol = (IPrincipalToLocal) klass.newInstance();
            ptol.prepare(storm_conf);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return ptol;
    }
57014
public static String getStringValue(Config stormConf, String key, String defaultValue)
    {
        Object config = stormConf.get(key);

        if (config == null)
        {
            return defaultValue;
        }

        return config.toString();
    }
748894
public FreemarkerConfigurationBuilder<MYSELF> configuration() {
		if (configurationBuilder == null) {
			configurationBuilder = new FreemarkerConfigurationBuilder<>(myself, environmentBuilder);
		}
		return configurationBuilder;
	}
400509
public CloudSdkConfig getConfig()
      throws CloudSdkNotFoundException, CloudSdkOutOfDateException, CloudSdkVersionFileException,
          IOException, ProcessHandlerException {
    sdk.validateCloudSdk();

    List<String> command =
        new ImmutableList.Builder<String>()
            .add("config", "list")
            .addAll(GcloudArgs.get("format", "json"))
            .build();

    String configJson = runCommand(command);
    return CloudSdkConfig.fromJson(configJson);
  }
1337918
private Configuration getClientConf() {
    return HeronClientConfiguration.CONF
        .set(ClientConfiguration.ON_JOB_RUNNING, ReefClientSideHandlers.RunningJobHandler.class)
        .set(ClientConfiguration.ON_JOB_FAILED, ReefClientSideHandlers.FailedJobHandler.class)
        .set(ClientConfiguration.ON_RUNTIME_ERROR, ReefClientSideHandlers.RuntimeErrorHandler.class)
        .set(HeronClientConfiguration.TOPOLOGY_NAME, topologyName)
        .build();
  }
1132624
public static Map<String, String> parseAttributes(final Configuration config) {
		Map<String, String> parameters = new HashMap<>();
		for (String key : new IterableIterator<>(config.getKeys())) {
			String value = config.getString(key);
			parameters.put(key, value);
		}
		return parameters;
	}