@Override public void destroy() { Connection conn = (Connection) this.clientToServerConn.get(); if (conn != null) { manager.connectionCrashed(conn); } // else someone else destroyed it }
@Override public void endpointCrashed(Endpoint endpoint) { QueueManagerImpl.this.endpointCrashed(endpoint); } };
List servers = findQueueServers(excludedServers, queuesNeeded, true, false, null); scheduleRedundancySatisfierIfNeeded(redundancyRetryInterval); synchronized (lock) { queueConnections = queueConnections.setPrimaryDiscoveryFailed(null); QueueConnectionImpl queueConnection = initializeQueueConnection(connection, false, null); if (queueConnection != null) { addToConnectionList(queueConnection, false); primaryQueue = initializeQueueConnection(newPrimary, true, null); if (primaryQueue == null) { newPrimary.destroy(); } else { if (!addToConnectionList(primaryQueue, true)) { primaryQueue = null; if (redundancyLevel != -1 && getCurrentRedundancy() < redundancyLevel) { if (isDebugEnabled) { logger.debug( "SubscriptionManager - Some initial connections failed. Trying to create redundant queues"); recoverRedundancy(excludedServers, false); primaryQueue = createNewPrimary(excludedServers); if (primaryQueue == null) { if (!addToConnectionList(primaryQueue, true)) { excludedServers.add(primaryQueue.getServer());
&& ((additionalBackups = redundancyLevel - getCurrentRedundancy()) > 0 || redundancyLevel == -1)) { List servers = findQueueServers(excludedServers, redundancyLevel == -1 ? -1 : additionalBackups, false, (redundancyLevel == -1 ? false : printRedundancyNotSatisfiedError), logger.info( "Redundancy level {} is not satisfied, but there are no more servers available. Redundancy is currently {}.", new Object[] {redundancyLevel, getCurrentRedundancy()}); QueueConnectionImpl queueConnection = initializeQueueConnection(connection, false, null); if (queueConnection != null) { boolean isFirstNewConnection = false; if (!promoteBackupCnxToPrimary(queueConnection)) { promotionFailed = true; if (addToConnectionList(queueConnection, isFirstNewConnection)) { recoverInterest(queueConnection, isFirstNewConnection);
while (newPrimary == null && pool.getPoolOrCacheCancelInProgress() == null) { List backups = queueConnections.getBackups(); newPrimary = promoteBackupToPrimary(backups); if (!addToConnectionList(newPrimary, true)) { synchronized (lock) { cqsConnected(); printPrimaryNotFoundError = true; printRecoveringPrimary = true; newPrimary = createNewPrimary(excludedServers); if (newPrimary == null) { if (!addToConnectionList(newPrimary, true)) { excludedServers.add(newPrimary.getServer()); newPrimary = null; if (!recoverInterest(newPrimary, true)) { excludedServers.add(newPrimary.getServer()); newPrimary = null; cqsConnected(); cqsDisconnected(); if (isDebugEnabled) { logger.debug("SubscriptionManager redundancy satisfier - Could not recover a new primary");
QueueConnectionImpl primary = null; while (primary == null && pool.getPoolOrCacheCancelInProgress() == null) { List servers = findQueueServers(excludedServers, 1, false, printPrimaryNotFoundError, "Could not find any server to host primary client queue. Number of excluded servers is %s and exception is %s"); printPrimaryNotFoundError = false; // printed above primary = initializeQueueConnection(connection, true, queueConnections.getFailedUpdater()); readyForEventsAfterFailover(primary);
@Override public void readyForEvents(InternalDistributedSystem system) { synchronized (lock) { this.sentClientReady = true; } QueueConnectionImpl primary = null; while (primary == null) { try { primary = (QueueConnectionImpl) getAllConnections().getPrimary(); } catch (NoSubscriptionServersAvailableException ignore) { primary = null; break; } if (primary.sendClientReady()) { try { logger.info("Sending ready for events to primary: {}", primary); ReadyForEventsOp.execute(pool, primary); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Error sending ready for events to {}", primary, e); } primary.destroy(); primary = null; } } } }
protected void scheduleRedundancySatisfierIfNeeded(long delay) { if (shuttingDown) { return; } synchronized (lock) { if (shuttingDown) { return; } if (queueConnections.getPrimary() == null || getCurrentRedundancy() < redundancyLevel || redundancyLevel == -1 || queueConnections.primaryDiscoveryFailed()) { if (redundancySatisfierTask != null) { if (redundancySatisfierTask.getRemainingDelay() > delay) { redundancySatisfierTask.cancel(); } else { return; } } redundancySatisfierTask = new RedundancySatisfierTask(); try { ScheduledFuture future = recoveryThread.schedule(redundancySatisfierTask, delay, TimeUnit.MILLISECONDS); redundancySatisfierTask.setFuture(future); } catch (RejectedExecutionException e) { // ignore, the timer has been cancelled, which means we're shutting down. } } } }
usedByGateway, gatewaySender, pingInterval, multiuserSecureModeEnabled, this); if (subscriptionEnabled) { queueManager = new QueueManagerImpl(this, endpointManager, source, connectionFactory, subscriptionRedundancyLevel, pingInterval, securityLogWriter, proxyId);
void connectionCrashed(Connection con) { // the endpoint has not crashed but this method does all the work // we need to do endpointCrashed(con.getEndpoint()); }