@Override public ClientProxyMembershipID getProxyID(String haRegionName) { CacheClientProxy proxy = haRegionNameToProxy.get(haRegionName); if (proxy != null) { return proxy.getProxyID(); } else { return null; } }
proxy.registerClientInterest(regionName, keyOfInterest, interestType, isDurable, sendUpdatesAsInvalidates, flushState); updateMapOfEmptyRegions(proxy.getRegionsWithEmptyDataPolicy(), regionName, regionDataPolicy); } finally { if (!done) { proxy.unregisterClientInterest(regionName, keyOfInterest, interestType, false);
public String getState() { StringBuffer buffer = new StringBuffer(); buffer.append("CacheClientProxy[") .append(this.proxyID) .append("; port=").append(this._socket.getPort()).append("; primary=").append(isPrimary) .append("; version=").append(clientVersion).append("; paused=").append(isPaused()) .append("; alive=").append(isAlive()).append("; connected=").append(isConnected()) .append("; isMarkedForRemoval=").append(isMarkedForRemoval).append("]"); if (_messageDispatcher != null && isAlive()) { buffer.append(LogWriterImpl.getStackTrace(_messageDispatcher)); } return buffer.toString(); }
private void closeTransientFields() { if (!closeSocket()) { // The thread who closed the socket will be responsible to // releaseResourcesForAddress and clearClientInterestList return; } closeOtherTransientFields(); }
public static boolean checkPrimary(CacheClientProxy proxy) { System.out.println("proxy " + proxy.getProxyID() + " : " + proxy.isPrimary()); return proxy.isPrimary(); }
private 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(); }
new CacheClientProxy(this, socket, proxyId, isPrimary, clientConflation, clientVersion, acceptorId, notifyBySubscription, this.cache.getSecurityService(), subject); successful = this.initializeProxy(l_proxy); } else { l_proxy.setSubject(subject); if (proxy.isPrimary()) { endpointType = (byte) 2; } else { endpointType = (byte) 1; queueSize = proxy.getQueueSize(); if (l_proxy.isPaused()) { if (CacheClientProxy.testHook != null) { CacheClientProxy.testHook.doTestHook("CLIENT_PRE_RECONNECT"); if (l_proxy.lockDrain()) { try { if (logger.isDebugEnabled()) { l_proxy.getProxyID().updateDurableTimeout(proxyId.getDurableTimeout()); l_proxy.reinitialize(socket, proxyId, this.getCache(), isPrimary, clientConflation, clientVersion); l_proxy.setMarkerEnqueued(true); if (CacheClientProxy.testHook != null) { CacheClientProxy.testHook.doTestHook("CLIENT_RECONNECTED"); l_proxy.unlockDrain();
protected Message getGFE61Message(CacheClientProxy proxy, byte[] latestValue, boolean conflation, Version clientVersion) throws IOException { Message message = null; ClientProxyMembershipID proxyId = proxy.getProxyID(); if (this.deltaBytes != null && !conflation && !proxy.isMarkerEnqueued() && !proxy.getRegionsWithEmptyDataPolicy().containsKey(_regionName)) { message.addObjPart(Boolean.TRUE); message.addBytesPart(this.deltaBytes); proxy.getStatistics().incDeltaMessagesSent(); } else { message.addObjPart(Boolean.FALSE);
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); } }
_maximumMessageCount); String name = "Client Message Dispatcher for " + getProxyID().getDistributedMember() + (isDurable() ? " (" + getDurableId() + ")" : ""); this._messageDispatcher = createMessageDispatcher(name); drainQueuedEvents(false); drainQueuedEvents(true);
new ClientConnInfo(p.getProxyID(), p.getSocketHost(), p.getRemotePort(), p.isPrimary()); uniqueIds.put(p.getProxyID().getDSMembership(), clientConInfo);
this.cils[RegisterInterestTracker.durableInterestListIndex].clearClientInterestList(); destroyRQ(); return; if (this.testAndSetPaused(false)) { if (logger.isDebugEnabled()) { logger.debug("{}: Paused but terminating processing", this); cancelDurableExpirationTask(false); closedSocket = closeSocket(); destroyRQ(); alreadyDestroyed = true; this._messageDispatcher.interrupt(); destroyRQ(); closeOtherTransientFields(); } else { closeTransientFields(); // make sure this happens
harq.setExpiryTime(proxy._messageTimeToLive); ((HAContainerWrapper) proxy._cacheClientNotifier.getHaContainer()) .putProxy(HARegionQueue.createRegionName(getProxy().getHARegionName()), getProxy()); boolean createDurableQueue = proxy.proxyID.isDurable(); boolean canHandleDelta = (proxy.clientVersion.compareTo(Version.GFE_61) >= 0) logger.debug("Creating a {} subscription queue for {}", createDurableQueue ? "durable" : "non-durable", proxy.getProxyID()); this._messageQueue = HARegionQueue.getHARegionQueueInstance(getProxy().getHARegionName(), getCache(), harq, HARegionQueue.BLOCKING_HA_QUEUE, createDurableQueue, proxy._cacheClientNotifier.getHaContainer(), proxy.getProxyID(), this._proxy.clientConflation, this._proxy.isPrimary(), canHandleDelta); if (this._proxy.hasRegisteredInterested()) { this._messageQueue.setHasRegisteredInterest(true);
if (proxy != null && proxy.waitRemoval()) { proxy = getAcceptor().getCacheClientNotifier().getClientProxy(this.proxyId); proxy); if (proxy.isPrimary()) { endpointType = (byte) 2; queueSize = proxy.getQueueSize(); } else { endpointType = (byte) 1; queueSize = proxy.getQueueSize(); if (proxy != null && !proxy.isPaused()) {
private void closeAllClientCqs(CacheClientProxy proxy) { CqService cqService = proxy.getCache().getCqService(); if (cqService != null) { final boolean isDebugEnabled = logger.isDebugEnabled(); // LocalizedMessage.create( try { if (isDebugEnabled) { logger.debug("CacheClientNotifier: Closing client CQs: {}", proxy); } cqService.closeClientCqs(proxy.getProxyID()); } catch (CqException e1) { logger.warn("Unable to close CQs for the client: {}", proxy.getProxyID()); if (isDebugEnabled) { e1.printStackTrace(); } } } }
@Override protected Message getMessage(CacheClientProxy proxy, byte[] latestValue) throws IOException { Version clientVersion = proxy.getVersion(); Message message = null; if (clientVersion.compareTo(Version.GFE_57) >= 0) { message = getGFEMessage(proxy.getProxyID(), null, clientVersion); } else { throw new IOException( "Unsupported client version for server-to-client message creation: " + clientVersion); } return message; }
private ClientQueueDetail getClientQueueDetail(CacheClientProxy p) { ClientQueueDetail queueDetail = new ClientQueueDetail(); ClientProxyMembershipID proxyID = p.getProxyID(); if (!p.isConnected() && !proxyID.isDurable()) { return null; } queueDetail.setClientId(getClientIdFromCacheClientProxy(p)); HARegionQueue queue = p.getHARegionQueue(); if (queue == null) { return queueDetail; } queueDetail.setQueueSize(p.getQueueSizeStat()); queueDetail.setEventsConflated(queue.getStatistics().getEventsConflated()); queueDetail.setEventsEnqued(queue.getStatistics().getEventsEnqued()); queueDetail.setEventsExpired(queue.getStatistics().getEventsExpired()); queueDetail.setEventsRemoved(queue.getStatistics().getEventsRemoved()); queueDetail.setEventsRemovedByQrm(queue.getStatistics().getEventsRemovedByQrm()); queueDetail.setEventsTaken(queue.getStatistics().getEventsTaken()); queueDetail.setMarkerEventsConflated(queue.getStatistics().getMarkerEventsConflated()); queueDetail.setNumVoidRemovals(queue.getStatistics().getNumVoidRemovals()); return queueDetail; }
private void handleInterestEvent(String regionName, Set keysOfInterest, int interestType, boolean isRegister) { // Notify the region about this register interest event if: // - the application has requested it // - this is a primary CacheClientProxy (otherwise multiple notifications // may occur) // - it is a key interest type (regex is currently not supported) InterestRegistrationEvent event = null; if (NOTIFY_REGION_ON_INTEREST && this.ccp.isPrimary() && interestType == InterestType.KEY) { event = new InterestRegistrationEventImpl(this.ccp, regionName, keysOfInterest, interestType, isRegister); try { notifyRegionOfInterest(event); } catch (Exception e) { logger.warn("Region notification of interest failed", e); } } // Invoke interest registration listeners if (containsInterestRegistrationListeners()) { if (event == null) { event = new InterestRegistrationEventImpl(this.ccp, regionName, keysOfInterest, interestType, isRegister); } notifyInterestRegistrationListeners(event); } }
/** * Shuts down durable client proxy */ public boolean closeDurableClientProxy(String durableClientId) throws CacheException { CacheClientProxy ccp = getClientProxy(durableClientId); if (ccp == null) { return false; } // we can probably remove the isPaused check if (ccp.isPaused() && !ccp.isConnected()) { ccp.setKeepAlive(false); closeDeadProxies(Collections.singletonList(ccp), true); return true; } else { if (logger.isDebugEnabled()) { logger.debug("Cannot close running durable client: {}", durableClientId); } // TODO: never throw an anonymous inner class throw new CacheException("Cannot close a running durable client : " + durableClientId) {}; } }
/** * Reinitialize a durable <code>CacheClientProxy</code> with a new client. * * @param socket The socket between the server and the client * @param ip whether this proxy represents the primary */ protected void reinitialize(Socket socket, ClientProxyMembershipID proxyId, Cache cache, boolean ip, byte cc, Version ver) { // Re-initialize transient fields initializeTransientFields(socket, proxyId, ip, cc, ver); getCacheClientNotifier().getAcceptorStats().incCurrentQueueConnections(); // Cancel expiration task cancelDurableExpirationTask(true); // Set the message dispatcher's primary flag. This could go from primary // to secondary this._messageDispatcher._messageQueue.setPrimary(ip); this._messageDispatcher._messageQueue.setClientConflation(cc); reinitializeClientAuths(); this.creationDate = new Date(); if (logger.isDebugEnabled()) { logger.debug("{}: Has been reinitialized", this); } }