@Override public void close(boolean permanently, boolean restarting) throws Exception { replicationManager = null; // To avoid a NPE cause by the stop NodeManager nodeManagerInUse = activeMQServer.getNodeManager(); if (nodeManagerInUse != null) { //todo does this actually make any difference, we only set a different flag in the lock file which replication doesn't use if (permanently) { nodeManagerInUse.crashLiveServer(); } else { nodeManagerInUse.pauseLiveServer(); } } }
@Override public void close(boolean permanently, boolean restarting) throws Exception { // TO avoid a NPE from stop NodeManager nodeManagerInUse = activeMQServer.getNodeManager(); if (nodeManagerInUse != null) { if (sharedStoreMasterPolicy.isFailoverOnServerShutdown() || permanently) { nodeManagerInUse.crashLiveServer(); } else { nodeManagerInUse.pauseLiveServer(); } } } }
@Override public void close(boolean permanently, boolean restarting) throws Exception { if (scaleDownServerLocator != null) { scaleDownServerLocator.close(); scaleDownServerLocator = null; } NodeManager nodeManagerInUse = activeMQServer.getNodeManager(); if (nodeManagerInUse != null) { if (permanently) { nodeManagerInUse.crashLiveServer(); } else { nodeManagerInUse.pauseLiveServer(); } } }
@Override public void run() { try { if (!restarting && activeMQServer.getNodeManager().isAwaitingFailback()) { if (backupListener.waitForBackup()) { ActiveMQServerLogger.LOGGER.awaitFailBack();
@Override public void run() { try { logger.debug(activeMQServer + "::Stopping live node in favor of failback"); NodeManager nodeManager = activeMQServer.getNodeManager(); activeMQServer.stop(true, false, true); // ensure that the server to which we are failing back actually starts fully before we restart nodeManager.start(); try { nodeManager.awaitLiveStatus(); } finally { nodeManager.stop(); } synchronized (failbackCheckerGuard) { if (cancelFailBackChecker || !sharedStoreSlavePolicy.isRestartBackup()) return; activeMQServer.setHAPolicy(sharedStoreSlavePolicy); logger.debug(activeMQServer + "::Starting backup node now after failback"); activeMQServer.start(); } } catch (Exception e) { ActiveMQServerLogger.LOGGER.serverRestartWarning(e); } } });
@Override public void close(final boolean permanently, boolean restarting) throws Exception { synchronized (this) { if (backupQuorum != null) backupQuorum.causeExit(STOP); replicationEndpoint = null; closed = true; } //we have to check as the server policy may have changed if (activeMQServer.getHAPolicy().isBackup()) { // To avoid a NPE cause by the stop NodeManager nodeManagerInUse = activeMQServer.getNodeManager(); activeMQServer.interruptActivationThread(nodeManagerInUse); if (nodeManagerInUse != null) { nodeManagerInUse.stopBackup(); } } }
public long scaleDown() throws Exception { ScaleDownHandler scaleDownHandler = new ScaleDownHandler(activeMQServer.getPagingManager(), activeMQServer.getPostOffice(), activeMQServer.getNodeManager(), activeMQServer.getClusterManager().getClusterController(), activeMQServer.getStorageManager()); ConcurrentMap<SimpleString, DuplicateIDCache> duplicateIDCaches = ((PostOfficeImpl) activeMQServer.getPostOffice()).getDuplicateIDCaches(); Map<SimpleString, List<Pair<byte[], Long>>> duplicateIDMap = new HashMap<>(); for (SimpleString address : duplicateIDCaches.keySet()) { DuplicateIDCache duplicateIDCache = activeMQServer.getPostOffice().getDuplicateIDCache(address); duplicateIDMap.put(address, duplicateIDCache.getMap()); } return scaleDownHandler.scaleDown(scaleDownClientSessionFactory, activeMQServer.getResourceManager(), duplicateIDMap, activeMQServer.getManagementService().getManagementAddress(), null); } }
@Override public void run() { try { activeMQServer.getNodeManager().startBackup(); ActiveMQServerLogger.LOGGER.backupServerStarted(activeMQServer.getVersion().getFullVersion(), activeMQServer.getNodeManager().getNodeId()); activeMQServer.getNodeManager().awaitLiveNode(); ActiveMQServerLogger.LOGGER.backupServerIsLive(); activeMQServer.getNodeManager().releaseBackup();
activeMQServer.getNodeManager().stop(); activeMQServer.moveServerData(replicaPolicy.getMaxSavedReplicatedJournalsSize()); activeMQServer.getNodeManager().start(); synchronized (this) { if (closed) { if (closed) return; backupQuorum = new SharedNothingBackupQuorum(activeMQServer.getStorageManager(), activeMQServer.getNodeManager(), activeMQServer.getScheduledPool(), networkHealthCheck, replicaPolicy.getQuorumSize(), replicaPolicy.getVoteRetries(), replicaPolicy.getVoteRetryWait(), replicaPolicy.getQuorumVoteWait()); activeMQServer.getClusterManager().getQuorumManager().registerQuorum(backupQuorum); activeMQServer.getClusterManager().getQuorumManager().registerQuorumHandler(new ServerConnectVoteHandler(activeMQServer)); ActiveMQServerLogger.LOGGER.backupServerStarted(activeMQServer.getVersion().getFullVersion(), activeMQServer.getNodeManager().getNodeId()); activeMQServer.setState(ActiveMQServerImpl.SERVER_STATE.STARTED); throw new RuntimeException("Could not establish the connection"); activeMQServer.getNodeManager().setNodeID(nodeID); activeMQServer.getNodeManager().stopBackup(); logger.trace("start store manager"); activeMQServer.getStorageManager().start();
@Override public void close(boolean permanently, boolean restarting) throws Exception { if (!restarting) { synchronized (failbackCheckerGuard) { cancelFailBackChecker = true; } } // To avoid a NPE cause by the stop NodeManager nodeManagerInUse = activeMQServer.getNodeManager(); //we need to check as the servers policy may have changed if (activeMQServer.getHAPolicy().isBackup()) { activeMQServer.interruptActivationThread(nodeManagerInUse); if (nodeManagerInUse != null) { nodeManagerInUse.stopBackup(); } } else { if (nodeManagerInUse != null) { // if we are now live, behave as live // We need to delete the file too, otherwise the backup will failover when we shutdown or if the backup is // started before the live if (sharedStoreSlavePolicy.isFailoverOnServerShutdown() || permanently) { nodeManagerInUse.crashLiveServer(); } else { nodeManagerInUse.pauseLiveServer(); } } } }
return; if (activeMQServer.getNodeManager().isBackupLive()) { activeMQServer.registerActivateCallback(activeMQServer.getNodeManager().startLiveNode());
SimpleString nodeId0; try { nodeId0 = activeMQServer.getNodeManager().readNodeId(); } catch (ActiveMQIllegalStateException e) { nodeId0 = null;
@Override public void run() { try { activeMQServer.initialisePart1(false); activeMQServer.registerActivateCallback(activeMQServer.getNodeManager().startLiveNode()); if (activeMQServer.getState() == ActiveMQServerImpl.SERVER_STATE.STOPPED || activeMQServer.getState() == ActiveMQServerImpl.SERVER_STATE.STOPPING) { return; } activeMQServer.initialisePart2(false); activeMQServer.completeActivation(); if (activeMQServer.getIdentity() != null) { ActiveMQServerLogger.LOGGER.serverIsLive(activeMQServer.getIdentity()); } else { ActiveMQServerLogger.LOGGER.serverIsLive(); } } catch (Exception e) { ActiveMQServerLogger.LOGGER.initializationError(e); activeMQServer.callActivationFailureListeners(e); } }
@Test public void shouldNotUseJdbcNodeManagerWithoutHAPolicy() throws Exception { Configuration configuration = createConfiguration("database-store-no-hapolicy-config.xml"); ActiveMQServerImpl server = new ActiveMQServerImpl(configuration); assertEquals(StoreConfiguration.StoreType.DATABASE, server.getConfiguration().getStoreConfiguration().getStoreType()); assertEquals(HAPolicyConfiguration.TYPE.LIVE_ONLY, server.getConfiguration().getHAPolicyConfiguration().getType()); try { server.start(); assertThat(server.getNodeManager(), instanceOf(FileLockNodeManager.class)); } finally { server.stop(); } }