Search in sources :

Example 1 with SystemFactory

use of org.apache.samza.system.SystemFactory in project samza by apache.

the class StorageRecovery method getSystemFactoriesAndAdmins.

/**
   * get the SystemFactories and SystemAdmins specified in the config file and
   * put them into the maps
   */
private void getSystemFactoriesAndAdmins() {
    JavaSystemConfig systemConfig = new JavaSystemConfig(jobConfig);
    List<String> systems = systemConfig.getSystemNames();
    for (String system : systems) {
        String systemFactory = systemConfig.getSystemFactory(system);
        if (systemFactory == null) {
            throw new SamzaException("A stream uses system " + system + " which is missing from the configuration.");
        }
        systemFactories.put(system, Util.<SystemFactory>getObj(systemFactory));
        systemAdmins.put(system, Util.<SystemFactory>getObj(systemFactory).getAdmin(system, jobConfig));
    }
    log.info("Got system factories: " + systemFactories.keySet().toString());
    log.info("Got system admins: " + systemAdmins.keySet().toString());
}
Also used : JavaSystemConfig(org.apache.samza.config.JavaSystemConfig) SystemFactory(org.apache.samza.system.SystemFactory) SamzaException(org.apache.samza.SamzaException)

Example 2 with SystemFactory

use of org.apache.samza.system.SystemFactory in project samza by apache.

the class PassthroughJobCoordinator method getJobModel.

@Override
public JobModel getJobModel() {
    JavaSystemConfig systemConfig = new JavaSystemConfig(this.config);
    Map<String, SystemAdmin> systemAdmins = new HashMap<>();
    for (String systemName : systemConfig.getSystemNames()) {
        String systemFactoryClassName = systemConfig.getSystemFactory(systemName);
        if (systemFactoryClassName == null) {
            LOGGER.error(String.format("A stream uses system %s, which is missing from the configuration.", systemName));
            throw new SamzaException(String.format("A stream uses system %s, which is missing from the configuration.", systemName));
        }
        SystemFactory systemFactory = Util.<SystemFactory>getObj(systemFactoryClassName);
        systemAdmins.put(systemName, systemFactory.getAdmin(systemName, this.config));
    }
    StreamMetadataCache streamMetadataCache = new StreamMetadataCache(Util.<String, SystemAdmin>javaMapAsScalaMap(systemAdmins), 5000, SystemClock.instance());
    /** TODO:
     Locality Manager seems to be required in JC for reading locality info and grouping tasks intelligently and also,
     in SamzaContainer for writing locality info to the coordinator stream. This closely couples together
     TaskNameGrouper with the LocalityManager! Hence, groupers should be a property of the jobcoordinator
     (job.coordinator.task.grouper, instead of task.systemstreampartition.grouper)
     */
    return JobModelManager.readJobModel(this.config, Collections.emptyMap(), null, streamMetadataCache, null);
}
Also used : StreamMetadataCache(org.apache.samza.system.StreamMetadataCache) JavaSystemConfig(org.apache.samza.config.JavaSystemConfig) SystemFactory(org.apache.samza.system.SystemFactory) HashMap(java.util.HashMap) SystemAdmin(org.apache.samza.system.SystemAdmin) SamzaException(org.apache.samza.SamzaException)

Example 3 with SystemFactory

use of org.apache.samza.system.SystemFactory 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)3 SystemFactory (org.apache.samza.system.SystemFactory)3 JavaSystemConfig (org.apache.samza.config.JavaSystemConfig)2 HashMap (java.util.HashMap)1 Log4jSystemConfig (org.apache.samza.config.Log4jSystemConfig)1 MetricsRegistryMap (org.apache.samza.metrics.MetricsRegistryMap)1 StreamMetadataCache (org.apache.samza.system.StreamMetadataCache)1 SystemAdmin (org.apache.samza.system.SystemAdmin)1 SystemStream (org.apache.samza.system.SystemStream)1