@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 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; }
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(); }
/** * 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; } }
} 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) {