@Override public void onNewJobModel(String processorId, JobModel jobModel) { synchronized (lock) { if (state == State.IN_REBALANCE) { containerShutdownLatch = new CountDownLatch(1); container = createSamzaContainer(processorId, jobModel); container.setContainerListener(new ContainerListener()); LOGGER.info("Starting the container: {} for the stream processor: {}.", container, processorId); containerExcecutorService.submit(container); } else { LOGGER.info("Ignoring onNewJobModel invocation since the current state is {} and not {}.", state, State.IN_REBALANCE); } } }
@Override public void onNewJobModel(String processorId, JobModel jobModel) { synchronized (lock) { if (state == State.IN_REBALANCE) { containerShutdownLatch = new CountDownLatch(1); container = createSamzaContainer(processorId, jobModel); container.setContainerListener(new ContainerListener()); LOGGER.info("Starting the container: {} for the stream processor: {}.", container, processorId); containerExcecutorService.submit(container); } else { LOGGER.info("Ignoring onNewJobModel invocation since the current state is {} and not {}.", state, State.IN_REBALANCE); } } }
@Override public void onNewJobModel(String processorId, JobModel jobModel) { synchronized (lock) { if (state == State.IN_REBALANCE) { containerShutdownLatch = new CountDownLatch(1); container = createSamzaContainer(processorId, jobModel); container.setContainerListener(new ContainerListener()); LOGGER.info("Starting the container: {} for the stream processor: {}.", container, processorId); containerExcecutorService.submit(container); } else { LOGGER.info("Ignoring onNewJobModel invocation since the current state is {} and not {}.", state, State.IN_REBALANCE); } } }
@Override public void onNewJobModel(String processorId, JobModel jobModel) { synchronized (lock) { if (state == State.IN_REBALANCE) { containerShutdownLatch = new CountDownLatch(1); container = createSamzaContainer(processorId, jobModel); container.setContainerListener(new ContainerListener()); LOGGER.info("Starting the container: {} for the stream processor: {}.", container, processorId); containerExcecutorService.submit(container); } else { LOGGER.info("Ignoring onNewJobModel invocation since the current state is {} and not {}.", state, State.IN_REBALANCE); } } }
@Override public void onNewJobModel(String processorId, JobModel jobModel) { synchronized (lock) { if (state == State.IN_REBALANCE) { containerShutdownLatch = new CountDownLatch(1); container = createSamzaContainer(processorId, jobModel); container.setContainerListener(new ContainerListener()); LOGGER.info("Starting the container: {} for the stream processor: {}.", container, processorId); containerExcecutorService.submit(container); } else { LOGGER.info("Ignoring onNewJobModel invocation since the current state is {} and not {}.", state, State.IN_REBALANCE); } } }
@Test public void testOnNewJobModelShouldResultInValidStateTransitions() throws Exception { JobCoordinator mockJobCoordinator = Mockito.mock(JobCoordinator.class); ProcessorLifecycleListener lifecycleListener = Mockito.mock(ProcessorLifecycleListener.class); SamzaContainer mockSamzaContainer = Mockito.mock(SamzaContainer.class); MapConfig config = new MapConfig(ImmutableMap.of("task.shutdown.ms", "0")); StreamProcessor streamProcessor = new TestableStreamProcessor(config, new HashMap<>(), null, lifecycleListener, mockJobCoordinator, mockSamzaContainer); streamProcessor.state = State.IN_REBALANCE; Mockito.doNothing().when(mockSamzaContainer).run(); streamProcessor.jobCoordinatorListener.onNewJobModel("TestProcessorId", new JobModel(new MapConfig(), new HashMap<>())); Mockito.verify(mockSamzaContainer, Mockito.times(1)).setContainerListener(any()); Mockito.verify(mockSamzaContainer, Mockito.atMost(1)).run(); }
.createInstance(new ProcessorContext() { }, config); container.setContainerListener( new SamzaContainerListener() { @Override
.createInstance(new ProcessorContext() { }, config); container.setContainerListener( new SamzaContainerListener() { @Override
.createInstance(new ProcessorContext() { }, config); container.setContainerListener( new SamzaContainerListener() { @Override
.createInstance(new ProcessorContext() { }, config); container.setContainerListener( new SamzaContainerListener() { @Override
.createInstance(new ProcessorContext() { }, config); container.setContainerListener( new SamzaContainerListener() { @Override