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

#160: fixing reload to a doman.xml snapshot #162

Merged
merged 1 commit into from
May 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ private Constants() {} // avoid instantiation
public static final String BLOCKING = "blocking";
public static final String COMPOSITE = "composite";
public static final String CORE_SERVICE = "core-service";
public static final String DOMAIN_CONFIG = "domain-config";
public static final String DOMAIN_FAILURE_DESCRIPTION = "domain-failure-description";
public static final String FAILED = "failed";
public static final String HOST_FAILURE_DESCRIPTIONS = "host-failure-descriptions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public ReloadToSnapshot(OnlineManagementClient client, String snapshot, int time
}

/**
* Reload the server to a snapshot. In managed domain, reloads the default host.
* Reload the server to a snapshot. In managed domain, reloads the default host to a domain.xml snapshot.
*/
public void perform() throws InterruptedException, TimeoutException, IOException {
if (client.options().isStandalone) {
new StandaloneAdministrationOperations(client, timeoutInSeconds)
.performRestartOperation(new ReloadToSnapshotRestartOperation(snapshot));
.performRestartOperation(new ReloadToStandaloneSnapshotRestartOperation(snapshot));
} else {
perform(client.options().defaultHost);
}
}

/**
* Reload given {@code host} to a snapshot. This method only makes sense in managed domain.
* Reload given {@code host} to a domain.xml snapshot. This method only makes sense in managed domain.
*/
public void perform(String host) throws InterruptedException, TimeoutException, IOException {
if (!client.options().isDomain) {
Expand All @@ -55,13 +55,13 @@ public void perform(String host) throws InterruptedException, TimeoutException,
}

new DomainAdministrationOperations(client, timeoutInSeconds)
.performRestartOperation(host, new ReloadToSnapshotRestartOperation(snapshot));
.performRestartOperation(host, new ReloadToDomainSnapshotRestartOperation(snapshot));
}

private static final class ReloadToSnapshotRestartOperation implements RestartOperation {
private static final class ReloadToStandaloneSnapshotRestartOperation implements RestartOperation {
private final String snapshot;

ReloadToSnapshotRestartOperation(String snapshot) {
ReloadToStandaloneSnapshotRestartOperation(String snapshot) {
this.snapshot = snapshot;
}

Expand All @@ -70,4 +70,17 @@ public ModelNodeResult perform(Operations ops, Address address) throws IOExcepti
return ops.invoke(Constants.RELOAD, address, Values.of(Constants.SERVER_CONFIG, snapshot));
}
}

private static final class ReloadToDomainSnapshotRestartOperation implements RestartOperation {
private final String snapshot;

ReloadToDomainSnapshotRestartOperation(String snapshot) {
this.snapshot = snapshot;
}

@Override
public ModelNodeResult perform(Operations ops, Address address) throws IOException {
return ops.invoke(Constants.RELOAD, address, Values.of(Constants.DOMAIN_CONFIG, snapshot));
}
}
}