Search in sources :

Example 71 with Address

use of io.envoyproxy.envoy.config.core.v3.Address in project grpc-java by grpc.

the class ClientXdsClient method parseServerSideListener.

@VisibleForTesting
static EnvoyServerProtoData.Listener parseServerSideListener(Listener proto, Set<String> rdsResources, TlsContextManager tlsContextManager, FilterRegistry filterRegistry, Set<String> certProviderInstances, boolean parseHttpFilter) throws ResourceInvalidException {
    if (!proto.getTrafficDirection().equals(TrafficDirection.INBOUND)) {
        throw new ResourceInvalidException("Listener " + proto.getName() + " with invalid traffic direction: " + proto.getTrafficDirection());
    }
    if (!proto.getListenerFiltersList().isEmpty()) {
        throw new ResourceInvalidException("Listener " + proto.getName() + " cannot have listener_filters");
    }
    if (proto.hasUseOriginalDst()) {
        throw new ResourceInvalidException("Listener " + proto.getName() + " cannot have use_original_dst set to true");
    }
    String address = null;
    if (proto.getAddress().hasSocketAddress()) {
        SocketAddress socketAddress = proto.getAddress().getSocketAddress();
        address = socketAddress.getAddress();
        switch(socketAddress.getPortSpecifierCase()) {
            case NAMED_PORT:
                address = address + ":" + socketAddress.getNamedPort();
                break;
            case PORT_VALUE:
                address = address + ":" + socketAddress.getPortValue();
                break;
            default:
        }
    }
    ImmutableList.Builder<FilterChain> filterChains = ImmutableList.builder();
    Set<FilterChainMatch> uniqueSet = new HashSet<>();
    for (io.envoyproxy.envoy.config.listener.v3.FilterChain fc : proto.getFilterChainsList()) {
        filterChains.add(parseFilterChain(fc, rdsResources, tlsContextManager, filterRegistry, uniqueSet, certProviderInstances, parseHttpFilter));
    }
    FilterChain defaultFilterChain = null;
    if (proto.hasDefaultFilterChain()) {
        defaultFilterChain = parseFilterChain(proto.getDefaultFilterChain(), rdsResources, tlsContextManager, filterRegistry, null, certProviderInstances, parseHttpFilter);
    }
    return EnvoyServerProtoData.Listener.create(proto.getName(), address, filterChains.build(), defaultFilterChain);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) FilterChain(io.grpc.xds.EnvoyServerProtoData.FilterChain) FilterChainMatch(io.grpc.xds.EnvoyServerProtoData.FilterChainMatch) SocketAddress(io.envoyproxy.envoy.config.core.v3.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) HashSet(java.util.HashSet) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 72 with Address

use of io.envoyproxy.envoy.config.core.v3.Address in project grpc-java by grpc.

the class ChannelzProtoUtil method toAddress.

static Address toAddress(SocketAddress address) {
    Preconditions.checkNotNull(address);
    Address.Builder builder = Address.newBuilder();
    if (address instanceof InetSocketAddress) {
        InetSocketAddress inetAddress = (InetSocketAddress) address;
        builder.setTcpipAddress(TcpIpAddress.newBuilder().setIpAddress(ByteString.copyFrom(inetAddress.getAddress().getAddress())).setPort(inetAddress.getPort()).build());
    } else if (address.getClass().getName().endsWith("io.netty.channel.unix.DomainSocketAddress")) {
        builder.setUdsAddress(UdsAddress.newBuilder().setFilename(// DomainSocketAddress.toString returns filename
        address.toString()).build());
    } else {
        builder.setOtherAddress(OtherAddress.newBuilder().setName(address.toString()).build());
    }
    return builder.build();
}
Also used : SocketAddress(java.net.SocketAddress) Address(io.grpc.channelz.v1.Address) InetSocketAddress(java.net.InetSocketAddress) UdsAddress(io.grpc.channelz.v1.Address.UdsAddress) TcpIpAddress(io.grpc.channelz.v1.Address.TcpIpAddress) OtherAddress(io.grpc.channelz.v1.Address.OtherAddress) InetSocketAddress(java.net.InetSocketAddress)

Example 73 with Address

use of io.envoyproxy.envoy.config.core.v3.Address in project okhttp by square.

the class RouteSelectorTest method singleRoute.

@Test
public void singleRoute() throws Exception {
    Address address = httpAddress();
    RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
    assertTrue(routeSelector.hasNext());
    dns.set(uriHost, dns.allocate(1));
    assertRoute(routeSelector.next(), address, NO_PROXY, dns.lookup(uriHost, 0), uriPort);
    dns.assertRequests(uriHost);
    assertFalse(routeSelector.hasNext());
    try {
        routeSelector.next();
        fail();
    } catch (NoSuchElementException expected) {
    }
}
Also used : SocketAddress(java.net.SocketAddress) Address(okhttp3.Address) InetAddress(java.net.InetAddress) InetSocketAddress(java.net.InetSocketAddress) NoSuchElementException(java.util.NoSuchElementException) Test(org.junit.Test)

Example 74 with Address

use of io.envoyproxy.envoy.config.core.v3.Address in project okhttp by square.

the class RouteSelectorTest method proxySelectorReturnsNull.

@Test
public void proxySelectorReturnsNull() throws Exception {
    ProxySelector nullProxySelector = new ProxySelector() {

        @Override
        public List<Proxy> select(URI uri) {
            assertEquals(uriHost, uri.getHost());
            return null;
        }

        @Override
        public void connectFailed(URI uri, SocketAddress socketAddress, IOException e) {
            throw new AssertionError();
        }
    };
    Address address = new Address(uriHost, uriPort, dns, socketFactory, null, null, null, authenticator, null, protocols, connectionSpecs, nullProxySelector);
    RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
    assertTrue(routeSelector.hasNext());
    dns.set(uriHost, dns.allocate(1));
    assertRoute(routeSelector.next(), address, NO_PROXY, dns.lookup(uriHost, 0), uriPort);
    dns.assertRequests(uriHost);
    assertFalse(routeSelector.hasNext());
}
Also used : ProxySelector(java.net.ProxySelector) RecordingProxySelector(okhttp3.internal.http.RecordingProxySelector) Proxy(java.net.Proxy) SocketAddress(java.net.SocketAddress) Address(okhttp3.Address) InetAddress(java.net.InetAddress) InetSocketAddress(java.net.InetSocketAddress) IOException(java.io.IOException) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) URI(java.net.URI) Test(org.junit.Test)

Example 75 with Address

use of io.envoyproxy.envoy.config.core.v3.Address in project okhttp by square.

the class RouteSelectorTest method multipleProxiesMultipleInetAddressesMultipleConfigurations.

@Test
public void multipleProxiesMultipleInetAddressesMultipleConfigurations() throws Exception {
    Address address = httpsAddress();
    proxySelector.proxies.add(proxyA);
    proxySelector.proxies.add(proxyB);
    RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
    // Proxy A
    dns.set(proxyAHost, dns.allocate(2));
    assertRoute(routeSelector.next(), address, proxyA, dns.lookup(proxyAHost, 0), proxyAPort);
    dns.assertRequests(proxyAHost);
    assertRoute(routeSelector.next(), address, proxyA, dns.lookup(proxyAHost, 1), proxyAPort);
    // Proxy B
    dns.set(proxyBHost, dns.allocate(2));
    assertRoute(routeSelector.next(), address, proxyB, dns.lookup(proxyBHost, 0), proxyBPort);
    dns.assertRequests(proxyBHost);
    assertRoute(routeSelector.next(), address, proxyB, dns.lookup(proxyBHost, 1), proxyBPort);
    // No more proxies to attempt.
    assertFalse(routeSelector.hasNext());
}
Also used : SocketAddress(java.net.SocketAddress) Address(okhttp3.Address) InetAddress(java.net.InetAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)86 Address (org.orcid.jaxb.model.record_v2.Address)82 Addresses (org.orcid.jaxb.model.record_v2.Addresses)43 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)43 Keyword (org.orcid.jaxb.model.record_v2.Keyword)42 OtherName (org.orcid.jaxb.model.record_v2.OtherName)42 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)42 Email (org.orcid.jaxb.model.record_v2.Email)41 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)35 Biography (org.orcid.jaxb.model.record_v2.Biography)34 Emails (org.orcid.jaxb.model.record_v2.Emails)34 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)33 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 Name (org.orcid.jaxb.model.record_v2.Name)31 Person (org.orcid.jaxb.model.record_v2.Person)31 InetSocketAddress (java.net.InetSocketAddress)20 Record (org.orcid.jaxb.model.record_v2.Record)19 Response (javax.ws.rs.core.Response)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18