public static String getClientIdFromCacheClientProxy(CacheClientProxy p){ if(p == null){ return null; } StringBuffer buffer = new StringBuffer(); buffer.append("[").append(p.getProxyID()).append(":port=").append(p.getRemotePort()).append(":primary=") .append(p.isPrimary()).append("]"); return buffer.toString(); }
/** * * @return a list of client Ids connected to this particular server instance */ public String[] listClientIds() throws Exception { String[] allConnectedClientStr = null; try { Collection<CacheClientProxy> clientProxies = acceptor.getCacheClientNotifier().getClientProxies(); if (clientProxies.size() > 0) { allConnectedClientStr = new String[clientProxies.size()]; int j = 0; for (CacheClientProxy p : clientProxies) { StringBuffer buffer = new StringBuffer(); buffer.append("[").append(p.getProxyID()).append("; port=").append(p.getRemotePort()).append("; primary=").append(p.isPrimary()) .append("]"); allConnectedClientStr[j] = buffer.toString(); j++; } return allConnectedClientStr; } else { return new String[0]; } } catch (Exception e) { throw new Exception(e.getMessage()); } }
/** * * @param clientId * @return stats for a given client ID */ public ClientHealthStatus showClientStats(String clientId) throws Exception { try { if (acceptor != null && acceptor.getCacheClientNotifier() != null) { Collection<CacheClientProxy> clientProxies = acceptor.getCacheClientNotifier().getClientProxies(); for (CacheClientProxy p : clientProxies) { StringBuffer buffer = new StringBuffer(); buffer.append("[").append(p.getProxyID()).append("; port=").append(p.getRemotePort()).append("; primary=") .append(p.isPrimary()).append("]"); if (buffer.toString().equals(clientId)) { ClientHealthStatus status = getClientHealthStatus(p); return status; } } } } catch (Exception e) { throw new Exception(e.getMessage()); } return null; }
ClientConnInfo clientConInfo = new ClientConnInfo(p.getProxyID(), p.getSocketHost(), p.getRemotePort(), p.isPrimary()); uniqueIds.put(p.getProxyID().getDSMembership(), clientConInfo);
buffer.append("[").append(proxyID).append("; port=").append(p.getRemotePort()).append("; primary=").append( p.isPrimary()).append("]");