@Override public int compare(Object o1, Object o2) { ServerQueueStatus s1 = (ServerQueueStatus) o1; ServerQueueStatus s2 = (ServerQueueStatus) o2; // sort primaries to the front of the list if (s1.isPrimary() && !s2.isPrimary()) { return -1; } else if (!s1.isPrimary() && s2.isPrimary()) { return 1; } else { int diff = s1.getServerQueueSize() - s2.getServerQueueSize(); if (diff != 0) { return diff; } else { return s1.getMemberId().compareTo(s2.getMemberId()); } } } }
public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("ServerQueueStatus [").append("queueSize=").append(this.qSize) .append("; endpointType=").append(getTypeAsString()).append("; pingInterval=") .append(this.pingInterval).append("ms]"); return buffer.toString(); }
protected String getTypeAsString() { String type = null; if (isNonRedundant()) { type = "NON_REDUNDANT"; } else if (isRedundant()) { type = "REDUNDANT"; } else { type = "PRIMARY"; } return type; }
if (serverQueueStatus.isPrimary() || serverQueueStatus.isNonRedundant()) { PoolImpl pool = (PoolImpl) this.qManager.getPool(); if (!pool.getReadyForEventsCalled()) { pool.setPendingEventCount(serverQueueStatus.getServerQueueSize());
void createClientCacheAndVerifyPingIntervalIsSet(String host, int port) throws Exception { PoolImpl pool = null; try { Properties props = new Properties(); props.setProperty(MCAST_PORT, "0"); props.setProperty(LOCATORS, ""); createCache(props); pool = (PoolImpl) PoolManager.createFactory().addServer(host, port) .setSubscriptionEnabled(true).setThreadLocalConnections(false).setReadTimeout(1000) .setSocketBufferSize(32768).setMinConnections(1).setSubscriptionRedundancy(-1) .setPingInterval(2000).create("test pool"); Region<Object, Object> region = cache.createRegionFactory(RegionShortcut.LOCAL) .setPoolName("test pool").create(REGION_NAME1); region.registerInterest(".*"); /** get the subscription connection and verify that it has the correct timeout setting */ QueueConnectionImpl primaryConnection = (QueueConnectionImpl) pool.getPrimaryConnection(); int pingInterval = ((CacheClientUpdater) primaryConnection.getUpdater()) .getServerQueueStatus().getPingInterval(); assertNotEquals(0, pingInterval); assertEquals(CacheClientNotifier.getClientPingInterval(), pingInterval); } finally { cache.close(); } }
if (status.isRedundant() || status.isPrimary()) { oldQueueServers.put(status, connection); } else {
serverQStatus = new ServerQueueStatus(endpointType, queueSize, member); && currentClientVersion.compareTo(Version.GFE_80) >= 0) { int remotePdxSize = dis.readInt(); serverQStatus.setPdxSize(remotePdxSize);
@Override public Object attempt(Connection cnx) throws Exception { ServerQueueStatus status = cnx.getQueueStatus(); return status.isNonRedundant() ? Boolean.FALSE : Boolean.TRUE; }
public ServerQueueStatus connect(EndpointManager endpointManager, ServerLocation location, ClientSideHandshake handshake, int socketBufferSize, int handshakeTimeout, int readTimeout, CommunicationMode communicationMode, GatewaySender sender, SocketCreator sc) throws IOException { theSocket = sc.connectForClient(location.getHostName(), location.getPort(), handshakeTimeout, socketBufferSize); theSocket.setTcpNoDelay(true); theSocket.setSendBufferSize(socketBufferSize); // Verify buffer sizes verifySocketBufferSize(socketBufferSize, theSocket.getReceiveBufferSize(), "receive"); verifySocketBufferSize(socketBufferSize, theSocket.getSendBufferSize(), "send"); theSocket.setSoTimeout(handshakeTimeout); out = theSocket.getOutputStream(); in = theSocket.getInputStream(); this.status = handshake.handshakeWithServer(this, location, communicationMode); commBuffer = ServerConnection.allocateCommBuffer(socketBufferSize, theSocket); if (sender != null) { commBufferForAsyncRead = ServerConnection.allocateCommBuffer(socketBufferSize, theSocket); } theSocket.setSoTimeout(readTimeout); endpoint = endpointManager.referenceEndpoint(location, this.status.getMemberId()); this.connectFinished = true; this.endpoint.getStats().incConnections(1); return status; }
return new ServerQueueStatus(endpointType, queueSize, member); serverQueueStatus = new ServerQueueStatus(endpointType, queueSize, member, pingInterval);
this.processor.checkIfPdxNeedsResend(this.connection.getQueueStatus().getPdxSize()); } catch (ConnectionDestroyedException e) { throw new GatewaySenderException(
final boolean isDebugEnabled = logger.isDebugEnabled(); final int headerReadTimeout = (int) Math.round(serverQueueStatus.getPingInterval() * qManager.getPool().getSubscriptionTimeoutMultiplier() * 1.25);