Search in sources :

Example 6 with Channel

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

the class TranscriptionClientFactory method getClient.

public TranscriptionClient getClient() {
    LogUtil.enterBlock("TranscriptionClientFactory.getClient");
    Assert.checkState(!originalChannel.isShutdown());
    Channel channel = ClientInterceptors.intercept(originalChannel, new Interceptor(packageName, cert, configProvider.getApiKey(), configProvider.getAuthToken()));
    return new TranscriptionClient(VoicemailTranscriptionServiceGrpc.newBlockingStub(channel));
}
Also used : ManagedChannel(io.grpc.ManagedChannel) Channel(io.grpc.Channel) ClientInterceptor(io.grpc.ClientInterceptor)

Example 7 with Channel

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project java-docs-samples by GoogleCloudPlatform.

the class BookstoreClient method createBookstoreStub.

static BookstoreGrpc.BookstoreBlockingStub createBookstoreStub(String address, String apiKey, String authToken) {
    Channel channel = ManagedChannelBuilder.forTarget(address).usePlaintext(true).build();
    channel = ClientInterceptors.intercept(channel, new Interceptor(apiKey, authToken));
    return BookstoreGrpc.newBlockingStub(channel);
}
Also used : Channel(io.grpc.Channel) ClientInterceptor(io.grpc.ClientInterceptor)

Example 8 with Channel

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

the class ClusterUcoreSender method init.

public static 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 9 with Channel

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

the class AlarmAppender method refreshConfig.

/**
 * refresh config of alarm address and re create the stub
 */
public static void refreshConfig() {
    try {
        AlarmConfig config = DbleServer.getInstance().getConfig().getAlarm();
        if (config != null) {
            // put the old config into  _old
            grpcUrlOld = grpcUrl;
            serverIdOld = serverId;
            alertComponentIdOld = alertComponentId;
            portOld = port;
            grpcUrlOld = grpcUrl;
            grpcLevelOld = grpcLevel;
            grpcLevel = "error".equalsIgnoreCase(config.getLevel()) ? 200 : 300;
            serverId = config.getServerId();
            port = Integer.parseInt(config.getPort());
            grpcUrl = config.getUrl();
            alertComponentId = config.getComponentId();
            if (port != portOld || !grpcUrlOld.equals(grpcUrl)) {
                Channel channel = ManagedChannelBuilder.forAddress(grpcUrl, port).usePlaintext(true).build();
                stub = UcoreGrpc.newBlockingStub(channel);
            }
        } else {
            stub = null;
        }
    } catch (Exception e) {
        // config not ready yeat
        return;
    }
}
Also used : Channel(io.grpc.Channel) AlarmConfig(com.actiontech.dble.config.model.AlarmConfig)

Example 10 with Channel

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

the class AlarmAppender method rollbackConfig.

/**
 * if the config is rollback the config of dbleAppender should be rollback too
 */
public static void rollbackConfig() {
    if (stub == null && (grpcUrlOld == null && "".equals(grpcUrlOld))) {
        grpcUrl = grpcUrlOld;
        serverId = serverIdOld;
        alertComponentId = alertComponentIdOld;
        port = portOld;
        grpcUrl = grpcUrlOld;
        grpcLevel = grpcLevelOld;
        return;
    } else {
        grpcUrl = grpcUrlOld;
        serverId = serverIdOld;
        alertComponentId = alertComponentIdOld;
        port = portOld;
        grpcUrl = grpcUrlOld;
        try {
            Channel channel = ManagedChannelBuilder.forAddress(grpcUrl, port).usePlaintext(true).build();
            stub = UcoreGrpc.newBlockingStub(channel);
        } catch (Exception e) {
            return;
        }
    }
}
Also used : Channel(io.grpc.Channel)

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