mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
guard for several restart requests for the same node at the same time
This commit is contained in:
parent
8573c26602
commit
fbde2c84ac
@ -52,6 +52,8 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
||||
|
||||
private final boolean disabled;
|
||||
|
||||
private volatile boolean restartRequested = false;
|
||||
|
||||
@Inject public TransportNodesRestartAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
Node node) {
|
||||
@ -99,6 +101,10 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
||||
if (disabled) {
|
||||
throw new ElasticSearchIllegalStateException("Restart is disabled");
|
||||
}
|
||||
if (restartRequested) {
|
||||
return new NodesRestartResponse.NodeRestartResponse(clusterService.state().nodes().localNode());
|
||||
}
|
||||
restartRequested = true;
|
||||
logger.info("Restarting in [{}]", request.delay);
|
||||
threadPool.schedule(new Runnable() {
|
||||
@Override public void run() {
|
||||
@ -120,6 +126,8 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
||||
node.start();
|
||||
} catch (Exception e) {
|
||||
logger.warn("Failed to restart", e);
|
||||
} finally {
|
||||
restartRequested = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user