Skip to content

Commit

Permalink
server tweaks for restarting test node
Browse files Browse the repository at this point in the history
  • Loading branch information
rjernst committed Nov 24, 2024
1 parent 43d36ed commit 33233dd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,18 @@ public Node(
}

public synchronized void start(Version version) {
if (process != null) {
// ES was previously started, so we don't need to reconfigure, just start
if (process.isAlive() == false) {
LOGGER.info("Restarting Elasticsearch node '{}'", name);
startElasticsearch();
} else {
throw new AssertionError("Elasticsearch is already started");
}
}

LOGGER.info("Starting Elasticsearch node '{}'", name);

if (version != null) {
spec.setVersion(version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,15 @@ public long getPid(int index) {
return nodes.get(index).getPid();
}

@Override
public void stopNode(int index, boolean forcibly) {
nodes.get(index).stop(false);
nodes.get(index).stop(forcibly);
}

public void restartNode(int index, boolean forcibly) {
Node node = nodes.get(index);
node.stop(forcibly);
node.start(null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public void stopNode(int index, boolean forcibly) {
handle.stopNode(index, forcibly);
}

@Override
public void restartNode(int index, boolean forcibly) {
checkHandle();
handle.restartNode(index, forcibly);
}

@Override
public void restart(boolean forcibly) {
checkHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public interface LocalClusterHandle extends ClusterHandle {
*/
void stopNode(int index, boolean forcibly);

/**
* Restarts the node by first stopping it and then starting it again.
* @param index of the node to stop
*/
void restartNode(int index, boolean forcibly);

/**
* Restarts the cluster. Effectively the same as calling {@link #stop(boolean)} followed by {@link #start()}
*
Expand Down

0 comments on commit 33233dd

Please sign in to comment.