mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Shutdown expunged resources cleanup executor properly, and allow other components to configure/start/stop on error (#9723)
This commit is contained in:
parent
04c428cb2f
commit
c159471434
@ -294,7 +294,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C
|
||||
}
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
logger.error("Unexcpeted exception: ", e);
|
||||
logger.error("Unexpected exception: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -346,7 +346,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C
|
||||
}
|
||||
});
|
||||
} catch (final Throwable e) {
|
||||
logger.error("Unexcpeted exception: ", e);
|
||||
logger.error("Unexpected exception: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -384,7 +384,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C
|
||||
}
|
||||
executeAsync(peerName, agentId, cmds, true);
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Caught exception while talkign to " + peer.getMsid());
|
||||
logger.warn("Caught exception while talking to " + peer.getMsid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,12 @@ public class CloudStackExtendedLifeCycle extends AbstractBeanCollector {
|
||||
with(new WithComponentLifeCycle() {
|
||||
@Override
|
||||
public void with(ComponentLifecycle lifecycle) {
|
||||
logger.info("starting bean {}.", lifecycle.getName());
|
||||
try {
|
||||
lifecycle.start();
|
||||
} catch (Exception e) {
|
||||
logger.error("Error on starting bean {} - {}", lifecycle.getName(), e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (lifecycle instanceof ManagementBean) {
|
||||
ManagementBean mbean = (ManagementBean)lifecycle;
|
||||
@ -93,13 +98,21 @@ public class CloudStackExtendedLifeCycle extends AbstractBeanCollector {
|
||||
}
|
||||
|
||||
public void stopBeans() {
|
||||
logger.info("Stopping CloudStack Components");
|
||||
|
||||
with(new WithComponentLifeCycle() {
|
||||
@Override
|
||||
public void with(ComponentLifecycle lifecycle) {
|
||||
logger.info("stopping bean " + lifecycle.getName());
|
||||
logger.info("stopping bean {}.", lifecycle.getName());
|
||||
try {
|
||||
lifecycle.stop();
|
||||
} catch (Exception e) {
|
||||
logger.error("Error on stopping bean {} - {}", lifecycle.getName(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
logger.info("Done Stopping CloudStack Components");
|
||||
}
|
||||
|
||||
private void configure() {
|
||||
@ -109,10 +122,13 @@ public class CloudStackExtendedLifeCycle extends AbstractBeanCollector {
|
||||
@Override
|
||||
public void with(ComponentLifecycle lifecycle) {
|
||||
try {
|
||||
logger.info("configuring bean {}.", lifecycle.getName());
|
||||
lifecycle.configure(lifecycle.getName(), lifecycle.getConfigParams());
|
||||
} catch (ConfigurationException e) {
|
||||
logger.error("Failed to configure " + lifecycle.getName(), e);
|
||||
throw new CloudRuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error on configuring bean {} - {}", lifecycle.getName(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -45,5 +45,4 @@ public class CloudStackExtendedLifeCycleStart extends AbstractSmartLifeCycle imp
|
||||
public void run() {
|
||||
lifeCycle.startBeans();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -77,8 +77,10 @@ public class CloudStackSpringContext {
|
||||
for (String appName : contextMap.keySet()) {
|
||||
ApplicationContext contex = contextMap.get(appName);
|
||||
if (contex instanceof ConfigurableApplicationContext) {
|
||||
logger.trace("registering shutdown hook for bean "+ appName);
|
||||
logger.trace("Registering shutdown hook for bean {}.", appName);
|
||||
((ConfigurableApplicationContext)contex).registerShutdownHook();
|
||||
} else {
|
||||
logger.warn("Shutdown hook not registered for bean {}.", appName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,7 +579,9 @@ public class ResourceCleanupServiceImpl extends ManagerBase implements ResourceC
|
||||
@Override
|
||||
public boolean stop() {
|
||||
purgeExpungedResourcesJobExecutor.shutdown();
|
||||
if (expungedResourcesCleanupExecutor != null) {
|
||||
expungedResourcesCleanupExecutor.shutdownNow();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user