use of org.apache.samza.config.StreamConfig in project samza by apache.
the class DiagnosticsUtil method createDiagnosticsStream.
public static void createDiagnosticsStream(Config config) {
if (!new JobConfig(config).getDiagnosticsEnabled()) {
return;
}
// if diagnostics is enabled, create diagnostics stream if it doesnt exist
String diagnosticsSystemStreamName = new MetricsConfig(config).getMetricsSnapshotReporterStream(MetricsConfig.METRICS_SNAPSHOT_REPORTER_NAME_FOR_DIAGNOSTICS).orElseThrow(() -> new ConfigException("Missing required config: " + String.format(MetricsConfig.METRICS_SNAPSHOT_REPORTER_STREAM, MetricsConfig.METRICS_SNAPSHOT_REPORTER_NAME_FOR_DIAGNOSTICS)));
SystemStream diagnosticsSystemStream = StreamUtil.getSystemStreamFromNames(diagnosticsSystemStreamName);
SystemConfig systemConfig = new SystemConfig(config);
SystemAdmin diagnosticsSysAdmin = systemConfig.getSystemFactories().get(diagnosticsSystemStream.getSystem()).getAdmin(diagnosticsSystemStream.getSystem(), config, DiagnosticsUtil.class.getSimpleName());
StreamSpec diagnosticsStreamSpec = new StreamSpec(DIAGNOSTICS_STREAM_ID, diagnosticsSystemStream.getStream(), diagnosticsSystemStream.getSystem(), new StreamConfig(config).getStreamProperties(DIAGNOSTICS_STREAM_ID));
log.info("Creating diagnostics stream {}", diagnosticsSystemStream.getStream());
diagnosticsSysAdmin.start();
if (diagnosticsSysAdmin.createStream(diagnosticsStreamSpec)) {
log.info("Created diagnostics stream {}", diagnosticsSystemStream.getStream());
} else {
log.info("Diagnostics stream {} already exists", diagnosticsSystemStream.getStream());
}
diagnosticsSysAdmin.stop();
}
use of org.apache.samza.config.StreamConfig in project samza by apache.
the class TestStreamUtil method testGetStreamStreamIdEmpty.
// Empty strings are NOT allowed for streamId, because it's used as an identifier in the config.
@Test(expected = IllegalArgumentException.class)
public void testGetStreamStreamIdEmpty() {
Config config = buildStreamConfig("", StreamConfig.SYSTEM, TEST_SYSTEM);
StreamUtil.getStreamSpec("", new StreamConfig(config));
}
use of org.apache.samza.config.StreamConfig in project samza by apache.
the class TestStreamUtil method testStreamConfigOverrides.
@Test
public void testStreamConfigOverrides() {
final String sysStreamPrefix = String.format("systems.%s.streams.%s.", TEST_SYSTEM, TEST_PHYSICAL_NAME);
Config config = addConfigs(buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME, TEST_PHYSICAL_NAME, StreamConfig.SYSTEM, TEST_SYSTEM, "systemProperty1", "systemValue1", "systemProperty2", "systemValue2", "systemProperty3", "systemValue3"), sysStreamPrefix + "systemProperty4", "systemValue4", sysStreamPrefix + "systemProperty2", "systemValue8");
StreamSpec spec = StreamUtil.getStreamSpec(STREAM_ID, new StreamConfig(config));
Map<String, String> properties = spec.getConfig();
assertEquals(4, properties.size());
assertEquals("systemValue4", properties.get("systemProperty4"));
assertEquals("systemValue2", properties.get("systemProperty2"));
}
use of org.apache.samza.config.StreamConfig in project samza by apache.
the class TestStreamUtil method testGetStreamPropertiesPassthrough.
// The properties in the config "streams.{streamId}.*" should be passed through to the spec.
@Test
public void testGetStreamPropertiesPassthrough() {
Config config = buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME, TEST_PHYSICAL_NAME, StreamConfig.SYSTEM, TEST_SYSTEM, "systemProperty1", "systemValue1", "systemProperty2", "systemValue2", "systemProperty3", "systemValue3");
StreamSpec spec = StreamUtil.getStreamSpec(STREAM_ID, new StreamConfig(config));
Map<String, String> properties = spec.getConfig();
assertEquals(3, properties.size());
assertEquals("systemValue1", properties.get("systemProperty1"));
assertEquals("systemValue2", properties.get("systemProperty2"));
assertEquals("systemValue3", properties.get("systemProperty3"));
assertEquals("systemValue1", spec.get("systemProperty1"));
assertEquals("systemValue2", spec.get("systemProperty2"));
assertEquals("systemValue3", spec.get("systemProperty3"));
}
use of org.apache.samza.config.StreamConfig in project samza by apache.
the class TestStreamUtil method testGetStreamWithSystemAtDefaultScopeInConfig.
// If system isn't specified at stream scope, use the default system
@Test
public void testGetStreamWithSystemAtDefaultScopeInConfig() {
Config config = addConfigs(buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME, TEST_PHYSICAL_NAME), JobConfig.JOB_DEFAULT_SYSTEM, TEST_DEFAULT_SYSTEM);
StreamSpec spec = StreamUtil.getStreamSpec(STREAM_ID, new StreamConfig(config));
assertEquals(TEST_DEFAULT_SYSTEM, spec.getSystemName());
}
Aggregations