protected CacheClientNotifier getCacheClientNotifier() { return getAcceptor().getCacheClientNotifier(); }
public static Map getClientQueueSizes(final InternalCache cache) { if (cache == null) { return Collections.emptyMap(); } Map clientQueueSizes = new HashMap(); for (CacheServer cacheServer : cache.getCacheServers()) { CacheServerImpl cacheServerImpl = (CacheServerImpl) cacheServer; AcceptorImpl acceptor = cacheServerImpl.getAcceptor(); if (acceptor != null && acceptor.getCacheClientNotifier() != null) { clientQueueSizes.putAll(acceptor.getCacheClientNotifier().getClientQueueSizes()); } } return clientQueueSizes; }
public ClientQueueDetail getClientQueueDetail(String clientId) throws Exception { try { if (acceptor != null && acceptor.getCacheClientNotifier() != null) { Collection<CacheClientProxy> clientProxies = acceptor.getCacheClientNotifier().getClientProxies(); for (CacheClientProxy p : clientProxies) { String buffer = getClientIdFromCacheClientProxy(p); if (buffer.equals(clientId)) { ClientQueueDetail queueDetail = getClientQueueDetail(p); return queueDetail; } } } } catch (Exception e) { throw new Exception(e.getMessage()); } return null; }
/** * @return Client Queue Details for all clients */ public ClientQueueDetail[] getClientQueueDetails() throws Exception { List<ClientQueueDetail> clientQueueDetailList = null; try { if (acceptor != null && acceptor.getCacheClientNotifier() != null) { Collection<CacheClientProxy> clientProxies = acceptor.getCacheClientNotifier().getClientProxies(); if (clientProxies.size() > 0) { clientQueueDetailList = new ArrayList<ClientQueueDetail>(); } else { return new ClientQueueDetail[0]; } for (CacheClientProxy p : clientProxies) { ClientQueueDetail status = getClientQueueDetail(p); if (status != null) { clientQueueDetailList.add(status); } } ClientQueueDetail[] queueDetailArr = new ClientQueueDetail[clientQueueDetailList.size()]; return clientQueueDetailList.toArray(queueDetailArr); } return new ClientQueueDetail[0]; } catch (Exception e) { throw new Exception(e.getMessage()); } }
/** * Caller must synchronize on cache.allClientServersLock * * @return all the clients */ public static Map getConnectedClients(InternalCache cache) { // Get all clients Map allClients = new HashMap(); for (Iterator bsii = cache.getCacheServers().iterator(); bsii.hasNext();) { CacheServerImpl bsi = (CacheServerImpl) bsii.next(); AcceptorImpl ai = bsi.getAcceptor(); if (ai != null && ai.getCacheClientNotifier() != null) { allClients.putAll(ai.getCacheClientNotifier().getAllClients()); } } // Fill in the missing info, if HealthMonitor started if (ClientHealthMonitor.getInstance() != null) ClientHealthMonitor.getInstance().fillInClientInfo(allClients); return allClients; }
/** * Unregisters a client to be monitored. * * @param proxyID The id of the client to be unregistered * @param acceptor non-null if the call is from a <code>ServerConnection</code> (as opposed to a * <code>CacheClientProxy</code>). * @param clientDisconnectedCleanly Whether the client disconnected cleanly or crashed */ public void unregisterClient(ClientProxyMembershipID proxyID, AcceptorImpl acceptor, boolean clientDisconnectedCleanly, Throwable clientDisconnectException) { unregisterClient(proxyID, clientDisconnectedCleanly, clientDisconnectException); // Unregister any CacheClientProxy instances associated with this member id // if this method was invoked from a ServerConnection and the client did // not disconnect cleanly. if (acceptor != null) { CacheClientNotifier ccn = acceptor.getCacheClientNotifier(); if (ccn != null) { try { ccn.unregisterClient(proxyID, clientDisconnectedCleanly); } catch (CancelException ignore) { } } } }
@Override protected void process(ClusterDistributionManager dm) { Cache c = dm.getCache(); if (c != null) { List l = c.getCacheServers(); if (l != null) { Iterator i = l.iterator(); while (i.hasNext()) { CacheServerImpl bs = (CacheServerImpl) i.next(); CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier(); Set s = ccn.getDenylistedClient(); if (s != null) { if (s.remove(proxyID)) { DistributedSystem ds = dm.getSystem(); if (ds != null) { if (logger.isDebugEnabled()) { logger.debug( "Remove the client from deny list as its queue is already destroyed: {}", proxyID); } } } } } } } }
private static void findLocalDurableQueues(ClientProxyMembershipID proxyId, ArrayList<ServerLocation> matches) { InternalCache cache = GemFireCacheImpl.getInstance(); if (cache != null) { List l = cache.getCacheServers(); if (l != null) { Iterator i = l.iterator(); while (i.hasNext()) { CacheServerImpl bs = (CacheServerImpl) i.next(); if (bs.getAcceptor().getCacheClientNotifier().getClientProxy(proxyId) != null) { ServerLocation loc = new ServerLocation(bs.getExternalAddress(), bs.getPort()); matches.add(loc); } } } } }
@Override public void run() { logger.info(":Cache server: Initializing {} server-to-client communication socket: {}", isPrimaryServerToClient ? "primary" : "secondary", socket); try { acceptor.getCacheClientNotifier().registerClient(socket, isPrimaryServerToClient, acceptor.getAcceptorId(), acceptor.isNotifyBySubscription()); } catch (IOException ex) { closeSocket(socket); if (acceptor.isRunning()) { if (!acceptor.loggedAcceptError) { acceptor.loggedAcceptError = true; if (ex instanceof SocketTimeoutException) { logger .warn("Cache server: failed accepting client connection due to socket timeout."); } else { logger.warn("Cache server: failed accepting client connection " + ex, ex); } } } } } }
private static void verifyCacheClientProxyOnServer() { Cache cache = new ClientServerMiscDUnitTestBase().getCache(); assertEquals("More than one BridgeServer", 1, cache.getCacheServers().size()); CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next(); assertNotNull(bs); assertNotNull(bs.getAcceptor()); final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier(); assertNotNull(ccn); await() .until(() -> ccn.getClientProxies().size() == 1); }
private static void verifyInterestListOnServer() { try { Cache cache = new ClientServerMiscDUnitTestBase().getCache(); assertEquals("More than one BridgeServer", 1, cache.getCacheServers().size()); CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next(); assertNotNull(bs); assertNotNull(bs.getAcceptor()); assertNotNull(bs.getAcceptor().getCacheClientNotifier()); for (CacheClientProxy ccp : bs.getAcceptor().getCacheClientNotifier().getClientProxies()) { // CCP should not contain region1 Set<String> akr = ccp.cils[RegisterInterestTracker.interestListIndex].regions; assertNotNull(akr); assertTrue(!akr.contains(Region.SEPARATOR + REGION_NAME1)); // CCP should contain region2 assertTrue(akr.contains(Region.SEPARATOR + REGION_NAME2)); assertEquals(1, akr.size()); } } catch (Exception ex) { ex.printStackTrace(); fail("while setting verifyInterestListOnServer " + ex); } }
/** * Returns a {@code DurableClientInfoResponse} that will be returned to the specified recipient. */ public static DurableClientInfoResponse create(DistributionManager dm, InternalDistributedMember recipient, DurableClientInfoRequest request) { DurableClientInfoResponse m = new DurableClientInfoResponse(); m.setRecipient(recipient); try { InternalCache c = (InternalCache) CacheFactory.getInstanceCloseOk(dm.getSystem()); if (!c.getCacheServers().isEmpty()) { CacheServerImpl server = (CacheServerImpl) c.getCacheServers().iterator().next(); switch (request.action) { case DurableClientInfoRequest.HAS_DURABLE_CLIENT_REQUEST: { m.returnVal = server.getAcceptor().getCacheClientNotifier().hasDurableClient(request.durableId); break; } case DurableClientInfoRequest.IS_PRIMARY_FOR_DURABLE_CLIENT_REQUEST: { m.returnVal = server.getAcceptor().getCacheClientNotifier() .hasPrimaryForDurableClient(request.durableId); break; } } } } catch (CacheClosedException ignore) { // do nothing } return m; }
public void setCq(String cqName, boolean isDurable) throws Exception { final boolean isDebugEnabled = logger.isDebugEnabled(); if (this.requestMessage.isSecureMode()) { if (isDebugEnabled) { logger.debug("setCq() security header found registering CQname = {}", cqName); } try { byte[] secureBytes = this.requestMessage.getSecureBytes(); secureBytes = this.handshake.getEncryptor().decryptBytes(secureBytes); AuthIds aIds = new AuthIds(secureBytes); long uniqueId = aIds.getUniqueId(); CacheClientProxy proxy = getAcceptor().getCacheClientNotifier().getClientProxy(this.proxyId); if (proxy != null) { proxy.setCQVsUserAuth(cqName, uniqueId, isDurable); } } catch (Exception ex) { if (isDebugEnabled) { logger.debug("While setting cq got exception ", ex); } throw ex; } } else { if (isDebugEnabled) { logger.debug("setCq() security header is not found "); } } }
private static void verifyNoCacheClientProxyOnServer() { try { Cache cache = new ClientServerMiscDUnitTestBase().getCache(); assertEquals("More than one BridgeServer", 1, cache.getCacheServers().size()); CacheServerImpl cacheServer = (CacheServerImpl) cache.getCacheServers().iterator().next(); assertNotNull(cacheServer); assertNotNull(cacheServer.getAcceptor()); final CacheClientNotifier ccn = cacheServer.getAcceptor().getCacheClientNotifier(); assertNotNull(ccn); await() .until(() -> ccn.getClientProxies().size() == 0); } catch (Exception ex) { System.out.println("The size of the client proxies != 0"); OSProcess.printStacks(0); throw ex; } }
acceptor.getCacheClientNotifier().getClientProxies();
when(this.acceptor.getCacheClientNotifier()).thenReturn(ccn);
@Override public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection, final SecurityService securityService, long start) throws IOException, ClassNotFoundException { serverConnection.setAsTrue(REQUIRES_RESPONSE); Part isClientReadyPart = clientMessage.getPart(0); byte[] isClientReadyPartBytes = (byte[]) isClientReadyPart.getObject(); boolean isClientReady = isClientReadyPartBytes[0] == 0x01; final boolean isDebugEnabled = logger.isDebugEnabled(); if (isDebugEnabled) { logger.debug("{}: Received make primary request ({} bytes) isClientReady={}: from {}", serverConnection.getName(), clientMessage.getPayloadLength(), isClientReady, serverConnection.getSocketString()); } try { serverConnection.getAcceptor().getCacheClientNotifier() .makePrimary(serverConnection.getProxyID(), isClientReady); writeReply(clientMessage, serverConnection); serverConnection.setAsTrue(RESPONDED); if (isDebugEnabled) { logger.debug("{}: Sent make primary response for {}", serverConnection.getName(), serverConnection.getSocketString()); } } catch (Exception e) { writeException(clientMessage, e, false, serverConnection); serverConnection.setAsTrue(RESPONDED); } }
serverConnection.getAcceptor().getCacheClientNotifier() .readyForEvents(serverConnection.getProxyID());
boolean keepalive = (keepaliveByte == null || keepaliveByte[0] == 0) ? false : true; serverConnection.getAcceptor().getCacheClientNotifier() .setKeepAlive(serverConnection.getProxyID(), keepalive);
while (i.hasNext()) { CacheServerImpl bs = (CacheServerImpl) i.next(); CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();