/** * Returns the <code>CacheClientProxy</code> associated to the durableClientId * * @return the <code>CacheClientProxy</code> associated to the durableClientId */ public CacheClientProxy getClientProxy(String durableClientId) { return getClientProxy(durableClientId, false); }
@Override public Set getAllClientSessions() { return new HashSet(getCacheClientNotifier().getClientProxies()); }
/** * this method uses CacheClientNotifier to try to obtain an ID that is equal to this one. This is * used during deserialization to reduce storage overhead. */ private ClientProxyMembershipID canonicalReference() { CacheClientNotifier ccn = CacheClientNotifier.getInstance(); if (ccn != null) { CacheClientProxy cp = ccn.getClientProxy(this, true); if (cp != null) { if (this.isCanonicalEquals(cp.getProxyID())) { return cp.getProxyID(); } } } return this; }
/** * Factory method to construct a CacheClientNotifier <code>CacheClientNotifier</code> instance. * * @param cache The GemFire <code>InternalCache</code> * @return A <code>CacheClientNotifier</code> instance */ public static synchronized CacheClientNotifier getInstance(InternalCache cache, CacheServerStats acceptorStats, int maximumMessageCount, int messageTimeToLive, ConnectionListener listener, List overflowAttributesList, boolean isGatewayReceiver) { if (ccnSingleton == null) { ccnSingleton = new CacheClientNotifier(cache, acceptorStats, maximumMessageCount, messageTimeToLive, listener, overflowAttributesList, isGatewayReceiver); } if (!isGatewayReceiver && ccnSingleton.getHaContainer() == null) { // Gateway receiver might have create CCN instance without HaContainer // In this case, the HaContainer should be lazily created here ccnSingleton.initHaContainer(overflowAttributesList); } return ccnSingleton; }
public void waitTillCacheClientProxyHasBeenPaused() { await().until(() -> { CacheClientNotifier clientNotifier = CacheClientNotifier.getInstance(); Collection<CacheClientProxy> clientProxies = clientNotifier.getClientProxies(); for (CacheClientProxy clientProxy : clientProxies) { if (clientProxy.isPaused()) { return true; } } return false; }); }
/** * Unregisters an existing client from this server. * * @param memberId Uniquely identifies the client */ public void unregisterClient(ClientProxyMembershipID memberId, boolean normalShutdown) { if (logger.isDebugEnabled()) { logger.debug("CacheClientNotifier: Unregistering all clients with member id: {}", memberId); } CacheClientProxy proxy = getClientProxy(memberId); if (proxy != null) { final boolean isTraceEnabled = logger.isTraceEnabled(); if (isTraceEnabled) { logger.trace("CacheClientNotifier: Potential client: {}", proxy); } // If the proxy's member id is the same as the input member id, add // it to the set of dead proxies. if (!proxy.startRemoval()) { if (isTraceEnabled) { logger.trace("CacheClientNotifier: Potential client: {} matches {}", proxy, memberId); } closeDeadProxies(Collections.singletonList(proxy), normalShutdown); } } }
serverConnection.getAcceptor().getCacheClientNotifier().registerClientInterest(regionName, keys, serverConnection.getProxyID(), isDurable, sendUpdatesAsInvalidates, false, 0, true); } catch (Exception ex) { .getClientProxy(serverConnection.getProxyID()).isPrimary(); if (!isPrimary) { chunkedResponseMsg.setMessageType(MessageType.RESPONSE_FROM_SECONDARY);
if (clientIsDurable) { if (l_proxy == null) { if (isTimedOut(proxyId)) { queueSize = PoolImpl.PRIMARY_QUEUE_TIMED_OUT; } else { new CacheClientProxy(this, socket, proxyId, isPrimary, clientConflation, clientVersion, acceptorId, notifyBySubscription, this.cache.getSecurityService(), subject); successful = this.initializeProxy(l_proxy); } else { l_proxy.setSubject(subject); l_proxy.reinitialize(socket, proxyId, this.getCache(), isPrimary, clientConflation, clientVersion); l_proxy.setMarkerEnqueued(true); CacheClientProxy staleClientProxy = this.getClientProxy(proxyId); boolean toCreateNewProxy = true; if (staleClientProxy != null) { } else { staleClientProxy.close(false, false); // do not check for queue, just close it removeClientProxy(staleClientProxy); // remove old proxy from proxy set new CacheClientProxy(this, socket, proxyId, isPrimary, clientConflation, clientVersion, acceptorId, notifyBySubscription, this.cache.getSecurityService(), subject); successful = this.initializeProxy(l_proxy); writeHandshakeMessage(dos, responseByte, unsuccessfulMsg, clientVersion, endpointType,
try { proxyID = ClientProxyMembershipID.readCanonicalized(dis); if (getDenylistedClient().contains(proxyID)) { writeException(dos, Handshake.REPLY_INVALID, new Exception("This client is denylisted by server"), clientVersion); return; proxy = getClientProxy(proxyID); DistributedMember member = proxyID.getDistributedMember(); DistributedSystem system = this.getCache().getDistributedSystem(); Properties sysProps = system.getProperties(); String authenticator = sysProps.getProperty(SECURITY_CLIENT_AUTHENTICATOR); break; default: writeException(dos, Handshake.REPLY_INVALID, new IllegalArgumentException("Invalid conflation byte"), clientVersion); return; proxy = registerClient(socket, proxyID, proxy, isPrimary, clientConflation, clientVersion, acceptorId, notifyBySubscription, shiroSubject); Method authzMethod = ClassLoadUtil.methodFromName(postAuthzFactoryName); authzCallback = (AccessControl) authzMethod.invoke(null, (Object[]) null); authzCallback.init(principal, member, this.getCache()); String.format("An exception was thrown for client [%s]. %s", new Object[] {proxyID, ex}));
clientMessage = constructClientMessage(event); } else { clientMessage = (ClientUpdateMessageImpl) cmsg; Set<ClientProxyMembershipID> ids = getProxyIDs(rawIDs, true); if (ids.remove(event.getContext())) { // don't send to member of origin CacheClientProxy ccp = getClientProxy(event.getContext()); if (ccp != null) { ccp.getStatistics().incMessagesNotQueuedOriginator(); Set<ClientProxyMembershipID> ids = getProxyIDs(rawIDs, true); if (ids.remove(event.getContext())) { // don't send to member of origin CacheClientProxy ccp = getClientProxy(event.getContext()); if (ccp != null) { ccp.getStatistics().incMessagesNotQueuedOriginator(); CacheClientProxy ccp = getClientProxy((ClientProxyMembershipID) id, true); if (ccp != null && ccp.getVersion().compareTo(Version.GFE_70) < 0) { filterClients.remove(id); singletonRouteClientMessage(conflatable, filterClients); removeDestroyTokensFromCqResultKeys(event, filterInfo);
/** * Registers client interest in the input region and list of keys. * * @param regionName The name of the region of interest * @param keysOfInterest The list of keys of interest * @param membershipID The <code>ClientProxyMembershipID</code> of the client no longer interested * in this <code>Region</code> and key */ public void registerClientInterest(String regionName, List keysOfInterest, ClientProxyMembershipID membershipID, boolean isDurable, boolean sendUpdatesAsInvalidates, boolean manageEmptyRegions, int regionDataPolicy, boolean flushState) throws IOException, RegionDestroyedException { CacheClientProxy proxy = getClientProxy(membershipID, true); if (logger.isDebugEnabled()) { logger.debug("CacheClientNotifier: Client {} registering interest in: {} -> {}", proxy, regionName, keysOfInterest); } if (proxy == null) { throw new IOException( "CacheClientProxy for this client is no longer on the server , so registerInterest operation is unsuccessful"); } proxy.registerClientInterestList(regionName, keysOfInterest, isDurable, sendUpdatesAsInvalidates, flushState); if (manageEmptyRegions) { updateMapOfEmptyRegions(proxy.getRegionsWithEmptyDataPolicy(), regionName, regionDataPolicy); } }
private CliFunctionResult createFunctionResult(String memberNameOrId, String durableClientId) { try { CacheClientNotifier cacheClientNotifier = CacheClientNotifier.getInstance(); if (cacheClientNotifier == null) { return new CliFunctionResult(memberNameOrId, CliFunctionResult.StatusState.ERROR, CliStrings.NO_CLIENT_FOUND); } CacheClientProxy ccp = cacheClientNotifier.getClientProxy(durableClientId); if (ccp == null) { return new CliFunctionResult(memberNameOrId, CliFunctionResult.StatusState.ERROR, CliStrings.format(CliStrings.NO_CLIENT_FOUND_WITH_CLIENT_ID, durableClientId)); } boolean isClosed = cacheClientNotifier.closeDurableClientProxy(durableClientId); if (isClosed) { return new CliFunctionResult(memberNameOrId, CliFunctionResult.StatusState.OK, CliStrings.format(CliStrings.CLOSE_DURABLE_CLIENTS__SUCCESS, durableClientId)); } else { return new CliFunctionResult(memberNameOrId, CliFunctionResult.StatusState.ERROR, CliStrings.format(CliStrings.NO_CLIENT_FOUND_WITH_CLIENT_ID, durableClientId)); } } catch (Exception e) { return new CliFunctionResult(memberNameOrId, CliFunctionResult.StatusState.ERROR, e.getMessage()); } }
private CliFunctionResult createFunctionResult(String memberNameOrId, String durableClientId, String cqName) { CacheClientNotifier cacheClientNotifier = CacheClientNotifier.getInstance(); try { if (cacheClientNotifier == null) { return new CliFunctionResult(memberNameOrId, CliFunctionResult.StatusState.ERROR, CliStrings.NO_CLIENT_FOUND); } CacheClientProxy cacheClientProxy = cacheClientNotifier.getClientProxy(durableClientId); if (cacheClientProxy == null) { return new CliFunctionResult(memberNameOrId, CliFunctionResult.StatusState.ERROR, CliStrings.format(CliStrings.NO_CLIENT_FOUND_WITH_CLIENT_ID, durableClientId)); } if (cacheClientNotifier.closeClientCq(durableClientId, cqName)) { return new CliFunctionResult(memberNameOrId, CliFunctionResult.StatusState.OK, CliStrings.format(CliStrings.CLOSE_DURABLE_CQS__SUCCESS, cqName, durableClientId)); } else { return new CliFunctionResult(memberNameOrId, CliFunctionResult.StatusState.ERROR, CliStrings.format(CliStrings.CLOSE_DURABLE_CQS__UNABLE__TO__CLOSE__CQ, cqName, durableClientId)); } } catch (Exception e) { return new CliFunctionResult(memberNameOrId, e); } }
CacheClientNotifier ccn = CacheClientNotifier.getInstance(); if (ccn == null || ccn.getHaContainer() == null) { logger.info("HA Container not found during HA Region GII for {}", haReg); return; ((HAContainerWrapper) ccn.getHaContainer()).getProxyID(haReg.getName()); if (clientID == null) { throw new ReplyException("Client proxy ID not found for queue " + haReg.getName()); clientProxy = ccn.getClientProxy(clientID); if (clientProxy == null) { throw new ReplyException("Client proxy not found for queue " + haReg.getName());
private CliFunctionResult createFunctionResult(String memberNameOrId, String durableClientId, String cqName) { try { CacheClientNotifier cacheClientNotifier = CacheClientNotifier.getInstance(); CacheClientProxy cacheClientProxy = cacheClientNotifier.getClientProxy(durableClientId); Integer.toString(cacheClientNotifier.getDurableClientHAQueueSize(durableClientId)));
private void singletonRouteClientMessage(Conflatable conflatable, Collection<ClientProxyMembershipID> filterClients) { this.cache.getCancelCriterion().checkCancelInProgress(null); // bug #43942 - client notified // but no p2p distribution List<CacheClientProxy> deadProxies = null; for (ClientProxyMembershipID clientId : filterClients) { CacheClientProxy proxy; proxy = this.getClientProxy(clientId, true); if (proxy != null) { if (proxy.isAlive() || proxy.isPaused() || proxy.isConnected() || proxy.isDurable()) { proxy.deliverMessage(conflatable); } else { proxy.getStatistics().incMessagesFailedQueued(); if (deadProxies == null) { deadProxies = new ArrayList<CacheClientProxy>(); } deadProxies.add(proxy); } this.denyListSlowReceiver(proxy); } } if (conflatable instanceof HAEventWrapper) { ((HAEventWrapper) conflatable).decrementPutInProgressCounter(); } // Remove any dead clients from the clients to notify if (deadProxies != null) { closeDeadProxies(deadProxies, false); } }
CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier(); ccn.addToDenylistedClient(this.proxyId); CacheClientProxy proxy = ccn.getClientProxy(this.proxyId); if (proxy != null) { ccn.removeClientProxy(proxy);
@Override protected boolean operateOnPartitionedRegion(final ClusterDistributionManager dm, PartitionedRegion r, long startTime) throws ForceReattemptException { if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) { logger.trace("PRTombstoneMessage operateOnRegion: {}", r.getFullPath()); } FilterProfile fp = r.getFilterProfile(); if (this.keys != null && this.keys.size() > 0) { // sanity check if (fp != null && CacheClientNotifier.getInstance() != null && this.eventID != null) { RegionEventImpl regionEvent = new RegionEventImpl(r, Operation.REGION_DESTROY, null, true, r.getGemFireCache().getMyId()); regionEvent.setLocalFilterInfo(fp.getLocalFilterRouting(regionEvent)); ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(r, this.keys, this.eventID); CacheClientNotifier.notifyClients(regionEvent, clientMessage); } } return true; }
CacheClientNotifier ccn = CacheClientNotifier.getInstance(); if (ccn != null && ccn.getHaContainer() != null) { CacheClientProxy proxy = ((HAContainerWrapper) ccn.getHaContainer()).getProxy(region.getName()); logger.debug("Processing FilterInfo for proxy: {} : {}", proxy, msg);
private boolean initializeProxy(CacheClientProxy l_proxy) throws IOException, CacheException { boolean status = false; if (!this.isProxyInInitializationMode(l_proxy)) { if (logger.isDebugEnabled()) { logger.debug("Initializing proxy: {}", l_proxy); } try { // Add client proxy to initialization list. This has to be done before // the queue is created so that events can be buffered here for delivery // to the queue once it's initialized (bug #41681 and others) addClientInitProxy(l_proxy); l_proxy.initializeMessageDispatcher(); // Initialization success. Add to client proxy list. addClientProxy(l_proxy); return true; } catch (RegionExistsException ree) { if (logger.isDebugEnabled()) { String name = ree.getRegion() != null ? ree.getRegion().getFullPath() : "null region"; logger.debug("Found RegionExistsException while initializing proxy. Region name: {}", name); } // This will return false; } finally { removeClientInitProxy(l_proxy); } } return status; }