Search in sources :

Example 96 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project jboss-remoting by jboss-remoting.

the class HeartbeatTestCase method testDisableHeartbeat.

/**
 * Test that heartbeat can be set and can be disabled by setting it to 0
 *
 * @throws Exception
 */
@Test
public void testDisableHeartbeat() throws Exception {
    Channel clientChannel = null;
    Channel serverChannel = null;
    Closeable streamServer = null;
    Connection connection = null;
    Registration serviceRegistration = null;
    final Endpoint endpoint = Endpoint.builder().setEndpointName("test").build();
    NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
    final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
    domainBuilder.addRealm("mainRealm", mainRealm).build();
    domainBuilder.setDefaultRealmName("mainRealm");
    domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
    final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
    mainRealm.setPasswordMap("bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
    final SaslServerFactory saslServerFactory = new ServiceLoaderSaslServerFactory(HeartbeatTestCase.class.getClassLoader());
    final SaslAuthenticationFactory.Builder builder = SaslAuthenticationFactory.builder();
    builder.setSecurityDomain(domainBuilder.build());
    builder.setFactory(saslServerFactory);
    builder.setMechanismConfigurationSelector(mechanismInformation -> SaslMechanismInformation.Names.SCRAM_SHA_256.equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null);
    final SaslAuthenticationFactory saslAuthenticationFactory = builder.build();
    streamServer = networkServerProvider.createServer(new InetSocketAddress("localhost", 30123), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE), saslAuthenticationFactory, SSLContext.getDefault());
    final FutureResult<Channel> passer = new FutureResult<Channel>();
    serviceRegistration = endpoint.registerService("org.jboss.test", new OpenListener() {

        public void channelOpened(final Channel channel) {
            passer.setResult(channel);
        }

        public void registrationTerminated() {
        }
    }, OptionMap.EMPTY);
    IoFuture<Connection> futureConnection = AuthenticationContext.empty().with(MatchRule.ALL, AuthenticationConfiguration.empty().useName("bob").usePassword("pass").setSaslMechanismSelector(SaslMechanismSelector.NONE.addMechanism("SCRAM-SHA-256"))).run(new PrivilegedAction<IoFuture<Connection>>() {

        public IoFuture<Connection> run() {
            try {
                return endpoint.connect(new URI("remote://localhost:30123"), OptionMap.create(RemotingOptions.HEARTBEAT_INTERVAL, 0));
            } catch (URISyntaxException e) {
                throw new RuntimeException(e);
            }
        }
    });
    connection = futureConnection.get();
    IoFuture<Channel> futureChannel = connection.openChannel("org.jboss.test", OptionMap.EMPTY);
    clientChannel = futureChannel.get();
    serverChannel = passer.getIoFuture().get();
    assertNotNull(serverChannel);
    RemoteConnectionChannel remoteClientChannel = (RemoteConnectionChannel) clientChannel;
    assertEquals(0, Utils.getInstanceValue(remoteClientChannel.getRemoteConnection(), "heartbeatInterval"));
    RemoteWriteListener clientWriteListener = (RemoteWriteListener) Utils.getInstanceValue(remoteClientChannel.getRemoteConnection(), "writeListener");
    assertNull(Utils.getInstanceValue(clientWriteListener, "heartKey"));
    afterTest(clientChannel, serverChannel, connection, serviceRegistration);
    destroy(endpoint, streamServer);
}
Also used : RemoteWriteListener(org.jboss.remoting3.remote.RemoteConnection.RemoteWriteListener) InetSocketAddress(java.net.InetSocketAddress) Closeable(java.io.Closeable) ClearPasswordSpec(org.wildfly.security.password.spec.ClearPasswordSpec) IoFuture(org.xnio.IoFuture) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain) Endpoint(org.jboss.remoting3.Endpoint) FutureResult(org.xnio.FutureResult) Registration(org.jboss.remoting3.Registration) NetworkServerProvider(org.jboss.remoting3.spi.NetworkServerProvider) ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) SimpleMapBackedSecurityRealm(org.wildfly.security.auth.realm.SimpleMapBackedSecurityRealm) SaslServerFactory(javax.security.sasl.SaslServerFactory) ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) OpenListener(org.jboss.remoting3.OpenListener) Channel(org.jboss.remoting3.Channel) Connection(org.jboss.remoting3.Connection) SaslAuthenticationFactory(org.wildfly.security.auth.server.sasl.SaslAuthenticationFactory) PasswordFactory(org.wildfly.security.password.PasswordFactory) Test(org.junit.Test)

Example 97 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project jboss-ejb-client by wildfly.

the class RemotingLegacyConfiguration method getConfiguredEndpoint.

public Endpoint getConfiguredEndpoint() {
    final JBossEJBProperties properties = JBossEJBProperties.getCurrent();
    if (properties == null) {
        return null;
    }
    Logs.MAIN.legacyEJBPropertiesRemotingConfigurationInUse();
    final EndpointBuilder endpointBuilder = Endpoint.builder();
    final String endpointName = properties.getEndpointName();
    if (endpointName != null) {
        endpointBuilder.setEndpointName(endpointName);
    }
    OptionMap endpointCreationOptions = properties.getEndpointCreationOptions();
    if (endpointCreationOptions != null && endpointCreationOptions.size() > 0) {
        if (!endpointCreationOptions.contains(Options.THREAD_DAEMON)) {
            endpointCreationOptions = OptionMap.builder().addAll(endpointCreationOptions).set(Options.THREAD_DAEMON, true).getMap();
        }
        endpointBuilder.buildXnioWorker(Xnio.getInstance()).populateFromOptions(endpointCreationOptions);
    }
    final List<JBossEJBProperties.ConnectionConfiguration> connectionList = properties.getConnectionList();
    List<URI> uris = new ArrayList<URI>();
    for (JBossEJBProperties.ConnectionConfiguration connectionConfiguration : connectionList) {
        final OptionMap connectionOptions = connectionConfiguration.getConnectionOptions();
        final URI uri = CommonLegacyConfiguration.getUri(connectionConfiguration, connectionOptions);
        if (uri == null) {
            continue;
        }
        if (connectionConfiguration.isConnectEagerly()) {
            uris.add(uri);
        }
        final ConnectionBuilder connectionBuilder = endpointBuilder.addConnection(uri);
        connectionBuilder.setHeartbeatInterval(connectionOptions.get(RemotingOptions.HEARTBEAT_INTERVAL, RemotingOptions.DEFAULT_HEARTBEAT_INTERVAL));
        if (connectionOptions.get(Options.READ_TIMEOUT, -1) != -1) {
            connectionBuilder.setReadTimeout(connectionOptions.get(Options.READ_TIMEOUT, -1));
        }
        if (connectionOptions.get(Options.WRITE_TIMEOUT, -1) != -1) {
            connectionBuilder.setWriteTimeout(connectionOptions.get(Options.WRITE_TIMEOUT, -1));
        }
        connectionBuilder.setTcpKeepAlive(connectionOptions.get(Options.KEEP_ALIVE, false));
    }
    final Endpoint endpoint;
    try {
        endpoint = endpointBuilder.build();
    } catch (IOException e) {
        throw Logs.MAIN.failedToConstructEndpoint(e);
    }
    for (URI uri : uris) {
        endpoint.getConnection(uri, "ejb", "jboss");
    }
    return endpoint;
}
Also used : ArrayList(java.util.ArrayList) EndpointBuilder(org.jboss.remoting3.EndpointBuilder) ConnectionBuilder(org.jboss.remoting3.ConnectionBuilder) IOException(java.io.IOException) URI(java.net.URI) Endpoint(org.jboss.remoting3.Endpoint) OptionMap(org.xnio.OptionMap)

Example 98 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.

the class V2SpanWriter method endpointSizeInBytes.

static int endpointSizeInBytes(Endpoint value, boolean writeEmptyServiceName) {
    // {
    int sizeInBytes = 1;
    String serviceName = value.serviceName();
    if (serviceName == null && writeEmptyServiceName)
        serviceName = "";
    if (serviceName != null) {
        // "serviceName":""
        sizeInBytes += 16;
        sizeInBytes += jsonEscapedSizeInBytes(serviceName);
    }
    if (value.ipv4() != null) {
        // ,
        if (sizeInBytes != 1)
            sizeInBytes++;
        // "ipv4":""
        sizeInBytes += 9;
        sizeInBytes += value.ipv4().length();
    }
    if (value.ipv6() != null) {
        // ,
        if (sizeInBytes != 1)
            sizeInBytes++;
        // "ipv6":""
        sizeInBytes += 9;
        sizeInBytes += value.ipv6().length();
    }
    int port = value.portAsInt();
    if (port != 0) {
        // ,
        if (sizeInBytes != 1)
            sizeInBytes++;
        // "port":
        sizeInBytes += 7;
        sizeInBytes += asciiSizeInBytes(port);
    }
    // }
    return ++sizeInBytes;
}
Also used : Endpoint(zipkin2.Endpoint)

Example 99 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.

the class V1BinaryAnnotation method hashCode.

@Override
public int hashCode() {
    int h = 1;
    h *= 1000003;
    h ^= key.hashCode();
    h *= 1000003;
    h ^= stringValue == null ? 0 : stringValue.hashCode();
    h *= 1000003;
    h ^= endpoint == null ? 0 : endpoint.hashCode();
    return h;
}
Also used : Endpoint(zipkin2.Endpoint)

Example 100 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.

the class JacksonSpanDecoder method parseEndpoint.

static Endpoint parseEndpoint(JsonParser jsonParser) throws IOException {
    if (!jsonParser.isExpectedStartObjectToken()) {
        throw new IOException("Not a valid JSON object, start token: " + jsonParser.currentToken());
    }
    String serviceName = null, ipv4 = null, ipv6 = null;
    int port = 0;
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        String fieldName = jsonParser.currentName();
        JsonToken value = jsonParser.nextToken();
        if (value == JsonToken.VALUE_NULL) {
            continue;
        }
        switch(fieldName) {
            case "serviceName":
                serviceName = jsonParser.getValueAsString();
                break;
            case "ipv4":
                ipv4 = jsonParser.getValueAsString();
                break;
            case "ipv6":
                ipv6 = jsonParser.getValueAsString();
                break;
            case "port":
                port = jsonParser.getValueAsInt();
                break;
            default:
                jsonParser.skipChildren();
        }
    }
    if (serviceName == null && ipv4 == null && ipv6 == null && port == 0)
        return null;
    return Endpoint.newBuilder().serviceName(serviceName).ip(ipv4).ip(ipv6).port(port).build();
}
Also used : JsonToken(com.fasterxml.jackson.core.JsonToken) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) Endpoint(zipkin2.Endpoint)

Aggregations

Endpoint (zipkin2.Endpoint)73 Span (zipkin2.Span)33 Test (org.junit.Test)28 Endpoint (org.jboss.remoting3.Endpoint)22 Test (org.junit.jupiter.api.Test)20 V1Span (zipkin2.v1.V1Span)16 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)10 SpanSampler (com.wavefront.agent.sampler.SpanSampler)10 ByteBuf (io.netty.buffer.ByteBuf)10 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)10 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)10 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)10 Span (wavefront.report.Span)10 IOException (java.io.IOException)8 URI (java.net.URI)8 HashMap (java.util.HashMap)8 Annotation (wavefront.report.Annotation)8 ServiceName (org.jboss.msc.service.ServiceName)7 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)6 SaslAuthenticationFactory (org.wildfly.security.auth.server.SaslAuthenticationFactory)6