@Override public CompositeData call() throws Exception { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); if (type == InfoType.memory) { ObjectName memName = new ObjectName("java.lang:type=Memory"); return (CompositeData) mbs.getAttribute(memName, "HeapMemoryUsage"); } else if (type == InfoType.timing) { ObjectName osName = new ObjectName("java.lang:type=Runtime"); Map<String, Object> times = new HashMap<String, Object>(2); long time = (Long) mbs.getAttribute(osName, "StartTime"); times.put("StartTime", new Date(time).toString()); time = (Long) mbs.getAttribute(osName, "Uptime"); times.put("Uptime", DateUtils.getDuration(time)); return JMXUtils.mapToComposite("Timings", "Timing info", times); } else { Set<HazelcastInstance> instances = Hazelcast.getAllHazelcastInstances(); Map<String, Object> clients = new HashMap<String, Object>(); for (HazelcastInstance hzInstance: instances) { for (Client client: hzInstance.getClientService().getConnectedClients()) { clients.put(client.getUuid(), client.getSocketAddress().toString()); } } return JMXUtils.mapToComposite("Clients", "Clients info", clients); } }
@Override public void clientDisconnected(Client client) { String clientId = client.getUuid(); logger.trace("clientDisconnected.enter; client: {}", clientId); // check and destroy client's resources for (Map.Entry<String, Properties> entry: clientsCache.entrySet()) { Properties props = entry.getValue(); String uuid = props.getProperty(pn_client_memberId); if (clientId.equals(uuid)) { clientsCache.remove(entry.getKey()); } } //XQProcessor proc = processors.remove(client.getUuid()); }
private void doFireClientEvent(final Client client, final boolean connected) { if (client == null) throw new IllegalArgumentException("Client is null."); for (final ClientListener clientListener : listeners) { concurrentMapManager.node.executorManager.executeNow(new Runnable() { public void run() { if (connected) { clientListener.clientConnected(client); } else { clientListener.clientDisconnected(client); } } }); } }
@Override public void clientConnected(Client client) { String clientId = client.getUuid(); logger.info("clientConnected.enter; client: {}", clientId); }
public Collection<Client> getConnectedClients() { return clients; }
void add(Client client) { this.clients.add(client); doFireClientEvent(client, true); }
void remove(Client client) { this.clients.remove(client); doFireClientEvent(client, false); }