private JobCoordinator createJobCoordinator() { String jobCoordinatorFactoryClassName = new JobCoordinatorConfig(config).getJobCoordinatorFactoryClassName(); return Util.getObj(jobCoordinatorFactoryClassName, JobCoordinatorFactory.class).getJobCoordinator(processorId, config, metricsRegistry); }
public String getJobCoordinatorFactoryClassName() { String jobCoordinatorFactoryClassName = get(JOB_COORDINATOR_FACTORY); if (Strings.isNullOrEmpty(jobCoordinatorFactoryClassName)) { return ZkJobCoordinatorFactory.class.getName(); } else { return jobCoordinatorFactoryClassName; } } }
public CoordinationUtilsFactory getCoordinationUtilsFactory() { // load the class String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName(); return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class); }
JobCoordinatorConfig jcConfig = new JobCoordinatorConfig(userConfig); String coordinationId = new ApplicationConfig(userConfig).getGlobalAppId() + APPLICATION_RUNNER_PATH_SUFFIX; CoordinationUtils coordinationUtils = jcConfig.getCoordinationUtilsFactory().getCoordinationUtils(coordinationId, uid, userConfig); if (coordinationUtils == null) { LOG.warn("Processor {} failed to create utils. Each processor will attempt to create streams.", uid);
@Test public void testStreamCreation() throws Exception { localPlanner = createLocalJobPlanner(mock(StreamApplicationDescriptorImpl.class)); StreamManager streamManager = mock(StreamManager.class); doReturn(streamManager).when(localPlanner).buildAndStartStreamManager(any(Config.class)); ExecutionPlan plan = mock(ExecutionPlan.class); when(plan.getIntermediateStreams()).thenReturn( Collections.singletonList(new StreamSpec("test-stream", "test-stream", "test-system"))); when(plan.getPlanAsJson()).thenReturn(""); when(plan.getJobConfigs()).thenReturn(Collections.singletonList(mock(JobConfig.class))); doReturn(plan).when(localPlanner).getExecutionPlan(any()); CoordinationUtilsFactory coordinationUtilsFactory = mock(CoordinationUtilsFactory.class); JobCoordinatorConfig mockJcConfig = mock(JobCoordinatorConfig.class); when(mockJcConfig.getCoordinationUtilsFactory()).thenReturn(coordinationUtilsFactory); PowerMockito.whenNew(JobCoordinatorConfig.class).withAnyArguments().thenReturn(mockJcConfig); localPlanner.prepareJobs(); ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class); verify(streamManager).createStreams(captor.capture()); List<StreamSpec> streamSpecs = captor.getValue(); assertEquals(streamSpecs.size(), 1); assertEquals(streamSpecs.get(0).getId(), "test-stream"); verify(streamManager).stop(); }
JobCoordinatorConfig jcConfig = new JobCoordinatorConfig(userConfig); String coordinationId = new ApplicationConfig(userConfig).getGlobalAppId() + APPLICATION_RUNNER_PATH_SUFFIX; CoordinationUtils coordinationUtils = jcConfig.getCoordinationUtilsFactory().getCoordinationUtils(coordinationId, uid, userConfig); if (coordinationUtils == null) { LOG.warn("Processor {} failed to create utils. Each processor will attempt to create streams.", uid);
@Test public void testStreamCreationWithCoordination() throws Exception { localPlanner = createLocalJobPlanner(mock(StreamApplicationDescriptorImpl.class)); StreamManager streamManager = mock(StreamManager.class); doReturn(streamManager).when(localPlanner).buildAndStartStreamManager(any(Config.class)); ExecutionPlan plan = mock(ExecutionPlan.class); when(plan.getIntermediateStreams()).thenReturn(Collections.singletonList(new StreamSpec("test-stream", "test-stream", "test-system"))); when(plan.getPlanAsJson()).thenReturn(""); when(plan.getJobConfigs()).thenReturn(Collections.singletonList(mock(JobConfig.class))); doReturn(plan).when(localPlanner).getExecutionPlan(any()); CoordinationUtils coordinationUtils = mock(CoordinationUtils.class); CoordinationUtilsFactory coordinationUtilsFactory = mock(CoordinationUtilsFactory.class); JobCoordinatorConfig mockJcConfig = mock(JobCoordinatorConfig.class); when(mockJcConfig.getCoordinationUtilsFactory()).thenReturn(coordinationUtilsFactory); PowerMockito.whenNew(JobCoordinatorConfig.class).withAnyArguments().thenReturn(mockJcConfig); DistributedLockWithState lock = mock(DistributedLockWithState.class); when(lock.lockIfNotSet(anyLong(), anyObject())).thenReturn(true); when(coordinationUtils.getLockWithState(anyString())).thenReturn(lock); when(coordinationUtilsFactory.getCoordinationUtils(anyString(), anyString(), anyObject())) .thenReturn(coordinationUtils); localPlanner.prepareJobs(); ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class); verify(streamManager).createStreams(captor.capture()); List<StreamSpec> streamSpecs = captor.getValue(); assertEquals(streamSpecs.size(), 1); assertEquals(streamSpecs.get(0).getId(), "test-stream"); verify(streamManager).stop(); }
JobCoordinatorConfig jcConfig = new JobCoordinatorConfig(userConfig); String coordinationId = new ApplicationConfig(userConfig).getGlobalAppId() + APPLICATION_RUNNER_PATH_SUFFIX; CoordinationUtils coordinationUtils = jcConfig.getCoordinationUtilsFactory().getCoordinationUtils(coordinationId, uid, userConfig); if (coordinationUtils == null) { LOG.warn("Processor {} failed to create utils. Each processor will attempt to create streams.", uid);
private JobCoordinator createJobCoordinator() { String jobCoordinatorFactoryClassName = new JobCoordinatorConfig(config).getJobCoordinatorFactoryClassName(); return Util.getObj(jobCoordinatorFactoryClassName, JobCoordinatorFactory.class).getJobCoordinator(config); }
public String getJobCoordinatorFactoryClassName() { String jobCoordinatorFactoryClassName = get(JOB_COORDINATOR_FACTORY); if (Strings.isNullOrEmpty(jobCoordinatorFactoryClassName)) { return ZkJobCoordinatorFactory.class.getName(); } else { return jobCoordinatorFactoryClassName; } } }
public CoordinationUtilsFactory getCoordinationUtilsFactory() { // load the class String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName(); return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class); }
JobCoordinatorConfig jcConfig = new JobCoordinatorConfig(userConfig); String coordinationId = new ApplicationConfig(userConfig).getGlobalAppId() + APPLICATION_RUNNER_PATH_SUFFIX; CoordinationUtils coordinationUtils = jcConfig.getCoordinationUtilsFactory().getCoordinationUtils(coordinationId, uid, userConfig); if (coordinationUtils == null) { LOG.warn("Processor {} failed to create utils. Each processor will attempt to create streams.", uid);
private JobCoordinator createJobCoordinator() { String jobCoordinatorFactoryClassName = new JobCoordinatorConfig(config).getJobCoordinatorFactoryClassName(); return Util.getObj(jobCoordinatorFactoryClassName, JobCoordinatorFactory.class).getJobCoordinator(config); }
public String getJobCoordinatorFactoryClassName() { String jobCoordinatorFactoryClassName = get(JOB_COORDINATOR_FACTORY); if (Strings.isNullOrEmpty(jobCoordinatorFactoryClassName)) { return ZkJobCoordinatorFactory.class.getName(); } else { return jobCoordinatorFactoryClassName; } } }
public CoordinationUtilsFactory getCoordinationUtilsFactory() { // load the class String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName(); return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class); }
JobCoordinatorConfig jcConfig = new JobCoordinatorConfig(userConfig); String coordinationId = new ApplicationConfig(userConfig).getGlobalAppId() + APPLICATION_RUNNER_PATH_SUFFIX; CoordinationUtils coordinationUtils = jcConfig.getCoordinationUtilsFactory().getCoordinationUtils(coordinationId, uid, userConfig); if (coordinationUtils == null) { LOG.warn("Processor {} failed to create utils. Each processor will attempt to create streams.", uid);
private JobCoordinator createJobCoordinator() { String jobCoordinatorFactoryClassName = new JobCoordinatorConfig(config).getJobCoordinatorFactoryClassName(); return Util.getObj(jobCoordinatorFactoryClassName, JobCoordinatorFactory.class).getJobCoordinator(config); }
public String getJobCoordinatorFactoryClassName() { String jobCoordinatorFactoryClassName = get(JOB_COORDINATOR_FACTORY); if (Strings.isNullOrEmpty(jobCoordinatorFactoryClassName)) { return ZkJobCoordinatorFactory.class.getName(); } else { return jobCoordinatorFactoryClassName; } } }
public CoordinationUtilsFactory getCoordinationUtilsFactory() { // load the class String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName(); return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class); }
private JobCoordinator createJobCoordinator() { String jobCoordinatorFactoryClassName = new JobCoordinatorConfig(config).getJobCoordinatorFactoryClassName(); return Util.getObj(jobCoordinatorFactoryClassName, JobCoordinatorFactory.class).getJobCoordinator(config); }