Search in sources :

Example 51 with Channel

use of com.google.cloud.video.livestream.v1.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();
        }
    });
}
Also used : JBossThreadFactory(org.jboss.threads.JBossThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) ProtocolConnectionConfiguration(org.jboss.as.protocol.ProtocolConnectionConfiguration) QueueExecutor(org.jboss.threads.QueueExecutor) InetSocketAddress(java.net.InetSocketAddress) OpenListener(org.jboss.remoting3.OpenListener) Channel(org.jboss.remoting3.Channel)

Example 52 with Channel

use of com.google.cloud.video.livestream.v1.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;
}
Also used : CancellationException(java.util.concurrent.CancellationException) Channel(org.jboss.remoting3.Channel) Connection(org.jboss.remoting3.Connection) IOException(java.io.IOException) ModelNode(org.jboss.dmr.ModelNode) ExecutionException(java.util.concurrent.ExecutionException)

Example 53 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project kubernetes-client by fabric8io.

the class ChannelTest method get.

@Test
void get() {
    // Given
    server.expect().get().withPath("/apis/apps.open-cluster-management.io/v1/namespaces/ns1/channels/test-get").andReturn(HttpURLConnection.HTTP_OK, createNewChannel("test-get")).once();
    // When
    Channel channel = client.apps().channels().inNamespace("ns1").withName("test-get").get();
    // Then
    assertThat(channel).isNotNull().hasFieldOrPropertyWithValue("metadata.name", "test-get");
}
Also used : Channel(io.fabric8.openclustermanagement.api.model.multicloudoperatorschannel.apps.v1.Channel) Test(org.junit.jupiter.api.Test)

Example 54 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project solarnetwork-node by SolarNetwork.

the class MasterDemo method run.

static void run(DNP3Manager manager) throws Exception {
    // Create a tcp channel class that will connect to the loopback
    Channel channel = manager.addTCPClient("client", LogMasks.NORMAL | LogMasks.APP_COMMS, ChannelRetry.getDefault(), "127.0.0.1", "0.0.0.0", 20000, new Slf4jChannelListener());
    // You can modify the defaults to change the way the master behaves
    MasterStackConfig config = new MasterStackConfig();
    // Create a master instance, pass in a simple singleton to print received values to the console
    Master master = channel.addMaster("master", PrintingSOEHandler.getInstance(), DefaultMasterApplication.getInstance(), config);
    // do an integrity scan every 2 seconds
    // master.addPeriodicScan(Duration.ofSeconds(2), Header.getIntegrity());
    master.enable();
    // all this cruft just to read a line of text in Java. Oh the humanity.
    InputStreamReader converter = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(converter);
    while (true) {
        System.out.println("Enter something to issue a command or type <quit> to exit");
        String line = in.readLine();
        switch(line) {
            case ("quit"):
                return;
            case ("crob"):
                ControlRelayOutputBlock crob = new ControlRelayOutputBlock(ControlCode.LATCH_ON, (short) 1, 100, 100, CommandStatus.SUCCESS);
                master.selectAndOperateCROB(crob, 0).thenAccept(// asynchronously print the result of the command operation
                (CommandTaskResult result) -> System.out.println(result));
                break;
            case ("scan"):
                master.scan(Header.getEventClasses());
                break;
            default:
                System.out.println("Unknown command: " + line);
                break;
        }
    }
}
Also used : MasterStackConfig(com.automatak.dnp3.MasterStackConfig) Master(com.automatak.dnp3.Master) Slf4jChannelListener(net.solarnetwork.dnp3.util.Slf4jChannelListener) InputStreamReader(java.io.InputStreamReader) CommandTaskResult(com.automatak.dnp3.CommandTaskResult) Channel(com.automatak.dnp3.Channel) BufferedReader(java.io.BufferedReader) ControlRelayOutputBlock(com.automatak.dnp3.ControlRelayOutputBlock)

Example 55 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project solarnetwork-node by SolarNetwork.

the class OutstationService method createOutstation.

private Outstation createOutstation() {
    Channel channel = channel();
    if (channel == null) {
        log.info("DNP3 channel not available for outstation [{}]", getUid());
        return null;
    }
    log.info("Initializing DNP3 outstation [{}]", getUid());
    try {
        return channel.addOutstation(getUid(), commandHandler, app, createOutstationStackConfig());
    } catch (DNP3Exception e) {
        log.error("Error creating outstation application [{}]: {}", getUid(), e.getMessage(), e);
        return null;
    }
}
Also used : Channel(com.automatak.dnp3.Channel) DNP3Exception(com.automatak.dnp3.DNP3Exception)

Aggregations

Channel (org.jboss.remoting3.Channel)41 IOException (java.io.IOException)29 Test (org.junit.Test)14 LivestreamServiceClient (com.google.cloud.video.livestream.v1.LivestreamServiceClient)13 Connection (org.jboss.remoting3.Connection)12 MessageInputStream (org.jboss.remoting3.MessageInputStream)12 CountDownLatch (java.util.concurrent.CountDownLatch)10 OpenListener (org.jboss.remoting3.OpenListener)10 MessageOutputStream (org.jboss.remoting3.MessageOutputStream)9 InetSocketAddress (java.net.InetSocketAddress)8 URI (java.net.URI)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 IoFuture (org.xnio.IoFuture)7 Channel (com.google.cloud.video.livestream.v1.Channel)6 URISyntaxException (java.net.URISyntaxException)6 ManagementClientChannelStrategy (org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy)6 FutureResult (org.xnio.FutureResult)6 ManagementChannelHandler (org.jboss.as.protocol.mgmt.ManagementChannelHandler)5 Endpoint (org.jboss.remoting3.Endpoint)5 Event (com.google.cloud.video.livestream.v1.Event)4