@Override public void connectionFinished() { this.connectionFinished = true; ROOT_LOGGER.debug("process controller connection closed."); synchronized (shutdownCondition) { shutdownCondition.notifyAll(); } }
/** * Unregister the mgmt channel. * * @param old the proxy controller to unregister * @param shuttingDown whether the server inventory is shutting down * @return whether the registration can be removed from the domain-controller */ protected synchronized boolean callbackUnregistered(final TransactionalProtocolClient old, final boolean shuttingDown) { // Disconnect the remote connection protocolClient.disconnected(old); // If the connection dropped without us stopping the process ask for reconnection if(! shuttingDown && requiredState == InternalState.SERVER_STARTED) { final InternalState state = internalState; if(state == InternalState.PROCESS_STOPPED || state == InternalState.PROCESS_STOPPING || state == InternalState.STOPPED) { // In case it stopped we don't reconnect return true; } try { HostControllerLogger.ROOT_LOGGER.tracef("trying to reconnect to %s current-state (%s) required-state (%s)", serverName, state, requiredState); internalSetState(new ReconnectTask(), state, InternalState.SEND_STDIN); } catch (Exception e) { HostControllerLogger.ROOT_LOGGER.debugf(e, "failed to send reconnect task"); } return false; } else { return true; } }
@Override public void handleClose(Channel closed, IOException exception) { handler.shutdown(); boolean interrupted = false; try { if (!handler.awaitCompletion(CHANNEL_SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS)) { ROOT_LOGGER.gracefulManagementChannelHandlerShutdownTimedOut(CHANNEL_SHUTDOWN_TIMEOUT); } } catch (InterruptedException e) { interrupted = true; ROOT_LOGGER.serviceShutdownIncomplete(e); } catch (Exception e) { ROOT_LOGGER.serviceShutdownIncomplete(e); } finally { handler.shutdownNow(); if (interrupted) { Thread.currentThread().interrupt(); } } } });
} catch (Exception e) { ROOT_LOGGER.cannotConnectToMaster(e); System.exit(ExitCodes.HOST_CONTROLLER_ABORT_EXIT_CODE); ROOT_LOGGER.noDomainControllerConfigurationProvided(currentRunningMode, CommandLineConstants.ADMIN_ONLY, RunningMode.ADMIN_ONLY); System.exit(ExitCodes.HOST_CONTROLLER_ABORT_EXIT_CODE); ROOT_LOGGER.reportAdminOnlyDomainXmlFailure(); ok = true; ROOT_LOGGER.caughtExceptionDuringBoot(e); if (!reachedServers) { ok = false; ROOT_LOGGER.unsuccessfulBoot(); System.exit(ExitCodes.HOST_CONTROLLER_ABORT_EXIT_CODE);
Long id = future.get(timeout, TimeUnit.MILLISECONDS); if (!cancelled && remoteConnectionID != null && !remoteConnectionID.equals(id)) { HostControllerLogger.DOMAIN_LOGGER.slaveHostControllerChanged(hostName); fail = true; } else { HostControllerLogger.DOMAIN_LOGGER.debug("Caught exception sending ping request", e); } catch (InterruptedException e) { safeCancel(future); Thread.currentThread().interrupt(); } catch (ExecutionException e) { HostControllerLogger.DOMAIN_LOGGER.debug("Caught exception sending ping request", e); } catch (TimeoutException e) { if (!cancelled) { fail = true; HostControllerLogger.DOMAIN_LOGGER.slaveHostControllerUnreachable(hostName, timeout);
Long id = future.get(TIMEOUT, TimeUnit.MILLISECONDS); if (remoteInstanceID != null && !remoteInstanceID.equals(id)) { HostControllerLogger.DOMAIN_LOGGER.masterHostControllerChanged(); fail = true; } else { HostControllerLogger.DOMAIN_LOGGER.debug("Caught exception sending ping request", e); } catch (InterruptedException e) { safeCancel(future); Thread.currentThread().interrupt(); } catch (ExecutionException e) { HostControllerLogger.DOMAIN_LOGGER.debug("Caught exception sending ping request", e); } catch (TimeoutException e) { fail = true; safeCancel(future); HostControllerLogger.DOMAIN_LOGGER.masterHostControllerUnreachable(TIMEOUT); } finally { if (fail) {
String securityRealm = hostControllerInfo.getHttpManagementSecurityRealm(); AS_ROOT_LOGGER.creatingHttpManagementService(interfaceName, port, securePort); builder.addDependency(SecurityRealmService.BASE_SERVICE_NAME.append(securityRealm), SecurityRealmService.class, service.getSecurityRealmInjector()); } else { AS_ROOT_LOGGER.noSecurityRealmDefined();
} catch (IOException e) { Throwable cause = e; HostControllerLogger.ROOT_LOGGER.debugf(e, "failed to connect to %s:%d", localHostInfo.getRemoteDomainControllerHost(), localHostInfo.getRemoteDomainControllerPort()); while ((cause = cause.getCause()) != null) { if (cause instanceof SaslException) { HostControllerLogger.ROOT_LOGGER.cannotConnect(localHostInfo.getRemoteDomainControllerHost(), localHostInfo.getRemoteDomainControllerPort(), e); ReconnectPolicy.CONNECT.wait(retries); retries++;
@Override public Connection call() throws Exception { final ReconnectPolicy reconnectPolicy = ReconnectPolicy.RECONNECT; int reconnectionCount = 0; for(;;) { try { // reconnectPolicy.wait(reconnectionCount); HostControllerLogger.ROOT_LOGGER.debugf("trying to reconnect to remote host-controller"); // Try to the connect to the remote host controller return connectionManager.connect(); } catch (IOException e) { HostControllerLogger.ROOT_LOGGER.debugf(e, "failed to reconnect to the remote host-controller"); } finally { reconnectionCount++; } } } });
private void cleanStartServers(final ModelNode servers, final ModelNode domainModel, OperationContext context) throws OperationFailedException { for(final Property serverProp : servers.asPropertyList()) { String serverName = serverProp.getName(); if (ServerConfigResourceDefinition.AUTO_START.resolveModelAttribute(context, serverProp.getValue()).asBoolean(true)) { try { serverInventory.startServer(serverName, domainModel, START_BLOCKING); } catch (Exception e) { ROOT_LOGGER.failedToStartServer(e, serverName); } } } }
@Override void addPermGen(JvmElement jvmElement, List<String> command) { if (jvmElement.getPermgenSize() != null || jvmElement.getMaxPermgen() != null) { ROOT_LOGGER.ignoringPermGen(type, jvmElement.getName()); } } }
@Override public void reconnectServer(final String serverName, final ModelNode domainModel, final byte[] authKey, final boolean running, final boolean stopping) { if(shutdown || connectionFinished) { throw HostControllerMessages.MESSAGES.hostAlreadyShutdown(); } ManagedServer existing = servers.get(serverName); if(existing != null) { ROOT_LOGGER.existingServerWithState(serverName, existing.getState()); return; } final ManagedServer server = createManagedServer(serverName, domainModel, authKey); if ((existing = servers.putIfAbsent(serverName, server)) != null) { ROOT_LOGGER.existingServerWithState(serverName, existing.getState()); return; } if(running) { if(!stopping) { server.reconnectServerProcess(); // Register the server proxy at the domain controller domainController.registerRunningServer(server.getProxyController()); } else { server.setServerProcessStopping(); } } else { server.removeServerProcess(); } synchronized (shutdownCondition) { shutdownCondition.notifyAll(); } }
private boolean internalSetState(final TransitionTask task, final InternalState current, final InternalState next) { assert Thread.holdsLock(this); // Call under lock final InternalState internalState = this.internalState; if(internalState == current) { try { if(task != null) { task.execute(this); } this.internalState = next; return true; } catch (final Exception e) { ROOT_LOGGER.debugf(e, "transition (%s > %s) failed for server \"%s\"", current, next, serverName); transitionFailed(current); } finally { notifyAll(); } } return false; }
private void restartedHcStartOrReconnectServers(final ModelNode servers, final ModelNode domainModel){ Map<String, ProcessInfo> processInfos = serverInventory.determineRunningProcesses(); for(final String serverName : servers.keys()) { ProcessInfo info = processInfos.get(serverInventory.getServerProcessName(serverName)); boolean auto = servers.get(serverName, AUTO_START).asBoolean(true); if (info == null && auto) { try { serverInventory.startServer(serverName, domainModel, START_BLOCKING); } catch (Exception e) { ROOT_LOGGER.failedToStartServer(e, serverName); } } else if (info != null){ // Reconnect the server using the current authKey final byte[] authKey = info.getAuthKey(); serverInventory.reconnectServer(serverName, domainModel, authKey, info.isRunning(), info.isStopping()); } } } }
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(); }
/** {@inheritDoc} */ @Override public synchronized void start(StartContext context) throws StartException { ROOT_LOGGER.debug("Starting Host Controller Server Inventory"); try { final ProcessControllerConnectionService processControllerConnectionService = client.getValue(); final InetSocketAddress binding = new InetSocketAddress(interfaceBinding.getValue().getAddress(), port); serverInventory = new ServerInventoryImpl(domainController, environment, binding, processControllerConnectionService.getClient(), extensionRegistry); processControllerConnectionService.setServerInventory(serverInventory); serverCallback.getValue().setCallbackHandler(serverInventory.getServerCallbackHandler()); futureInventory.setInventory(serverInventory); } catch (Exception e) { futureInventory.setFailure(e); throw new StartException(e); } }