Search in sources :

Example 1 with Log4jSystemConfig

use of org.apache.samza.config.Log4jSystemConfig in project samza by apache.

the class StreamAppender method setupSystem.

protected void setupSystem() {
    config = getConfig();
    SystemFactory systemFactory = null;
    Log4jSystemConfig log4jSystemConfig = new Log4jSystemConfig(config);
    if (streamName == null) {
        streamName = getStreamName(log4jSystemConfig.getJobName(), log4jSystemConfig.getJobId());
    }
    String systemName = log4jSystemConfig.getSystemName();
    String systemFactoryName = log4jSystemConfig.getSystemFactory(systemName);
    if (systemFactoryName != null) {
        systemFactory = Util.<SystemFactory>getObj(systemFactoryName);
    } else {
        throw new SamzaException("Could not figure out \"" + systemName + "\" system factory for log4j StreamAppender to use");
    }
    setSerde(log4jSystemConfig, systemName, streamName);
    systemProducer = systemFactory.getProducer(systemName, config, new MetricsRegistryMap());
    systemStream = new SystemStream(systemName, streamName);
    systemProducer.register(SOURCE);
    systemProducer.start();
    log.info(SOURCE + " has been registered in " + systemName + ". So all the logs will be sent to " + streamName + " in " + systemName + ". Logs are partitioned by " + key);
}
Also used : SystemFactory(org.apache.samza.system.SystemFactory) SystemStream(org.apache.samza.system.SystemStream) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) Log4jSystemConfig(org.apache.samza.config.Log4jSystemConfig) SamzaException(org.apache.samza.SamzaException)

Aggregations

SamzaException (org.apache.samza.SamzaException)1 Log4jSystemConfig (org.apache.samza.config.Log4jSystemConfig)1 MetricsRegistryMap (org.apache.samza.metrics.MetricsRegistryMap)1 SystemFactory (org.apache.samza.system.SystemFactory)1 SystemStream (org.apache.samza.system.SystemStream)1