/** * Checks if the server / host controller was started using the {@code --read-only-*-config} parameter. If not, * reloading to original doesn't make sense. * * @param host should be {@code null} for standalone server or for default host in managed domain; * should only be non-{@code null} if a specific host in managed domain is checked */ private static void checkReloadToOriginalMakesSense(OnlineManagementClient client, String host) throws IOException { // the system property shouldn't be documented, it's only meant as a workaround for potential issues if (System.getProperty("creaper.reloadToOriginal.skipCheck") != null) { return; } String command = commandUsedToStartTheServer(client, host); if (client.options().isStandalone && !command.contains("--read-only-server-config")) { throw new IllegalStateException("Reloading to original configuration doesn't make sense, the server must be started with --read-only-server-config=standalone*.xml"); } if (client.options().isDomain && !command.contains("--read-only-domain-config") && !command.contains("--read-only-host-config")) { throw new IllegalStateException("Reloading to original configuration doesn't make sense, the host contoller must be started with --read-only-domain-config=domain.xml and/or --read-only-host-config=host*.xml"); } }
/** * Performs the reload from original configuration. */ // in managed domain, this would apply to the default host public void perform() throws InterruptedException, TimeoutException, IOException { checkReloadToOriginalMakesSense(client, null); new StandaloneAdministrationOperations(client, timeoutInSeconds) .performRestartOperation(new ReloadToOriginalRestartOperation()); }