use of org.apache.samza.coordinator.stream.CoordinatorStreamValueSerde in project samza by apache.
the class TestContainerHeartbeatMonitor method testConnectToNewAMSerdeException.
@Test
public void testConnectToNewAMSerdeException() throws InterruptedException {
String newCoordinatorUrl = "http://some-host-2.prod.linkedin.com";
this.containerHeartbeatMonitor = spy(buildContainerHeartbeatMonitor(true));
CoordinatorStreamValueSerde serde = new CoordinatorStreamValueSerde(SetConfig.TYPE);
ContainerHeartbeatMonitor.ContainerHeartbeatMetrics metrics = this.containerHeartbeatMonitor.getMetrics();
when(this.containerHeartbeatClient.requestHeartbeat()).thenReturn(FAILURE_RESPONSE);
when(this.containerHeartbeatMonitor.createContainerHeartbeatClient(newCoordinatorUrl, CONTAINER_EXECUTION_ID)).thenReturn(this.containerHeartbeatClient);
when(this.coordinatorStreamStore.get(CoordinationConstants.YARN_COORDINATOR_URL)).thenThrow(new NullPointerException("serde failed"));
this.containerHeartbeatMonitor.start();
// wait for the executor to finish the heartbeat check task
boolean fixedRateTaskCompleted = this.schedulerFixedRateExecutionLatch.await(10, TimeUnit.SECONDS);
assertTrue("Did not complete heartbeat check", fixedRateTaskCompleted);
assertEquals("Heartbeat expired count should be 1", 1, metrics.getHeartbeatExpiredCount().getCount());
assertEquals("Heartbeat established failure count should be 1", 1, metrics.getHeartbeatEstablishedFailureCount().getCount());
// shutdown task should have been submitted
verify(this.scheduler).schedule(any(Runnable.class), eq((long) ContainerHeartbeatMonitor.SHUTDOWN_TIMOUT_MS), eq(TimeUnit.MILLISECONDS));
verify(this.onExpired).run();
this.containerHeartbeatMonitor.stop();
verify(this.scheduler).shutdown();
}
use of org.apache.samza.coordinator.stream.CoordinatorStreamValueSerde in project samza by apache.
the class TestContainerHeartbeatMonitor method testConnectToNewAMFailed.
@Test
public void testConnectToNewAMFailed() throws InterruptedException {
String newCoordinatorUrl = "http://some-host-2.prod.linkedin.com";
this.containerHeartbeatMonitor = spy(buildContainerHeartbeatMonitor(true));
CoordinatorStreamValueSerde serde = new CoordinatorStreamValueSerde(SetConfig.TYPE);
ContainerHeartbeatMonitor.ContainerHeartbeatMetrics metrics = this.containerHeartbeatMonitor.getMetrics();
when(this.containerHeartbeatClient.requestHeartbeat()).thenReturn(FAILURE_RESPONSE);
when(this.containerHeartbeatMonitor.createContainerHeartbeatClient(newCoordinatorUrl, CONTAINER_EXECUTION_ID)).thenReturn(this.containerHeartbeatClient);
when(this.coordinatorStreamStore.get(CoordinationConstants.YARN_COORDINATOR_URL)).thenReturn(serde.toBytes(newCoordinatorUrl));
this.containerHeartbeatMonitor.start();
// wait for the executor to finish the heartbeat check task
boolean fixedRateTaskCompleted = this.schedulerFixedRateExecutionLatch.await(2, TimeUnit.SECONDS);
assertTrue("Did not complete heartbeat check", fixedRateTaskCompleted);
assertEquals("Heartbeat expired count should be 1", 1, metrics.getHeartbeatExpiredCount().getCount());
assertEquals("Heartbeat established failure count should be 1", 1, metrics.getHeartbeatEstablishedFailureCount().getCount());
// shutdown task should have been submitted
verify(this.scheduler).schedule(any(Runnable.class), eq((long) ContainerHeartbeatMonitor.SHUTDOWN_TIMOUT_MS), eq(TimeUnit.MILLISECONDS));
verify(this.onExpired).run();
this.containerHeartbeatMonitor.stop();
verify(this.scheduler).shutdown();
}
use of org.apache.samza.coordinator.stream.CoordinatorStreamValueSerde in project samza by apache.
the class TestExecutionContainerIdManager method testExecutionContainerIdManager.
@Test
public void testExecutionContainerIdManager() {
String physicalId = "container_123_123_123";
String processorId = "0";
executionContainerIdManager.writeExecutionEnvironmentContainerIdMapping(processorId, physicalId);
Map<String, String> localMap = executionContainerIdManager.readExecutionEnvironmentContainerIdMapping();
Map<String, String> expectedMap = ImmutableMap.of(processorId, physicalId);
assertEquals(expectedMap, localMap);
executionContainerIdManager.close();
MockCoordinatorStreamSystemFactory.MockCoordinatorStreamSystemProducer producer = coordinatorStreamStoreTestUtil.getMockCoordinatorStreamSystemProducer();
MockCoordinatorStreamSystemFactory.MockCoordinatorStreamSystemConsumer consumer = coordinatorStreamStoreTestUtil.getMockCoordinatorStreamSystemConsumer();
assertTrue(producer.isStopped());
assertTrue(consumer.isStopped());
ArgumentCaptor<byte[]> argument1 = ArgumentCaptor.forClass(byte[].class);
Mockito.verify(store).put(Mockito.eq(processorId), argument1.capture());
CoordinatorStreamValueSerde valueSerde = new CoordinatorStreamValueSerde(SetExecutionEnvContainerIdMapping.TYPE);
assertEquals(physicalId, valueSerde.fromBytes(argument1.getValue()));
}
Aggregations