use of org.apache.samza.config.SystemConfig in project samza by apache.
the class MetricsSnapshotReporterFactory method getProducer.
protected SystemProducer getProducer(String reporterName, Config config, MetricsRegistryMap registry) {
SystemConfig systemConfig = new SystemConfig(config);
String systemName = getSystemStream(reporterName, config).getSystem();
String systemFactoryClassName = systemConfig.getSystemFactory(systemName).orElseThrow(() -> new SamzaException(String.format("Trying to fetch system factory for system %s, which isn't defined in config.", systemName)));
SystemFactory systemFactory = ReflectionUtil.getObj(systemFactoryClassName, SystemFactory.class);
LOG.info("Got system factory {}.", systemFactory);
SystemProducer producer = systemFactory.getProducer(systemName, config, registry);
LOG.info("Got producer {}.", producer);
return producer;
}
use of org.apache.samza.config.SystemConfig in project samza by apache.
the class MetricsSnapshotReporterFactory method getSerde.
protected Serde<MetricsSnapshot> getSerde(String reporterName, Config config) {
StreamConfig streamConfig = new StreamConfig(config);
SystemConfig systemConfig = new SystemConfig(config);
SystemStream systemStream = getSystemStream(reporterName, config);
Optional<String> streamSerdeName = streamConfig.getStreamMsgSerde(systemStream);
Optional<String> systemSerdeName = systemConfig.getSystemMsgSerde(systemStream.getSystem());
String serdeName = streamSerdeName.orElse(systemSerdeName.orElse(null));
SerializerConfig serializerConfig = new SerializerConfig(config);
Serde<MetricsSnapshot> serde;
if (serdeName != null) {
Optional<String> serdeFactoryClass = serializerConfig.getSerdeFactoryClass(serdeName);
if (serdeFactoryClass.isPresent()) {
SerdeFactory<MetricsSnapshot> serdeFactory = ReflectionUtil.getObj(serdeFactoryClass.get(), SerdeFactory.class);
serde = serdeFactory.getSerde(serdeName, config);
} else {
serde = null;
}
} else {
serde = new MetricsSnapshotSerdeV2();
}
LOG.info("Got serde {}.", serde);
return serde;
}
Aggregations