Search in sources :

Example 6 with Channel

use of io.grpc.channelz.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 7 with Channel

use of io.grpc.channelz.v1.Channel in project wildfly-core by wildfly.

the class JConsoleCLIPlugin method connectUsingRemoting.

private boolean connectUsingRemoting(CommandContext cmdCtx, RemotingMBeanServerConnection rmtMBeanSvrConn) throws IOException, CliInitializationException {
    Connection conn = rmtMBeanSvrConn.getConnection();
    Channel channel;
    final IoFuture<Channel> futureChannel = conn.openChannel("management", OptionMap.EMPTY);
    IoFuture.Status result = futureChannel.await(5, TimeUnit.SECONDS);
    if (result == IoFuture.Status.DONE) {
        channel = futureChannel.get();
    } else {
        futureChannel.cancel();
        return false;
    }
    ModelControllerClient modelCtlrClient = ExistingChannelModelControllerClient.createReceiving(channel, createExecutor());
    cmdCtx.bindClient(modelCtlrClient);
    return true;
}
Also used : ExistingChannelModelControllerClient(org.jboss.as.controller.client.impl.ExistingChannelModelControllerClient) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) Channel(org.jboss.remoting3.Channel) Connection(org.jboss.remoting3.Connection) MBeanServerConnection(javax.management.MBeanServerConnection) RemotingMBeanServerConnection(org.jboss.remotingjmx.RemotingMBeanServerConnection) IoFuture(org.xnio.IoFuture)

Example 8 with Channel

use of io.grpc.channelz.v1.Channel 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);
    }
}
Also used : TransactionalProtocolClient(org.jboss.as.controller.remote.TransactionalProtocolClient) Channel(org.jboss.remoting3.Channel) IOException(java.io.IOException)

Example 9 with Channel

use of io.grpc.channelz.v1.Channel in project wildfly-core by wildfly.

the class RemoteDomainConnection method connectionOpened.

@Override
public void connectionOpened(final Connection connection) throws IOException {
    final Channel channel = openChannel(connection, CHANNEL_SERVICE_TYPE, configuration.getOptionMap());
    if (setChannel(channel)) {
        channel.receiveMessage(channelHandler.getReceiver());
        channel.addCloseHandler(channelHandler);
        try {
            if (runningMode == RunningMode.ADMIN_ONLY) {
                // Fetch the domain configuration
                channelHandler.executeRequest(new FetchDomainConfigurationRequest(), null).getResult().get();
            } else {
                // Start the registration process
                channelHandler.executeRequest(new RegisterHostControllerRequest(), null).getResult().get();
            }
        } catch (Exception e) {
            if (e.getCause() instanceof IOException) {
                throw (IOException) e.getCause();
            }
            throw new IOException(e);
        }
        // Registered
        registered();
    } else {
        channel.closeAsync();
    }
}
Also used : FutureManagementChannel(org.jboss.as.protocol.mgmt.FutureManagementChannel) Channel(org.jboss.remoting3.Channel) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) TimeoutException(java.util.concurrent.TimeoutException) PrivilegedActionException(java.security.PrivilegedActionException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) SlaveRegistrationException(org.jboss.as.domain.controller.SlaveRegistrationException)

Example 10 with Channel

use of io.grpc.channelz.v1.Channel in project wildfly-core by wildfly.

the class HostControllerConnection method connectionOpened.

@Override
public void connectionOpened(final Connection connection) throws IOException {
    final Channel channel = openChannel(connection, SERVER_CHANNEL_TYPE, configuration.getOptionMap());
    if (setChannel(channel)) {
        channel.receiveMessage(channelHandler.getReceiver());
        channel.addCloseHandler(channelHandler);
    } else {
        channel.closeAsync();
    }
}
Also used : FutureManagementChannel(org.jboss.as.protocol.mgmt.FutureManagementChannel) Channel(org.jboss.remoting3.Channel)

Aggregations

Channel (org.jboss.remoting3.Channel)21 IOException (java.io.IOException)12 ManagementClientChannelStrategy (org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy)6 InetSocketAddress (java.net.InetSocketAddress)5 ManagementChannelHandler (org.jboss.as.protocol.mgmt.ManagementChannelHandler)5 Connection (org.jboss.remoting3.Connection)5 ProtocolConnectionConfiguration (org.jboss.as.protocol.ProtocolConnectionConfiguration)4 Channel (io.fabric8.openclustermanagement.api.model.multicloudoperatorschannel.apps.v1.Channel)3 ChannelStats (io.grpc.InternalChannelz.ChannelStats)3 ThreadFactory (java.util.concurrent.ThreadFactory)3 ResponseAttachmentInputStreamSupport (org.jboss.as.controller.remote.ResponseAttachmentInputStreamSupport)3 TransactionalProtocolOperationHandler (org.jboss.as.controller.remote.TransactionalProtocolOperationHandler)3 FutureManagementChannel (org.jboss.as.protocol.mgmt.FutureManagementChannel)3 JBossThreadFactory (org.jboss.threads.JBossThreadFactory)3 InternalChannelz (io.grpc.InternalChannelz)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 ExecutionException (java.util.concurrent.ExecutionException)2 MBeanServerConnection (javax.management.MBeanServerConnection)2 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)2 RemoteProxyController (org.jboss.as.controller.remote.RemoteProxyController)2