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;
}
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));
}
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");
}
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");
}
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());
}
Aggregations