Search in sources :

Example 66 with MapConfig

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

the class TestZkStreamProcessorBase method createStreamProcessor.

protected StreamProcessor createStreamProcessor(final String pId, Map<String, String> map, final Object mutexStart, final Object mutexStop) {
    map.put(ApplicationConfig.PROCESSOR_ID, pId);
    Config config = new MapConfig(map);
    JobCoordinator jobCoordinator = Util.<JobCoordinatorFactory>getObj(new JobCoordinatorConfig(config).getJobCoordinatorFactoryClassName()).getJobCoordinator(config);
    StreamProcessorLifecycleListener listener = new StreamProcessorLifecycleListener() {

        @Override
        public void onStart() {
            if (mutexStart != null) {
                synchronized (mutexStart) {
                    mutexStart.notifyAll();
                }
            }
            LOG.info("onStart is called for pid=" + pId);
        }

        @Override
        public void onShutdown() {
            if (mutexStop != null) {
                synchronized (mutexStart) {
                    mutexStart.notify();
                }
            }
            LOG.info("onShutdown is called for pid=" + pId);
        }

        @Override
        public void onFailure(Throwable t) {
            LOG.info("onFailure is called for pid=" + pId);
        }
    };
    StreamProcessor processor = new StreamProcessor(config, new HashMap<>(), (StreamTaskFactory) TestStreamTask::new, listener, jobCoordinator);
    return processor;
}
Also used : ApplicationConfig(org.apache.samza.config.ApplicationConfig) MapConfig(org.apache.samza.config.MapConfig) ZkConfig(org.apache.samza.config.ZkConfig) JobCoordinatorConfig(org.apache.samza.config.JobCoordinatorConfig) Config(org.apache.samza.config.Config) JobCoordinator(org.apache.samza.coordinator.JobCoordinator) JobCoordinatorConfig(org.apache.samza.config.JobCoordinatorConfig) MapConfig(org.apache.samza.config.MapConfig)

Example 67 with MapConfig

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

the class TestFileSystemImplConfig method testFileSystemImplConfigSuccess.

@Test
public void testFileSystemImplConfigSuccess() {
    Map<String, String> configMap = new HashMap<>();
    configMap.put("fs.http.impl", "org.apache.samza.HttpFileSystem");
    configMap.put("fs.myscheme.impl", "org.apache.samza.MySchemeFileSystem");
    Config conf = new MapConfig(configMap);
    FileSystemImplConfig manager = new FileSystemImplConfig(conf);
    assertEquals(2, manager.getSchemes().size());
    assertEquals("http", manager.getSchemes().get(0));
    assertEquals("myscheme", manager.getSchemes().get(1));
}
Also used : HashMap(java.util.HashMap) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Example 68 with MapConfig

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

the class TestLocalizerResourceConfig method testInvalidType.

@Test
public void testInvalidType() {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("No enum constant org.apache.hadoop.yarn.api.records.LocalResourceType.INVALIDTYPE");
    Map<String, String> configMap = new HashMap<>();
    configMap.put("yarn.resources.myResource1.path", "http://host1.com/readme");
    configMap.put("yarn.resources.myResource1.local.name", "readme");
    configMap.put("yarn.resources.myResource1.local.type", "invalidType");
    configMap.put("yarn.resources.myResource1.local.visibility", "application");
    Config conf = new MapConfig(configMap);
    LocalizerResourceConfig manager = new LocalizerResourceConfig(conf);
    manager.getResourceLocalType("myResource1");
}
Also used : HashMap(java.util.HashMap) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Example 69 with MapConfig

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

the class TestLocalizerResourceConfig method testInvalidVisibility.

@Test
public void testInvalidVisibility() {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("No enum constant org.apache.hadoop.yarn.api.records.LocalResourceVisibility.INVALIDVISIBILITY");
    Map<String, String> configMap = new HashMap<>();
    configMap.put("yarn.resources.myResource1.path", "http://host1.com/readme");
    configMap.put("yarn.resources.myResource1.local.name", "readme");
    configMap.put("yarn.resources.myResource1.local.type", "file");
    configMap.put("yarn.resources.myResource1.local.visibility", "invalidVisibility");
    Config conf = new MapConfig(configMap);
    LocalizerResourceConfig manager = new LocalizerResourceConfig(conf);
    manager.getResourceLocalVisibility("myResource1");
}
Also used : HashMap(java.util.HashMap) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Example 70 with MapConfig

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

the class TestLocalizerResourceMapper method testResourceMapWithDefaultValues.

@Test
public void testResourceMapWithDefaultValues() {
    Map<String, String> configMap = new HashMap<>();
    configMap.put("yarn.resources.myResource1.path", "http://host1.com/readme");
    Config conf = new MapConfig(configMap);
    YarnConfiguration yarnConfiguration = new YarnConfiguration();
    yarnConfiguration.set("fs.http.impl", HttpFileSystem.class.getName());
    LocalizerResourceMapper mapper = new LocalizerResourceMapper(new LocalizerResourceConfig(conf), yarnConfiguration);
    Map<String, LocalResource> resourceMap = mapper.getResourceMap();
    assertNull("Resource does not exist with a name readme", resourceMap.get("readme"));
    assertNotNull("Resource exists with a name myResource1", resourceMap.get("myResource1"));
    assertEquals("host1.com", resourceMap.get("myResource1").getResource().getHost());
    assertEquals(LocalResourceType.FILE, resourceMap.get("myResource1").getType());
    assertEquals(LocalResourceVisibility.APPLICATION, resourceMap.get("myResource1").getVisibility());
}
Also used : HashMap(java.util.HashMap) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) HttpFileSystem(org.apache.samza.util.hadoop.HttpFileSystem) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) Test(org.junit.Test)

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