public void start() { if (started) { LOG.warn("Skipping attempt to start an already started ContainerHeartbeatMonitor."); return; } LOG.info("Starting ContainerHeartbeatMonitor"); scheduler.scheduleAtFixedRate(() -> { ContainerHeartbeatResponse response = containerHeartbeatClient.requestHeartbeat(); if (!response.isAlive()) { scheduler.schedule(() -> { // On timeout of container shutting down, force exit. LOG.error("Graceful shutdown timeout expired. Force exiting."); ThreadUtil.logThreadDump("Thread dump at heartbeat monitor shutdown timeout."); System.exit(1); }, SHUTDOWN_TIMOUT_MS, TimeUnit.MILLISECONDS); onContainerExpired.run(); } }, 0, SCHEDULE_MS, TimeUnit.MILLISECONDS); started = true; }
public void start() { if (started) { LOG.warn("Skipping attempt to start an already started ContainerHeartbeatMonitor."); return; } LOG.info("Starting ContainerHeartbeatMonitor"); scheduler.scheduleAtFixedRate(() -> { ContainerHeartbeatResponse response = containerHeartbeatClient.requestHeartbeat(); if (!response.isAlive()) { scheduler.schedule(() -> { // On timeout of container shutting down, force exit. LOG.error("Graceful shutdown timeout expired. Force exiting."); Util.logThreadDump("Thread dump at heartbeat monitor shutdown timeout."); System.exit(1); }, SHUTDOWN_TIMOUT_MS, TimeUnit.MILLISECONDS); onContainerExpired.run(); } }, 0, SCHEDULE_MS, TimeUnit.MILLISECONDS); started = true; }
public void start() { if (started) { LOG.warn("Skipping attempt to start an already started ContainerHeartbeatMonitor."); return; } LOG.info("Starting ContainerHeartbeatMonitor"); scheduler.scheduleAtFixedRate(() -> { ContainerHeartbeatResponse response = containerHeartbeatClient.requestHeartbeat(); if (!response.isAlive()) { scheduler.schedule(() -> { // On timeout of container shutting down, force exit. LOG.error("Graceful shutdown timeout expired. Force exiting."); Util.logThreadDump("Thread dump at heartbeat monitor shutdown timeout."); System.exit(1); }, SHUTDOWN_TIMOUT_MS, TimeUnit.MILLISECONDS); onContainerExpired.run(); } }, 0, SCHEDULE_MS, TimeUnit.MILLISECONDS); started = true; }
public void start() { if (started) { LOG.warn("Skipping attempt to start an already started ContainerHeartbeatMonitor."); return; } LOG.info("Starting ContainerHeartbeatMonitor"); scheduler.scheduleAtFixedRate(() -> { ContainerHeartbeatResponse response = containerHeartbeatClient.requestHeartbeat(); if (!response.isAlive()) { scheduler.schedule(() -> { // On timeout of container shutting down, force exit. LOG.error("Graceful shutdown timeout expired. Force exiting."); Util.logThreadDump("Thread dump at heartbeat monitor shutdown timeout."); System.exit(1); }, SHUTDOWN_TIMOUT_MS, TimeUnit.MILLISECONDS); onContainerExpired.run(); } }, 0, SCHEDULE_MS, TimeUnit.MILLISECONDS); started = true; }
public void start() { if (started) { LOG.warn("Skipping attempt to start an already started ContainerHeartbeatMonitor."); return; } LOG.info("Starting ContainerHeartbeatMonitor"); scheduler.scheduleAtFixedRate(() -> { ContainerHeartbeatResponse response = containerHeartbeatClient.requestHeartbeat(); if (!response.isAlive()) { scheduler.schedule(() -> { // On timeout of container shutting down, force exit. LOG.error("Graceful shutdown timeout expired. Force exiting."); Util.logThreadDump("Thread dump at heartbeat monitor shutdown timeout."); System.exit(1); }, SHUTDOWN_TIMOUT_MS, TimeUnit.MILLISECONDS); onContainerExpired.run(); } }, 0, SCHEDULE_MS, TimeUnit.MILLISECONDS); started = true; }
@Test public void testClientResponseOnBadRequest() throws IOException { client.shouldThrowException(true); ContainerHeartbeatResponse response = client.requestHeartbeat(); Assert.assertFalse(response.isAlive()); }
@Test public void testClientResponseForHeartbeatAlive() throws IOException { client.setHttpOutput("{\"alive\": true}"); ContainerHeartbeatResponse response = client.requestHeartbeat(); Assert.assertTrue(response.isAlive()); }
@Test public void testClientResponseForHeartbeatDead() throws IOException { client.setHttpOutput("{\"alive\": false}"); ContainerHeartbeatResponse response = client.requestHeartbeat(); Assert.assertFalse(response.isAlive()); }