InstanceManager { public void shutdown() { synchronized (this.lock) { if (this.isShutdown) { return; } this.isShutdown = true; for (Instance i : this.registeredHostsById.values()) { i.markDead(); } this.registeredHostsById.clear(); this.registeredHostsByConnection.clear(); this.deadHosts.clear(); this.totalNumberOfAliveTaskSlots = 0; } } InstanceManager(); void shutdown(); boolean reportHeartBeat(InstanceID instanceId, byte[] lastMetricsReport); InstanceID registerTaskManager(
			ActorRef taskManager,
			InstanceConnectionInfo connectionInfo,
			HardwareDescription resources,
			int numberOfSlots,
			UUID leaderSessionID); void unregisterTaskManager(ActorRef taskManager, boolean terminated); void unregisterAllTaskManagers(); boolean isRegistered(ActorRef taskManager); int getNumberOfRegisteredTaskManagers(); int getTotalNumberOfSlots(); int getNumberOfAvailableSlots(); Collection<Instance> getAllRegisteredInstances(); Instance getRegisteredInstanceById(InstanceID instanceID); Instance getRegisteredInstance(ActorRef ref); void addInstanceListener(InstanceListener listener); void removeInstanceListener(InstanceListener listener);  }
@Test public void testShutdown() { try { InstanceManager cm = new InstanceManager(); cm.shutdown(); try { HardwareDescription resources = HardwareDescription.extractFromSystem(4096); InetAddress address = InetAddress.getByName("127.0.0.1"); InstanceConnectionInfo ici = new InstanceConnectionInfo(address, 20000); JavaTestKit probe = new JavaTestKit(system); cm.registerTaskManager(probe.getRef(), ici, resources, 1, leaderSessionID); fail("Should raise exception in shutdown state"); } catch (IllegalStateException e) { } assertFalse(cm.reportHeartBeat(new InstanceID(), new byte[] {})); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); Assert.fail("Test erroneous: " + e.getMessage()); } }