Search in sources :

Example 76 with Channel

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

the class AlarmAppender method append.

@Override
public void append(LogEvent event) {
    if (stub == null && DbleStartup.isInitZKend()) {
        // only if the dbleserver init config file finished than the config can be use for alert
        try {
            AlarmConfig config = DbleServer.getInstance().getConfig().getAlarm();
            if (config != null && config.getUrl() != null) {
                grpcLevel = "error".equalsIgnoreCase(config.getLevel()) ? 200 : 300;
                serverId = config.getServerId();
                port = Integer.parseInt(config.getPort());
                grpcUrl = config.getUrl();
                alertComponentId = config.getComponentId();
                ushardCode = config.getComponentType();
                Channel channel = ManagedChannelBuilder.forAddress(grpcUrl, port).usePlaintext(true).build();
                stub = UcoreGrpc.newBlockingStub(channel);
            }
        } catch (Exception e) {
            // config not ready yeat
            return;
        }
    }
    if (stub != null) {
        if (grpcLevel >= event.getLevel().intLevel()) {
            String data = new String(getLayout().toByteArray(event));
            String[] d = data.split("::");
            if (d.length >= 2) {
                String level = event.getLevel().intLevel() == 300 ? "WARN" : "CRITICAL";
                UcoreInterface.AlertInput inpurt = UcoreInterface.AlertInput.newBuilder().setCode(d[0]).setDesc(d[1]).setLevel(level).setSourceComponentType(ushardCode).setSourceComponentId(alertComponentId).setAlertComponentId(alertComponentId).setAlertComponentType(ushardCode).setServerId(serverId).setTimestampUnix(System.currentTimeMillis() * 1000000).build();
                stub.alert(inpurt);
            }
        }
    }
}
Also used : Channel(io.grpc.Channel) UcoreInterface(com.actiontech.dble.log.alarm.UcoreInterface) AlarmConfig(com.actiontech.dble.config.model.AlarmConfig)

Example 77 with Channel

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

the class UOffLineListener 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 78 with Channel

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

the class UcoreSingleKeyListener 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 79 with Channel

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

the class UnaryCallDeadlineInterceptorTest method withoutDeadlineTest.

@Test
public void withoutDeadlineTest() {
    Channel channel = new TestChannel();
    UnaryCallDeadlineInterceptor unaryCallDeadlineInterceptor = new UnaryCallDeadlineInterceptor(5000);
    unaryCallDeadlineInterceptor.interceptCall(createMethodDescritor(MethodDescriptor.MethodType.BIDI_STREAMING), CallOptions.DEFAULT.withAuthority("test"), channel);
    Assert.assertNull(((TestChannel) channel).callOptions.getDeadline());
}
Also used : Channel(io.grpc.Channel) Test(org.junit.Test)

Example 80 with Channel

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

the class UnaryCallDeadlineInterceptorTest method withDeadlineTest.

@Test
public void withDeadlineTest() {
    Channel channel = new TestChannel();
    UnaryCallDeadlineInterceptor unaryCallDeadlineInterceptor = new UnaryCallDeadlineInterceptor(5000);
    ClientCall<PAgentInfo, PResult> pAgentInfoPResultClientCall = unaryCallDeadlineInterceptor.interceptCall(createMethodDescritor(MethodDescriptor.MethodType.UNARY), CallOptions.DEFAULT.withAuthority("test"), channel);
    Assert.assertNotNull(((TestChannel) channel).callOptions.getDeadline());
}
Also used : Channel(io.grpc.Channel) PResult(com.navercorp.pinpoint.grpc.trace.PResult) PAgentInfo(com.navercorp.pinpoint.grpc.trace.PAgentInfo) Test(org.junit.Test)

Aggregations

Channel (io.grpc.Channel)63 Test (org.junit.Test)55 CallOptions (io.grpc.CallOptions)38 Metadata (io.grpc.Metadata)26 ManagedChannel (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.ManagedChannel)25 MethodDescriptor (io.grpc.MethodDescriptor)21 ClientInterceptor (io.grpc.ClientInterceptor)20 ManagedChannel (io.grpc.ManagedChannel)20 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 SimpleForwardingClientCall (io.grpc.ForwardingClientCall.SimpleForwardingClientCall)8 SocketAddress (java.net.SocketAddress)8