Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFLY-16383 mod_cluster: Do not register contexts when in suspend mode #15563

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,17 @@ private Context createContext(String contextPath, Host host) {
}

private synchronized void onStart(Context context) {
ContainerEventHandler handler = this.configuration.getContainerEventHandler();

handler.add(context);

State state = this.configuration.getSuspendController().getState();

// TODO break into onDeploymentAdd once implemented in Undertow
if(state == State.RUNNING) {
if (state == State.RUNNING) {
// Following handler calls result in context registration on the proxy side, which in turn results in
// the proxy starting to serve 503 responses for this context. We want to avoid context registration unless
// the server is in RUNNING state.
// During normal server startup, this block is skipped and the add() & start() handler calls are done later
// in the `#resume()` method.
ContainerEventHandler handler = this.configuration.getContainerEventHandler();
handler.add(context);
// TODO break into onDeploymentAdd once implemented in Undertow
handler.start(context);
}

Expand Down Expand Up @@ -202,8 +205,16 @@ public void suspended(ServerActivityCallback listener) {

@Override
public void resume() {
// This is run just before container enters RUNNING state - contexts need to be registered.
ContainerEventHandler handler = this.configuration.getContainerEventHandler();
for (Context context : this.contexts) {
this.configuration.getContainerEventHandler().start(context);
handler.add(context);
handler.start(context);
}
// Proxy will not consider this node to be ready, until it receives a STATUS request - send it now to minimize
// time when the proxy serves 503.
for (Engine engine : this.server.getEngines()) {
this.configuration.getContainerEventHandler().status(engine);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.jboss.as.controller.client.helpers.ClientConstants.ADDRESS;
import static org.jboss.as.controller.client.helpers.ClientConstants.INCLUDE_RUNTIME;
import static org.jboss.as.controller.client.helpers.ClientConstants.OUTCOME;
import static org.jboss.as.controller.client.helpers.ClientConstants.READ_RESOURCE_OPERATION;
Expand Down Expand Up @@ -85,7 +84,6 @@ private void assertWorkerNodeContextIsStopped() throws Exception {

ModelNode op = createOpNode("subsystem=undertow/configuration=filter/mod-cluster=load-balancer/balancer=mycluster/node=" + NODE_1,
READ_RESOURCE_OPERATION);
op.get(ADDRESS).add("context", "/" + MODULE_NAME);
op.get(RECURSIVE).set(true);
op.get(INCLUDE_RUNTIME).set(true);

Expand All @@ -105,8 +103,11 @@ private void assertWorkerNodeContextIsStopped() throws Exception {
Thread.sleep(100);
}

Assert.assertEquals(SUCCESS, modelNode.get(OUTCOME).asString());
Assert.assertEquals("stopped", modelNode.get(RESULT).get(STATUS).asString());
Assert.assertEquals("Operation failed: " + modelNode.asString(),
SUCCESS, modelNode.get(OUTCOME).asString());
Assert.assertFalse("No contexts are expected to be registered by mod_cluster: "
+ modelNode.get(RESULT).get("context").asString(),
modelNode.get(RESULT).get("context").isDefined());
}

static class ServerSetupTask extends CLIServerSetupTask {
Expand Down