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 authored and Ladicek committed May 25, 2017
1 parent c544248 commit 97e7666
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
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));
}
}
}

0 comments on commit 97e7666

Please sign in to comment.