@Override public boolean execute(ManagedServer server) throws Exception { assert Thread.holdsLock(ManagedServer.this); // Call under lock // Stop process try { // graceful shutdown // this just suspends the server, it does not actually shut it down if (permit != -1) { final ModelNode operation = new ModelNode(); operation.get(OP).set("shutdown"); operation.get(OP_ADDR).setEmptyList(); operation.get("operation-id").set(permit); operation.get("timeout").set(timeout); final TransactionalProtocolClient.PreparedOperation<?> prepared = TransactionalProtocolHandlers.executeBlocking(operation, protocolClient); if (prepared.isFailed()) { return true; } // we stop the server via an operation prepared.commit(); prepared.getFinalResult().get(); } } catch (Exception ignore) { } finally { try { processControllerClient.stopProcess(serverProcessName); } catch (IOException ignore) { } } return true; }
/** * Create the protocol client to talk to the remote controller. * * @param channel the remoting channel * @return the client * @throws Exception */ TransactionalProtocolClient createClient(final Channel channel) { channels.add(channel); final ManagementChannelHandler channelAssociation = new ManagementChannelHandler(channel, clientExecutor); final TransactionalProtocolClient client = TransactionalProtocolHandlers.createClient(channelAssociation); channel.addCloseHandler(channelAssociation); channel.receiveMessage(channelAssociation.getReceiver()); return client; }
@Override public AsyncFuture<ModelNode> execute( final TransactionalOperationListener<Operation> listener, final ModelNode operation, final OperationMessageHandler messageHandler, final OperationAttachments attachments) throws IOException { return execute( listener, TransactionalProtocolHandlers.wrap(operation, messageHandler, attachments)); }
boolean resume() { final ModelNode operation = new ModelNode(); operation.get(OP).set("resume"); operation.get(OP_ADDR).setEmptyList(); try { final TransactionalProtocolClient.PreparedOperation<?> prepared = TransactionalProtocolHandlers.executeBlocking(operation, protocolClient); if (prepared.isFailed()) { return false; } prepared.commit(); prepared.getFinalResult().get(); } catch (Exception ignore) { return false; } return true; }
@Override public boolean execute(ManagedServer server) throws Exception { final ModelNode operation = new ModelNode(); operation.get(OP).set("reload"); operation.get(OP_ADDR).setEmptyList(); operation.get("operation-id").set(permit); try { final TransactionalProtocolClient.PreparedOperation<?> prepared = TransactionalProtocolHandlers.executeBlocking(operation, protocolClient); if (prepared.isFailed()) { return false; } prepared.commit(); // Just commit and discard the result } catch (IOException ignore) { // } return true; }
void awaitSuspended(long timeout) { // we just re-suspend, but this time give a timeout final ModelNode operation = new ModelNode(); operation.get(OP).set("suspend"); operation.get(OP_ADDR).setEmptyList(); operation.get(TIMEOUT).set(timeout); try { final TransactionalProtocolClient.PreparedOperation<?> prepared = TransactionalProtocolHandlers.executeBlocking(operation, protocolClient); if (prepared.isFailed()) { return; } prepared.commit(); prepared.getFinalResult().get(); } catch (Exception ignore) { return; } return; }
synchronized TransactionalProtocolClient channelRegistered( final ManagementChannelHandler channelAssociation) { final InternalState current = this.internalState; // Create the remote controller client channelAssociation .getAttachments() .attach(TransactionalProtocolClient.SEND_SUBJECT, Boolean.TRUE); final TransactionalProtocolClient remoteClient = TransactionalProtocolHandlers.createClient(channelAssociation); if (current == InternalState.RELOADING) { internalSetState( new TransitionTask() { @Override public boolean execute(ManagedServer server) throws Exception { // Update the current remote connection protocolClient.connected(remoteClient); // clear reload required state requiresReload = false; return true; } }, InternalState.RELOADING, InternalState.SERVER_STARTING); } else { internalSetState( new TransitionTask() { @Override public boolean execute(final ManagedServer server) throws Exception { // Update the current remote connection protocolClient.connected(remoteClient); return true; } // TODO we just check that we are in the correct state, perhaps introduce a new state }, InternalState.SEND_STDIN, InternalState.SERVER_STARTING); } return remoteClient; }