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; }
private String getJavaCommand() { String javaHome = jvmElement.getJavaHome(); if (javaHome == null) { if(environment.getDefaultJVM() != null) { String defaultJvm = environment.getDefaultJVM().getAbsolutePath(); if (!defaultJvm.equals("java") || (defaultJvm.equals("java") && System.getenv("JAVA_HOME") != null)) { return defaultJvm; } } javaHome = DefaultJvmUtils.getCurrentJvmHome(); } return DefaultJvmUtils.findJavaExecutable(javaHome); }
this.processState = processState; this.hostControllerInfo = hostControllerInfo; this.localFileRepository = new LocalFileRepository(environment.getDomainBaseDir(), environment.getDomainContentDir(), environment.getDomainConfigurationDir());
private ConfigurationFile getStandardDomainConfigurationFile() { final String defaultDomainConfig = WildFlySecurityManager.getPropertyPrivileged(HostControllerEnvironment.JBOSS_DOMAIN_DEFAULT_CONFIG, "domain.xml"); final String initialDomainConfig = environment.getInitialDomainConfig(); return new ConfigurationFile(environment.getDomainConfigurationDir(), defaultDomainConfig, initialDomainConfig == null ? environment.getDomainConfig() : initialDomainConfig, environment.getDomainConfigurationFileInteractionPolicy(), false); }
private ConfigurationFile getBackupDomainConfigurationFile() { return new ConfigurationFile(environment.getDomainConfigurationDir(), ConfigurationPersisterFactory.CACHED_DOMAIN_XML, null, environment.getInitialDomainConfig() == null); } }
public static ServiceController<?> addService(ServiceTarget serviceTarget, HostPathManagerService service, HostControllerEnvironment hostEnvironment) { ServiceBuilder<?> serviceBuilder = serviceTarget.addService(SERVICE_NAME, service); service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.HOME_DIR, hostEnvironment.getHomeDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.DOMAIN_CONFIG_DIR, hostEnvironment.getDomainConfigurationDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.DOMAIN_DATA_DIR, hostEnvironment.getDomainDataDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.DOMAIN_LOG_DIR, hostEnvironment.getDomainLogDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.DOMAIN_TEMP_DIR, hostEnvironment.getDomainTempDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.CONTROLLER_TEMP_DIR, hostEnvironment.getDomainTempDir().getAbsolutePath()); return serviceBuilder.install(); } }
final String name = operation.require(NAME).asString(); if (equals(name, PROCESS_CONTROLLER_ADDRESS)) { set(result, environment.getProcessControllerAddress()); } else if (equals(name, PROCESS_CONTROLLER_PORT)) { set(result, environment.getProcessControllerPort()); } else if (equals(name, HOST_CONTROLLER_ADDRESS)) { set(result, environment.getHostControllerAddress()); } else if (equals(name, HOST_CONTROLLER_PORT)) { set(result, environment.getHostControllerPort()); } else if (equals(name, HOME_DIR)) { set(result, environment.getHomeDir()); } else if (equals(name, MODULES_DIR)) { set (result, environment.getModulesDir()); } else if (equals(name, DOMAIN_BASE_DIR)) { set(result, environment.getDomainBaseDir()); } else if (equals(name, DOMAIN_CONFIG_DIR)) { set(result, environment.getDomainConfigurationDir()); } else if (equals(name, HOST_CONFIG_FILE)) { set(result, environment.getHostConfigurationFile()); } else if (equals(name, DOMAIN_CONFIG_FILE)) { set(result, environment.getDomainConfigurationFile()); } else if (equals(name, DOMAIN_CONTENT_DIR)) { set(result, environment.getDomainContentDir()); } else if (equals(name, DOMAIN_DATA_DIR)) { set(result, environment.getDomainDataDir()); } else if (equals(name, DOMAIN_LOG_DIR)) { set(result, environment.getDomainLogDir()); } else if (equals(name, DOMAIN_SERVERS_DIR)) { set(result, environment.getDomainServersDir());
for (Map.Entry<String, String> hostProp : environment.getHostSystemProperties().entrySet()) { if (!bootTimeProperties.containsKey(hostProp.getKey())) { bootTimeProperties.put(hostProp.getKey(), hostProp.getValue()); File serverDir = serverDirProp == null ? new File(environment.getDomainServersDir(), serverName) : new File(serverDirProp); final String logDir = addPathProperty(command, "log", ServerEnvironment.SERVER_LOG_DIR, bootTimeProperties, directoryGrouping, environment.getDomainLogDir(), serverDir); addPathProperty(command, "tmp", ServerEnvironment.SERVER_TEMP_DIR, bootTimeProperties, directoryGrouping, environment.getDomainTempDir(), serverDir); addPathProperty(command, "data", ServerEnvironment.SERVER_DATA_DIR, bootTimeProperties, directoryGrouping, environment.getDomainDataDir(), serverDir); final File loggingConfig = new File(getAbsolutePath(environment.getDomainServersDir(), serverName, "data", "logging.properties")); final String path; if (loggingConfig.exists()) { final String fileName = SecurityActions.getSystemProperty("logging.configuration"); if (fileName == null) { path = "file:" + getAbsolutePath(environment.getDomainConfigurationDir(), "logging.properties"); } else { path = fileName; command.add(getAbsolutePath(environment.getHomeDir(), "jboss-modules.jar")); command.add("-mp"); command.add(environment.getModulePath()); command.add("-jaxpmodule"); command.add("javax.xml.jaxp-provider");
final File configDir = environment.getDomainConfigurationDir(); ConfigurationFile domainConfigurationFile = null; if (slave) { if (environment.isBackupDomainFiles() || environment.isUseCachedDc()) { domainConfigurationFile = getBackupDomainConfigurationFile(); domainPersister = ConfigurationPersisterFactory.createRemoteBackupDomainXmlConfigurationPersister(configDir, executorService, extensionRegistry); final HostRunningModeControl runningModeControl = environment.getRunningModeControl(); if (runningModeControl.isReloaded()) { if (environment.isBackupDomainFiles()) { environment.setDomainConfigurationFile(domainConfigurationFile);
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 LocalHostControllerInfoImpl(final ControlledProcessState processState, final HostControllerEnvironment hostEnvironment) { this.processState = processState; this.hostEnvironment = hostEnvironment; this.localHostName = hostEnvironment.getRunningModeControl().getReloadHostName(); if (localHostName != null) overrideLocalHostName = true; }
@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(); }
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); }
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; }
final AbstractVaultReader vaultReader = loadVaultReaderService(); ROOT_LOGGER.debugf("Using VaultReader %s", vaultReader); final ContentRepository contentRepository = ContentRepository.Factory.create(environment.getDomainContentDir(), environment.getDomainTempDir()); ContentRepository.Factory.addService(serviceTarget, contentRepository); final IgnoredDomainResourceRegistry ignoredRegistry = new IgnoredDomainResourceRegistry(hostControllerInfo); final ManagementSecurityIdentitySupplier securityIdentitySupplier = new ManagementSecurityIdentitySupplier(); final RuntimeHostControllerInfoAccessor hostControllerInfoAccessor = new DomainHostControllerInfoAccessor(hostControllerInfo); final ProcessType processType = environment.getProcessType(); final ExtensionRegistry hostExtensionRegistry = new ExtensionRegistry(processType, runningModeControl, auditLogger, authorizer, securityIdentitySupplier, hostControllerInfoAccessor); final ExtensionRegistry extensionRegistry = new ExtensionRegistry(processType, runningModeControl, auditLogger, authorizer, securityIdentitySupplier, hostControllerInfoAccessor);
boolean useCachedDc = false; ProductConfig productConfig = ProductConfig.fromFilesystemSlot(null, "", props); return new HostControllerEnvironment(props, isRestart, modulePath, processControllerAddress, processControllerPort, hostControllerAddress, hostControllerPort, defaultJVM, domainConfig, initialDomainConfig, hostConfig, initialHostConfig, initialRunningMode, backupDomainFiles, useCachedDc, productConfig);
throw HostControllerLogger.ROOT_LOGGER.cannotBothHaveFalseUseCurrentHostConfigAndHostConfig(); if (domainConfig != null && !environment.getDomainConfigurationFile().checkCanFindNewBootFile(domainConfig)) { throw HostControllerLogger.ROOT_LOGGER.domainConfigForReloadNotFound(domainConfig); if (hostConfig != null && !environment.getHostConfigurationFile().checkCanFindNewBootFile(hostConfig)) { throw HostControllerLogger.ROOT_LOGGER.domainConfigForReloadNotFound(hostConfig);
hostRegistration.registerSubModel(new ServerConfigResourceDefinition(hostControllerInfo, serverInventory, pathManager, processState, environment.getDomainDataDir())); hostRegistration.registerSubModel(new StoppedServerResource(serverInventory));
public static ServiceController<ModelController> addService(final ServiceTarget serviceTarget, final HostControllerEnvironment environment, final HostRunningModeControl runningModeControl, final ControlledProcessState processState, final BootstrapListener bootstrapListener, final PathManagerService pathManager){ final ConcurrentMap<String, ProxyController> hostProxies = new ConcurrentHashMap<String, ProxyController>(); final Map<String, ProxyController> serverProxies = new ConcurrentHashMap<String, ProxyController>(); final LocalHostControllerInfoImpl hostControllerInfo = new LocalHostControllerInfoImpl(processState, environment); final AbstractVaultReader vaultReader = service(AbstractVaultReader.class); ROOT_LOGGER.debugf("Using VaultReader %s", vaultReader); final ContentRepository contentRepository = ContentRepository.Factory.create(environment.getDomainContentDir()); IgnoredDomainResourceRegistry ignoredRegistry = new IgnoredDomainResourceRegistry(hostControllerInfo); final PrepareStepHandler prepareStepHandler = new PrepareStepHandler(hostControllerInfo, contentRepository, hostProxies, serverProxies, ignoredRegistry); final ExpressionResolver expressionResolver = new RuntimeExpressionResolver(vaultReader); DomainModelControllerService service = new DomainModelControllerService(environment, runningModeControl, processState, hostControllerInfo, contentRepository, hostProxies, serverProxies, prepareStepHandler, vaultReader, ignoredRegistry, bootstrapListener, pathManager, expressionResolver, new DelegatingResourceDefinition()); return serviceTarget.addService(SERVICE_NAME, service) .addDependency(HostControllerService.HC_EXECUTOR_SERVICE_NAME, ExecutorService.class, service.getExecutorServiceInjector()) .addDependency(ProcessControllerConnectionService.SERVICE_NAME, ProcessControllerConnectionService.class, service.injectedProcessControllerConnection) .addDependency(PathManagerService.SERVICE_NAME) // ensure this is up .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
final String name = operation.require(NAME).asString(); if (equals(name, PROCESS_CONTROLLER_ADDRESS)) { set(result, environment.getProcessControllerAddress()); } else if (equals(name, PROCESS_CONTROLLER_PORT)) { set(result, environment.getProcessControllerPort()); } else if (equals(name, HOST_CONTROLLER_ADDRESS)) { set(result, environment.getHostControllerAddress()); } else if (equals(name, HOST_CONTROLLER_PORT)) { set(result, environment.getHostControllerPort()); } else if (equals(name, HOME_DIR)) { set(result, environment.getHomeDir()); } else if (equals(name, MODULES_DIR)) { set (result, environment.getModulesDir()); } else if (equals(name, DOMAIN_BASE_DIR)) { set(result, environment.getDomainBaseDir()); } else if (equals(name, DOMAIN_CONFIG_DIR)) { set(result, environment.getDomainConfigurationDir()); } else if (equals(name, HOST_CONFIG_FILE)) { set(result, environment.getHostConfigurationFile()); } else if (equals(name, DOMAIN_CONFIG_FILE)) { set(result, environment.getDomainConfigurationFile()); } else if (equals(name, DOMAIN_CONTENT_DIR)) { set(result, environment.getDomainContentDir()); } else if (equals(name, DOMAIN_DATA_DIR)) { set(result, environment.getDomainDataDir()); } else if (equals(name, DOMAIN_LOG_DIR)) { set(result, environment.getDomainLogDir()); } else if (equals(name, DOMAIN_SERVERS_DIR)) { set(result, environment.getDomainServersDir());