public ConnectionList removeConnection(QueueConnectionImpl connection) { if (primary == connection) { return new ConnectionList(null, backups, primaryDiscoveryException, primary); } else { ArrayList newBackups = new ArrayList(backups); newBackups.remove(connection); return new ConnectionList(primary, newBackups, primaryDiscoveryException, failedPrimary); } }
QueueConnectionImpl primary = (QueueConnectionImpl) queueConnections.getPrimary(); if (logger.isDebugEnabled()) { logger.debug("QueueManagerImpl - closing connections with keepAlive={}", keepAlive); List backups = queueConnections.getBackups(); for (Iterator itr = backups.iterator(); itr.hasNext();) { QueueConnectionImpl backup = (QueueConnectionImpl) itr.next();
primary = initializeQueueConnection(connection, true, queueConnections.getFailedUpdater());
scheduleRedundancySatisfierIfNeeded(redundancyRetryInterval); synchronized (lock) { queueConnections = queueConnections.setPrimaryDiscoveryFailed(null); lock.notifyAll(); primaryQueue = promoteBackupToPrimary(queueConnections.getBackups()); if (primaryQueue == null) { synchronized (lock) { queueConnections = queueConnections.removeConnection(primaryQueue); synchronized (lock) { queueConnections = queueConnections.setPrimaryDiscoveryFailed(new NoSubscriptionServersAvailableException( "Could not initialize a primary queue on startup. No queue servers available.")); lock.notifyAll();
if (queueConnections.getPrimary() != null) { if (isDebugEnabled) { logger.debug("Primary recovery not needed"); List backups = queueConnections.getBackups(); newPrimary = promoteBackupToPrimary(backups); synchronized (lock) { queueConnections = queueConnections.removeConnection(newPrimary); queueConnections = queueConnections.setPrimaryDiscoveryFailed(null); lock.notifyAll();
boolean isFirstNewConnection = false; synchronized (lock) { if (recoverInterest && queueConnections.getPrimary() == null && queueConnections.getBackups().isEmpty()) {
Set excludedServers = queueConnections.getAllLocations(); excludedServers.addAll(denyList.getBadServers()); excludedServers.addAll(factory.getDenyList().getBadServers()); if (t instanceof GemFireSecurityException) { queueConnections = queueConnections.setPrimaryDiscoveryFailed((GemFireSecurityException) t); } else { queueConnections = queueConnections.setPrimaryDiscoveryFailed(null);
isBadConnection = false; if (isPrimary) { queueConnections = queueConnections.setPrimary(connection); lock.notifyAll(); } else { queueConnections = queueConnections.addBackup(connection);
if (snapshot.getPrimary() == null) { while (snapshot.getPrimary() == null && !snapshot.primaryDiscoveryFailed() && !shuttingDown && pool.getPoolOrCacheCancelInProgress() == null) { try { if (snapshot.getPrimary() == null) { pool.getCancelCriterion().checkCancelInProgress(null); GemFireException exception = snapshot.getPrimaryDiscoveryException(); if (exception == null || exception instanceof NoSubscriptionServersAvailableException) { exception = new NoSubscriptionServersAvailableException(exception);
updater.setFailedUpdater(queueConnections.getFailedUpdater()); MakePrimaryOp.execute(pool, cnx, haveSentClientReady); result = true;
deadConnection = queueConnections.getConnection(endpoint); if (deadConnection != null && ccu.equals(deadConnection.getUpdater())) { queueConnections = queueConnections.removeConnection(deadConnection); try { deadConnection.internalClose(pool.getKeepAlive());
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. } } } }
void endpointCrashed(Endpoint endpoint) { QueueConnectionImpl deadConnection = null; // We must be synchronized while checking to see if we have a queue connection for the endpoint, // because when we need to prevent a race between adding a queue connection to the map // and the endpoint for that connection crashing. synchronized (lock) { deadConnection = queueConnections.getConnection(endpoint); if (deadConnection != null) { queueConnections = queueConnections.removeConnection(deadConnection); } } if (deadConnection != null) { logger .info("{} subscription endpoint {} crashed. Scheduling recovery.", new Object[] {deadConnection.getUpdater() != null ? (deadConnection.getUpdater().isPrimary() ? "Primary" : "Redundant") : "Queue", endpoint}); scheduleRedundancySatisfierIfNeeded(0); deadConnection.internalDestroy(); } else { if (logger.isDebugEnabled()) { logger.debug("Ignoring crashed endpoint {} it does not have a queue.", endpoint); } } }
private int getCurrentRedundancy() { return queueConnections.getBackups().size(); }
public ConnectionList setPrimary(QueueConnectionImpl newPrimary) { List newBackups = backups; if (backups.contains(newPrimary)) { newBackups = new ArrayList(backups); newBackups.remove(newPrimary); } return new ConnectionList(newPrimary, newBackups, null, null); }
public boolean isPrimaryUpdaterAlive() { boolean result = false; QueueConnectionImpl primary = (QueueConnectionImpl) queueConnections.getPrimary(); if (primary != null) { ClientUpdater cu = primary.getUpdater(); if (cu != null) { result = cu.isAlive(); } } return result; }
@Override public void emergencyClose() { shuttingDown = true; queueConnections.getPrimary().emergencyClose(); List backups = queueConnections.getBackups(); for (int i = 0; i < backups.size(); i++) { Connection backup = (Connection) backups.get(i); backup.emergencyClose(); } }
public ConnectionList setPrimaryDiscoveryFailed(GemFireException p_discoveryException) { GemFireException discoveryException = p_discoveryException; if (discoveryException == null) { discoveryException = new NoSubscriptionServersAvailableException("Primary discovery failed."); } return new ConnectionList(primary, backups, discoveryException, failedPrimary); }
public ConnectionList addBackup(QueueConnectionImpl queueConnection) { ArrayList newBackups = new ArrayList(backups); newBackups.add(queueConnection); return new ConnectionList(primary, newBackups, primaryDiscoveryException, failedPrimary); }