/** * Get {@link SystemFactory} instances for all the systems defined in this config. * * @return a map from system name to {@link SystemFactory} */ public Map<String, SystemFactory> getSystemFactories() { Map<String, SystemFactory> systemFactories = getSystemNames().stream().collect(Collectors.toMap( systemName -> systemName, systemName -> { String systemFactoryClassName = getSystemFactory(systemName); if (systemFactoryClassName == null) { throw new SamzaException( String.format("A stream uses system %s, which is missing from the configuration.", systemName)); } return Util.getObj(systemFactoryClassName, SystemFactory.class); })); return systemFactories; }
/** * Get {@link SystemFactory} instances for all the systems defined in this config. * * @return a map from system name to {@link SystemFactory} */ public Map<String, SystemFactory> getSystemFactories() { Map<String, SystemFactory> systemFactories = getSystemNames().stream().collect(Collectors.toMap( systemName -> systemName, systemName -> { String systemFactoryClassName = getSystemFactory(systemName); if (systemFactoryClassName == null) { throw new SamzaException( String.format("A stream uses system %s, which is missing from the configuration.", systemName)); } return Util.getObj(systemFactoryClassName, SystemFactory.class); })); return systemFactories; }
/** * Get {@link SystemFactory} instances for all the systems defined in this config. * * @return a map from system name to {@link SystemFactory} */ public Map<String, SystemFactory> getSystemFactories() { Map<String, SystemFactory> systemFactories = getSystemNames().stream().collect(Collectors.toMap( systemName -> systemName, systemName -> { String systemFactoryClassName = getSystemFactory(systemName); if (systemFactoryClassName == null) { throw new SamzaException( String.format("A stream uses system %s, which is missing from the configuration.", systemName)); } return Util.getObj(systemFactoryClassName, SystemFactory.class); })); return systemFactories; }
/** * Get {@link SystemFactory} instances for all the systems defined in this config. * * @return a map from system name to {@link SystemFactory} */ public Map<String, SystemFactory> getSystemFactories() { Map<String, SystemFactory> systemFactories = getSystemNames().stream().collect(Collectors.toMap( systemName -> systemName, systemName -> { String systemFactoryClassName = getSystemFactory(systemName); if (systemFactoryClassName == null) { throw new SamzaException( String.format("A stream uses system %s, which is missing from the configuration.", systemName)); } return Util.getObj(systemFactoryClassName, SystemFactory.class); })); return systemFactories; }
/** * Get {@link SystemFactory} instances for all the systems defined in this config. * * @return a map from system name to {@link SystemFactory} */ public Map<String, SystemFactory> getSystemFactories() { Map<String, SystemFactory> systemFactories = getSystemNames().stream().collect(Collectors.toMap( systemName -> systemName, systemName -> { String systemFactoryClassName = getSystemFactory(systemName); if (systemFactoryClassName == null) { throw new SamzaException( String.format("A stream uses system %s, which is missing from the configuration.", systemName)); } return Util.getObj(systemFactoryClassName, SystemFactory.class); })); return systemFactories; }
@Test public void testGetEmptyClassNameAsNull() { Map<String, String> map = new HashMap<String, String>(); map.put(MOCK_SYSTEM_FACTORY_NAME1, ""); map.put(MOCK_SYSTEM_FACTORY_NAME2, " "); JavaSystemConfig systemConfig = new JavaSystemConfig(new MapConfig(map)); assertNull(systemConfig.getSystemFactory(MOCK_SYSTEM_NAME1)); assertNull(systemConfig.getSystemFactory(MOCK_SYSTEM_NAME2)); }
@Test public void testClassName() { Map<String, String> map = new HashMap<String, String>(); map.put(MOCK_SYSTEM_FACTORY_NAME1, MOCK_SYSTEM_FACTORY_CLASSNAME1); JavaSystemConfig systemConfig = new JavaSystemConfig(new MapConfig(map)); assertEquals(MOCK_SYSTEM_FACTORY_CLASSNAME1, systemConfig.getSystemFactory(MOCK_SYSTEM_NAME1)); }