Search in sources :

Example 1 with JobCoordinatorConfig

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

the class TestZkStreamProcessorBase method createStreamProcessor.

protected StreamProcessor createStreamProcessor(final String pId, Map<String, String> map, final Object mutexStart, final Object mutexStop) {
    map.put(ApplicationConfig.PROCESSOR_ID, pId);
    Config config = new MapConfig(map);
    JobCoordinator jobCoordinator = Util.<JobCoordinatorFactory>getObj(new JobCoordinatorConfig(config).getJobCoordinatorFactoryClassName()).getJobCoordinator(config);
    StreamProcessorLifecycleListener listener = new StreamProcessorLifecycleListener() {

        @Override
        public void onStart() {
            if (mutexStart != null) {
                synchronized (mutexStart) {
                    mutexStart.notifyAll();
                }
            }
            LOG.info("onStart is called for pid=" + pId);
        }

        @Override
        public void onShutdown() {
            if (mutexStop != null) {
                synchronized (mutexStart) {
                    mutexStart.notify();
                }
            }
            LOG.info("onShutdown is called for pid=" + pId);
        }

        @Override
        public void onFailure(Throwable t) {
            LOG.info("onFailure is called for pid=" + pId);
        }
    };
    StreamProcessor processor = new StreamProcessor(config, new HashMap<>(), (StreamTaskFactory) TestStreamTask::new, listener, jobCoordinator);
    return processor;
}
Also used : ApplicationConfig(org.apache.samza.config.ApplicationConfig) MapConfig(org.apache.samza.config.MapConfig) ZkConfig(org.apache.samza.config.ZkConfig) JobCoordinatorConfig(org.apache.samza.config.JobCoordinatorConfig) Config(org.apache.samza.config.Config) JobCoordinator(org.apache.samza.coordinator.JobCoordinator) JobCoordinatorConfig(org.apache.samza.config.JobCoordinatorConfig) MapConfig(org.apache.samza.config.MapConfig)

Aggregations

ApplicationConfig (org.apache.samza.config.ApplicationConfig)1 Config (org.apache.samza.config.Config)1 JobCoordinatorConfig (org.apache.samza.config.JobCoordinatorConfig)1 MapConfig (org.apache.samza.config.MapConfig)1 ZkConfig (org.apache.samza.config.ZkConfig)1 JobCoordinator (org.apache.samza.coordinator.JobCoordinator)1