Skip to content

Commit

Permalink
fixing reload to a doman.xml snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
zebrik committed May 24, 2017
1 parent c544248 commit be45f7a
Showing 1 changed file with 20 additions and 6 deletions.
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,18 @@ 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 static final String DOMAIN_CONFIG = "domain-config";
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(DOMAIN_CONFIG, snapshot));
}
}
}

0 comments on commit be45f7a

Please sign in to comment.