use of org.jboss.as.controller.remote.TransactionalProtocolClient in project wildfly-core by wildfly.
the class ServerInventoryImpl method serverCommunicationRegistered.
@Override
public ProxyController serverCommunicationRegistered(final String serverProcessName, final ManagementChannelHandler channelAssociation) {
if (shutdown || connectionFinished) {
throw HostControllerLogger.ROOT_LOGGER.hostAlreadyShutdown();
}
final String serverName = ManagedServer.getServerName(serverProcessName);
final ManagedServer server = servers.get(serverName);
if (server == null) {
ROOT_LOGGER.noServerAvailable(serverName);
return null;
}
try {
final TransactionalProtocolClient client = server.channelRegistered(channelAssociation);
final Channel channel = channelAssociation.getChannel();
channel.addCloseHandler(new CloseHandler<Channel>() {
public void handleClose(final Channel closed, final IOException exception) {
final boolean shuttingDown = shutdown || connectionFinished;
// Unregister right away
if (server.callbackUnregistered(client, shuttingDown)) {
domainController.unregisterRunningServer(server.getServerName());
}
}
});
return server.getProxyController();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.jboss.as.controller.remote.TransactionalProtocolClient in project wildfly-core by wildfly.
the class ManagedServerProxy method execute.
@Override
public <T extends Operation> AsyncFuture<OperationResponse> execute(final TransactionalOperationListener<T> listener, final T operation) throws IOException {
final TransactionalProtocolClient remoteClient = this.remoteClient;
final ModelNode op = operation.getOperation();
if (remoteClient == DISCONNECTED) {
// Handle the restartRequired operation also when disconnected
final String operationName = op.get(OP).asString();
if (ServerProcessStateHandler.REQUIRE_RESTART_OPERATION.equals(operationName)) {
server.requireReload();
}
}
AsyncFuture<OperationResponse> future = remoteClient.execute(listener, operation);
registerFuture(remoteClient, future);
return future;
}
use of org.jboss.as.controller.remote.TransactionalProtocolClient in project wildfly-core by wildfly.
the class TransactionalProtocolClientTestCase method testSimpleRequest.
@Test
public void testSimpleRequest() throws Exception {
//
final TestUpdateWrapper update = createTestClient(0);
final TransactionalProtocolClient client = update.getClient();
final BlockingOperationListener listener = new BlockingOperationListener();
client.execute(listener, update);
//
final TransactionalProtocolClient.PreparedOperation<TestUpdateWrapper> prepared = listener.retrievePreparedOperation();
assert !prepared.isFailed();
assert !prepared.isDone();
// Commit
prepared.commit();
// Block until we have the result
final ModelNode result = prepared.getFinalResult().get().getResponseNode();
assert result.hasDefined(ModelDescriptionConstants.OUTCOME);
assert prepared.isDone();
}
use of org.jboss.as.controller.remote.TransactionalProtocolClient in project wildfly-core by wildfly.
the class TransactionalProtocolClientTestCase method createClient.
/**
* 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 ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
final ManagementChannelHandler channelAssociation = new ManagementChannelHandler(strategy, clientExecutor);
final TransactionalProtocolClient client = TransactionalProtocolHandlers.createClient(channelAssociation);
channel.addCloseHandler(channelAssociation);
channel.receiveMessage(channelAssociation.getReceiver());
return client;
}
use of org.jboss.as.controller.remote.TransactionalProtocolClient in project wildfly-core by wildfly.
the class TransactionalProtocolClientTestCase method testConcurrentGroup.
@Test
public void testConcurrentGroup() throws Exception {
//
final BlockingOperationListener listener = new BlockingOperationListener(CLIENTS);
final List<TestUpdateWrapper> wrappers = createTestClients(CLIENTS);
// First execute all operations
for (final TestUpdateWrapper update : wrappers) {
final TransactionalProtocolClient client = update.getClient();
client.execute(listener, update);
}
// Now wait for all operations to be prepared
final List<TransactionalProtocolClient.PreparedOperation<TestUpdateWrapper>> preparedOps = new ArrayList<TransactionalProtocolClient.PreparedOperation<TestUpdateWrapper>>();
for (int i = 0; i < CLIENTS; i++) {
// Wait for 10 prepared results
final TransactionalProtocolClient.PreparedOperation<TestUpdateWrapper> prepared = listener.retrievePreparedOperation();
assert !prepared.isFailed();
assert !prepared.isDone();
// Check that the controller is locked in the prepared state
final MockController controller = prepared.getOperation().getController();
assert controller.lock.isLocked();
// Commit all
prepared.commit();
preparedOps.add(prepared);
}
final ModelNode result = new ModelNode();
// Now we just need to get the final results
for (final TransactionalProtocolClient.PreparedOperation<TestUpdateWrapper> prepared : preparedOps) {
// Block until we have the result
final ModelNode finalResult = prepared.getFinalResult().get().getResponseNode();
final MockController controller = prepared.getOperation().getController();
assert prepared.isDone();
assert !controller.lock.isLocked();
final int id = prepared.getOperation().getId();
result.get("" + id).set(finalResult);
}
for (int i = 0; i < CLIENTS; i++) {
assert result.hasDefined("" + i);
assert result.get("" + i).hasDefined(ModelDescriptionConstants.OUTCOME);
}
}
Aggregations