@Test public void testHeartbeat() throws Exception { String consumerName = "c1"; String ip = "1.1.1.1"; long heartbeatTime = 1L; m_list.heartbeat(consumerName, heartbeatTime, ip); Map<String, ClientContext> activeConsumers = m_list.getActiveConsumers(); assertEquals(1, activeConsumers.size()); TestHelper.assertClientContextEquals(consumerName, ip, heartbeatTime, activeConsumers.get(consumerName)); assertTrue(m_list.getAndResetChanged()); }
public void heartbeat(String consumerName, long heartbeatTime, String ip) { if (!m_consumers.containsKey(consumerName)) { m_changed = true; m_consumers.put(consumerName, new ClientContext(consumerName, ip, -1, null, null, heartbeatTime)); } else { ClientContext consumerContext = m_consumers.get(consumerName); if (!StringUtils.equals(consumerContext.getIp(), ip)) { m_changed = true; consumerContext.setIp(ip); } consumerContext.setLastHeartbeatTime(heartbeatTime); } }
ActiveConsumerList { public void heartbeat(String consumerName, long heartbeatTime, String ip) { if (!m_consumers.containsKey(consumerName)) { m_changed = true; m_consumers.put(consumerName, new ClientContext(consumerName, ip, -1, null, null, heartbeatTime)); } else { ClientContext consumerContext = m_consumers.get(consumerName); if (!StringUtils.equals(consumerContext.getIp(), ip)) { m_changed = true; consumerContext.setIp(ip); } consumerContext.setLastHeartbeatTime(heartbeatTime); } } }
ActiveConsumerList { public void heartbeat(String consumerName, long heartbeatTime, String ip) { if (!m_consumers.containsKey(consumerName)) { m_changed = true; m_consumers.put(consumerName, new ClientContext(consumerName, ip, -1, null, null, heartbeatTime)); } else { ClientContext consumerContext = m_consumers.get(consumerName); if (!StringUtils.equals(consumerContext.getIp(), ip)) { m_changed = true; consumerContext.setIp(ip); } consumerContext.setLastHeartbeatTime(heartbeatTime); } }  }
ActiveConsumerList { public void heartbeat(String consumerName, long heartbeatTime, String ip) { if (!m_consumers.containsKey(consumerName)) { m_changed = true; m_consumers.put(consumerName, new ClientContext(consumerName, ip, -1, null, null, heartbeatTime)); } else { ClientContext consumerContext = m_consumers.get(consumerName); if (!StringUtils.equals(consumerContext.getIp(), ip)) { m_changed = true; consumerContext.setIp(ip); } consumerContext.setLastHeartbeatTime(heartbeatTime); } }  void heartbeat(String consumerName, long heartbeatTime, String ip); void purgeExpired(long timeoutMillis, long now); boolean getAndResetChanged(); Map<String, ClientContext> getActiveConsumers(); }
ActiveConsumerList { public void heartbeat(String consumerName, long heartbeatTime, String ip) { if (!m_consumers.containsKey(consumerName)) { m_changed = true; m_consumers.put(consumerName, new ClientContext(consumerName, ip, -1, null, null, heartbeatTime)); } else { ClientContext consumerContext = m_consumers.get(consumerName); if (!StringUtils.equals(consumerContext.getIp(), ip)) { m_changed = true; consumerContext.setIp(ip); } consumerContext.setLastHeartbeatTime(heartbeatTime); } }  void heartbeat(String consumerName, long heartbeatTime, String ip); void purgeExpired(long timeoutMillis, long now); boolean getAndResetChanged(); Map<String, ClientContext> getActiveConsumers();  }