Search in sources :

Example 11 with Channel

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project dble by actiontech.

the class UcoreClearKeyListener method init.

public void init() {
    Channel channel = ManagedChannelBuilder.forAddress(UcoreConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_PLUGINS_IP), Integer.parseInt(UcoreConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_PLUGINS_PORT))).usePlaintext(true).build();
    stub = UcoreGrpc.newBlockingStub(channel);
}
Also used : Channel(io.grpc.Channel)

Example 12 with Channel

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project incubator-skywalking by apache.

the class AbstractStubInterceptor method onConstruct.

@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
    Channel channel = (Channel) allArguments[0];
    objInst.setSkyWalkingDynamicField(ClientInterceptors.intercept(channel, new GRPCClientInterceptor()));
}
Also used : Channel(io.grpc.Channel)

Example 13 with Channel

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project sharding-jdbc by shardingjdbc.

the class EtcdChannelFactory method getInstance.

/**
 * Get etcd channel instance.
 *
 * @param endpoints etcd endpoints
 * @return etcd channel
 */
public static Channel getInstance(final List<String> endpoints) {
    if (etcdChannels.containsKey(endpoints)) {
        return etcdChannels.get(endpoints);
    }
    Channel channel = NettyChannelBuilder.forTarget(TARGET).usePlaintext(true).nameResolverFactory(new EtcdNameSolverFactory(TARGET, endpoints)).loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance()).build();
    Channel result = etcdChannels.putIfAbsent(endpoints, channel);
    return null == result ? channel : result;
}
Also used : Channel(io.grpc.Channel)

Example 14 with Channel

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project pinpoint by naver.

the class ManagedChannelUtilsTest method testGetLogId.

@Test
public void testGetLogId() {
    Channel channel = mock(Channel.class);
    when(channel.toString()).thenReturn("ManagedChannelOrphanWrapper{delegate=ManagedChannelImpl{logId=1, target=127.0.0.1:9993}}");
    Assert.assertEquals(1, ManagedChannelUtils.getLogId(channel));
}
Also used : Channel(io.grpc.Channel) Test(org.junit.Test)

Example 15 with Channel

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project beam by apache.

the class ServerFactoryTest method runTestUsing.

private Endpoints.ApiServiceDescriptor runTestUsing(ServerFactory serverFactory, ManagedChannelFactory channelFactory) throws Exception {
    Endpoints.ApiServiceDescriptor.Builder apiServiceDescriptorBuilder = Endpoints.ApiServiceDescriptor.newBuilder();
    final Collection<Elements> serverElements = new ArrayList<>();
    final CountDownLatch clientHangedUp = new CountDownLatch(1);
    CallStreamObserver<Elements> serverInboundObserver = TestStreams.withOnNext(serverElements::add).withOnCompleted(clientHangedUp::countDown).build();
    TestDataService service = new TestDataService(serverInboundObserver);
    Server server = serverFactory.allocateAddressAndCreate(ImmutableList.of(service), apiServiceDescriptorBuilder);
    assertFalse(server.isShutdown());
    ManagedChannel channel = channelFactory.forDescriptor(apiServiceDescriptorBuilder.build());
    BeamFnDataGrpc.BeamFnDataStub stub = BeamFnDataGrpc.newStub(channel);
    final Collection<BeamFnApi.Elements> clientElements = new ArrayList<>();
    final CountDownLatch serverHangedUp = new CountDownLatch(1);
    CallStreamObserver<BeamFnApi.Elements> clientInboundObserver = TestStreams.withOnNext(clientElements::add).withOnCompleted(serverHangedUp::countDown).build();
    StreamObserver<Elements> clientOutboundObserver = stub.data(clientInboundObserver);
    StreamObserver<BeamFnApi.Elements> serverOutboundObserver = service.outboundObservers.take();
    clientOutboundObserver.onNext(CLIENT_DATA);
    serverOutboundObserver.onNext(SERVER_DATA);
    clientOutboundObserver.onCompleted();
    clientHangedUp.await();
    serverOutboundObserver.onCompleted();
    serverHangedUp.await();
    assertThat(clientElements, contains(SERVER_DATA));
    assertThat(serverElements, contains(CLIENT_DATA));
    return apiServiceDescriptorBuilder.build();
}
Also used : ApiServiceDescriptor(org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor) Server(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Server) ArrayList(java.util.ArrayList) Elements(org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements) CountDownLatch(java.util.concurrent.CountDownLatch) ManagedChannel(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.ManagedChannel) BeamFnDataGrpc(org.apache.beam.model.fnexecution.v1.BeamFnDataGrpc)

Aggregations

Channel (io.grpc.Channel)60 Test (org.junit.Test)53 CallOptions (io.grpc.CallOptions)37 Metadata (io.grpc.Metadata)25 ManagedChannel (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.ManagedChannel)25 MethodDescriptor (io.grpc.MethodDescriptor)20 ClientInterceptor (io.grpc.ClientInterceptor)19 ManagedChannel (io.grpc.ManagedChannel)17 CountDownLatch (java.util.concurrent.CountDownLatch)16 ClientCall (io.grpc.ClientCall)14 ArrayList (java.util.ArrayList)14 ExecutorService (java.util.concurrent.ExecutorService)12 StreamObserver (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.stub.StreamObserver)12 AtomicReference (java.util.concurrent.atomic.AtomicReference)11 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)10 BeamFnApi (org.apache.beam.model.fnexecution.v1.BeamFnApi)10 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)9 Endpoints (org.apache.beam.model.pipeline.v1.Endpoints)9 SocketAddress (java.net.SocketAddress)8 ByteString (com.google.protobuf.ByteString)7