Search in sources :

Example 11 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project wildfly-core by wildfly.

the class AbstractChannelOpenListenerService method channelOpened.

@Override
public void channelOpened(Channel channel) {
    // this should be using the graceful shutdown control
    if (closed) {
        RemotingLogger.ROOT_LOGGER.debugf("server shutting down, closing channel %s.", channel);
        channel.closeAsync();
        return;
    }
    final ManagementChannelShutdownHandle handle = handleChannelOpened(channel);
    trackerService.registerTracker(handle);
    handles.add(handle);
    channel.addCloseHandler(new CloseHandler<Channel>() {

        public void handleClose(final Channel closed, final IOException exception) {
            handles.remove(handle);
            handle.shutdownNow();
            trackerService.unregisterTracker(handle);
            RemotingLogger.ROOT_LOGGER.tracef("Handling close for %s", handle);
        }
    });
}
Also used : ManagementChannelShutdownHandle(org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle) Channel(org.jboss.remoting3.Channel) IOException(java.io.IOException)

Example 12 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project wildfly-core by wildfly.

the class ManagementChannelHandler method getRemoteAddress.

/**
 * Get the remote address.
 *
 * @return the remote address, {@code null} if not available
 */
public InetAddress getRemoteAddress() {
    final Channel channel;
    try {
        channel = strategy.getChannel();
    } catch (IOException e) {
        return null;
    }
    final Connection connection = channel.getConnection();
    final InetSocketAddress peerAddress = connection.getPeerAddress(InetSocketAddress.class);
    return peerAddress == null ? null : peerAddress.getAddress();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Channel(org.jboss.remoting3.Channel) Connection(org.jboss.remoting3.Connection) IOException(java.io.IOException)

Example 13 with Channel

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

the class ChannelTest method builderShouldCreateObject.

@Test
void builderShouldCreateObject() {
    // Given
    ChannelBuilder channelBuilder = new ChannelBuilder().withNewMetadata().addToLabels("vendor", "OpenShift").withName("sample-channel").endMetadata().withNewSpec().withType("HelmRepo").withPathname("https://charts.helm.sh/stable").withNewConfigMapRef().withKind("ConfigMap").withName("test-configmap").endConfigMapRef().endSpec();
    // When
    Channel channel = channelBuilder.build();
    // Then
    assertNotNull(channel);
    assertEquals("sample-channel", channel.getMetadata().getName());
    assertEquals(1, channel.getMetadata().getLabels().size());
    assertEquals("HelmRepo", channel.getSpec().getType());
    assertEquals("https://charts.helm.sh/stable", channel.getSpec().getPathname());
    assertEquals("test-configmap", channel.getSpec().getConfigMapRef().getName());
    assertEquals("ConfigMap", channel.getSpec().getConfigMapRef().getKind());
}
Also used : Channel(io.fabric8.openclustermanagement.api.model.multicloudoperatorschannel.apps.v1.Channel) ChannelBuilder(io.fabric8.openclustermanagement.api.model.multicloudoperatorschannel.apps.v1.ChannelBuilder) Test(org.junit.jupiter.api.Test)

Example 14 with Channel

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

the class ChannelTest method deserializationAndSerializationShouldWorkAsExpected.

@Test
void deserializationAndSerializationShouldWorkAsExpected() throws IOException {
    // Given
    String originalJson = new Scanner(getClass().getResourceAsStream("/valid-channel.json")).useDelimiter("\\A").next();
    // When
    final Channel channel = mapper.readValue(originalJson, Channel.class);
    final String serializedJson = mapper.writeValueAsString(channel);
    final Channel apiRequestCountFromSerializedJson = mapper.readValue(serializedJson, Channel.class);
    // Then
    assertNotNull(channel);
    assertNotNull(serializedJson);
    assertNotNull(apiRequestCountFromSerializedJson);
    assertEquals(channel.getMetadata().getName(), apiRequestCountFromSerializedJson.getMetadata().getName());
    assertEquals("HelmRepo", channel.getSpec().getType());
    assertEquals("https://charts.helm.sh/stable", channel.getSpec().getPathname());
    assertEquals("bookinfo-resource-filter-configmap", channel.getSpec().getConfigMapRef().getName());
    assertEquals("configmap", channel.getSpec().getConfigMapRef().getKind());
}
Also used : Scanner(java.util.Scanner) Channel(io.fabric8.openclustermanagement.api.model.multicloudoperatorschannel.apps.v1.Channel) Test(org.junit.jupiter.api.Test)

Example 15 with Channel

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

the class OutstationDemo method run.

public static void run(DNP3Manager manager) throws Exception {
    // Create a tcp channel class that will connect to the loopback
    Channel channel = manager.addTCPServer("client", LogMasks.NORMAL | LogMasks.APP_COMMS, ServerAcceptMode.CloseNew, "127.0.0.1", 20000, new Slf4jChannelListener());
    // Create the default outstation configuration
    OutstationStackConfig config = new OutstationStackConfig(DatabaseConfig.allValues(5), EventBufferConfig.allTypes(50));
    // Create an Outstation instance, pass in a simple a command handler that responds successfully to everything
    Outstation outstation = channel.addOutstation("outstation", SuccessCommandHandler.getInstance(), DefaultOutstationApplication.getInstance(), config);
    outstation.enable();
    // all this stuff just to read a line of text in Java. Oh the humanity.
    String line = "";
    InputStreamReader converter = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(converter);
    int i = 0;
    while (true) {
        System.out.println("Enter something to update a counter or type <quit> to exit");
        line = in.readLine();
        if (line.equals("quit"))
            break;
        else {
            OutstationChangeSet set = new OutstationChangeSet();
            set.update(new Counter(i, (byte) 0x01, 0), 0);
            outstation.apply(set);
            ++i;
        }
    }
}
Also used : Slf4jChannelListener(net.solarnetwork.dnp3.util.Slf4jChannelListener) Outstation(com.automatak.dnp3.Outstation) Counter(com.automatak.dnp3.Counter) InputStreamReader(java.io.InputStreamReader) OutstationChangeSet(com.automatak.dnp3.OutstationChangeSet) Channel(com.automatak.dnp3.Channel) OutstationStackConfig(com.automatak.dnp3.OutstationStackConfig) BufferedReader(java.io.BufferedReader)

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