SystemConfig extends MapConfig { public String getSystemOffsetDefault(String systemName) { String systemOffsetDefault = get(String.format("systems.%s.default.stream.samza.offset.default", systemName)); if (StringUtils.isBlank(systemOffsetDefault)) { systemOffsetDefault = get(String.format("systems.%s.samza.offset.default", systemName)); if (StringUtils.isBlank(systemOffsetDefault)) { return SAMZA_SYSTEM_OFFSET_UPCOMING; } } return systemOffsetDefault; } SystemConfig(Config config); Optional<String> getSystemFactory(String systemName); List<String> getSystemNames(); Map<String, SystemAdmin> getSystemAdmins(String adminLabel); Map<String, SystemAdmin> getSystemAdmins(); SystemAdmin getSystemAdmin(String systemName, String adminLabel); SystemAdmin getSystemAdmin(String systemName); Map<String, SystemFactory> getSystemFactories(); Config getDefaultStreamProperties(String systemName); String getSystemOffsetDefault(String systemName); Optional<String> getSystemKeySerde(String systemName); Optional<String> getSystemMsgSerde(String systemName); boolean deleteCommittedMessages(String systemName); static final String SYSTEM_ID_PREFIX; static final String SYSTEM_FACTORY_FORMAT; static final String SYSTEM_DEFAULT_STREAMS_PREFIX_FORMAT; }
@Test public void testGetSystemOffsetDefault() { String system1OffsetDefault = "offset-system-1"; String system2OffsetDefault = "offset-system-2"; Config config = new MapConfig(ImmutableMap.of( String.format(SystemConfig.SYSTEM_DEFAULT_STREAMS_PREFIX_FORMAT, MOCK_SYSTEM_NAME1) + SAMZA_OFFSET_DEFAULT, system1OffsetDefault, String.format(SystemConfig.SYSTEM_ID_PREFIX, MOCK_SYSTEM_NAME1) + SAMZA_OFFSET_DEFAULT, "wrong-value", String.format(SystemConfig.SYSTEM_ID_PREFIX, MOCK_SYSTEM_NAME2) + SAMZA_OFFSET_DEFAULT, system2OffsetDefault)); SystemConfig systemConfig = new SystemConfig(config); assertEquals(system1OffsetDefault, systemConfig.getSystemOffsetDefault(MOCK_SYSTEM_NAME1)); assertEquals(system2OffsetDefault, systemConfig.getSystemOffsetDefault(MOCK_SYSTEM_NAME2)); assertEquals(SystemConfig.SAMZA_SYSTEM_OFFSET_UPCOMING, systemConfig.getSystemOffsetDefault("other-system")); }