test_class.declarator: system
test_class.modifier: static
test_class.original_string: static ActorSystem system;
test_class.type: ActorSystem
test_class.var_name: system
test_class.declarator: leaderSessionID = UUID.randomUUID()
test_class.modifier: static
test_class.original_string: static UUID leaderSessionID = UUID.randomUUID();
test_class.type: UUID
test_class.var_name: leaderSessionID
test_class.file: flink-runtime/src/test/java/org/apache/flink/runtime/instance/InstanceManagerTest.java
test_class.identifier: InstanceManagerTest
test_case.body: @Test
  	public void testReportHeartbeat() {
  		try {
  			InstanceManager cm = new InstanceManager();
  			
  			final int dataPort = 20000;
  
  			HardwareDescription hardwareDescription = HardwareDescription.extractFromSystem(4096);
  
  			InetAddress address = InetAddress.getByName("127.0.0.1");
  			
  			// register three instances
  			InstanceConnectionInfo ici1 = new InstanceConnectionInfo(address, dataPort);
  			InstanceConnectionInfo ici2 = new InstanceConnectionInfo(address, dataPort + 1);
  			InstanceConnectionInfo ici3 = new InstanceConnectionInfo(address, dataPort + 2);
  
  			JavaTestKit probe1 = new JavaTestKit(system);
  			JavaTestKit probe2 = new JavaTestKit(system);
  			JavaTestKit probe3 = new JavaTestKit(system);
  			
  			InstanceID i1 = cm.registerTaskManager(probe1.getRef(), ici1, hardwareDescription, 1, leaderSessionID);
  			InstanceID i2 = cm.registerTaskManager(probe2.getRef(), ici2, hardwareDescription, 1, leaderSessionID);
  			InstanceID i3 = cm.registerTaskManager(probe3.getRef(), ici3, hardwareDescription, 1, leaderSessionID);
  
  			// report some immediate heart beats
  			assertTrue(cm.reportHeartBeat(i1, new byte[] {}));
  			assertTrue(cm.reportHeartBeat(i2, new byte[] {}));
  			assertTrue(cm.reportHeartBeat(i3, new byte[] {}));
  			
  			// report heart beat for non-existing instance
  			assertFalse(cm.reportHeartBeat(new InstanceID(), new byte[] {}));
  			
  			final long WAIT = 200;
  			CommonTestUtils.sleepUninterruptibly(WAIT);
  
  			Iterator<Instance> it = cm.getAllRegisteredInstances().iterator();
  
  			Instance instance1 = it.next();
  
  			long h1 = instance1.getLastHeartBeat();
  			long h2 = it.next().getLastHeartBeat();
  			long h3 = it.next().getLastHeartBeat();
  
  			// send one heart beat again and verify that the
  			assertTrue(cm.reportHeartBeat(instance1.getId(), new byte[] {}));
  			long newH1 = instance1.getLastHeartBeat();
  			
  			long now = System.currentTimeMillis();
  			
  			assertTrue(now - h1 >= WAIT);
  			assertTrue(now - h2 >= WAIT);
  			assertTrue(now - h3 >= WAIT);
  			assertTrue(now - newH1 <= WAIT);
  			
  			cm.shutdown();
  		}
  		catch (Exception e) {
  			System.err.println(e.getMessage());
  			e.printStackTrace();
  			Assert.fail("Test erroneous: " + e.getMessage());
  		}
  	}
test_case.class_method_signature: InstanceManagerTest.testReportHeartbeat()
test_case.full_signature: @Test public void testReportHeartbeat()
test_case.identifier: testReportHeartbeat
test_case.invocations: extractFromSystem getByName registerTaskManager getRef registerTaskManager getRef registerTaskManager getRef assertTrue reportHeartBeat assertTrue reportHeartBeat assertTrue reportHeartBeat assertFalse reportHeartBeat sleepUninterruptibly iterator getAllRegisteredInstances next getLastHeartBeat getLastHeartBeat next getLastHeartBeat next assertTrue reportHeartBeat getId getLastHeartBeat currentTimeMillis assertTrue assertTrue assertTrue assertTrue shutdown println getMessage printStackTrace fail getMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testReportHeartbeat()
focal_class.declarator: LOG = LoggerFactory.getLogger(InstanceManager.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(InstanceManager.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: lock = new Object()
focal_class.modifier: private final
focal_class.original_string: private final Object lock = new Object();
focal_class.type: Object
focal_class.var_name: lock
focal_class.declarator: registeredHostsById
focal_class.modifier: private final
focal_class.original_string: private final Map<InstanceID, Instance> registeredHostsById;
focal_class.type: Map<InstanceID, Instance>
focal_class.var_name: registeredHostsById
focal_class.declarator: registeredHostsByConnection
focal_class.modifier: private final
focal_class.original_string: private final Map<ActorRef, Instance> registeredHostsByConnection;
focal_class.type: Map<ActorRef, Instance>
focal_class.var_name: registeredHostsByConnection
focal_class.declarator: deadHosts
focal_class.modifier: private final
focal_class.original_string: private final Set<ActorRef> deadHosts;
focal_class.type: Set<ActorRef>
focal_class.var_name: deadHosts
focal_class.declarator: instanceListeners = new ArrayList<InstanceListener>()
focal_class.modifier: private final
focal_class.original_string: private final List<InstanceListener> instanceListeners = new ArrayList<InstanceListener>();
focal_class.type: List<InstanceListener>
focal_class.var_name: instanceListeners
focal_class.declarator: totalNumberOfAliveTaskSlots
focal_class.modifier: private
focal_class.original_string: private int totalNumberOfAliveTaskSlots;
focal_class.type: int
focal_class.var_name: totalNumberOfAliveTaskSlots
focal_class.declarator: isShutdown
focal_class.modifier: private volatile
focal_class.original_string: private volatile boolean isShutdown;
focal_class.type: boolean
focal_class.var_name: isShutdown
focal_class.file: flink-runtime/src/main/java/org/apache/flink/runtime/instance/InstanceManager.java
focal_class.identifier: InstanceManager
focal_class.class_method_signature: InstanceManager.InstanceManager()
focal_class.full_signature: public  InstanceManager()
focal_class.identifier: InstanceManager
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  InstanceManager()
focal_class.class_method_signature: InstanceManager.shutdown()
focal_class.full_signature: public void shutdown()
focal_class.identifier: shutdown
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void shutdown()
focal_class.class_method_signature: InstanceManager.reportHeartBeat(InstanceID instanceId, byte[] lastMetricsReport)
focal_class.full_signature: public boolean reportHeartBeat(InstanceID instanceId, byte[] lastMetricsReport)
focal_class.identifier: reportHeartBeat
focal_class.modifiers: public
focal_class.parameters: (InstanceID instanceId, byte[] lastMetricsReport)
focal_class.return: boolean
focal_class.signature: boolean reportHeartBeat(InstanceID instanceId, byte[] lastMetricsReport)
focal_class.class_method_signature: InstanceManager.registerTaskManager(
  			ActorRef taskManager,
  			InstanceConnectionInfo connectionInfo,
  			HardwareDescription resources,
  			int numberOfSlots,
  			UUID leaderSessionID)
focal_class.full_signature: public InstanceID registerTaskManager(
  			ActorRef taskManager,
  			InstanceConnectionInfo connectionInfo,
  			HardwareDescription resources,
  			int numberOfSlots,
  			UUID leaderSessionID)
focal_class.identifier: registerTaskManager
focal_class.modifiers: public
focal_class.parameters: (
  			ActorRef taskManager,
  			InstanceConnectionInfo connectionInfo,
  			HardwareDescription resources,
  			int numberOfSlots,
  			UUID leaderSessionID)
focal_class.return: InstanceID
focal_class.signature: InstanceID registerTaskManager(
  			ActorRef taskManager,
  			InstanceConnectionInfo connectionInfo,
  			HardwareDescription resources,
  			int numberOfSlots,
  			UUID leaderSessionID)
focal_class.class_method_signature: InstanceManager.unregisterTaskManager(ActorRef taskManager, boolean terminated)
focal_class.full_signature: public void unregisterTaskManager(ActorRef taskManager, boolean terminated)
focal_class.identifier: unregisterTaskManager
focal_class.modifiers: public
focal_class.parameters: (ActorRef taskManager, boolean terminated)
focal_class.return: void
focal_class.signature: void unregisterTaskManager(ActorRef taskManager, boolean terminated)
focal_class.class_method_signature: InstanceManager.unregisterAllTaskManagers()
focal_class.full_signature: public void unregisterAllTaskManagers()
focal_class.identifier: unregisterAllTaskManagers
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void unregisterAllTaskManagers()
focal_class.class_method_signature: InstanceManager.isRegistered(ActorRef taskManager)
focal_class.full_signature: public boolean isRegistered(ActorRef taskManager)
focal_class.identifier: isRegistered
focal_class.modifiers: public
focal_class.parameters: (ActorRef taskManager)
focal_class.return: boolean
focal_class.signature: boolean isRegistered(ActorRef taskManager)
focal_class.class_method_signature: InstanceManager.getNumberOfRegisteredTaskManagers()
focal_class.full_signature: public int getNumberOfRegisteredTaskManagers()
focal_class.identifier: getNumberOfRegisteredTaskManagers
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getNumberOfRegisteredTaskManagers()
focal_class.class_method_signature: InstanceManager.getTotalNumberOfSlots()
focal_class.full_signature: public int getTotalNumberOfSlots()
focal_class.identifier: getTotalNumberOfSlots
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getTotalNumberOfSlots()
focal_class.class_method_signature: InstanceManager.getNumberOfAvailableSlots()
focal_class.full_signature: public int getNumberOfAvailableSlots()
focal_class.identifier: getNumberOfAvailableSlots
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getNumberOfAvailableSlots()
focal_class.class_method_signature: InstanceManager.getAllRegisteredInstances()
focal_class.full_signature: public Collection<Instance> getAllRegisteredInstances()
focal_class.identifier: getAllRegisteredInstances
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Collection<Instance>
focal_class.signature: Collection<Instance> getAllRegisteredInstances()
focal_class.class_method_signature: InstanceManager.getRegisteredInstanceById(InstanceID instanceID)
focal_class.full_signature: public Instance getRegisteredInstanceById(InstanceID instanceID)
focal_class.identifier: getRegisteredInstanceById
focal_class.modifiers: public
focal_class.parameters: (InstanceID instanceID)
focal_class.return: Instance
focal_class.signature: Instance getRegisteredInstanceById(InstanceID instanceID)
focal_class.class_method_signature: InstanceManager.getRegisteredInstance(ActorRef ref)
focal_class.full_signature: public Instance getRegisteredInstance(ActorRef ref)
focal_class.identifier: getRegisteredInstance
focal_class.modifiers: public
focal_class.parameters: (ActorRef ref)
focal_class.return: Instance
focal_class.signature: Instance getRegisteredInstance(ActorRef ref)
focal_class.class_method_signature: InstanceManager.addInstanceListener(InstanceListener listener)
focal_class.full_signature: public void addInstanceListener(InstanceListener listener)
focal_class.identifier: addInstanceListener
focal_class.modifiers: public
focal_class.parameters: (InstanceListener listener)
focal_class.return: void
focal_class.signature: void addInstanceListener(InstanceListener listener)
focal_class.class_method_signature: InstanceManager.removeInstanceListener(InstanceListener listener)
focal_class.full_signature: public void removeInstanceListener(InstanceListener listener)
focal_class.identifier: removeInstanceListener
focal_class.modifiers: public
focal_class.parameters: (InstanceListener listener)
focal_class.return: void
focal_class.signature: void removeInstanceListener(InstanceListener listener)
focal_class.class_method_signature: InstanceManager.notifyNewInstance(Instance instance)
focal_class.full_signature: private void notifyNewInstance(Instance instance)
focal_class.identifier: notifyNewInstance
focal_class.modifiers: private
focal_class.parameters: (Instance instance)
focal_class.return: void
focal_class.signature: void notifyNewInstance(Instance instance)
focal_class.class_method_signature: InstanceManager.notifyDeadInstance(Instance instance)
focal_class.full_signature: private void notifyDeadInstance(Instance instance)
focal_class.identifier: notifyDeadInstance
focal_class.modifiers: private
focal_class.parameters: (Instance instance)
focal_class.return: void
focal_class.signature: void notifyDeadInstance(Instance instance)
focal_method.body: public boolean reportHeartBeat(InstanceID instanceId, byte[] lastMetricsReport) {
  		if (instanceId == null) {
  			throw new IllegalArgumentException("InstanceID may not be null.");
  		}
  
  		synchronized (this.lock) {
  			if (this.isShutdown) {
  				return false;
  			}
  
  			Instance host = registeredHostsById.get(instanceId);
  
  			if (host == null){
  				if (LOG.isDebugEnabled()) {
  					LOG.debug("Received heartbeat from unknown TaskManager with instance ID " + instanceId.toString() +
  							" Possibly TaskManager was marked as dead (timed-out) earlier. " +
  							"Reporting back that task manager is no longer known.");
  				}
  				return false;
  			}
  
  			host.reportHeartBeat();
  			host.setMetricsReport(lastMetricsReport);
  
  			if (LOG.isDebugEnabled()) {
  				LOG.debug("Received heartbeat from TaskManager " + host);
  			}
  
  			return true;
  		}
  	}
focal_method.class_method_signature: InstanceManager.reportHeartBeat(InstanceID instanceId, byte[] lastMetricsReport)
focal_method.full_signature: public boolean reportHeartBeat(InstanceID instanceId, byte[] lastMetricsReport)
focal_method.identifier: reportHeartBeat
focal_method.invocations: get isDebugEnabled debug toString reportHeartBeat setMetricsReport isDebugEnabled debug
focal_method.modifiers: public
focal_method.parameters: (InstanceID instanceId, byte[] lastMetricsReport)
focal_method.return: boolean
focal_method.signature: boolean reportHeartBeat(InstanceID instanceId, byte[] lastMetricsReport)