use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.
the class ManagementRemotingServices method installManagementChannelOpenListenerService.
/**
* Set up the services to create a channel listener. This assumes that an endpoint service called {@code endpointName} exists.
* @param serviceTarget the service target to install the services into
* @param endpointName the name of the endpoint to install a channel listener into
* @param channelName the name of the channel
* @param operationHandlerName the name of the operation handler to handle request for this channel
* @param options the remoting options
* @param onDemand whether to install the services on demand
*/
public static void installManagementChannelOpenListenerService(final ServiceTarget serviceTarget, final ServiceName endpointName, final String channelName, final ServiceName operationHandlerName, final OptionMap options, final boolean onDemand) {
final ServiceName serviceName = RemotingServices.channelServiceName(endpointName, channelName);
final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
final Supplier<ManagementChannelInitialization> ohfSupplier = builder.requires(operationHandlerName);
final Supplier<ExecutorService> esSupplier = builder.requires(SHUTDOWN_EXECUTOR_NAME);
final Supplier<Endpoint> eSupplier = builder.requires(endpointName);
final Supplier<ManagementChannelRegistryService> rSupplier = builder.requires(ManagementChannelRegistryService.SERVICE_NAME);
builder.setInstance(new ManagementChannelOpenListenerService(ohfSupplier, esSupplier, eSupplier, rSupplier, channelName, options));
builder.setInitialMode(onDemand ? ON_DEMAND : ACTIVE);
builder.install();
}
use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.
the class ModelControllerClientTestCase method setupTestClient.
private ModelControllerClient setupTestClient(final ModelController controller) throws IOException {
try {
channels.setupRemoting(new ManagementChannelInitialization() {
@Override
public ManagementChannelHandler startReceiving(Channel channel) {
final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
support.addHandlerFactory(new ModelControllerClientOperationHandler(controller, support, new ResponseAttachmentInputStreamSupport(), getClientRequestExecutor()));
channel.receiveMessage(support.getReceiver());
return support;
}
private ExecutorService getClientRequestExecutor() {
final BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(512);
final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<ThreadFactory>() {
public ThreadFactory run() {
return new JBossThreadFactory(new ThreadGroup("management-handler-thread"), Boolean.FALSE, null, "%G - %t", null, null);
}
});
ThreadPoolExecutor executor = new ThreadPoolExecutor(4, 4, 250L, TimeUnit.MILLISECONDS, workQueue, threadFactory);
// Allow the core threads to time out as well
executor.allowCoreThreadTimeOut(true);
return executor;
}
});
channels.startClientConnetion();
} catch (Exception e) {
throw new RuntimeException(e);
}
final Channel clientChannel = channels.getClientChannel();
return ExistingChannelModelControllerClient.createReceiving(clientChannel, channels.getExecutorService());
}
use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.
the class RemoteProxyControllerProtocolTestCase method setupProxyHandlers.
private RemoteProxyController setupProxyHandlers(final ModelController proxiedController) {
try {
channels = new RemoteChannelPairSetup();
channels.setupRemoting(new ManagementChannelInitialization() {
@Override
public ManagementChannelHandler startReceiving(Channel channel) {
final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
support.addHandlerFactory(new TransactionalProtocolOperationHandler(proxiedController, support, responseAttachmentSupport));
channel.addCloseHandler(new CloseHandler<Channel>() {
@Override
public void handleClose(Channel closed, IOException exception) {
support.shutdownNow();
}
});
channel.receiveMessage(support.getReceiver());
return support;
}
});
channels.startClientConnetion();
} catch (Exception e) {
throw new RuntimeException(e);
}
final Channel clientChannel = channels.getClientChannel();
final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(clientChannel);
final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
final RemoteProxyController proxyController = RemoteProxyController.create(support, PathAddress.pathAddress(), ProxyOperationAddressTranslator.HOST);
clientChannel.addCloseHandler(new CloseHandler<Channel>() {
@Override
public void handleClose(Channel closed, IOException exception) {
support.shutdownNow();
}
});
clientChannel.receiveMessage(support.getReceiver());
return proxyController;
}
use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.
the class RemoteChannelProxyControllerTestCase method createProxyController.
@Override
protected ProxyController createProxyController(final ModelController proxiedController, final PathAddress proxyNodeAddress) {
try {
channels = new RemoteChannelPairSetup();
channels.setupRemoting(new ManagementChannelInitialization() {
@Override
public ManagementChannelHandler startReceiving(Channel channel) {
final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
support.addHandlerFactory(new TransactionalProtocolOperationHandler(proxiedController, support, new ResponseAttachmentInputStreamSupport()));
channel.addCloseHandler(new CloseHandler<Channel>() {
@Override
public void handleClose(Channel closed, IOException exception) {
support.shutdownNow();
}
});
channel.receiveMessage(support.getReceiver());
return support;
}
});
channels.startClientConnetion();
} catch (Exception e) {
throw new RuntimeException(e);
}
final Channel clientChannel = channels.getClientChannel();
final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(clientChannel);
final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
final RemoteProxyController proxyController = RemoteProxyController.create(support, proxyNodeAddress, ProxyOperationAddressTranslator.SERVER);
clientChannel.addCloseHandler(new CloseHandler<Channel>() {
@Override
public void handleClose(Channel closed, IOException exception) {
support.shutdownNow();
}
});
clientChannel.receiveMessage(support.getReceiver());
return proxyController;
}
use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.
the class ManagementChannelOpenListenerService method handleChannelOpened.
@Override
protected ManagementChannelShutdownHandle handleChannelOpened(final Channel channel) {
final ManagementChannelInitialization initialization = operationHandlerFactorySupplier.get();
RemotingLogger.ROOT_LOGGER.tracef("Opened %s: %s with handler %s", channelName, channel, initialization);
return initialization.startReceiving(channel);
}
Aggregations