@Override public RunningMode getCurrentRunningMode() { return runningModeControl.getRunningMode(); }
public HostControllerConfigurationPersister(final HostControllerEnvironment environment, final LocalHostControllerInfo localHostControllerInfo, final ExecutorService executorService, final ExtensionRegistry hostExtensionRegistry, final ExtensionRegistry extensionRegistry) { this.environment = environment; this.hostControllerInfo = localHostControllerInfo; this.executorService = executorService; this.hostExtensionRegistry = hostExtensionRegistry; this.extensionRegistry = extensionRegistry; final ConfigurationFile configurationFile = environment.getHostConfigurationFile(); final HostRunningModeControl runningModeControl = environment.getRunningModeControl(); if (runningModeControl.isReloaded()) { configurationFile.resetBootFile(runningModeControl.isUseCurrentConfig(), runningModeControl.getAndClearNewBootFileName()); } this.hostPersister = ConfigurationPersisterFactory.createHostXmlConfigurationPersister(configurationFile, environment, executorService, hostExtensionRegistry, hostControllerInfo); }
@Override public void doReload(HostRunningModeControl runningModeControl) { runningModeControl.setRunningMode(adminOnly ? RunningMode.ADMIN_ONLY : RunningMode.NORMAL); runningModeControl.setReloaded(); runningModeControl.setUseCurrentConfig(useCurrentHostConfig); runningModeControl.setUseCurrentDomainConfig(useCurrentDomainConfig); runningModeControl.setNewDomainBootFileName(domainConfig); runningModeControl.setNewBootFileName(hostConfig); runningModeControl.setReloadHostName(hostName); } };
@Override public void doReload(HostRunningModeControl runningModeControl) { runningModeControl.setRunningMode(adminOnly ? RunningMode.ADMIN_ONLY : RunningMode.NORMAL); runningModeControl.setReloaded(); runningModeControl.setUseCurrentConfig(useCurrentHostConfig); runningModeControl.setUseCurrentDomainConfig(useCurrentDomainConfig); } };
public KernelServicesBuilderImpl(TestModelType type) { this.type = type; this.processType = type == TestModelType.HOST || type == TestModelType.DOMAIN ? ProcessType.HOST_CONTROLLER : ProcessType.STANDALONE_SERVER; runningModeControl = type == TestModelType.HOST ? new HostRunningModeControl(RunningMode.ADMIN_ONLY, RestartMode.HC_ONLY) : new RunningModeControl(RunningMode.ADMIN_ONLY); extensionRegistry = new ExtensionRegistry(processType, runningModeControl, null, null, null, RuntimeHostControllerInfoAccessor.SERVER); testParser = TestParser.create(extensionRegistry, xmlMapper, type); }
public static ExtensibleConfigurationPersister createHostXmlConfigurationPersister(final ConfigurationFile file, final HostControllerEnvironment environment, final ExecutorService executorService, final ExtensionRegistry hostExtensionRegistry, final LocalHostControllerInfo localHostControllerInfo) { String defaultHostname = localHostControllerInfo.getLocalHostName(); if (environment.getRunningModeControl().isReloaded()) { if (environment.getRunningModeControl().getReloadHostName() != null) { defaultHostname = environment.getRunningModeControl().getReloadHostName(); } } HostXml hostXml = new HostXml(defaultHostname, environment.getRunningModeControl().getRunningMode(), environment.isUseCachedDc(), Module.getBootModuleLoader(), executorService, hostExtensionRegistry); BackupXmlConfigurationPersister persister = new BackupXmlConfigurationPersister(file, new QName(Namespace.CURRENT.getUriString(), "host"), hostXml, hostXml, false); for (Namespace namespace : Namespace.domainValues()) { if (!namespace.equals(Namespace.CURRENT)) { persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "host"), hostXml); } } hostExtensionRegistry.setWriterRegistry(persister); return persister; }
domainConfigurationFile = getStandardDomainConfigurationFile(); final HostRunningModeControl runningModeControl = environment.getRunningModeControl(); if (runningModeControl.isReloaded()) { if (environment.isBackupDomainFiles()) { runningModeControl.isUseCurrentDomainConfig(), runningModeControl.getAndClearNewDomainBootFileName());
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { // start servers final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode hostModel = Resource.Tools.readModel(resource); if(hostModel.hasDefined(SERVER_CONFIG)) { final ModelNode servers = hostModel.get(SERVER_CONFIG).clone(); if (hostControllerEnvironment.isRestart() || runningModeControl.getRestartMode() == RestartMode.HC_ONLY){ restartedHcStartOrReconnectServers(servers, domainModel, context); runningModeControl.setRestartMode(RestartMode.SERVERS); } else { cleanStartServers(servers, domainModel, context); } } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
public HostControllerConfigurationPersister(final HostControllerEnvironment environment, final LocalHostControllerInfo localHostControllerInfo, final ExecutorService executorService, final ExtensionRegistry extensionRegistry) { this.environment = environment; this.hostControllerInfo = localHostControllerInfo; this.executorService = executorService; this.extensionRegistry = extensionRegistry; final ConfigurationFile configurationFile = environment.getHostConfigurationFile(); if (environment.getRunningModeControl().isReloaded()) { configurationFile.resetBootFile(environment.getRunningModeControl().isUseCurrentConfig()); } this.hostPersister = ConfigurationPersisterFactory.createHostXmlConfigurationPersister(configurationFile, environment.getHostControllerName()); }
public void initializeDomainConfigurationPersister(boolean slave) { if (domainPersister != null) { throw MESSAGES.configurationPersisterAlreadyInitialized(); } final File configDir = environment.getDomainConfigurationDir(); if (slave) { if (environment.isBackupDomainFiles()) { // --backup domainPersister = ConfigurationPersisterFactory.createRemoteBackupDomainXmlConfigurationPersister(configDir, executorService, extensionRegistry); } else if(environment.isUseCachedDc()) { // --cached-dc domainPersister = ConfigurationPersisterFactory.createCachedRemoteDomainXmlConfigurationPersister(configDir, executorService, extensionRegistry); } else { domainPersister = ConfigurationPersisterFactory.createTransientDomainXmlConfigurationPersister(executorService, extensionRegistry); } } else { final ConfigurationFile configurationFile = environment.getDomainConfigurationFile(); if (environment.getRunningModeControl().isReloaded()) { configurationFile.resetBootFile(environment.getRunningModeControl().isUseCurrentDomainConfig()); } domainPersister = ConfigurationPersisterFactory.createDomainXmlConfigurationPersister(configurationFile, executorService, extensionRegistry); } this.slave = slave; }
final boolean shutdownServers = runningModeControl.getRestartMode() == RestartMode.SERVERS; if (shutdownServers) { Runnable task = new Runnable() {
@Override public List<ModelNode> load() throws ConfigurationPersistenceException { // TODO investigate replacing all this with something more like BackupXmlConfigurationPersister.isSuppressLoad if (environment.getProcessType() == ProcessType.EMBEDDED_HOST_CONTROLLER) { final ConfigurationFile configurationFile = environment.getHostConfigurationFile(); final File bootFile = configurationFile.getBootFile(); final ConfigurationFile.InteractionPolicy policy = configurationFile.getInteractionPolicy(); final HostRunningModeControl runningModeControl = environment.getRunningModeControl(); if (bootFile.exists() && bootFile.length() == 0) { // empty config, by definition return new ArrayList<>(); } if (policy == ConfigurationFile.InteractionPolicy.NEW && (bootFile.exists() && bootFile.length() != 0)) { throw HostControllerLogger.ROOT_LOGGER.cannotOverwriteHostXmlWithEmpty(bootFile.getName()); } // if we started with new / discard but now we're reloading, ignore it. Otherwise on a reload, we have no way to drop the --empty-host-config // if we're loading a 0 byte file, treat this the same as booting with an emoty config if (bootFile.length() == 0 || (!runningModeControl.isReloaded() && (policy == ConfigurationFile.InteractionPolicy.NEW || policy == ConfigurationFile.InteractionPolicy.DISCARD))) { return new ArrayList<>(); } } return hostPersister.load(); }
@Override public void reloadInitiated(HostRunningModeControl runningModeControl) { runningModeControl.setRestartMode(restartServers ? RestartMode.SERVERS : RestartMode.HC_ONLY); }
public KernelServicesBuilderImpl(TestModelType type) { this.type = type; this.processType = type == TestModelType.HOST || type == TestModelType.DOMAIN ? ProcessType.HOST_CONTROLLER : ProcessType.STANDALONE_SERVER; runningModeControl = type == TestModelType.HOST ? new HostRunningModeControl(RunningMode.ADMIN_ONLY, RestartMode.HC_ONLY) : new RunningModeControl(RunningMode.ADMIN_ONLY); extensionRegistry = new ExtensionRegistry(processType, runningModeControl, null, null, null, RuntimeHostControllerInfoAccessor.SERVER); testParser = TestParser.create(extensionRegistry, xmlMapper, type); }
public static ExtensibleConfigurationPersister createHostXmlConfigurationPersister(final ConfigurationFile file, final HostControllerEnvironment environment, final ExecutorService executorService, final ExtensionRegistry hostExtensionRegistry, final LocalHostControllerInfo localHostControllerInfo) { String defaultHostname = localHostControllerInfo.getLocalHostName(); if (environment.getRunningModeControl().isReloaded()) { if (environment.getRunningModeControl().getReloadHostName() != null) { defaultHostname = environment.getRunningModeControl().getReloadHostName(); } } HostXml hostXml = new HostXml(defaultHostname, environment.getRunningModeControl().getRunningMode(), environment.isUseCachedDc(), Module.getBootModuleLoader(), executorService, hostExtensionRegistry); BackupXmlConfigurationPersister persister = new BackupXmlConfigurationPersister(file, new QName(Namespace.CURRENT.getUriString(), "host"), hostXml, hostXml, false); for (Namespace namespace : Namespace.domainValues()) { if (!namespace.equals(Namespace.CURRENT)) { persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "host"), hostXml); } } hostExtensionRegistry.setWriterRegistry(persister); return persister; }
domainConfigurationFile = getStandardDomainConfigurationFile(); final HostRunningModeControl runningModeControl = environment.getRunningModeControl(); if (runningModeControl.isReloaded()) { if (environment.isBackupDomainFiles()) { runningModeControl.isUseCurrentDomainConfig(), runningModeControl.getAndClearNewDomainBootFileName());
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { // start servers final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode hostModel = Resource.Tools.readModel(resource); if(hostModel.hasDefined(SERVER_CONFIG)) { final ModelNode servers = hostModel.get(SERVER_CONFIG).clone(); if (hostControllerEnvironment.isRestart() || runningModeControl.getRestartMode() == RestartMode.HC_ONLY){ restartedHcStartOrReconnectServers(servers, domainModel, context); runningModeControl.setRestartMode(RestartMode.SERVERS); } else { cleanStartServers(servers, domainModel, context); } } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
final boolean shutdownServers = runningModeControl.getRestartMode() == RestartMode.SERVERS; if (shutdownServers) { Runnable task = new Runnable() {
@Override public List<ModelNode> load() throws ConfigurationPersistenceException { // TODO investigate replacing all this with something more like BackupXmlConfigurationPersister.isSuppressLoad if (environment.getProcessType() == ProcessType.EMBEDDED_HOST_CONTROLLER) { final ConfigurationFile configurationFile = environment.getHostConfigurationFile(); final File bootFile = configurationFile.getBootFile(); final ConfigurationFile.InteractionPolicy policy = configurationFile.getInteractionPolicy(); final HostRunningModeControl runningModeControl = environment.getRunningModeControl(); if (bootFile.exists() && bootFile.length() == 0) { // empty config, by definition return new ArrayList<>(); } if (policy == ConfigurationFile.InteractionPolicy.NEW && (bootFile.exists() && bootFile.length() != 0)) { throw HostControllerLogger.ROOT_LOGGER.cannotOverwriteHostXmlWithEmpty(bootFile.getName()); } // if we started with new / discard but now we're reloading, ignore it. Otherwise on a reload, we have no way to drop the --empty-host-config // if we're loading a 0 byte file, treat this the same as booting with an emoty config if (bootFile.length() == 0 || (!runningModeControl.isReloaded() && (policy == ConfigurationFile.InteractionPolicy.NEW || policy == ConfigurationFile.InteractionPolicy.DISCARD))) { return new ArrayList<>(); } } return hostPersister.load(); }
@Override public void reloadInitiated(HostRunningModeControl runningModeControl) { runningModeControl.setRestartMode(restartServers ? RestartMode.SERVERS : RestartMode.HC_ONLY); }