use of org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy in project activemq-artemis by apache.
the class SharedStoreBackupActivation method run.
@Override
public void run() {
try {
activeMQServer.getNodeManager().startBackup();
ScaleDownPolicy scaleDownPolicy = sharedStoreSlavePolicy.getScaleDownPolicy();
boolean scalingDown = scaleDownPolicy != null && scaleDownPolicy.isEnabled();
if (!activeMQServer.initialisePart1(scalingDown))
return;
activeMQServer.getBackupManager().start();
activeMQServer.setState(ActiveMQServerImpl.SERVER_STATE.STARTED);
ActiveMQServerLogger.LOGGER.backupServerStarted(activeMQServer.getVersion().getFullVersion(), activeMQServer.getNodeManager().getNodeId());
activeMQServer.getNodeManager().awaitLiveNode();
sharedStoreSlavePolicy.getSharedStoreMasterPolicy().setSharedStoreSlavePolicy(sharedStoreSlavePolicy);
activeMQServer.setHAPolicy(sharedStoreSlavePolicy.getSharedStoreMasterPolicy());
// activeMQServer.configuration.getHAPolicy().setPolicyType(HAPolicy.POLICY_TYPE.SHARED_STORE);
activeMQServer.getBackupManager().activated();
if (activeMQServer.getState() != ActiveMQServerImpl.SERVER_STATE.STARTED) {
return;
}
activeMQServer.initialisePart2(scalingDown);
activeMQServer.completeActivation();
if (scalingDown) {
ActiveMQServerLogger.LOGGER.backupServerScaledDown();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
activeMQServer.stop();
// we are shared store but if we were started by a parent server then we shouldn't restart
if (sharedStoreSlavePolicy.isRestartBackup()) {
activeMQServer.start();
}
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.serverRestartWarning(e);
}
}
});
t.start();
return;
} else {
ActiveMQServerLogger.LOGGER.backupServerIsLive();
activeMQServer.getNodeManager().releaseBackup();
}
if (sharedStoreSlavePolicy.isAllowAutoFailBack()) {
startFailbackChecker();
}
} catch (ClosedChannelException | InterruptedException e) {
// these are ok, we are being stopped
} catch (Exception e) {
if (!(e.getCause() instanceof InterruptedException)) {
ActiveMQServerLogger.LOGGER.initializationError(e);
}
} catch (Throwable e) {
ActiveMQServerLogger.LOGGER.initializationError(e);
}
}
Aggregations