Search in sources :

Example 1 with Endpoint

use of zipkin2.Endpoint in project wildfly by wildfly.

the class EJBRemoteConnectorService method start.

@Override
public void start(StartContext context) throws StartException {
    final AssociationService associationService = associationServiceInjectedValue.getValue();
    final Endpoint endpoint = endpointValue.getValue();
    Executor executor = executorService.getOptionalValue();
    if (executor != null) {
        associationService.setExecutor(executor);
    }
    RemoteEJBService remoteEJBService = RemoteEJBService.create(associationService.getAssociation(), remotingTransactionServiceInjectedValue.getValue());
    final ControlledProcessStateService processStateService = controlledProcessStateServiceInjectedValue.getValue();
    if (processStateService.getCurrentState() == ControlledProcessState.State.STARTING) {
        final PropertyChangeListener listener = new PropertyChangeListener() {

            public void propertyChange(final PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("currentState") && evt.getOldValue() == ControlledProcessState.State.STARTING) {
                    remoteEJBService.serverUp();
                    // can't use a lambda because of this line...
                    processStateService.removePropertyChangeListener(this);
                }
            }
        };
        processStateService.addPropertyChangeListener(listener);
        // this is actually racy, so we have to double-check the state afterwards just to be sure it didn't transition before we got here.
        if (processStateService.getCurrentState() != ControlledProcessState.State.STARTING) {
            // this method is idempotent so it's OK if the listener got fired
            remoteEJBService.serverUp();
            // this one too
            processStateService.removePropertyChangeListener(listener);
        }
    } else {
        remoteEJBService.serverUp();
    }
    // Register an EJB channel open listener
    OpenListener channelOpenListener = remoteEJBService.getOpenListener();
    try {
        registration = endpoint.registerService(EJB_CHANNEL_NAME, channelOpenListener, this.channelCreationOptions);
    } catch (ServiceRegistrationException e) {
        throw new StartException(e);
    }
}
Also used : RemoteEJBService(org.jboss.ejb.protocol.remote.RemoteEJBService) ControlledProcessStateService(org.jboss.as.controller.ControlledProcessStateService) PropertyChangeEvent(java.beans.PropertyChangeEvent) Executor(java.util.concurrent.Executor) Endpoint(org.jboss.remoting3.Endpoint) PropertyChangeListener(java.beans.PropertyChangeListener) OpenListener(org.jboss.remoting3.OpenListener) ServiceRegistrationException(org.jboss.remoting3.ServiceRegistrationException) StartException(org.jboss.msc.service.StartException)

Example 2 with Endpoint

use of zipkin2.Endpoint in project openstack4j by ContainX.

the class DefaultEndpointURLResolver method resolveV2.

private String resolveV2(URLResolverParams p) {
    SortedSetMultimap<String, ? extends Access.Service> catalog = p.access.getAggregatedCatalog();
    SortedSet<? extends Access.Service> services = catalog.get(p.type.getServiceName());
    if (services.isEmpty()) {
        services = catalog.get(p.type.getType());
    }
    if (!services.isEmpty()) {
        Access.Service sc = p.getV2Resolver().resolveV2(p.type, services);
        for (org.openstack4j.model.identity.v2.Endpoint ep : sc.getEndpoints()) {
            if (p.region != null && !p.region.equalsIgnoreCase(ep.getRegion()))
                continue;
            if (sc.getServiceType() == ServiceType.NETWORK) {
                sc.getEndpoints().get(0).toBuilder().type(sc.getServiceType().name());
            }
            if (p.perspective == null)
                return getEndpointURL(p.access, ep);
            switch(p.perspective) {
                case ADMIN:
                    return ep.getAdminURL().toString();
                case INTERNAL:
                    return ep.getInternalURL().toString();
                case PUBLIC:
                default:
                    return ep.getPublicURL().toString();
            }
        }
    } else {
        //if no catalog returned, if is identity service, just return endpoint
        if (ServiceType.IDENTITY.equals(p.type)) {
            return p.access.getEndpoint();
        }
    }
    return null;
}
Also used : Endpoint(org.openstack4j.model.identity.v2.Endpoint) Access(org.openstack4j.model.identity.v2.Access)

Example 3 with Endpoint

use of zipkin2.Endpoint in project carbon-apimgt by wso2.

the class WSDL20ProcessorImpl method getEndpoints.

/**
 * Get endpoints defined in the provided WSDL description.
 *
 * @param description WSDL 2.0 description
 * @return a Map of endpoint names and their URIs.
 * @throws APIMgtWSDLException if error occurs while reading endpoints
 */
private Map<String, String> getEndpoints(Description description) throws APIMgtWSDLException {
    Service[] services = description.getServices();
    Map<String, String> serviceEndpointMap = new HashMap<>();
    for (Service service : services) {
        Endpoint[] endpoints = service.getEndpoints();
        for (Endpoint endpoint : endpoints) {
            serviceEndpointMap.put(endpoint.getName().toString(), endpoint.getAddress().toString());
        }
    }
    return serviceEndpointMap;
}
Also used : Endpoint(org.apache.woden.wsdl20.Endpoint) HashMap(java.util.HashMap) Service(org.apache.woden.wsdl20.Service)

Example 4 with Endpoint

use of zipkin2.Endpoint in project brave by openzipkin.

the class ITHttpServer method routeBasedRequestNameIncludesPathPrefix.

private void routeBasedRequestNameIncludesPathPrefix(String prefix) throws Exception {
    // Reading the route parameter from the response ensures the test endpoint is correct
    assertThat(get(prefix + "/1?foo").body().string()).isEqualTo("1");
    assertThat(get(prefix + "/2?bar").body().string()).isEqualTo("2");
    Span span1 = takeSpan(), span2 = takeSpan();
    // verify that the path and url reflect the initial request (not a route expression)
    assertThat(span1.tags()).containsEntry("http.method", "GET").containsEntry("http.path", prefix + "/1").containsEntry("http.url", url(prefix + "/1?foo"));
    assertThat(span2.tags()).containsEntry("http.method", "GET").containsEntry("http.path", prefix + "/2").containsEntry("http.url", url(prefix + "/2?bar"));
    // We don't know the exact format of the http route as it is framework specific
    // However, we know that it should match both requests and include the common part of the path
    Set<String> routeBasedNames = new LinkedHashSet<>(Arrays.asList(span1.name(), span2.name()));
    assertThat(routeBasedNames).hasSize(1);
    assertThat(routeBasedNames.iterator().next()).startsWith("get " + prefix).doesNotEndWith(// no trailing slashes
    "/").doesNotContain(// no duplicate slashes
    "//");
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Span(zipkin2.Span)

Example 5 with Endpoint

use of zipkin2.Endpoint in project brave by openzipkin.

the class Platform method produceEndpoint.

Endpoint produceEndpoint() {
    Endpoint.Builder builder = Endpoint.newBuilder().serviceName("unknown");
    try {
        Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
        if (nics == null)
            return builder.build();
        while (nics.hasMoreElements()) {
            NetworkInterface nic = nics.nextElement();
            Enumeration<InetAddress> addresses = nic.getInetAddresses();
            while (addresses.hasMoreElements()) {
                InetAddress address = addresses.nextElement();
                if (address.isSiteLocalAddress()) {
                    builder.ip(address);
                    break;
                }
            }
        }
    } catch (Exception e) {
        // don't crash the caller if there was a problem reading nics.
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "error reading nics", e);
        }
    }
    return builder.build();
}
Also used : Endpoint(zipkin2.Endpoint) NetworkInterface(java.net.NetworkInterface) InetAddress(java.net.InetAddress)

Aggregations

Test (org.junit.Test)7 Endpoint (zipkin2.Endpoint)7 Span (zipkin2.Span)5 Endpoint (org.jboss.remoting3.Endpoint)2 Access (org.openstack4j.model.identity.v2.Access)2 Tracing (brave.Tracing)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1 CrnkClient (io.crnk.client.CrnkClient)1 Task (io.crnk.monitor.brave.mock.models.Task)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 NetworkInterface (java.net.NetworkInterface)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Callable (java.util.concurrent.Callable)1