Search in sources :

Example 56 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project wildfly-core by wildfly.

the class RemotingSubsystemTestCase method testRuntime.

/**
 * Tests that the outbound connections configured in the remoting subsytem are processed and services
 * are created for them
 *
 * @throws Exception
 */
@Test
public void testRuntime() throws Exception {
    KernelServices services = createKernelServicesBuilder(createRuntimeAdditionalInitialization()).setSubsystemXml(getSubsystemXml()).build();
    ServiceName remotingEndpointSN = RemotingServices.SUBSYSTEM_ENDPOINT;
    ServiceName remotingConnectorSN = RemotingServices.serverServiceName("remoting-connector");
    DependenciesRetrievalService dependencies = DependenciesRetrievalService.create(services, remotingEndpointSN, remotingConnectorSN);
    Endpoint endpointService = dependencies.getService(remotingEndpointSN);
    assertNotNull("Endpoint service was null", endpointService);
    assertNotNull(endpointService.getName());
    Object remotingConnector = dependencies.getService(remotingConnectorSN);
    assertNotNull("Remoting connector was null", remotingConnector);
}
Also used : Endpoint(org.jboss.remoting3.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) KernelServices(org.jboss.as.subsystem.test.KernelServices) Test(org.junit.Test)

Example 57 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project wildfly-core by wildfly.

the class RemotingHttpUpgradeService method start.

@Override
public synchronized void start(final StartContext context) throws StartException {
    final Endpoint endpoint = endpointSupplier.get();
    OptionMap.Builder builder = OptionMap.builder();
    ListenerRegistry.Listener listenerInfo = listenerRegistrySupplier.get().getListener(httpConnectorName);
    assert listenerInfo != null;
    listenerInfo.addHttpUpgradeMetadata(httpUpgradeMetadata = new ListenerRegistry.HttpUpgradeMetadata("jboss-remoting", endpointName));
    RemotingConnectorBindingInfoService.install(context.getChildTarget(), context.getController().getName().getSimpleName(), (SocketBinding) listenerInfo.getContextInformation("socket-binding"), listenerInfo.getProtocol().equals("https") ? REMOTE_HTTPS : REMOTE_HTTP);
    if (connectorPropertiesOptionMap != null) {
        builder.addAll(connectorPropertiesOptionMap);
    }
    OptionMap resultingMap = builder.getMap();
    try {
        final ExternalConnectionProvider provider = endpoint.getConnectionProviderInterface(Protocol.HTTP_REMOTING.toString(), ExternalConnectionProvider.class);
        SaslAuthenticationFactory saslAuthenticationFactory = saslAuthenticationFactorySupplier != null ? saslAuthenticationFactorySupplier.get() : null;
        if (saslAuthenticationFactory == null) {
            // TODO Elytron Inject the sasl server factory.
            RemotingLogger.ROOT_LOGGER.warn("****** All authentication is ANONYMOUS for " + getClass().getName());
            final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
            domainBuilder.addRealm("default", SecurityRealm.EMPTY_REALM).build();
            domainBuilder.setDefaultRealmName("default");
            domainBuilder.setPermissionMapper((permissionMappable, roles) -> createPermissionVerifier());
            final SaslAuthenticationFactory.Builder authBuilder = SaslAuthenticationFactory.builder();
            authBuilder.setSecurityDomain(domainBuilder.build());
            authBuilder.setFactory(new AnonymousServerFactory());
            authBuilder.setMechanismConfigurationSelector(mechanismInformation -> MechanismConfiguration.EMPTY);
            saslAuthenticationFactory = authBuilder.build();
        }
        final Consumer<StreamConnection> adaptor = provider.createConnectionAdaptor(resultingMap, saslAuthenticationFactory);
        upgradeRegistrySupplier.get().addProtocol(JBOSS_REMOTING, new ChannelListener<StreamConnection>() {

            @Override
            public void handleEvent(final StreamConnection channel) {
                adaptor.accept(channel);
            /*if (channel instanceof SslConnection) {
                        adaptor.accept(new AssembledConnectedSslStreamChannel((SslConnection) channel, channel.getSourceChannel(), channel.getSinkChannel()));
                    } else {
                        adaptor.adapt(new AssembledConnectedStreamChannel(channel, channel.getSourceChannel(), channel.getSinkChannel()));
                    }*/
            }
        }, new SimpleHttpUpgradeHandshake(MAGIC_NUMBER, SEC_JBOSS_REMOTING_KEY, SEC_JBOSS_REMOTING_ACCEPT));
        serviceConsumer.accept(this);
    } catch (UnknownURISchemeException e) {
        throw new StartException(e);
    } catch (IOException e) {
        throw new StartException(e);
    }
}
Also used : ListenerRegistry(io.undertow.server.ListenerRegistry) ExternalConnectionProvider(org.jboss.remoting3.spi.ExternalConnectionProvider) UnknownURISchemeException(org.jboss.remoting3.UnknownURISchemeException) IOException(java.io.IOException) StreamConnection(org.xnio.StreamConnection) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain) SaslAuthenticationFactory(org.wildfly.security.auth.server.SaslAuthenticationFactory) Endpoint(org.jboss.remoting3.Endpoint) AnonymousServerFactory(org.wildfly.security.sasl.anonymous.AnonymousServerFactory) OptionMap(org.xnio.OptionMap) StartException(org.jboss.msc.service.StartException)

Example 58 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project wildfly-core by wildfly.

the class RemotingSubsystemAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    // WFCORE-4510 -- the effective endpoint configuration is from the root subsystem resource,
    // not from the placeholder configuration=endpoint child resource.
    ModelNode endpointModel = resource.getModel();
    String workerName = WORKER.resolveModelAttribute(context, endpointModel).asString();
    final OptionMap map = EndpointConfigFactory.populate(context, endpointModel);
    // create endpoint
    final String nodeName = WildFlySecurityManager.getPropertyPrivileged(RemotingExtension.NODE_NAME_PROPERTY, null);
    // In case of a managed server the subsystem endpoint might already be installed {@see DomainServerCommunicationServices}
    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        final ServiceController<?> controller = context.getServiceRegistry(false).getService(RemotingServices.SUBSYSTEM_ENDPOINT);
        if (controller != null) {
            // if installed, just skip the rest
            return;
        }
    }
    final CapabilityServiceBuilder<?> builder = context.getCapabilityServiceTarget().addCapability(REMOTING_ENDPOINT_CAPABILITY);
    final Consumer<Endpoint> endpointConsumer = builder.provides(REMOTING_ENDPOINT_CAPABILITY);
    final Supplier<XnioWorker> workerSupplier = builder.requiresCapability(IO_WORKER_CAPABILITY_NAME, XnioWorker.class, workerName);
    builder.setInstance(new EndpointService(endpointConsumer, workerSupplier, nodeName, EndpointService.EndpointType.SUBSYSTEM, map));
    builder.install();
}
Also used : Endpoint(org.jboss.remoting3.Endpoint) XnioWorker(org.xnio.XnioWorker) OptionMap(org.xnio.OptionMap) ModelNode(org.jboss.dmr.ModelNode)

Example 59 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project wildfly-core by wildfly.

the class ManagementRemotingServices method installManagementChannelOpenListenerService.

/**
 * Set up the services to create a channel listener. This assumes that an endpoint service called {@code endpointName} exists.
 *  @param serviceTarget the service target to install the services into
 * @param endpointName the name of the endpoint to install a channel listener into
 * @param channelName the name of the channel
 * @param operationHandlerName the name of the operation handler to handle request for this channel
 * @param options the remoting options
 * @param onDemand whether to install the services on demand
 */
public static void installManagementChannelOpenListenerService(final ServiceTarget serviceTarget, final ServiceName endpointName, final String channelName, final ServiceName operationHandlerName, final OptionMap options, final boolean onDemand) {
    final ServiceName serviceName = RemotingServices.channelServiceName(endpointName, channelName);
    final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
    final Supplier<ManagementChannelInitialization> ohfSupplier = builder.requires(operationHandlerName);
    final Supplier<ExecutorService> esSupplier = builder.requires(SHUTDOWN_EXECUTOR_NAME);
    final Supplier<Endpoint> eSupplier = builder.requires(endpointName);
    final Supplier<ManagementChannelRegistryService> rSupplier = builder.requires(ManagementChannelRegistryService.SERVICE_NAME);
    builder.setInstance(new ManagementChannelOpenListenerService(ohfSupplier, esSupplier, eSupplier, rSupplier, channelName, options));
    builder.setInitialMode(onDemand ? ON_DEMAND : ACTIVE);
    builder.install();
}
Also used : Endpoint(org.jboss.remoting3.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization)

Example 60 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project wildfly-core by wildfly.

the class ChannelServer method create.

public static ChannelServer create(final Configuration configuration) throws IOException {
    checkNotNullParam("configuration", configuration).validate();
    // Hack WFCORE-3302/REM3-303 workaround
    if (firstCreate) {
        firstCreate = false;
    } else {
        try {
            // wait in case the previous socket has not closed
            Thread.sleep(100);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(e);
        }
    }
    // TODO WFCORE-3302 -- Endpoint.getCurrent() should be ok
    final Endpoint endpoint = Endpoint.builder().setEndpointName(configuration.getEndpointName()).build();
    final NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface(configuration.getUriScheme(), NetworkServerProvider.class);
    final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
    final SimpleMapBackedSecurityRealm realm = new SimpleMapBackedSecurityRealm();
    domainBuilder.addRealm("default", realm).build();
    domainBuilder.setDefaultRealmName("default");
    domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
    SecurityDomain testDomain = domainBuilder.build();
    SaslAuthenticationFactory saslAuthenticationFactory = SaslAuthenticationFactory.builder().setSecurityDomain(testDomain).setMechanismConfigurationSelector(mechanismInformation -> "ANONYMOUS".equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null).setFactory(new AnonymousServerFactory()).build();
    System.out.println(configuration.getBindAddress());
    AcceptingChannel<StreamConnection> streamServer = networkServerProvider.createServer(configuration.getBindAddress(), OptionMap.EMPTY, saslAuthenticationFactory, null);
    return new ChannelServer(endpoint, null, streamServer);
}
Also used : SaslAuthenticationFactory(org.wildfly.security.auth.server.SaslAuthenticationFactory) SimpleMapBackedSecurityRealm(org.wildfly.security.auth.realm.SimpleMapBackedSecurityRealm) Endpoint(org.jboss.remoting3.Endpoint) AnonymousServerFactory(org.wildfly.security.sasl.anonymous.AnonymousServerFactory) NetworkServerProvider(org.jboss.remoting3.spi.NetworkServerProvider) StreamConnection(org.xnio.StreamConnection) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain)

Aggregations

Endpoint (zipkin2.Endpoint)73 Span (zipkin2.Span)33 Test (org.junit.Test)26 Test (org.junit.jupiter.api.Test)20 Endpoint (org.jboss.remoting3.Endpoint)18 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 Annotation (wavefront.report.Annotation)8 ServiceName (org.jboss.msc.service.ServiceName)7 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)6 IOException (java.io.IOException)6 SaslAuthenticationFactory (org.wildfly.security.auth.server.SaslAuthenticationFactory)6 SpanBytesEncoder (zipkin2.codec.SpanBytesEncoder)6 ArrayList (java.util.ArrayList)5