Search in sources :

Example 76 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class TestTasksResource method configure.

@Override
protected Application configure() {
    Map<String, String> configMap = ImmutableMap.of(TaskResourceConfig.CONFIG_TASK_PROXY_FACTORY, MockTaskProxyFactory.class.getName(), SamzaRestConfig.CONFIG_REST_RESOURCE_FACTORIES, MockResourceFactory.class.getName());
    SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
    return new SamzaRestApplication(config);
}
Also used : SamzaRestConfig(org.apache.samza.rest.SamzaRestConfig) SamzaRestApplication(org.apache.samza.rest.SamzaRestApplication) MapConfig(org.apache.samza.config.MapConfig) MockTaskProxyFactory(org.apache.samza.rest.resources.mock.MockTaskProxyFactory) MockResourceFactory(org.apache.samza.rest.resources.mock.MockResourceFactory)

Example 77 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class TestJobsResource method configure.

@Override
protected Application configure() {
    Map<String, String> configMap = ImmutableMap.of(JobsResourceConfig.CONFIG_JOB_PROXY_FACTORY, MockJobProxyFactory.class.getName(), SamzaRestConfig.CONFIG_REST_RESOURCE_FACTORIES, MockResourceFactory.class.getName());
    SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
    return new SamzaRestApplication(config);
}
Also used : SamzaRestConfig(org.apache.samza.rest.SamzaRestConfig) SamzaRestApplication(org.apache.samza.rest.SamzaRestApplication) MapConfig(org.apache.samza.config.MapConfig) MockJobProxyFactory(org.apache.samza.rest.resources.mock.MockJobProxyFactory) MockResourceFactory(org.apache.samza.rest.resources.mock.MockResourceFactory)

Example 78 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class JobNode method extractScopedConfig.

/**
   * This function extract the subset of configs from the full config, and use it to override the generated configs
   * from the job.
   * @param fullConfig full config
   * @param generatedConfig config generated for the job
   * @param configPrefix prefix to extract the subset of the config overrides
   * @return config that merges the generated configs and overrides
   */
private static Config extractScopedConfig(Config fullConfig, Config generatedConfig, String configPrefix) {
    Config scopedConfig = fullConfig.subset(configPrefix);
    Config[] configPrecedence = new Config[] { fullConfig, generatedConfig, scopedConfig };
    // Strip empty configs so they don't override the configs before them.
    Map<String, String> mergedConfig = new HashMap<>();
    for (Map<String, String> config : configPrecedence) {
        for (Map.Entry<String, String> property : config.entrySet()) {
            String value = property.getValue();
            if (!(value == null || value.isEmpty())) {
                mergedConfig.put(property.getKey(), property.getValue());
            }
        }
    }
    scopedConfig = new MapConfig(mergedConfig);
    log.debug("Prefix '{}' has merged config {}", configPrefix, scopedConfig);
    return scopedConfig;
}
Also used : HashMap(java.util.HashMap) TaskConfig(org.apache.samza.config.TaskConfig) JobConfig(org.apache.samza.config.JobConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) HashMap(java.util.HashMap) Map(java.util.Map)

Example 79 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class JobNode method generateConfig.

/**
   * Generate the configs for a job
   * @param executionPlanJson JSON representation of the execution plan
   * @return config of the job
   */
public JobConfig generateConfig(String executionPlanJson) {
    Map<String, String> configs = new HashMap<>();
    configs.put(JobConfig.JOB_NAME(), jobName);
    List<String> inputs = inEdges.stream().map(edge -> edge.getFormattedSystemStream()).collect(Collectors.toList());
    configs.put(TaskConfig.INPUT_STREAMS(), Joiner.on(',').join(inputs));
    // set triggering interval if a window or join is defined
    if (streamGraph.hasWindowOrJoins()) {
        if ("-1".equals(config.get(TaskConfig.WINDOW_MS(), "-1"))) {
            long triggerInterval = computeTriggerInterval();
            log.info("Using triggering interval: {} for jobName: {}", triggerInterval, jobName);
            configs.put(TaskConfig.WINDOW_MS(), String.valueOf(triggerInterval));
        }
    }
    log.info("Job {} has generated configs {}", jobName, configs);
    configs.put(CONFIG_INTERNAL_EXECUTION_PLAN, executionPlanJson);
    String configPrefix = String.format(CONFIG_JOB_PREFIX, jobName);
    // TODO: Disallow user specifying job inputs/outputs. This info comes strictly from the pipeline.
    return new JobConfig(Util.rewriteConfig(extractScopedConfig(config, new MapConfig(configs), configPrefix)));
}
Also used : Util(org.apache.samza.util.Util) Logger(org.slf4j.Logger) TaskConfig(org.apache.samza.config.TaskConfig) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) JobConfig(org.apache.samza.config.JobConfig) WindowOperatorSpec(org.apache.samza.operators.spec.WindowOperatorSpec) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) StreamGraphImpl(org.apache.samza.operators.StreamGraphImpl) MathUtils(org.apache.samza.operators.util.MathUtils) List(java.util.List) OperatorSpec(org.apache.samza.operators.spec.OperatorSpec) PartialJoinOperatorSpec(org.apache.samza.operators.spec.PartialJoinOperatorSpec) Map(java.util.Map) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) Joiner(com.google.common.base.Joiner) HashMap(java.util.HashMap) MapConfig(org.apache.samza.config.MapConfig) JobConfig(org.apache.samza.config.JobConfig)

Example 80 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class StateStorageTool method main.

public static void main(String[] args) {
    StateStorageTool tool = new StateStorageTool();
    OptionSet options = tool.parser().parse(args);
    MapConfig config = tool.loadConfig(options);
    String path = tool.getPath();
    StorageRecovery storageRecovery = new StorageRecovery(config, path);
    storageRecovery.run();
}
Also used : MapConfig(org.apache.samza.config.MapConfig) OptionSet(joptsimple.OptionSet)

Aggregations

MapConfig (org.apache.samza.config.MapConfig)80 Test (org.junit.Test)60 HashMap (java.util.HashMap)51 Config (org.apache.samza.config.Config)51 JobConfig (org.apache.samza.config.JobConfig)21 StreamApplication (org.apache.samza.application.StreamApplication)8 TaskConfig (org.apache.samza.config.TaskConfig)8 StreamGraphImpl (org.apache.samza.operators.StreamGraphImpl)8 SamzaException (org.apache.samza.SamzaException)7 ApplicationConfig (org.apache.samza.config.ApplicationConfig)7 HashSet (java.util.HashSet)6 ConfigException (org.apache.samza.config.ConfigException)6 TaskName (org.apache.samza.container.TaskName)6 MetricsRegistryMap (org.apache.samza.metrics.MetricsRegistryMap)6 StreamProcessor (org.apache.samza.processor.StreamProcessor)6 StreamSpec (org.apache.samza.system.StreamSpec)6 SystemStreamPartition (org.apache.samza.system.SystemStreamPartition)6 HttpFileSystem (org.apache.samza.util.hadoop.HttpFileSystem)6 Field (java.lang.reflect.Field)5 Map (java.util.Map)5