use of com.automatak.dnp3.Channel in project wildfly-core by wildfly.
the class TransactionalProtocolClientTestCase method startChannelServer.
@Before
public void startChannelServer() throws Exception {
final ChannelServer.Configuration configuration = new ChannelServer.Configuration();
configuration.setEndpointName(ENDPOINT_NAME);
configuration.setUriScheme(URI_SCHEME);
configuration.setBindAddress(new InetSocketAddress("127.0.0.1", PORT));
channelServer = ChannelServer.create(configuration);
//
channelServer.addChannelOpenListener(TEST_CHANNEL, new OpenListener() {
@Override
public void channelOpened(final Channel channel) {
final MockController controller = new MockController();
final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
final ManagementChannelHandler channels = new ManagementChannelHandler(strategy, remoteExecutors);
final ManagementRequestHandlerFactory handlerFactory = new TransactionalProtocolOperationHandler(controller, channels, new ResponseAttachmentInputStreamSupport());
channels.addHandlerFactory(handlerFactory);
transferQueue.offer(controller);
channel.addCloseHandler(channels);
channel.receiveMessage(channels.getReceiver());
}
@Override
public void registrationTerminated() {
//
}
});
final ProtocolConnectionConfiguration connectionConfig = ProtocolConnectionConfiguration.create(channelServer.getEndpoint(), new URI("" + URI_SCHEME + "://127.0.0.1:" + PORT + ""));
connectionConfig.setEndpoint(channelServer.getEndpoint());
//
futureConnection = connectionConfig.getEndpoint().getConnection(connectionConfig.getUri());
}
use of com.automatak.dnp3.Channel in project wildfly-core by wildfly.
the class TransactionalProtocolClientTestCase method createClient.
/**
* Create the protocol client to talk to the remote controller.
*
* @return the client
* @throws Exception
*/
TransactionalProtocolClient createClient() throws Exception {
final Connection connection = futureConnection.get();
final IoFuture<Channel> channelIoFuture = connection.openChannel(TEST_CHANNEL, OptionMap.EMPTY);
return createClient(channelIoFuture.get());
}
use of com.automatak.dnp3.Channel in project wildfly-core by wildfly.
the class TestControllerClient method executeAwaitClosed.
protected ModelNode executeAwaitClosed(final ModelNode operation) throws IOException {
final Channel channel = getChannelAssociation().getChannel();
final Connection connection = channel.getConnection();
final ModelNode result = execute(operation);
if (!ModelDescriptionConstants.SUCCESS.equals(result.get(ModelDescriptionConstants.OUTCOME).asString())) {
return result;
}
try {
connection.awaitClosed();
} catch (InterruptedException e) {
e.printStackTrace();
}
return result;
}
use of com.automatak.dnp3.Channel in project wildfly-core by wildfly.
the class RemoteChannelPairSetup method setupRemoting.
public void setupRemoting(final ManagementChannelInitialization initialization) throws IOException {
// executorService = Executors.newCachedThreadPool();
final ThreadFactory threadFactory = new JBossThreadFactory(new ThreadGroup("Remoting"), Boolean.FALSE, null, "Remoting %f thread %t", null, null);
executorService = new QueueExecutor(EXECUTOR_MAX_THREADS / 4 + 1, EXECUTOR_MAX_THREADS, EXECUTOR_KEEP_ALIVE_TIME, TimeUnit.MILLISECONDS, 500, threadFactory, true, null);
final ChannelServer.Configuration configuration = new ChannelServer.Configuration();
configuration.setEndpointName(ENDPOINT_NAME);
configuration.setUriScheme(URI_SCHEME);
configuration.setBindAddress(new InetSocketAddress("127.0.0.1", PORT));
configuration.setExecutor(executorService);
channelServer = ChannelServer.create(configuration);
channelServer.addChannelOpenListener(TEST_CHANNEL, new OpenListener() {
@Override
public void registrationTerminated() {
}
@Override
public void channelOpened(Channel channel) {
serverChannel = channel;
initialization.startReceiving(channel);
clientConnectedLatch.countDown();
}
});
}
use of com.automatak.dnp3.Channel in project wildfly-core by wildfly.
the class DomainLifecycleUtil method executeAwaitConnectionClosed.
/**
* Execute an operation and wait until the connection is closed. This is only useful for :reload and :shutdown operations.
*
* @param operation the operation to execute
* @return the operation result
* @throws IOException for any error
* @throws IllegalStateException if {@link #close()} has previously been invoked on this instance.
*/
public ModelNode executeAwaitConnectionClosed(final ModelNode operation) throws IOException {
checkClosed();
final DomainTestClient client = internalGetOrCreateClient();
final Channel channel = client.getChannel();
if (null == channel) {
throw new IllegalStateException("Didn't get a remoting channel from the DomainTestClient.");
}
final Connection ref = channel.getConnection();
ModelNode result = new ModelNode();
try {
result = client.execute(operation);
// IN case the operation wasn't successful, don't bother waiting
if (!"success".equals(result.get("outcome").asString())) {
return result;
}
} catch (IOException e) {
final Throwable cause = e.getCause();
if (!(cause instanceof ExecutionException) && !(cause instanceof CancellationException)) {
throw e;
}
// else ignore, this might happen if the channel gets closed before we got the response
}
try {
// Wait for the channel to close
channel.awaitClosed();
// Wait for the connection to be closed
connection.awaitConnectionClosed(ref);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return result;
}
Aggregations