From ab1d30477efd1135ef934e5d8ee9b60917025154 Mon Sep 17 00:00:00 2001 From: Kim YoungJin Date: Thu, 5 Jan 2023 02:50:46 +0900 Subject: [PATCH] [#9601] Fix tests aarch64 compatible --- .../spring/data/r2dbc/DockerTestUtils.java | 65 +++ .../plugin/spring/data/r2dbc/R2dbcH2Test.java | 3 +- .../spring/data/r2dbc/R2dbcMariadbTest.java | 3 +- .../spring/data/r2dbc/R2dbcMssqlTest.java | 2 +- .../spring/data/r2dbc/R2dbcMysqlTest.java | 2 +- .../spring/data/r2dbc/R2dbcOracleTest.java | 1 + .../AgentDirBaseClassPathResolverTest.java | 1 + plugins-it/google-grpc-it/pom.xml | 47 +- .../grpc/examples/helloworld/GreeterGrpc.java | 307 ++++++++++ .../grpc/examples/helloworld/HelloReply.java | 524 ++++++++++++++++++ .../helloworld/HelloReplyOrBuilder.java | 19 + .../examples/helloworld/HelloRequest.java | 524 ++++++++++++++++++ .../helloworld/HelloRequestOrBuilder.java | 19 + .../examples/helloworld/HelloWorldProto.java | 70 +++ .../manualflowcontrol/HelloReply.java | 524 ++++++++++++++++++ .../HelloReplyOrBuilder.java | 19 + .../manualflowcontrol/HelloRequest.java | 524 ++++++++++++++++++ .../HelloRequestOrBuilder.java | 19 + .../HelloStreamingProto.java | 72 +++ .../StreamingGreeterGrpc.java | 285 ++++++++++ plugins-it/google-grpc-it2/pom.xml | 95 ++++ .../pinpoint/plugin/grpc/BuilderUtils.java | 60 ++ .../plugin/grpc/BuilderUtilsTest.java | 14 + .../pinpoint/plugin/grpc/GrpcITBase.java | 156 ++++++ .../plugin/grpc/Grpc_1_42_0_to_IT.java | 0 .../plugin/grpc/Grpc_1_44_0_to_IT.java | 0 .../plugin/grpc/HelloWorldClient.java | 26 + .../plugin/grpc/HelloWorldServer.java | 34 ++ .../plugin/grpc/HelloWorldSimpleClient.java | 92 +++ .../plugin/grpc/HelloWorldSimpleServer.java | 122 ++++ .../plugin/grpc/HelloWorldStreamClient.java | 276 +++++++++ .../plugin/grpc/HelloWorldStreamServer.java | 197 +++++++ .../src/test/proto/hello_streaming.proto | 37 ++ .../src/test/proto/helloworld.proto | 37 ++ .../pinpoint-grpc-plugin-test.config | 398 +++++++++++++ .../plugin/jdbc/jtds/JtdsConnectionIT.java | 4 + .../kotlinx/coroutines/CoroutinesIT.java | 63 ++- .../kotlinx/coroutines/CoroutinesLaunch.kt | 4 +- .../pinpoint/plugin/jdbc/MariaDBServer.java | 4 +- .../plugin/jdbc/mysql/MySqlServer.java | 6 +- plugins-it/paho-mqtt-it/pom.xml | 1 - .../plugin/paho/mqtt/PahoMqttContainer.java | 77 --- .../plugin/paho/mqtt/PahoMqttV3ClientIT.java | 44 +- .../plugin/paho/mqtt/PahoMqttV5ClientIT.java | 41 +- .../pluginit/utils/DockerTestUtils.java | 65 +++ .../pluginit/utils/TestcontainersOption.java | 2 +- plugins-it/pom.xml | 1 + .../plugin/jdbc/r2dbc/MariadbServer.java | 6 +- .../plugin/jdbc/r2dbc/MssqlServer.java | 4 +- .../plugin/jdbc/r2dbc/MysqlServer.java | 4 +- .../plugin/jdbc/r2dbc/PostgreSqlServer.java | 2 +- pom.xml | 2 +- .../zookeeper/ZookeeperClusterTest.java | 5 +- .../web/util/PinpointWebTestUtils.java | 22 +- 54 files changed, 4734 insertions(+), 197 deletions(-) create mode 100644 agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/DockerTestUtils.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/GreeterGrpc.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloReply.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloReplyOrBuilder.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloRequest.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloRequestOrBuilder.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloWorldProto.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloReply.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloReplyOrBuilder.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloRequest.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloRequestOrBuilder.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloStreamingProto.java create mode 100644 plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/StreamingGreeterGrpc.java create mode 100644 plugins-it/google-grpc-it2/pom.xml create mode 100644 plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/BuilderUtils.java create mode 100644 plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/BuilderUtilsTest.java create mode 100644 plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/GrpcITBase.java rename plugins-it/{google-grpc-it => google-grpc-it2}/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_42_0_to_IT.java (100%) rename plugins-it/{google-grpc-it => google-grpc-it2}/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_44_0_to_IT.java (100%) create mode 100644 plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldClient.java create mode 100644 plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldServer.java create mode 100644 plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldSimpleClient.java create mode 100644 plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldSimpleServer.java create mode 100644 plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldStreamClient.java create mode 100644 plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldStreamServer.java create mode 100644 plugins-it/google-grpc-it2/src/test/proto/hello_streaming.proto create mode 100644 plugins-it/google-grpc-it2/src/test/proto/helloworld.proto create mode 100644 plugins-it/google-grpc-it2/src/test/resources/pinpoint-grpc-plugin-test.config delete mode 100644 plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttContainer.java create mode 100644 plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/DockerTestUtils.java diff --git a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/DockerTestUtils.java b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/DockerTestUtils.java new file mode 100644 index 000000000000..c995c4986c40 --- /dev/null +++ b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/DockerTestUtils.java @@ -0,0 +1,65 @@ +/* + * Copyright 2023 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.pinpoint.test.plugin.spring.data.r2dbc; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * @author youngjin.kim2 + */ +public class DockerTestUtils { + public static boolean isArmDockerServer() { + return getDockerArchitecture().contains("arm"); + } + + private static String getDockerArchitecture() { + final String dockerInfo = execute("docker version", 3000); + final String dockerServerInfo = dockerInfo.substring(dockerInfo.indexOf("Server: ")); + final String archLine = Arrays.stream(dockerServerInfo.split("\n")) + .filter(line -> line.contains("OS/Arch:")) + .findFirst() + .orElseThrow(() -> new RuntimeException("Invalid docker version result")); + return archLine.split(":")[1].trim(); + } + + private static String execute(String command, long waitMillis) { + try { + return execute0(command, waitMillis); + } catch (Throwable th) { + throw new RuntimeException("Failed to run '" + command + "'"); + } + } + + private static String execute0(String command, long waitMillis) throws InterruptedException, IOException { + final Process proc = Runtime.getRuntime().exec(command); + if (!proc.waitFor(waitMillis, TimeUnit.MILLISECONDS)) { + throw new RuntimeException(); + } + return readAll(proc.getInputStream()); + } + + private static String readAll(InputStream is) { + return new BufferedReader(new InputStreamReader(is)) + .lines() + .collect(Collectors.joining("\n")); + } +} diff --git a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcH2Test.java b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcH2Test.java index 161f6a7eedf5..45137225aca2 100644 --- a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcH2Test.java +++ b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcH2Test.java @@ -35,8 +35,9 @@ public class R2dbcH2Test { @BeforeClass public static void beforeClass() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); + Assume.assumeFalse(DockerTestUtils.isArmDockerServer()); - container = new MariaDBContainer(); + container = new MariaDBContainer("mariadb:10.3.6"); container.withDatabaseName(DATABASE_NAME); container.withUsername(USERNAME); container.withPassword(PASSWORD); diff --git a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMariadbTest.java b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMariadbTest.java index 497e2f68eb95..7fb5968de2e5 100644 --- a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMariadbTest.java +++ b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMariadbTest.java @@ -35,8 +35,9 @@ public class R2dbcMariadbTest { @BeforeClass public static void beforeClass() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); + Assume.assumeFalse(DockerTestUtils.isArmDockerServer()); - container = new MariaDBContainer(); + container = new MariaDBContainer("mariadb:10.3.6"); container.withDatabaseName(DATABASE_NAME); container.withUsername(USERNAME); container.withPassword(PASSWORD); diff --git a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMssqlTest.java b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMssqlTest.java index 676b72d966d3..935c2bd5722a 100644 --- a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMssqlTest.java +++ b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMssqlTest.java @@ -32,7 +32,7 @@ public class R2dbcMssqlTest { public static void beforeClass() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); - container = new MSSQLServerContainer(); + container = new MSSQLServerContainer("mcr.microsoft.com/mssql/server:2017-CU12"); container.withInitScript("mssql-init.sql"); container.start(); diff --git a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMysqlTest.java b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMysqlTest.java index d95bd38d24c6..f12d65af8e74 100644 --- a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMysqlTest.java +++ b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcMysqlTest.java @@ -37,7 +37,7 @@ public class R2dbcMysqlTest { public static void beforeClass() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); - container = new MySQLContainer(); + container = new MySQLContainer("mysql:5.7.34"); container.withDatabaseName(DATABASE_NAME); container.withUsername(USERNAME); container.withPassword(PASSWORD); diff --git a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcOracleTest.java b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcOracleTest.java index 2da16a0d9c95..4c736bfeff6b 100644 --- a/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcOracleTest.java +++ b/agent-testweb/spring-data-r2dbc-plugin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/R2dbcOracleTest.java @@ -39,6 +39,7 @@ public class R2dbcOracleTest { @BeforeClass public static void beforeClass() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); + Assume.assumeFalse(DockerTestUtils.isArmDockerServer()); container = new OracleContainer(ORACLE_21_X_IMAGE); container.setWaitStrategy(Wait.forLogMessage(".*Completed.*", 1)); diff --git a/bootstraps/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/agentdir/AgentDirBaseClassPathResolverTest.java b/bootstraps/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/agentdir/AgentDirBaseClassPathResolverTest.java index f7b8ddaa36da..05870bb49b30 100644 --- a/bootstraps/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/agentdir/AgentDirBaseClassPathResolverTest.java +++ b/bootstraps/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/agentdir/AgentDirBaseClassPathResolverTest.java @@ -55,6 +55,7 @@ public class AgentDirBaseClassPathResolverTest { @BeforeAll public static void beforeClass() throws Exception { + TEMP_DIR = TEMP_DIR.toRealPath().normalize(); logger.debug("buildDir:{}", TEMP_DIR); String testDir = TEST_AGENT_DIR + '_' + AGENT_ID_ALLOCATOR.incrementAndGet(); diff --git a/plugins-it/google-grpc-it/pom.xml b/plugins-it/google-grpc-it/pom.xml index 74f3f639688d..e093799e6d82 100644 --- a/plugins-it/google-grpc-it/pom.xml +++ b/plugins-it/google-grpc-it/pom.xml @@ -85,25 +85,34 @@ org.apache.maven.plugins maven-failsafe-plugin - - - org.xolstice.maven.plugins - protobuf-maven-plugin - 0.5.1 - - com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} - grpc-java - io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} - - - - - test-compile - test-compile-custom - - - - + + + + renew-grpc + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.5.1 + + com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} + grpc-java + io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} + + + + + test-compile + test-compile-custom + + + + + + + + diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/GreeterGrpc.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/GreeterGrpc.java new file mode 100644 index 000000000000..c30461c4ad11 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/GreeterGrpc.java @@ -0,0 +1,307 @@ +package io.grpc.examples.helloworld; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + *
+ * The greeting service definition.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.14.0)", + comments = "Source: helloworld.proto") +public final class GreeterGrpc { + + private GreeterGrpc() {} + + public static final String SERVICE_NAME = "helloworld.Greeter"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getSayHelloMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "SayHello", + requestType = io.grpc.examples.helloworld.HelloRequest.class, + responseType = io.grpc.examples.helloworld.HelloReply.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getSayHelloMethod() { + io.grpc.MethodDescriptor getSayHelloMethod; + if ((getSayHelloMethod = GreeterGrpc.getSayHelloMethod) == null) { + synchronized (GreeterGrpc.class) { + if ((getSayHelloMethod = GreeterGrpc.getSayHelloMethod) == null) { + GreeterGrpc.getSayHelloMethod = getSayHelloMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "helloworld.Greeter", "SayHello")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.examples.helloworld.HelloRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.examples.helloworld.HelloReply.getDefaultInstance())) + .setSchemaDescriptor(new GreeterMethodDescriptorSupplier("SayHello")) + .build(); + } + } + } + return getSayHelloMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static GreeterStub newStub(io.grpc.Channel channel) { + return new GreeterStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static GreeterBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new GreeterBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static GreeterFutureStub newFutureStub( + io.grpc.Channel channel) { + return new GreeterFutureStub(channel); + } + + /** + *
+   * The greeting service definition.
+   * 
+ */ + public static abstract class GreeterImplBase implements io.grpc.BindableService { + + /** + *
+     * Sends a greeting
+     * 
+ */ + public void sayHello(io.grpc.examples.helloworld.HelloRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSayHelloMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getSayHelloMethod(), + asyncUnaryCall( + new MethodHandlers< + io.grpc.examples.helloworld.HelloRequest, + io.grpc.examples.helloworld.HelloReply>( + this, METHODID_SAY_HELLO))) + .build(); + } + } + + /** + *
+   * The greeting service definition.
+   * 
+ */ + public static final class GreeterStub extends io.grpc.stub.AbstractStub { + private GreeterStub(io.grpc.Channel channel) { + super(channel); + } + + private GreeterStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected GreeterStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new GreeterStub(channel, callOptions); + } + + /** + *
+     * Sends a greeting
+     * 
+ */ + public void sayHello(io.grpc.examples.helloworld.HelloRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getSayHelloMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + *
+   * The greeting service definition.
+   * 
+ */ + public static final class GreeterBlockingStub extends io.grpc.stub.AbstractStub { + private GreeterBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private GreeterBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected GreeterBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new GreeterBlockingStub(channel, callOptions); + } + + /** + *
+     * Sends a greeting
+     * 
+ */ + public io.grpc.examples.helloworld.HelloReply sayHello(io.grpc.examples.helloworld.HelloRequest request) { + return blockingUnaryCall( + getChannel(), getSayHelloMethod(), getCallOptions(), request); + } + } + + /** + *
+   * The greeting service definition.
+   * 
+ */ + public static final class GreeterFutureStub extends io.grpc.stub.AbstractStub { + private GreeterFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private GreeterFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected GreeterFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new GreeterFutureStub(channel, callOptions); + } + + /** + *
+     * Sends a greeting
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture sayHello( + io.grpc.examples.helloworld.HelloRequest request) { + return futureUnaryCall( + getChannel().newCall(getSayHelloMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_SAY_HELLO = 0; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final GreeterImplBase serviceImpl; + private final int methodId; + + MethodHandlers(GreeterImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_SAY_HELLO: + serviceImpl.sayHello((io.grpc.examples.helloworld.HelloRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class GreeterBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + GreeterBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("Greeter"); + } + } + + private static final class GreeterFileDescriptorSupplier + extends GreeterBaseDescriptorSupplier { + GreeterFileDescriptorSupplier() {} + } + + private static final class GreeterMethodDescriptorSupplier + extends GreeterBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + GreeterMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (GreeterGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new GreeterFileDescriptorSupplier()) + .addMethod(getSayHelloMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloReply.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloReply.java new file mode 100644 index 000000000000..9dea9f265be7 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloReply.java @@ -0,0 +1,524 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +/** + *
+ * The response message containing the greetings
+ * 
+ * + * Protobuf type {@code helloworld.HelloReply} + */ +public final class HelloReply extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:helloworld.HelloReply) + HelloReplyOrBuilder { +private static final long serialVersionUID = 0L; + // Use HelloReply.newBuilder() to construct. + private HelloReply(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private HelloReply() { + message_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private HelloReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.helloworld.HelloReply.class, io.grpc.examples.helloworld.HelloReply.Builder.class); + } + + public static final int MESSAGE_FIELD_NUMBER = 1; + private volatile java.lang.Object message_; + /** + * string message = 1; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + * string message = 1; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, message_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, message_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.grpc.examples.helloworld.HelloReply)) { + return super.equals(obj); + } + io.grpc.examples.helloworld.HelloReply other = (io.grpc.examples.helloworld.HelloReply) obj; + + boolean result = true; + result = result && getMessage() + .equals(other.getMessage()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.grpc.examples.helloworld.HelloReply parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.grpc.examples.helloworld.HelloReply prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * The response message containing the greetings
+   * 
+ * + * Protobuf type {@code helloworld.HelloReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:helloworld.HelloReply) + io.grpc.examples.helloworld.HelloReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.helloworld.HelloReply.class, io.grpc.examples.helloworld.HelloReply.Builder.class); + } + + // Construct using io.grpc.examples.helloworld.HelloReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_descriptor; + } + + public io.grpc.examples.helloworld.HelloReply getDefaultInstanceForType() { + return io.grpc.examples.helloworld.HelloReply.getDefaultInstance(); + } + + public io.grpc.examples.helloworld.HelloReply build() { + io.grpc.examples.helloworld.HelloReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.grpc.examples.helloworld.HelloReply buildPartial() { + io.grpc.examples.helloworld.HelloReply result = new io.grpc.examples.helloworld.HelloReply(this); + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.grpc.examples.helloworld.HelloReply) { + return mergeFrom((io.grpc.examples.helloworld.HelloReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.grpc.examples.helloworld.HelloReply other) { + if (other == io.grpc.examples.helloworld.HelloReply.getDefaultInstance()) return this; + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.grpc.examples.helloworld.HelloReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.grpc.examples.helloworld.HelloReply) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object message_ = ""; + /** + * string message = 1; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string message = 1; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string message = 1; + */ + public Builder setMessage( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * string message = 1; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + * string message = 1; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:helloworld.HelloReply) + } + + // @@protoc_insertion_point(class_scope:helloworld.HelloReply) + private static final io.grpc.examples.helloworld.HelloReply DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.grpc.examples.helloworld.HelloReply(); + } + + public static io.grpc.examples.helloworld.HelloReply getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HelloReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HelloReply(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public io.grpc.examples.helloworld.HelloReply getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloReplyOrBuilder.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloReplyOrBuilder.java new file mode 100644 index 000000000000..eba408ed0c94 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloReplyOrBuilder.java @@ -0,0 +1,19 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +public interface HelloReplyOrBuilder extends + // @@protoc_insertion_point(interface_extends:helloworld.HelloReply) + com.google.protobuf.MessageOrBuilder { + + /** + * string message = 1; + */ + java.lang.String getMessage(); + /** + * string message = 1; + */ + com.google.protobuf.ByteString + getMessageBytes(); +} diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloRequest.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloRequest.java new file mode 100644 index 000000000000..ce28c7fac1d4 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloRequest.java @@ -0,0 +1,524 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +/** + *
+ * The request message containing the user's name.
+ * 
+ * + * Protobuf type {@code helloworld.HelloRequest} + */ +public final class HelloRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:helloworld.HelloRequest) + HelloRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use HelloRequest.newBuilder() to construct. + private HelloRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private HelloRequest() { + name_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private HelloRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.helloworld.HelloRequest.class, io.grpc.examples.helloworld.HelloRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.grpc.examples.helloworld.HelloRequest)) { + return super.equals(obj); + } + io.grpc.examples.helloworld.HelloRequest other = (io.grpc.examples.helloworld.HelloRequest) obj; + + boolean result = true; + result = result && getName() + .equals(other.getName()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.grpc.examples.helloworld.HelloRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * The request message containing the user's name.
+   * 
+ * + * Protobuf type {@code helloworld.HelloRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:helloworld.HelloRequest) + io.grpc.examples.helloworld.HelloRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.helloworld.HelloRequest.class, io.grpc.examples.helloworld.HelloRequest.Builder.class); + } + + // Construct using io.grpc.examples.helloworld.HelloRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor; + } + + public io.grpc.examples.helloworld.HelloRequest getDefaultInstanceForType() { + return io.grpc.examples.helloworld.HelloRequest.getDefaultInstance(); + } + + public io.grpc.examples.helloworld.HelloRequest build() { + io.grpc.examples.helloworld.HelloRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.grpc.examples.helloworld.HelloRequest buildPartial() { + io.grpc.examples.helloworld.HelloRequest result = new io.grpc.examples.helloworld.HelloRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.grpc.examples.helloworld.HelloRequest) { + return mergeFrom((io.grpc.examples.helloworld.HelloRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.grpc.examples.helloworld.HelloRequest other) { + if (other == io.grpc.examples.helloworld.HelloRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.grpc.examples.helloworld.HelloRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.grpc.examples.helloworld.HelloRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 1; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * string name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:helloworld.HelloRequest) + } + + // @@protoc_insertion_point(class_scope:helloworld.HelloRequest) + private static final io.grpc.examples.helloworld.HelloRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.grpc.examples.helloworld.HelloRequest(); + } + + public static io.grpc.examples.helloworld.HelloRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HelloRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HelloRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public io.grpc.examples.helloworld.HelloRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloRequestOrBuilder.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloRequestOrBuilder.java new file mode 100644 index 000000000000..3568bc941046 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloRequestOrBuilder.java @@ -0,0 +1,19 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +public interface HelloRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:helloworld.HelloRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string name = 1; + */ + java.lang.String getName(); + /** + * string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); +} diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloWorldProto.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloWorldProto.java new file mode 100644 index 000000000000..96527e6d7227 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/helloworld/HelloWorldProto.java @@ -0,0 +1,70 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +public final class HelloWorldProto { + private HelloWorldProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_helloworld_HelloRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_helloworld_HelloRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_helloworld_HelloReply_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_helloworld_HelloReply_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\020helloworld.proto\022\nhelloworld\"\034\n\014HelloR" + + "equest\022\014\n\004name\030\001 \001(\t\"\035\n\nHelloReply\022\017\n\007me" + + "ssage\030\001 \001(\t2I\n\007Greeter\022>\n\010SayHello\022\030.hel" + + "loworld.HelloRequest\032\026.helloworld.HelloR" + + "eply\"\000B6\n\033io.grpc.examples.helloworldB\017H" + + "elloWorldProtoP\001\242\002\003HLWb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_helloworld_HelloRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_helloworld_HelloRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_helloworld_HelloRequest_descriptor, + new java.lang.String[] { "Name", }); + internal_static_helloworld_HelloReply_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_helloworld_HelloReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_helloworld_HelloReply_descriptor, + new java.lang.String[] { "Message", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloReply.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloReply.java new file mode 100644 index 000000000000..2f9c05f507fa --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloReply.java @@ -0,0 +1,524 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: hello_streaming.proto + +package io.grpc.examples.manualflowcontrol; + +/** + *
+ * The response message containing the greetings
+ * 
+ * + * Protobuf type {@code manualflowcontrol.HelloReply} + */ +public final class HelloReply extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:manualflowcontrol.HelloReply) + HelloReplyOrBuilder { +private static final long serialVersionUID = 0L; + // Use HelloReply.newBuilder() to construct. + private HelloReply(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private HelloReply() { + message_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private HelloReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.manualflowcontrol.HelloReply.class, io.grpc.examples.manualflowcontrol.HelloReply.Builder.class); + } + + public static final int MESSAGE_FIELD_NUMBER = 1; + private volatile java.lang.Object message_; + /** + * string message = 1; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + * string message = 1; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, message_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, message_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.grpc.examples.manualflowcontrol.HelloReply)) { + return super.equals(obj); + } + io.grpc.examples.manualflowcontrol.HelloReply other = (io.grpc.examples.manualflowcontrol.HelloReply) obj; + + boolean result = true; + result = result && getMessage() + .equals(other.getMessage()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.manualflowcontrol.HelloReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.grpc.examples.manualflowcontrol.HelloReply prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * The response message containing the greetings
+   * 
+ * + * Protobuf type {@code manualflowcontrol.HelloReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:manualflowcontrol.HelloReply) + io.grpc.examples.manualflowcontrol.HelloReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.manualflowcontrol.HelloReply.class, io.grpc.examples.manualflowcontrol.HelloReply.Builder.class); + } + + // Construct using io.grpc.examples.manualflowcontrol.HelloReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloReply_descriptor; + } + + public io.grpc.examples.manualflowcontrol.HelloReply getDefaultInstanceForType() { + return io.grpc.examples.manualflowcontrol.HelloReply.getDefaultInstance(); + } + + public io.grpc.examples.manualflowcontrol.HelloReply build() { + io.grpc.examples.manualflowcontrol.HelloReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.grpc.examples.manualflowcontrol.HelloReply buildPartial() { + io.grpc.examples.manualflowcontrol.HelloReply result = new io.grpc.examples.manualflowcontrol.HelloReply(this); + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.grpc.examples.manualflowcontrol.HelloReply) { + return mergeFrom((io.grpc.examples.manualflowcontrol.HelloReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.grpc.examples.manualflowcontrol.HelloReply other) { + if (other == io.grpc.examples.manualflowcontrol.HelloReply.getDefaultInstance()) return this; + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.grpc.examples.manualflowcontrol.HelloReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.grpc.examples.manualflowcontrol.HelloReply) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object message_ = ""; + /** + * string message = 1; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string message = 1; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string message = 1; + */ + public Builder setMessage( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * string message = 1; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + * string message = 1; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:manualflowcontrol.HelloReply) + } + + // @@protoc_insertion_point(class_scope:manualflowcontrol.HelloReply) + private static final io.grpc.examples.manualflowcontrol.HelloReply DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.grpc.examples.manualflowcontrol.HelloReply(); + } + + public static io.grpc.examples.manualflowcontrol.HelloReply getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HelloReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HelloReply(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public io.grpc.examples.manualflowcontrol.HelloReply getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloReplyOrBuilder.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloReplyOrBuilder.java new file mode 100644 index 000000000000..84c166985c70 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloReplyOrBuilder.java @@ -0,0 +1,19 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: hello_streaming.proto + +package io.grpc.examples.manualflowcontrol; + +public interface HelloReplyOrBuilder extends + // @@protoc_insertion_point(interface_extends:manualflowcontrol.HelloReply) + com.google.protobuf.MessageOrBuilder { + + /** + * string message = 1; + */ + java.lang.String getMessage(); + /** + * string message = 1; + */ + com.google.protobuf.ByteString + getMessageBytes(); +} diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloRequest.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloRequest.java new file mode 100644 index 000000000000..1d80564da635 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloRequest.java @@ -0,0 +1,524 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: hello_streaming.proto + +package io.grpc.examples.manualflowcontrol; + +/** + *
+ * The request message containing the user's name.
+ * 
+ * + * Protobuf type {@code manualflowcontrol.HelloRequest} + */ +public final class HelloRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:manualflowcontrol.HelloRequest) + HelloRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use HelloRequest.newBuilder() to construct. + private HelloRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private HelloRequest() { + name_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private HelloRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.manualflowcontrol.HelloRequest.class, io.grpc.examples.manualflowcontrol.HelloRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.grpc.examples.manualflowcontrol.HelloRequest)) { + return super.equals(obj); + } + io.grpc.examples.manualflowcontrol.HelloRequest other = (io.grpc.examples.manualflowcontrol.HelloRequest) obj; + + boolean result = true; + result = result && getName() + .equals(other.getName()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.manualflowcontrol.HelloRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.grpc.examples.manualflowcontrol.HelloRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * The request message containing the user's name.
+   * 
+ * + * Protobuf type {@code manualflowcontrol.HelloRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:manualflowcontrol.HelloRequest) + io.grpc.examples.manualflowcontrol.HelloRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.manualflowcontrol.HelloRequest.class, io.grpc.examples.manualflowcontrol.HelloRequest.Builder.class); + } + + // Construct using io.grpc.examples.manualflowcontrol.HelloRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.internal_static_manualflowcontrol_HelloRequest_descriptor; + } + + public io.grpc.examples.manualflowcontrol.HelloRequest getDefaultInstanceForType() { + return io.grpc.examples.manualflowcontrol.HelloRequest.getDefaultInstance(); + } + + public io.grpc.examples.manualflowcontrol.HelloRequest build() { + io.grpc.examples.manualflowcontrol.HelloRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.grpc.examples.manualflowcontrol.HelloRequest buildPartial() { + io.grpc.examples.manualflowcontrol.HelloRequest result = new io.grpc.examples.manualflowcontrol.HelloRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.grpc.examples.manualflowcontrol.HelloRequest) { + return mergeFrom((io.grpc.examples.manualflowcontrol.HelloRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.grpc.examples.manualflowcontrol.HelloRequest other) { + if (other == io.grpc.examples.manualflowcontrol.HelloRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.grpc.examples.manualflowcontrol.HelloRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.grpc.examples.manualflowcontrol.HelloRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 1; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * string name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:manualflowcontrol.HelloRequest) + } + + // @@protoc_insertion_point(class_scope:manualflowcontrol.HelloRequest) + private static final io.grpc.examples.manualflowcontrol.HelloRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.grpc.examples.manualflowcontrol.HelloRequest(); + } + + public static io.grpc.examples.manualflowcontrol.HelloRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HelloRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HelloRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public io.grpc.examples.manualflowcontrol.HelloRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloRequestOrBuilder.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloRequestOrBuilder.java new file mode 100644 index 000000000000..fd28a19c1b56 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloRequestOrBuilder.java @@ -0,0 +1,19 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: hello_streaming.proto + +package io.grpc.examples.manualflowcontrol; + +public interface HelloRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:manualflowcontrol.HelloRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string name = 1; + */ + java.lang.String getName(); + /** + * string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); +} diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloStreamingProto.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloStreamingProto.java new file mode 100644 index 000000000000..7ca08dba2109 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/HelloStreamingProto.java @@ -0,0 +1,72 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: hello_streaming.proto + +package io.grpc.examples.manualflowcontrol; + +public final class HelloStreamingProto { + private HelloStreamingProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_manualflowcontrol_HelloRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_manualflowcontrol_HelloRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_manualflowcontrol_HelloReply_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_manualflowcontrol_HelloReply_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\025hello_streaming.proto\022\021manualflowcontr" + + "ol\"\034\n\014HelloRequest\022\014\n\004name\030\001 \001(\t\"\035\n\nHell" + + "oReply\022\017\n\007message\030\001 \001(\t2m\n\020StreamingGree" + + "ter\022Y\n\021SayHelloStreaming\022\037.manualflowcon" + + "trol.HelloRequest\032\035.manualflowcontrol.He" + + "lloReply\"\000(\0010\001BB\n\"io.grpc.examples.manua" + + "lflowcontrolB\023HelloStreamingProtoP\001\242\002\004HL" + + "WSb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_manualflowcontrol_HelloRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_manualflowcontrol_HelloRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_manualflowcontrol_HelloRequest_descriptor, + new java.lang.String[] { "Name", }); + internal_static_manualflowcontrol_HelloReply_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_manualflowcontrol_HelloReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_manualflowcontrol_HelloReply_descriptor, + new java.lang.String[] { "Message", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/StreamingGreeterGrpc.java b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/StreamingGreeterGrpc.java new file mode 100644 index 000000000000..e7daf0b97ac9 --- /dev/null +++ b/plugins-it/google-grpc-it/src/test/java/io/grpc/examples/manualflowcontrol/StreamingGreeterGrpc.java @@ -0,0 +1,285 @@ +package io.grpc.examples.manualflowcontrol; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + *
+ * The greeting service definition.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.14.0)", + comments = "Source: hello_streaming.proto") +public final class StreamingGreeterGrpc { + + private StreamingGreeterGrpc() {} + + public static final String SERVICE_NAME = "manualflowcontrol.StreamingGreeter"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getSayHelloStreamingMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "SayHelloStreaming", + requestType = io.grpc.examples.manualflowcontrol.HelloRequest.class, + responseType = io.grpc.examples.manualflowcontrol.HelloReply.class, + methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + public static io.grpc.MethodDescriptor getSayHelloStreamingMethod() { + io.grpc.MethodDescriptor getSayHelloStreamingMethod; + if ((getSayHelloStreamingMethod = StreamingGreeterGrpc.getSayHelloStreamingMethod) == null) { + synchronized (StreamingGreeterGrpc.class) { + if ((getSayHelloStreamingMethod = StreamingGreeterGrpc.getSayHelloStreamingMethod) == null) { + StreamingGreeterGrpc.getSayHelloStreamingMethod = getSayHelloStreamingMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName(generateFullMethodName( + "manualflowcontrol.StreamingGreeter", "SayHelloStreaming")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.examples.manualflowcontrol.HelloRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.examples.manualflowcontrol.HelloReply.getDefaultInstance())) + .setSchemaDescriptor(new StreamingGreeterMethodDescriptorSupplier("SayHelloStreaming")) + .build(); + } + } + } + return getSayHelloStreamingMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static StreamingGreeterStub newStub(io.grpc.Channel channel) { + return new StreamingGreeterStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static StreamingGreeterBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new StreamingGreeterBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static StreamingGreeterFutureStub newFutureStub( + io.grpc.Channel channel) { + return new StreamingGreeterFutureStub(channel); + } + + /** + *
+   * The greeting service definition.
+   * 
+ */ + public static abstract class StreamingGreeterImplBase implements io.grpc.BindableService { + + /** + *
+     * Streams a many greetings
+     * 
+ */ + public io.grpc.stub.StreamObserver sayHelloStreaming( + io.grpc.stub.StreamObserver responseObserver) { + return asyncUnimplementedStreamingCall(getSayHelloStreamingMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getSayHelloStreamingMethod(), + asyncBidiStreamingCall( + new MethodHandlers< + io.grpc.examples.manualflowcontrol.HelloRequest, + io.grpc.examples.manualflowcontrol.HelloReply>( + this, METHODID_SAY_HELLO_STREAMING))) + .build(); + } + } + + /** + *
+   * The greeting service definition.
+   * 
+ */ + public static final class StreamingGreeterStub extends io.grpc.stub.AbstractStub { + private StreamingGreeterStub(io.grpc.Channel channel) { + super(channel); + } + + private StreamingGreeterStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected StreamingGreeterStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new StreamingGreeterStub(channel, callOptions); + } + + /** + *
+     * Streams a many greetings
+     * 
+ */ + public io.grpc.stub.StreamObserver sayHelloStreaming( + io.grpc.stub.StreamObserver responseObserver) { + return asyncBidiStreamingCall( + getChannel().newCall(getSayHelloStreamingMethod(), getCallOptions()), responseObserver); + } + } + + /** + *
+   * The greeting service definition.
+   * 
+ */ + public static final class StreamingGreeterBlockingStub extends io.grpc.stub.AbstractStub { + private StreamingGreeterBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private StreamingGreeterBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected StreamingGreeterBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new StreamingGreeterBlockingStub(channel, callOptions); + } + } + + /** + *
+   * The greeting service definition.
+   * 
+ */ + public static final class StreamingGreeterFutureStub extends io.grpc.stub.AbstractStub { + private StreamingGreeterFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private StreamingGreeterFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected StreamingGreeterFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new StreamingGreeterFutureStub(channel, callOptions); + } + } + + private static final int METHODID_SAY_HELLO_STREAMING = 0; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final StreamingGreeterImplBase serviceImpl; + private final int methodId; + + MethodHandlers(StreamingGreeterImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_SAY_HELLO_STREAMING: + return (io.grpc.stub.StreamObserver) serviceImpl.sayHelloStreaming( + (io.grpc.stub.StreamObserver) responseObserver); + default: + throw new AssertionError(); + } + } + } + + private static abstract class StreamingGreeterBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + StreamingGreeterBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return io.grpc.examples.manualflowcontrol.HelloStreamingProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("StreamingGreeter"); + } + } + + private static final class StreamingGreeterFileDescriptorSupplier + extends StreamingGreeterBaseDescriptorSupplier { + StreamingGreeterFileDescriptorSupplier() {} + } + + private static final class StreamingGreeterMethodDescriptorSupplier + extends StreamingGreeterBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + StreamingGreeterMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (StreamingGreeterGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new StreamingGreeterFileDescriptorSupplier()) + .addMethod(getSayHelloStreamingMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/plugins-it/google-grpc-it2/pom.xml b/plugins-it/google-grpc-it2/pom.xml new file mode 100644 index 000000000000..d109ce9ad402 --- /dev/null +++ b/plugins-it/google-grpc-it2/pom.xml @@ -0,0 +1,95 @@ + + + + pinpoint-plugins-it + com.navercorp.pinpoint + 2.5.1-SNAPSHOT + + 4.0.0 + + pinpoint-grpc-plugin-it2 + + jar + + + 1.8 + ${env.JAVA_8_HOME} + 1.42.1 + 3.17.3 + + + + + + + io.grpc + grpc-protobuf + ${grpc.version} + test + + + io.grpc + grpc-stub + ${grpc.version} + test + + + io.grpc + grpc-netty + ${grpc.version} + test + + + + io.netty + netty-all + + ${netty4.version} + test + + + + com.navercorp.pinpoint + pinpoint-plugin-it-utils + ${project.version} + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.5.1 + + com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} + grpc-java + io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} + + + + + test-compile + test-compile-custom + + + + + + + + \ No newline at end of file diff --git a/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/BuilderUtils.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/BuilderUtils.java new file mode 100644 index 000000000000..2458d7b8f422 --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/BuilderUtils.java @@ -0,0 +1,60 @@ +package com.navercorp.pinpoint.plugin.grpc; + +import io.grpc.ManagedChannelBuilder; + +import java.lang.reflect.Method; + +public class BuilderUtils { + + private interface Call { + void call(T target); + } + + private static Call> usePlaintext = getUsePlainText(); + + public static void usePlainText(ManagedChannelBuilder builder) { + usePlaintext.call(builder); + } + + private static Call getUsePlainText() { + final Class builderClass = ManagedChannelBuilder.class; + + final Method oldUsePlaintext = getMethod(builderClass, "usePlaintext"); + if (oldUsePlaintext != null) { + return new Call>() { + @Override + public void call(ManagedChannelBuilder target) { + try { + oldUsePlaintext.invoke(target); + } catch (Exception e) { + throw new RuntimeException(e.getMessage(), e); + } + } + }; + } + + final Method newUsePlaintext = getMethod(builderClass, "usePlaintext", boolean.class); + if (newUsePlaintext != null) { + return new Call>() { + @Override + public void call(ManagedChannelBuilder target) { + try { + newUsePlaintext.invoke(target, true); + } catch (Exception e) { + throw new RuntimeException(e.getMessage(), e); + } + } + }; + } + + throw new UnsupportedOperationException("usePlaintext method not found"); + } + + private static Method getMethod(Class builderClass, String method, Class... parameterTypes) { + try { + return builderClass.getMethod(method, parameterTypes); + } catch (NoSuchMethodException e) { + return null; + } + } +} \ No newline at end of file diff --git a/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/BuilderUtilsTest.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/BuilderUtilsTest.java new file mode 100644 index 000000000000..cd1e78465f04 --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/BuilderUtilsTest.java @@ -0,0 +1,14 @@ +package com.navercorp.pinpoint.plugin.grpc; + +import io.grpc.ManagedChannelBuilder; +import org.junit.Test; + +import static org.mockito.Mockito.mock; + +public class BuilderUtilsTest { + @Test + public void usePlainText() { + ManagedChannelBuilder mock = mock(ManagedChannelBuilder.class); + BuilderUtils.usePlainText(mock); + } +} diff --git a/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/GrpcITBase.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/GrpcITBase.java new file mode 100644 index 000000000000..564dadd1efa6 --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/GrpcITBase.java @@ -0,0 +1,156 @@ +/* + * Copyright 2019 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.plugin.grpc; + +import com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace; +import com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTraceField; +import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; +import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static com.navercorp.pinpoint.bootstrap.plugin.test.Expectations.annotation; +import static com.navercorp.pinpoint.bootstrap.plugin.test.Expectations.event; + +/** + * @author Taejin Koo + */ +public abstract class GrpcITBase { + + private final Logger logger = Logger.getLogger(Grpc_1_42_0_to_IT.class.getName()); + + private final String REQUEST = "hello"; + + @Test + public void requestResponseTest() throws Exception { + HelloWorldSimpleServer server = null; + HelloWorldSimpleClient client = null; + try { + server = new HelloWorldSimpleServer(); + server.start(); + + client = new HelloWorldSimpleClient("127.0.0.1", server.getBindPort()); + String response = client.greet(REQUEST); + Assert.assertEquals(REQUEST.toUpperCase(), response); + + PluginTestVerifier verifier = getPluginTestVerifier(); + + assertTrace(server, verifier); + + verifier.awaitTraceCount(getExpectedRequestResponseTestTraceCount(), 20, 3000); + verifier.verifyTraceCount(getExpectedRequestResponseTestTraceCount()); + } finally { + clearResources(client, server); + } + } + + protected int getExpectedRequestResponseTestTraceCount() { + return 8; + } + + @Test + public void streamingTest() throws Exception { + HelloWorldStreamServer server = null; + HelloWorldStreamClient client = null; + + Random random = new Random(System.currentTimeMillis()); + int requestCount = random.nextInt(5) + 1; + + try { + server = new HelloWorldStreamServer(); + server.start(); + + client = new HelloWorldStreamClient("127.0.0.1", server.getBindPort()); + client.greet(requestCount); + Assert.assertEquals(requestCount, server.getRequestCount()); + + PluginTestVerifier verifier = getPluginTestVerifier(); + + assertTrace(server, verifier); + + verifier.awaitTraceCount(getExpectedStreamingTestInitializationCount() + (requestCount * 2), 20, 3000); + verifier.verifyTraceCount(getExpectedStreamingTestInitializationCount() + (requestCount * 2)); + } finally { + clearResources(client, server); + } + } + + protected int getExpectedStreamingTestInitializationCount() { + return 6; + } + + + private PluginTestVerifier getPluginTestVerifier() { + PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); + if (logger.isLoggable(Level.FINE)) { + verifier.printCache(); + } + return verifier; + } + + + private void assertTrace(HelloWorldServer server, PluginTestVerifier verifier) { + verifier.verifyTrace(clientCallStartEvent(server)); + verifier.verifyTrace(event("GRPC_INTERNAL", "io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl()")); + + verifier.awaitTrace(createServerRootTrace(server), 10, 1000); + verifier.verifyTrace(createServerRootTrace(server)); + + String streacmCreatedMethodDescritor = "io.grpc.internal.ServerImpl$ServerTransportListenerImpl.streamCreated(io.grpc.internal.ServerStream, java.lang.String, io.grpc.Metadata)"; + verifier.verifyTrace(event("GRPC_SERVER_INTERNAL", streacmCreatedMethodDescritor)); + } + + private ExpectedTrace clientCallStartEvent(HelloWorldServer server) { + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder("GRPC"); + eventBuilder.setMethodSignature("io.grpc.internal.ClientCallImpl.start(io.grpc.ClientCall$Listener, io.grpc.Metadata)"); + + String remoteAddress = "127.0.0.1:" + server.getBindPort(); + eventBuilder.setEndPoint(remoteAddress); + eventBuilder.setDestinationId(remoteAddress); + eventBuilder.setAnnotations(annotation("http.url", "http://" + remoteAddress + "/" + server.getMethodName())); + + return eventBuilder.build(); + } + + private ExpectedTrace createServerRootTrace(HelloWorldServer server) { + ExpectedTrace.Builder rootBuilder = ExpectedTrace.createRootBuilder("GRPC_SERVER"); + rootBuilder.setMethodSignature("gRPC HTTP Server"); + rootBuilder.setRpc("/" + server.getMethodName()); + rootBuilder.setRemoteAddr(ExpectedTraceField.createStartWith("127.0.0.1:")); + return rootBuilder.build(); + } + + private void clearResources(HelloWorldClient client, HelloWorldServer server) { + try { + if (client != null) { + client.shutdown(); + } + } catch (Exception e) { + } + try { + if (server != null) { + server.stop(); + } + } catch (Exception e) { + } + } + +} diff --git a/plugins-it/google-grpc-it/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_42_0_to_IT.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_42_0_to_IT.java similarity index 100% rename from plugins-it/google-grpc-it/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_42_0_to_IT.java rename to plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_42_0_to_IT.java diff --git a/plugins-it/google-grpc-it/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_44_0_to_IT.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_44_0_to_IT.java similarity index 100% rename from plugins-it/google-grpc-it/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_44_0_to_IT.java rename to plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/Grpc_1_44_0_to_IT.java diff --git a/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldClient.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldClient.java new file mode 100644 index 000000000000..4031259e8b70 --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldClient.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.plugin.grpc; + +/** + * @author Taejin Koo + */ +public interface HelloWorldClient { + + void shutdown() throws Exception; + +} diff --git a/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldServer.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldServer.java new file mode 100644 index 000000000000..c22b157b5d0b --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldServer.java @@ -0,0 +1,34 @@ +/* + * Copyright 2019 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.plugin.grpc; + +import java.io.IOException; + +/** + * @author Taejin Koo + */ +public interface HelloWorldServer { + + void start() throws IOException; + + void stop() throws InterruptedException; + + int getBindPort(); + + String getMethodName(); + +} diff --git a/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldSimpleClient.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldSimpleClient.java new file mode 100644 index 000000000000..df4266c03fc9 --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldSimpleClient.java @@ -0,0 +1,92 @@ +/* + * Copyright 2019 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.plugin.grpc; + +import com.navercorp.pinpoint.common.util.CpuUtils; +import io.grpc.ManagedChannel; +import io.grpc.Metadata; +import io.grpc.examples.helloworld.GreeterGrpc; +import io.grpc.examples.helloworld.HelloReply; +import io.grpc.examples.helloworld.HelloRequest; +import io.grpc.netty.NettyChannelBuilder; +import io.grpc.stub.MetadataUtils; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.util.concurrent.Future; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import java.util.logging.Logger; + +/** + * copy grpc framework + * - https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java + * + * A simple client that requests a greeting from the {@link HelloWorldServer}. + */ +public class HelloWorldSimpleClient implements HelloWorldClient { + + private final Logger logger = Logger.getLogger(this.getClass().getName()); + + private final ManagedChannel channel; + private final GreeterGrpc.GreeterBlockingStub blockingStub; + + private final ExecutorService workerExecutor; + private final NioEventLoopGroup eventExecutors; + + /** + * Construct client connecting to HelloWorld server at {@code host:port}. + */ + @SuppressWarnings("deprecated") + public HelloWorldSimpleClient(String host, int port) { + this.workerExecutor = Executors.newCachedThreadPool(); + this.eventExecutors = new NioEventLoopGroup(CpuUtils.cpuCount() + 5, workerExecutor); + + this.channel = newChannel(host, port, eventExecutors); + this.blockingStub = GreeterGrpc.newBlockingStub(channel); + } + + private static ManagedChannel newChannel(String host, int port, NioEventLoopGroup eventExecutors) { + NettyChannelBuilder builder = NettyChannelBuilder.forAddress(host, port); + BuilderUtils.usePlainText(builder); + + builder.eventLoopGroup(eventExecutors); + builder.channelType(NioSocketChannel.class); + + builder.intercept(MetadataUtils.newCaptureMetadataInterceptor(new AtomicReference(), new AtomicReference())); + return builder.build(); + } + + @Override + public void shutdown() throws InterruptedException { + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); + Future future = eventExecutors.shutdownGracefully(500, 500, TimeUnit.MILLISECONDS); + future.await(1000); + workerExecutor.shutdownNow(); + } + + public String greet(String name) { + HelloRequest request = HelloRequest.newBuilder().setName(name).build(); + HelloReply response = blockingStub.sayHello(request); + + logger.info("Greeting: {}" + response.getMessage()); + return response.getMessage(); + } + +} diff --git a/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldSimpleServer.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldSimpleServer.java new file mode 100644 index 000000000000..17ffd81cbafc --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldSimpleServer.java @@ -0,0 +1,122 @@ +/* + * Copyright 2019 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.plugin.grpc; + +import com.navercorp.pinpoint.common.util.CpuUtils; +import com.navercorp.pinpoint.pluginit.utils.SocketUtils; +import io.grpc.Server; +import io.grpc.examples.helloworld.GreeterGrpc; +import io.grpc.examples.helloworld.HelloReply; +import io.grpc.examples.helloworld.HelloRequest; +import io.grpc.netty.NettyServerBuilder; +import io.grpc.stub.StreamObserver; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.util.concurrent.Future; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import java.io.IOException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; + +/** + * copy grpc framework + * - https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java + * + * Server that manages startup/shutdown of a {@code Greeter} server. + */ +public class HelloWorldSimpleServer implements HelloWorldServer { + + private final Logger logger = Logger.getLogger(this.getClass().getName()); + + private Server server; + + private int bindPort; + + private final ExecutorService workerExecutor; + private final NioEventLoopGroup eventExecutors; + + public HelloWorldSimpleServer() { + this.workerExecutor = Executors.newCachedThreadPool(); + this.eventExecutors = new NioEventLoopGroup(CpuUtils.cpuCount(), workerExecutor); + } + + @PostConstruct + public void start() throws IOException { + bindPort = SocketUtils.findAvailableTcpPort(10000, 19999); + + /* The port on which the server should run */ + NettyServerBuilder builder = NettyServerBuilder.forPort(bindPort); + builder.bossEventLoopGroup(eventExecutors); + builder.workerEventLoopGroup(eventExecutors); + builder.channelType(NioServerSocketChannel.class); + builder.addService(new GreeterImpl()); + + this.server = builder + .build() + .start(); + + logger.info("Server started, listening on " + bindPort); + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + // Use stderr here since the logger may have been reset by its JVM shutdown hook. + System.err.println("*** shutting down gRPC server since JVM is shutting down"); + try { + HelloWorldSimpleServer.this.stop(); + } catch (InterruptedException e) { + } + System.err.println("*** server shut down"); + } + }); + } + + @PreDestroy + public void stop() throws InterruptedException { + if (server != null) { + server.shutdown().awaitTermination(5, TimeUnit.SECONDS); + } + + Future future = eventExecutors.shutdownGracefully(500, 500, TimeUnit.MILLISECONDS); + future.await(1000); + workerExecutor.shutdownNow(); + } + + @Override + public int getBindPort() { + return bindPort; + } + + @Override + public String getMethodName() { + return GreeterGrpc.getSayHelloMethod().getFullMethodName(); + } + + static class GreeterImpl extends GreeterGrpc.GreeterImplBase { + + @Override + public void sayHello(HelloRequest req, StreamObserver responseObserver) { + HelloReply reply = HelloReply.newBuilder().setMessage(req.getName().toUpperCase()).build(); + responseObserver.onNext(reply); + responseObserver.onCompleted(); + } + } + +} diff --git a/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldStreamClient.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldStreamClient.java new file mode 100644 index 000000000000..c73ace0a4bdc --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldStreamClient.java @@ -0,0 +1,276 @@ +/* + * Copyright 2019 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.plugin.grpc; + +import com.navercorp.pinpoint.common.util.CpuUtils; +import io.grpc.ManagedChannel; +import io.grpc.Metadata; +import io.grpc.examples.manualflowcontrol.StreamingGreeterGrpc; +import io.grpc.netty.NettyChannelBuilder; +import io.grpc.stub.ClientCallStreamObserver; +import io.grpc.stub.ClientResponseObserver; +import io.grpc.stub.MetadataUtils; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.util.concurrent.Future; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import java.util.logging.Logger; + +/** + * copy grpc framework + * - https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/manualflowcontrol/ManualFlowControlClient.java + */ +public class HelloWorldStreamClient implements HelloWorldClient { + + private final Logger logger = Logger.getLogger(this.getClass().getName()); + + private final ManagedChannel channel; + private final StreamingGreeterGrpc.StreamingGreeterStub stub; + + private final ExecutorService workerExecutor; + private final NioEventLoopGroup eventExecutors; + + /** + * Construct client connecting to HelloWorld server at {@code host:port}. + */ + @SuppressWarnings("deprecated") + public HelloWorldStreamClient(String host, int port) { + this.workerExecutor = Executors.newCachedThreadPool(); + this.eventExecutors = new NioEventLoopGroup(CpuUtils.cpuCount() + 5, workerExecutor); + + this.channel = newChannel(host, port, eventExecutors); + this.stub = StreamingGreeterGrpc.newStub(channel); + } + + private static ManagedChannel newChannel(String host, int port, EventLoopGroup eventExecutors) { + NettyChannelBuilder builder = NettyChannelBuilder.forAddress(host, port); + BuilderUtils.usePlainText(builder); + + builder.eventLoopGroup(eventExecutors); + builder.channelType(NioSocketChannel.class); + + builder.intercept(MetadataUtils.newCaptureMetadataInterceptor(new AtomicReference(), new AtomicReference())); + return builder.build(); + } + + @Override + public void shutdown() throws InterruptedException { + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); + + Future future = eventExecutors.shutdownGracefully(500, 500, TimeUnit.MILLISECONDS); + future.await(1000); + workerExecutor.shutdownNow(); + } + + /** + * Say hello to server. + */ + public void greet(final int callCount) throws InterruptedException { + + final CountDownLatch done = new CountDownLatch(1); + + ClientResponseObserver clientResponseObserver = + new ClientResponseObserver() { + + ClientCallStreamObserver requestStream; + + @Override + public void beforeStart(final ClientCallStreamObserver requestStream) { + this.requestStream = requestStream; + // Set up manual flow control for the response stream. It feels backwards to configure the response + // stream's flow control using the request stream's observer, but this is the way it is. + requestStream.disableAutoInboundFlowControl(); + + // Set up a back-pressure-aware producer for the request stream. The onReadyHandler will be invoked + // when the consuming side has enough buffer space to receive more messages. + // + // Messages are serialized into a transport-specific transmit buffer. Depending on the size of this buffer, + // MANY messages may be buffered, however, they haven't yet been sent to the server. The server must call + // request() to pull a buffered message from the client. + // + // Note: the onReadyHandler's invocation is serialized on the same thread pool as the incoming + // StreamObserver'sonNext(), onError(), and onComplete() handlers. Blocking the onReadyHandler will prevent + // additional messages from being processed by the incoming StreamObserver. The onReadyHandler must return + // in a timely manor or else message processing throughput will suffer. + requestStream.setOnReadyHandler(new Runnable() { + // An iterator is used so we can pause and resume iteration of the request data. + Iterator iterator = names().iterator(); + + @Override + public void run() { + int count = 0; + + // Start generating values from where we left off on a non-gRPC thread. + while (requestStream.isReady()) { + if (iterator.hasNext() && callCount > count) { + // Send more messages if there are more messages to send. + String name = iterator.next(); + logger.info("--> " + name); + io.grpc.examples.manualflowcontrol.HelloRequest request = io.grpc.examples.manualflowcontrol.HelloRequest.newBuilder().setName(name).build(); + requestStream.onNext(request); + count++; + } else { + // Signal completion if there is nothing left to send. + requestStream.onCompleted(); + } + } + } + }); + } + + @Override + public void onNext(io.grpc.examples.manualflowcontrol.HelloReply value) { + logger.info("<-- " + value.getMessage()); + // Signal the sender to send one message. + requestStream.request(1); + } + + @Override + public void onError(Throwable t) { + t.printStackTrace(); + done.countDown(); + } + + @Override + public void onCompleted() { + logger.info("All Done"); + done.countDown(); + } + }; + + // Note: clientResponseObserver is handling both request and response stream processing. + stub.sayHelloStreaming(clientResponseObserver); + + done.await(); + } + + private static List names() { + return Arrays.asList( + "Sophia", + "Jackson", + "Emma", + "Aiden", + "Olivia", + "Lucas", + "Ava", + "Liam", + "Mia", + "Noah", + "Isabella", + "Ethan", + "Riley", + "Mason", + "Aria", + "Caden", + "Zoe", + "Oliver", + "Charlotte", + "Elijah", + "Lily", + "Grayson", + "Layla", + "Jacob", + "Amelia", + "Michael", + "Emily", + "Benjamin", + "Madelyn", + "Carter", + "Aubrey", + "James", + "Adalyn", + "Jayden", + "Madison", + "Logan", + "Chloe", + "Alexander", + "Harper", + "Caleb", + "Abigail", + "Ryan", + "Aaliyah", + "Luke", + "Avery", + "Daniel", + "Evelyn", + "Jack", + "Kaylee", + "William", + "Ella", + "Owen", + "Ellie", + "Gabriel", + "Scarlett", + "Matthew", + "Arianna", + "Connor", + "Hailey", + "Jayce", + "Nora", + "Isaac", + "Addison", + "Sebastian", + "Brooklyn", + "Henry", + "Hannah", + "Muhammad", + "Mila", + "Cameron", + "Leah", + "Wyatt", + "Elizabeth", + "Dylan", + "Sarah", + "Nathan", + "Eliana", + "Nicholas", + "Mackenzie", + "Julian", + "Peyton", + "Eli", + "Maria", + "Levi", + "Grace", + "Isaiah", + "Adeline", + "Landon", + "Elena", + "David", + "Anna", + "Christian", + "Victoria", + "Andrew", + "Camilla", + "Brayden", + "Lillian", + "John", + "Natalie", + "Lincoln" + ); + } + + +} diff --git a/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldStreamServer.java b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldStreamServer.java new file mode 100644 index 000000000000..70460080008a --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/java/com/navercorp/pinpoint/plugin/grpc/HelloWorldStreamServer.java @@ -0,0 +1,197 @@ +/* + * Copyright 2019 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.plugin.grpc; + +import com.navercorp.pinpoint.common.util.CpuUtils; +import com.navercorp.pinpoint.pluginit.utils.SocketUtils; +import io.grpc.Server; +import io.grpc.Status; +import io.grpc.examples.manualflowcontrol.HelloReply; +import io.grpc.examples.manualflowcontrol.HelloRequest; +import io.grpc.examples.manualflowcontrol.StreamingGreeterGrpc; +import io.grpc.netty.NettyServerBuilder; +import io.grpc.stub.ServerCallStreamObserver; +import io.grpc.stub.StreamObserver; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.util.concurrent.Future; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import java.io.IOException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Logger; + +/** + * copy grpc framework + * - https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/manualflowcontrol/ManualFlowControlServer.java + */ +public class HelloWorldStreamServer implements HelloWorldServer { + + private final Logger logger = Logger.getLogger(this.getClass().getName()); + + private int requestCount; + + private Server server; + + private int bindPort; + + private final ExecutorService workerExecutor; + private final NioEventLoopGroup eventExecutors; + + public HelloWorldStreamServer() { + this.workerExecutor = Executors.newCachedThreadPool(); + this.eventExecutors = new NioEventLoopGroup(CpuUtils.cpuCount(), workerExecutor); + } + + @PostConstruct + public void start() throws IOException { + StreamingGreeterGrpc.StreamingGreeterImplBase svc = new StreamingGreeterGrpc.StreamingGreeterImplBase() { + @Override + public StreamObserver sayHelloStreaming(final StreamObserver responseObserver) { + // Set up manual flow control for the request stream. It feels backwards to configure the request + // stream's flow control using the response stream's observer, but this is the way it is. + final ServerCallStreamObserver serverCallStreamObserver = + (ServerCallStreamObserver) responseObserver; + serverCallStreamObserver.disableAutoInboundFlowControl(); + + // Guard against spurious onReady() calls caused by a race between onNext() and onReady(). If the transport + // toggles isReady() from false to true while onNext() is executing, but before onNext() checks isReady(), + // request(1) would be called twice - once by onNext() and once by the onReady() scheduled during onNext()'s + // execution. + final AtomicBoolean wasReady = new AtomicBoolean(false); + + // Set up a back-pressure-aware consumer for the request stream. The onReadyHandler will be invoked + // when the consuming side has enough buffer space to receive more messages. + // + // Note: the onReadyHandler's invocation is serialized on the same thread pool as the incoming StreamObserver's + // onNext(), onError(), and onComplete() handlers. Blocking the onReadyHandler will prevent additional messages + // from being processed by the incoming StreamObserver. The onReadyHandler must return in a timely manor or else + // message processing throughput will suffer. + serverCallStreamObserver.setOnReadyHandler(new Runnable() { + public void run() { + if (serverCallStreamObserver.isReady() && wasReady.compareAndSet(false, true)) { + logger.info("READY"); + // Signal the request sender to send one message. This happens when isReady() turns true, signaling that + // the receive buffer has enough free space to receive more messages. Calling request() serves to prime + // the message pump. + serverCallStreamObserver.request(1); + } + } + }); + + // Give gRPC a StreamObserver that can observe and process incoming requests. + return new StreamObserver() { + @Override + public void onNext(HelloRequest request) { + requestCount++; + + // Process the request and send a response or an error. + try { + // Accept and enqueue the request. + String name = request.getName(); + logger.info("--> " + name); + + // Simulate server "work" + Thread.sleep(100); + + // Send a response. + String message = "Hello " + name; + logger.info("<-- " + message); + HelloReply reply = HelloReply.newBuilder().setMessage(message).build(); + responseObserver.onNext(reply); + + // Check the provided ServerCallStreamObserver to see if it is still ready to accept more messages. + if (serverCallStreamObserver.isReady()) { + // Signal the sender to send another request. As long as isReady() stays true, the server will keep + // cycling through the loop of onNext() -> request()...onNext() -> request()... until either the client + // runs out of messages and ends the loop or the server runs out of receive buffer space. + // + // If the server runs out of buffer space, isReady() will turn false. When the receive buffer has + // sufficiently drained, isReady() will turn true, and the serverCallStreamObserver's onReadyHandler + // will be called to restart the message pump. + serverCallStreamObserver.request(1); + } else { + // If not, note that back-pressure has begun. + wasReady.set(false); + } + } catch (Throwable throwable) { + throwable.printStackTrace(); + responseObserver.onError( + Status.UNKNOWN.withDescription("Error handling request").withCause(throwable).asException()); + } + } + + @Override + public void onError(Throwable t) { + // End the response stream if the client presents an error. + t.printStackTrace(); + responseObserver.onCompleted(); + } + + @Override + public void onCompleted() { + // Signal the end of work when the client ends the request stream. + logger.info("COMPLETED"); + responseObserver.onCompleted(); + } + }; + } + }; + + bindPort = SocketUtils.findAvailableTcpPort(20000, 29999); + + NettyServerBuilder serverBuilder = NettyServerBuilder.forPort(bindPort); + serverBuilder.bossEventLoopGroup(eventExecutors); + serverBuilder.workerEventLoopGroup(eventExecutors); + serverBuilder.channelType(NioServerSocketChannel.class); + serverBuilder.addService(svc); + this.server = serverBuilder + .build() + .start(); + } + + @Override + public int getBindPort() { + return bindPort; + } + + @Override + public String getMethodName() { + return StreamingGreeterGrpc.getSayHelloStreamingMethod().getFullMethodName(); + } + + public int getRequestCount() { + return requestCount; + } + + @PreDestroy + public void stop() throws InterruptedException { + if (server != null) { + server.shutdown().awaitTermination(5, TimeUnit.SECONDS); + } + + Future future = eventExecutors.shutdownGracefully(500, 500, TimeUnit.MILLISECONDS); + future.await(1000); + workerExecutor.shutdownNow(); + } + + +} diff --git a/plugins-it/google-grpc-it2/src/test/proto/hello_streaming.proto b/plugins-it/google-grpc-it2/src/test/proto/hello_streaming.proto new file mode 100644 index 000000000000..325b9093b0c4 --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/proto/hello_streaming.proto @@ -0,0 +1,37 @@ +// Copyright 2015 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "io.grpc.examples.manualflowcontrol"; +option java_outer_classname = "HelloStreamingProto"; +option objc_class_prefix = "HLWS"; + +package manualflowcontrol; + +// The greeting service definition. +service StreamingGreeter { + // Streams a many greetings + rpc SayHelloStreaming (stream HelloRequest) returns (stream HelloReply) {} +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +// The response message containing the greetings +message HelloReply { + string message = 1; +} diff --git a/plugins-it/google-grpc-it2/src/test/proto/helloworld.proto b/plugins-it/google-grpc-it2/src/test/proto/helloworld.proto new file mode 100644 index 000000000000..c60d9416f1fc --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/proto/helloworld.proto @@ -0,0 +1,37 @@ +// Copyright 2015 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "io.grpc.examples.helloworld"; +option java_outer_classname = "HelloWorldProto"; +option objc_class_prefix = "HLW"; + +package helloworld; + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc SayHello (HelloRequest) returns (HelloReply) {} +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +// The response message containing the greetings +message HelloReply { + string message = 1; +} diff --git a/plugins-it/google-grpc-it2/src/test/resources/pinpoint-grpc-plugin-test.config b/plugins-it/google-grpc-it2/src/test/resources/pinpoint-grpc-plugin-test.config new file mode 100644 index 000000000000..e6389ad4d909 --- /dev/null +++ b/plugins-it/google-grpc-it2/src/test/resources/pinpoint-grpc-plugin-test.config @@ -0,0 +1,398 @@ +# +# Pinpoint agent configuration +# + +########################################################### +# Collector server # +########################################################### +profiler.collector.ip=127.0.0.1 + +# placeHolder support "${key}" +profiler.collector.span.ip=${profiler.collector.ip} +profiler.collector.span.port=9996 + +# placeHolder support "${key}" +profiler.collector.stat.ip=${profiler.collector.ip} +profiler.collector.stat.port=9995 + +# placeHolder support "${key}" +profiler.collector.tcp.ip=${profiler.collector.ip} +profiler.collector.tcp.port=9994 + + +########################################################### +# Profiler Global Configuration # +########################################################### +profiler.enable=true + +profiler.jvm.collect.interval=1000 + +profiler.sampling.enable=true + +# Set sampling rate. If you set it to 10, 1 out of 10 transaction will be sampled. +profiler.sampling.rate=1 + +profiler.io.buffering.enable=true +profiler.io.buffering.buffersize=20 + +profiler.spandatasender.write.queue.size=5120 +#profiler.spandatasender.socket.sendbuffersize=1048576 +#profiler.spandatasender.socket.timeout=3000 +profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP + +profiler.statdatasender.write.queue.size=5120 +#profiler.statdatasender.socket.sendbuffersize=1048576 +#profiler.statdatasender.socket.timeout=3000 +profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP + +profiler.agentInfo.send.retry.interval=300000 + +# Allows TCP data command +profiler.tcpdatasender.command.accept.enable=true + +# Allow bytecode framework (JAVASSIST or ASM) +profiler.instrument.engine=ASM + + +########################################################### +# application type # +########################################################### +#profiler.applicationservertype=TOMCAT +#profiler.applicationservertype=BLOC + +########################################################### +# application type detect order # +########################################################### +profiler.type.detect.order= + +profiler.plugin.disable=com.navercorp.pinpoint.plugin.jackson.JacksonPlugin + +########################################################### +# user defined classes # +########################################################### +profiler.include= + +########################################################### +# TOMCAT # +########################################################### +profiler.tomcat.enable=true +# Classes for detecting application server type. Comma separated list of fully qualified class names. Wildcard not supported. +profiler.tomcat.bootstrap.main=org.apache.catalina.startup.Bootstrap +# Check pre-conditions when registering class file transformers mainly due to JBoss plugin transforming the same class. +# Setting this to true currently adds transformers only if the application was launched via org.apache.catalina.startup.Bootstrap, +# or SpringBoot's launchers. +# Set this to false to bypass this check entirely (such as when launching standalone applications running embedded Tomcat). +profiler.tomcat.conditional.transform=true +# Hide pinpoint headers. +profiler.tomcat.hidepinpointheader=true +# URLs to exclude from tracing +profiler.tomcat.excludeurl=/aa/test.html, /bb/exclude.html +profiler.tomcat.tracerequestparam=true + +# original IP address header +# https://en.wikipedia.org/wiki/X-Forwarded-For +#profiler.tomcat.realipheader=X-Forwarded-For +# nginx real ip header +#profiler.tomcat.realipheader=X-Real-IP +# optional parameter, If the header value is ${profiler.tomcat.realipemptyvalue}, Ignore header value. +#profiler.tomcat.realipemptyvalue=unknown + + +########################################################### +# JETTY # +########################################################### +profiler.jetty.enable=true +# Classes for detecting application server type. Comma separated list of fully qualified class names. Wildcard not supported. +profiler.jetty.bootstrap.main=org.eclipse.jetty.start.Main +# URLs to exclude from tracing +profiler.jetty.excludeurl= + + +########################################################### +# DUBBO # +########################################################### +profiler.dubbo.enable=true +# Classes for detecting application server type. Comma separated list of fully qualified class names. Wildcard not supported. +profiler.dubbo.bootstrap.main=com.alibaba.dubbo.container.Main + + +########################################################### +# JBOSS # +########################################################### +profiler.jboss.enable=true +# Classes for detecting application server type. Comma separated list of fully qualified class names. Wildcard not supported. +profiler.jboss.bootstrap.main=org.jboss.modules.Main +# Check pre-conditions when registering class file transformers mainly due to Tomcat plugin transforming the same class. +# Setting this to true currently adds transformers only if the application was launched via org.jboss.modules.Main. +# Set this to false to bypass this check entirely. +profiler.jboss.conditional.transform=true +# Hide pinpoint headers. +profiler.jboss.hidepinpointheader=true +# URLs to exclude from tracing +profiler.jboss.excludeurl= +# HTTP Request methods to exclude from tracing +#profiler.jboss.excludemethod= +profiler.jboss.tracerequestparam=true + +# original IP address header +# https://en.wikipedia.org/wiki/X-Forwarded-For +#profiler.jboss.realipheader=X-Forwarded-For +# nginx real ip header +#profiler.jboss.realipheader=X-Real-IP +# optional parameter, If the header value is ${profiler.jboss.realipemptyvalue}, Ignore header value. +#profiler.jboss.realipemptyvalue=unknown + + +########################################################### +# SPRING BOOT # +########################################################### +profiler.springboot.enable=true +# Classes for detecting application server type. Comma separated list of fully qualified class names. Wildcard not supported. +profiler.springboot.bootstrap.main=org.springframework.boot.loader.JarLauncher, org.springframework.boot.loader.WarLauncher, org.springframework.boot.loader.PropertiesLauncher + +########################################################### +# JDBC # +########################################################### +profiler.jdbc=true +profiler.jdbc.sqlcachesize=1024 +profiler.jdbc.maxsqlbindvaluesize=1024 + +# +# MYSQL +# +profiler.jdbc.mysql=true +profiler.jdbc.mysql.setautocommit=true +profiler.jdbc.mysql.commit=true +profiler.jdbc.mysql.rollback=true + +# +# MSSQL Jtds +# +profiler.jdbc.jtds=true +profiler.jdbc.jtds.setautocommit=true +profiler.jdbc.jtds.commit=true +profiler.jdbc.jtds.rollback=true + +# +# Oracle +# +profiler.jdbc.oracle=true +profiler.jdbc.oracle.setautocommit=true +profiler.jdbc.oracle.commit=true +profiler.jdbc.oracle.rollback=true + +# +# CUBRID +# +profiler.jdbc.cubrid=true +profiler.jdbc.cubrid.setautocommit=true +profiler.jdbc.cubrid.commit=true +profiler.jdbc.cubrid.rollback=true + +# +# INFORMIX +# +profiler.jdbc.informix=true +profiler.jdbc.informix.setautocommit=true +profiler.jdbc.informix.commit=true +profiler.jdbc.informix.rollback=true + +# +# DBCP +# +profiler.jdbc.dbcp=true +profiler.jdbc.dbcp.connectionclose=true + +# +# DBCP2 +# +profiler.jdbc.dbcp2=true +profiler.jdbc.dbcp2.connectionclose=true + +# +# HIKARICP +# +profiler.jdbc.hikaricp=true +profiler.jdbc.hikaricp.connectionclose=true + +########################################################### +# Apache HTTP Client 4.x # +########################################################### +profiler.apache.httpclient4=true +profiler.apache.httpclient4.cookie=true + +# When cookies should be dumped. It could be ALWAYS or EXCEPTION. +profiler.apache.httpclient4.cookie.dumptype=ALWAYS +profiler.apache.httpclient4.cookie.sampling.rate=1 + +# Dump entities of POST or PUT request. limited to entities which is HttpEntity.isRepeatable() == true. +profiler.apache.httpclient4.entity=true + +# When entities should be dumped. ALWAYS or EXCEPTION. +profiler.apache.httpclient4.entity.dumptype=ALWAYS +profiler.apache.httpclient4.entity.sampling.rate=1 + +profiler.apache.nio.httpclient4=true + + +########################################################### +# JDK HTTPURLConnection # +########################################################### +profiler.jdk.httpurlconnection=true + + +########################################################### +# Ning Async HTTP Client # +########################################################### +profiler.ning.asynchttpclient=true +profiler.ning.asynchttpclient.cookie=true +profiler.ning.asynchttpclient.cookie.dumptype=ALWAYS +profiler.ning.asynchttpclient.cookie.dumpsize=1024 +profiler.ning.asynchttpclient.cookie.sampling.rate=1 +profiler.ning.asynchttpclient.entity=true +profiler.ning.asynchttpclient.entity.dumptype=ALWAYS +profiler.ning.asynchttpclient.entity.dumpsize=1024 +profiler.ning.asynchttpclient.entity.sampling.rate=1 +profiler.ning.asynchttpclient.param=true +profiler.ning.asynchttpclient.param.dumptype=ALWAYS +profiler.ning.asynchttpclient.param.dumpsize=1024 +profiler.ning.asynchttpclient.param.sampling.rate=1 + +########################################################### +# RestTemplate # +########################################################### +profiler.resttemplate=true + +########################################################### +# Arcus # +########################################################### +profiler.arcus=true +profiler.arcus.keytrace=true + + +########################################################### +# Memcached # +########################################################### +profiler.memcached=true +profiler.memcached.keytrace=true + + +########################################################### +# ibatis # +########################################################### +profiler.orm.ibatis=true + + +########################################################### +# mybatis # +########################################################### +profiler.orm.mybatis=true + + +########################################################### +# spring-beans +########################################################### +# Profile spring-beans +profiler.spring.beans=true + +# filters +# filter +# filter OR filters +# filter +# value +# value AND filter +# value +# token +# token OR token +# token +# profiler.spring.beans.n.scope= [component-scan | post-processor] default is component-scan. +# profiler.spring.beans.n.base-packages= [package name, ...] +# profiler.spring.beans.n.name.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...] +# profiler.spring.beans.n.class.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...] +# profiler.spring.beans.n.annotation= [annotation name, ...] +# +# Scope: +# component-scan: or @ComponentScan +# post-processor: BeanPostProcessor - Slow!!! +# +# ANT Style pattern rules: +# ? - matches on character +# * - matches zero or more characters +# ** - matches zero or more 'directories' in a path + +# Examples +# profiler.spring.beans.1.scope=component-scan +# profiler.spring.beans.1.base-packages=com.foo, com.bar +# profiler.spring.beans.1.name.pattern=.*Foo, regex:.*Bar, antstyle:*Controller +# profiler.spring.beans.1.class.pattern= +# profiler.spring.beans.1.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository +# +# profiler.spring.beans.2.scope=post-processor +# profiler.spring.beans.2.base-packages=com.foo +# profiler.spring.beans.2.name.pattern= +# profiler.spring.beans.2.class.pattern=antstyle:com.foo.repository.*Repository, antstyle:com.foo.Service.Main* +# profiler.spring.beans.2.annotation= + +profiler.spring.beans.1.name.pattern=ma.*, outer +profiler.spring.beans.2.class.pattern=.*Morae +profiler.spring.beans.3.annotation=org.springframework.stereotype.Component + +profiler.spring.beans.mark.error=false + +########################################################### +# log4j +########################################################### +profiler.log4j.logging.transactioninfo=false + +########################################################### +# log4j2 +########################################################### +profiler.log4j2.logging.transactioninfo=false + +########################################################### +# logback +########################################################### +profiler.logback.logging.transactioninfo=false + +########################################################### +# gson +########################################################### +profiler.json.gson=true + +########################################################### +# jackson +########################################################### +profiler.json.jackson=true + +########################################################### +# json-lib +########################################################### +profiler.json.jsonlib=true + +########################################################### +# Netty +########################################################### +# recommend netty plugin disable, when using VERTX. +profiler.netty=false +profiler.netty.http=false + +########################################################### +# GRPC (Reliability and stability can not be guaranteed) +# Version 1.6.0+ is supported. +########################################################### +profiler.grpc.client.enable=true +profiler.grpc.server.enable=true +# In case of streaming, does not track all of each stream request. +# After the streaming open in client, all of each stream request are tracked in one remote trace. +# Therefore, tracking stream request that you want can be difficult. +# please be sure that this description. +profiler.grpc.server.streaming.enable=true +profiler.grpc.server.streaming.onmessage.enable=true \ No newline at end of file diff --git a/plugins-it/jtds-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/jtds/JtdsConnectionIT.java b/plugins-it/jtds-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/jtds/JtdsConnectionIT.java index 1d1754ba2e8c..408f1edead43 100644 --- a/plugins-it/jtds-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/jtds/JtdsConnectionIT.java +++ b/plugins-it/jtds-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/jtds/JtdsConnectionIT.java @@ -22,7 +22,9 @@ import com.navercorp.pinpoint.pluginit.jdbc.DriverProperties; import com.navercorp.pinpoint.pluginit.jdbc.JDBCTestConstants; import com.navercorp.pinpoint.pluginit.utils.AgentPath; +import com.navercorp.pinpoint.pluginit.utils.DockerTestUtils; import com.navercorp.pinpoint.pluginit.utils.LogUtils; +import com.navercorp.pinpoint.pluginit.utils.PluginITConstants; import com.navercorp.pinpoint.pluginit.utils.TestcontainersOption; import com.navercorp.pinpoint.test.plugin.Dependency; import com.navercorp.pinpoint.test.plugin.ImportPlugin; @@ -58,6 +60,7 @@ @ImportPlugin("com.navercorp.pinpoint:pinpoint-jtds-plugin") @Dependency({"net.sourceforge.jtds:jtds:[1.2.8]", "com.microsoft.sqlserver:mssql-jdbc:[6.1.0.jre8]", "log4j:log4j:1.2.16", "org.slf4j:slf4j-log4j12:1.7.5", + PluginITConstants.VERSION, JDBCTestConstants.VERSION, TestcontainersOption.TEST_CONTAINER, TestcontainersOption.MSSQL}) public class JtdsConnectionIT { @@ -87,6 +90,7 @@ public void accept(OutputFrame outputFrame) { @BeforeClass public static void beforeClass() throws Exception { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); + Assume.assumeFalse(DockerTestUtils.isArmDockerServer()); mssqlserver.start(); String address = mssqlserver.getJdbcUrl().substring(JtdsITConstants.JDBC_URL_PREFIX.length()); diff --git a/plugins-it/kotlin-coroutines-it/src/test/java/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesIT.java b/plugins-it/kotlin-coroutines-it/src/test/java/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesIT.java index f4868961221f..ec5888e98085 100644 --- a/plugins-it/kotlin-coroutines-it/src/test/java/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesIT.java +++ b/plugins-it/kotlin-coroutines-it/src/test/java/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesIT.java @@ -29,6 +29,7 @@ import kotlinx.coroutines.CoroutineDispatcher; import kotlinx.coroutines.Dispatchers; import org.junit.Assert; +import org.junit.Assume; import org.junit.Test; import org.junit.runner.RunWith; @@ -106,32 +107,42 @@ public void executeRunBlocking() { verifier.awaitTraceCount(17, 10L, 1000L); List executedMethod = verifier.getExecutedMethod(); - - AtomicInteger index = new AtomicInteger(); - - // runBlocking(context) { - Assert.assertTrue(executedMethod.get(index.getAndIncrement()).contains(DISPATCH_METHOD)); - // runBlocking(context) { - assertResumeWith(executedMethod, index, activeAsync); - - // val job1 = async(CoroutineName("first")) { - Assert.assertTrue(executedMethod.get(index.getAndIncrement()).contains(DISPATCH_METHOD)); - // val job2 = launch(CoroutineName("second")) { - Assert.assertTrue(executedMethod.get(index.getAndIncrement()).contains(DISPATCH_METHOD)); - - // println("Hello all of jobs") // rootjob - assertResumeWith(executedMethod, index, activeAsync); - - // delay(10L) // job1 - assertResumeWithAndSchedule(executedMethod, index, activeAsync); - - // delay(5L) // job2 - assertResumeWithAndSchedule(executedMethod, index, activeAsync); - - // println("Hello World 1") // job1 - assertResumeWith(executedMethod, index, activeAsync); - // println("Hello World 2") // job2 - assertResumeWith(executedMethod, index, activeAsync); + Assume.assumeTrue(executedMethod.size() == 17); + + AtomicInteger index = new AtomicInteger(0); + + try { + // runBlocking(context) { + Assert.assertTrue(executedMethod.get(index.getAndIncrement()).contains(DISPATCH_METHOD)); + // runBlocking(context) { + assertResumeWith(executedMethod, index, activeAsync); + + // val job1 = async(CoroutineName("first")) { + Assert.assertTrue(executedMethod.get(index.getAndIncrement()).contains(DISPATCH_METHOD)); + // val job2 = launch(CoroutineName("second")) { + Assert.assertTrue(executedMethod.get(index.getAndIncrement()).contains(DISPATCH_METHOD)); + + // println("Hello all of jobs") // rootjob + assertResumeWith(executedMethod, index, activeAsync); + + // delay(10L) // job1 + assertResumeWithAndSchedule(executedMethod, index, activeAsync); + + // delay(5L) // job2 + assertResumeWithAndSchedule(executedMethod, index, activeAsync); + + // println("Hello World 1") // job1 + assertResumeWith(executedMethod, index, activeAsync); + // println("Hello World 2") // job2 + assertResumeWith(executedMethod, index, activeAsync); + } catch (Throwable th) { + System.out.println("methods:"); + for (final String method: executedMethod) { + System.out.println(" " + method); + } + th.printStackTrace(); + throw th; + } } private void assertResumeWithAndSchedule(List executedMethod, AtomicInteger index, boolean activeAsync) { diff --git a/plugins-it/kotlin-coroutines-it/src/test/kotlin/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesLaunch.kt b/plugins-it/kotlin-coroutines-it/src/test/kotlin/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesLaunch.kt index 1589aaef39e3..3bf8b7963a8a 100644 --- a/plugins-it/kotlin-coroutines-it/src/test/kotlin/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesLaunch.kt +++ b/plugins-it/kotlin-coroutines-it/src/test/kotlin/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesLaunch.kt @@ -29,11 +29,11 @@ class CoroutinesLaunch { fun executeWithRunBlocking(context: CoroutineContext = EmptyCoroutineContext) { runBlocking(context) { val job1 = async(CoroutineName("first")) { - delay(10L) + delay(100L) println("Hello World 1") } val job2 = launch(CoroutineName("second")) { - delay(5L) + delay(10L) println("Hello World 2") } joinAll(job1, job2) diff --git a/plugins-it/mariadb-jdbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/MariaDBServer.java b/plugins-it/mariadb-jdbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/MariaDBServer.java index 9676af01685a..e32f7a5ee929 100644 --- a/plugins-it/mariadb-jdbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/MariaDBServer.java +++ b/plugins-it/mariadb-jdbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/MariaDBServer.java @@ -9,6 +9,7 @@ import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.MariaDBContainer; import org.testcontainers.containers.output.OutputFrame; +import org.testcontainers.containers.wait.strategy.Wait; import java.util.Properties; import java.util.function.Consumer; @@ -25,13 +26,14 @@ public class MariaDBServer implements SharedTestLifeCycle { public Properties beforeAll() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); - mariaDB = new MariaDBContainer(); + mariaDB = new MariaDBContainer("mariadb:10.3.6"); mariaDB.withLogConsumer(new Consumer() { @Override public void accept(OutputFrame outputFrame) { logger.info(LogUtils.removeLineBreak(outputFrame.getUtf8String())); } }); + mariaDB.waitingFor(Wait.forListeningPort()); mariaDB.withDatabaseName(DATABASE_NAME); mariaDB.withUsername(USERNAME); mariaDB.withPassword(PASSWORD); diff --git a/plugins-it/mysql-jdbc-driver-plugin-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/mysql/MySqlServer.java b/plugins-it/mysql-jdbc-driver-plugin-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/mysql/MySqlServer.java index c4d987c401be..bece5d0c0dfe 100644 --- a/plugins-it/mysql-jdbc-driver-plugin-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/mysql/MySqlServer.java +++ b/plugins-it/mysql-jdbc-driver-plugin-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/mysql/MySqlServer.java @@ -9,6 +9,7 @@ import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.MySQLContainer; import org.testcontainers.containers.output.OutputFrame; +import org.testcontainers.containers.wait.strategy.Wait; import java.util.Properties; import java.util.function.Consumer; @@ -20,19 +21,20 @@ public class MySqlServer implements SharedTestLifeCycle { public static final String USERNAME = "root"; public static final String PASSWORD = ""; - private MySQLContainer mysqlDB = new MySQLContainer(); + private MySQLContainer mysqlDB = new MySQLContainer("mysql:5.7.34"); @Override public Properties beforeAll() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); - mysqlDB = new MySQLContainer(); + mysqlDB = new MySQLContainer("mysql:5.7.34"); mysqlDB.withLogConsumer(new Consumer() { @Override public void accept(OutputFrame outputFrame) { logger.info(LogUtils.removeLineBreak(outputFrame.getUtf8String())); } }); + mysqlDB.waitingFor(Wait.forListeningPort()); mysqlDB.withDatabaseName(DATABASE_NAME); mysqlDB.withUsername(USERNAME); mysqlDB.withPassword(PASSWORD); diff --git a/plugins-it/paho-mqtt-it/pom.xml b/plugins-it/paho-mqtt-it/pom.xml index b5c3e439794b..a7007b24ce04 100644 --- a/plugins-it/paho-mqtt-it/pom.xml +++ b/plugins-it/paho-mqtt-it/pom.xml @@ -46,7 +46,6 @@ org.testcontainers testcontainers ${testcontainers.version} - test diff --git a/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttContainer.java b/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttContainer.java deleted file mode 100644 index 233390c4f47e..000000000000 --- a/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttContainer.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2020 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.plugin.paho.mqtt; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.testcontainers.containers.ContainerLaunchException; -import org.testcontainers.containers.GenericContainer; - -import java.util.concurrent.TimeUnit; - -/** - * @author Taejin Koo - */ -public abstract class PahoMqttContainer extends GenericContainer { - - private static final String IMAGE_NAME = "eclipse-mosquitto:1.6.12"; - private static final int DEFAULT_BROKER_PORT = 1883; - private static final String LOCAL_BROKER_URL_PREFIX = "tcp://localhost:"; - - private final Logger logger = LogManager.getLogger(this.getClass()); - - private final int brokerPort; - - public PahoMqttContainer() { - this(DEFAULT_BROKER_PORT); - } - - public PahoMqttContainer(int brokerPort) { - super(IMAGE_NAME); - this.brokerPort = brokerPort; - } - - public int getBrokerPort() { - return brokerPort; - } - - public String getBrokerUrl() { - Integer mappedPort = getMappedPort(brokerPort); - String brokerUrl = LOCAL_BROKER_URL_PREFIX + mappedPort; - return brokerUrl; - } - - @Override - protected void waitUntilContainerStarted() { - long start = System.currentTimeMillis(); - while (System.currentTimeMillis() < start + TimeUnit.SECONDS.toMillis(30)) { - try { - Integer mappedPort = getMappedPort(brokerPort); - if (checkBrokerStarted()) { - return; - } - } catch (Exception e) { - logger.warn("Failed to check. message:{}", e.getMessage(), e); - } - } - - throw new ContainerLaunchException("Container startup failed"); - } - - abstract boolean checkBrokerStarted() throws Exception; - -} \ No newline at end of file diff --git a/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttV3ClientIT.java b/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttV3ClientIT.java index 2b0de917133b..fe863b070f56 100644 --- a/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttV3ClientIT.java +++ b/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttV3ClientIT.java @@ -20,6 +20,7 @@ import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder; import com.navercorp.pinpoint.pluginit.utils.AgentPath; +import com.navercorp.pinpoint.pluginit.utils.TestcontainersOption; import com.navercorp.pinpoint.test.plugin.Dependency; import com.navercorp.pinpoint.test.plugin.ImportPlugin; import com.navercorp.pinpoint.test.plugin.PinpointAgent; @@ -37,6 +38,9 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.DockerImageName; import java.lang.reflect.Method; import java.util.UUID; @@ -55,11 +59,12 @@ @PinpointConfig("pinpoint-paho-mqttv3-plugin-test.config") @Dependency({"org.eclipse.paho:org.eclipse.paho.client.mqttv3:[1.2.5][1.1.1][1.0.2]", "log4j:log4j:1.2.16", "org.slf4j:slf4j-log4j12:1.7.5", - "org.testcontainers:testcontainers:1.15.3" + TestcontainersOption.TEST_CONTAINER }) public class PahoMqttV3ClientIT { - - private static PahoMqttContainer container = new PahoMqttV3Container(); + private static final GenericContainer container = new GenericContainer(DockerImageName.parse("eclipse-mosquitto:1.6.15")) + .withExposedPorts(1883) + .waitingFor(Wait.forListeningPort()); static String MESSAGE_PAYLOAD = "todareistodo"; static String TOPIC = "pahotest"; @@ -74,12 +79,18 @@ public class PahoMqttV3ClientIT { public static void before() throws MqttException { container.start(); - mqttClient = new MqttAsyncClient(container.getBrokerUrl(), UUID.randomUUID().toString(), new MemoryPersistence()); + mqttClient = new MqttAsyncClient(getBrokerUrl(), UUID.randomUUID().toString(), new MemoryPersistence()); IMqttToken token = mqttClient.connect(); token.waitForCompletion(WAIT_FOR_COMPLETION); subscribe(); } + private static String getBrokerUrl() { + final String address = container.getHost(); + final Integer port = container.getFirstMappedPort(); + return "tcp://" + address + ':' + port; + } + private static void subscribe() throws MqttException { IMqttToken mqttToken = mqttClient.subscribe(TOPIC, QOS); mqttToken.waitForCompletion(WAIT_FOR_COMPLETION); @@ -113,7 +124,7 @@ private void verifyTrace(PluginTestVerifier verifier) throws NoSuchMethodExcepti Object.class, org.eclipse.paho.client.mqttv3.IMqttActionListener.class ); - ExpectedTrace publishExpected = event(PAHO_MQTT_CLIENT, publishMethod, annotation("mqtt.broker.uri", container.getBrokerUrl()), annotation("mqtt.topic", TOPIC), + ExpectedTrace publishExpected = event(PAHO_MQTT_CLIENT, publishMethod, annotation("mqtt.broker.uri", getBrokerUrl()), annotation("mqtt.topic", TOPIC), annotation("mqtt.message.payload", MESSAGE_PAYLOAD), annotation("mqtt.qos", QOS)); String expectedRpcName = "mqtt://topic=" + TOPIC + "&qos=" + QOS; @@ -121,32 +132,11 @@ private void verifyTrace(PluginTestVerifier verifier) throws NoSuchMethodExcepti "MQTT Message Arrived Invocation", expectedRpcName, null, - container.getBrokerUrl(), annotation("mqtt.message.payload", MESSAGE_PAYLOAD)); + getBrokerUrl(), annotation("mqtt.message.payload", MESSAGE_PAYLOAD)); Method messageArrivedMethod = CommsCallback.class.getDeclaredMethod("messageArrived", MqttPublish.class); ExpectedTrace messageArrivedExpected = event(PAHO_MQTT_CLIENT_INTERNAL, messageArrivedMethod); verifier.verifyDiscreteTrace(publishExpected, messageArrivedInvocationExpected, messageArrivedExpected); } - - private static class PahoMqttV3Container extends PahoMqttContainer { - - @Override - boolean checkBrokerStarted() throws Exception { - - MqttAsyncClient mqttClient = null; - try { - mqttClient = new MqttAsyncClient(getBrokerUrl(), UUID.randomUUID().toString(), new MemoryPersistence()); - IMqttToken token = mqttClient.connect(); - token.waitForCompletion(WAIT_FOR_COMPLETION); - return true; - } finally { - if (mqttClient != null) { - mqttClient.disconnect(); - } - } - } - - } - } diff --git a/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttV5ClientIT.java b/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttV5ClientIT.java index 0dcbee6b9f27..f6208c914f8f 100644 --- a/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttV5ClientIT.java +++ b/plugins-it/paho-mqtt-it/src/test/java/com/navercorp/pinpoint/plugin/paho/mqtt/PahoMqttV5ClientIT.java @@ -20,6 +20,7 @@ import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder; import com.navercorp.pinpoint.pluginit.utils.AgentPath; +import com.navercorp.pinpoint.pluginit.utils.TestcontainersOption; import com.navercorp.pinpoint.test.plugin.Dependency; import com.navercorp.pinpoint.test.plugin.ImportPlugin; import com.navercorp.pinpoint.test.plugin.PinpointAgent; @@ -37,6 +38,9 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.DockerImageName; import java.lang.reflect.Method; import java.util.UUID; @@ -55,12 +59,13 @@ @PinpointConfig("pinpoint-paho-mqttv5-plugin-test.config") @Dependency({"org.eclipse.paho:org.eclipse.paho.mqttv5.client:[1.2.5]", "log4j:log4j:1.2.16", "org.slf4j:slf4j-log4j12:1.7.5", - "org.testcontainers:testcontainers:1.15.3" + TestcontainersOption.TEST_CONTAINER }) public class PahoMqttV5ClientIT { - - private static PahoMqttContainer container = new PahoMqttV5Container(); + private static final GenericContainer container = new GenericContainer(DockerImageName.parse("eclipse-mosquitto:1.6.15")) + .withExposedPorts(1883) + .waitingFor(Wait.forListeningPort()); static String MESSAGE_PAYLOAD = "todareistodo"; static String TOPIC = "pahotest"; @@ -75,7 +80,7 @@ public class PahoMqttV5ClientIT { public static void before() throws MqttException { container.start(); - mqttClient = new MqttAsyncClient(container.getBrokerUrl(), UUID.randomUUID().toString(), new MemoryPersistence()); + mqttClient = new MqttAsyncClient(getBrokerUrl(), UUID.randomUUID().toString(), new MemoryPersistence()); IMqttToken token = mqttClient.connect(); token.waitForCompletion(WAIT_FOR_COMPLETION); subscribe(); @@ -112,7 +117,7 @@ private void verifyTrace(PluginTestVerifier verifier) throws NoSuchMethodExcepti Object.class, org.eclipse.paho.mqttv5.client.MqttActionListener.class ); - ExpectedTrace publishExpected = event(PAHO_MQTT_CLIENT, publishMethod, annotation("mqtt.broker.uri", container.getBrokerUrl()), annotation("mqtt.topic", TOPIC), + ExpectedTrace publishExpected = event(PAHO_MQTT_CLIENT, publishMethod, annotation("mqtt.broker.uri", getBrokerUrl()), annotation("mqtt.topic", TOPIC), annotation("mqtt.message.payload", MESSAGE_PAYLOAD), annotation("mqtt.qos", QOS)); String expectedRpcName = "mqtt://topic=" + TOPIC + "&qos=" + QOS; @@ -120,7 +125,7 @@ private void verifyTrace(PluginTestVerifier verifier) throws NoSuchMethodExcepti "MQTT Message Arrived Invocation", expectedRpcName, null, - container.getBrokerUrl(), annotation("mqtt.message.payload", MESSAGE_PAYLOAD)); + getBrokerUrl(), annotation("mqtt.message.payload", MESSAGE_PAYLOAD)); Method messageArrivedMethod = CommsCallback.class.getDeclaredMethod("messageArrived", MqttPublish.class); ExpectedTrace messageArrivedExpected = event(PAHO_MQTT_CLIENT_INTERNAL, messageArrivedMethod); @@ -128,25 +133,9 @@ private void verifyTrace(PluginTestVerifier verifier) throws NoSuchMethodExcepti verifier.verifyDiscreteTrace(publishExpected, messageArrivedInvocationExpected, messageArrivedExpected); } - private static class PahoMqttV5Container extends PahoMqttContainer { - - @Override - boolean checkBrokerStarted() throws Exception { - MqttAsyncClient mqttClient = null; - try { - String brokerUrl = getBrokerUrl(); - mqttClient = new MqttAsyncClient(brokerUrl, UUID.randomUUID().toString(), new MemoryPersistence()); - IMqttToken token = mqttClient.connect(); - token.waitForCompletion(WAIT_FOR_COMPLETION); - return true; - } finally { - if (mqttClient != null) { - mqttClient.disconnect(); - mqttClient.close(true); - } - } - } - + private static String getBrokerUrl() { + final String address = container.getHost(); + final Integer port = container.getFirstMappedPort(); + return "tcp://" + address + ':' + port; } - } diff --git a/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/DockerTestUtils.java b/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/DockerTestUtils.java new file mode 100644 index 000000000000..9b07f110fbb6 --- /dev/null +++ b/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/DockerTestUtils.java @@ -0,0 +1,65 @@ +/* + * Copyright 2023 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.navercorp.pinpoint.pluginit.utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * @author youngjin.kim2 + */ +public class DockerTestUtils { + public static boolean isArmDockerServer() { + return getDockerArchitecture().contains("arm"); + } + + private static String getDockerArchitecture() { + final String dockerInfo = execute("docker version", 3000); + final String dockerServerInfo = dockerInfo.substring(dockerInfo.indexOf("Server: ")); + final String archLine = Arrays.stream(dockerServerInfo.split("\n")) + .filter(line -> line.contains("OS/Arch:")) + .findFirst() + .orElseThrow(() -> new RuntimeException("Invalid docker version result")); + return archLine.split(":")[1].trim(); + } + + private static String execute(String command, long waitMillis) { + try { + return execute0(command, waitMillis); + } catch (Throwable th) { + throw new RuntimeException("Failed to run '" + command + "'"); + } + } + + private static String execute0(String command, long waitMillis) throws InterruptedException, IOException { + final Process proc = Runtime.getRuntime().exec(command); + if (!proc.waitFor(waitMillis, TimeUnit.MILLISECONDS)) { + throw new RuntimeException(); + } + return readAll(proc.getInputStream()); + } + + private static String readAll(InputStream is) { + return new BufferedReader(new InputStreamReader(is)) + .lines() + .collect(Collectors.joining("\n")); + } +} diff --git a/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/TestcontainersOption.java b/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/TestcontainersOption.java index c58300cebd86..e861740d1249 100644 --- a/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/TestcontainersOption.java +++ b/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/TestcontainersOption.java @@ -23,7 +23,7 @@ public final class TestcontainersOption { private TestcontainersOption() { } - public static final String VERSION = "1.17.2"; + public static final String VERSION = "1.17.6"; public static final String TEST_CONTAINER = "org.testcontainers:testcontainers:" + VERSION; public static final String MSSQL = "org.testcontainers:mssqlserver:" + VERSION; diff --git a/plugins-it/pom.xml b/plugins-it/pom.xml index f0c60d3dc69b..23c190b05445 100644 --- a/plugins-it/pom.xml +++ b/plugins-it/pom.xml @@ -79,6 +79,7 @@ jtds-it mysql-jdbc-driver-plugin-it spring-data-r2dbc-it + google-grpc-it2 diff --git a/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MariadbServer.java b/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MariadbServer.java index 376ff0b9e2b6..4cdff95f5244 100644 --- a/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MariadbServer.java +++ b/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MariadbServer.java @@ -17,12 +17,14 @@ package com.navercorp.pinpoint.plugin.jdbc.r2dbc; import com.navercorp.pinpoint.pluginit.jdbc.testcontainers.DatabaseContainers; +import com.navercorp.pinpoint.pluginit.utils.DockerTestUtils; import com.navercorp.pinpoint.test.plugin.shared.SharedTestLifeCycle; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assume; import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.MariaDBContainer; +import org.testcontainers.containers.wait.strategy.Wait; import java.util.Properties; @@ -34,8 +36,10 @@ public class MariadbServer implements SharedTestLifeCycle { @Override public Properties beforeAll() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); + Assume.assumeFalse(DockerTestUtils.isArmDockerServer()); - container = new MariaDBContainer(); + container = new MariaDBContainer("mariadb:10.3.6"); + container.waitingFor(Wait.forListeningPort()); container.withInitScript("mariadb-init.sql"); container.start(); diff --git a/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MssqlServer.java b/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MssqlServer.java index b3f983bdc79d..564df3ad5416 100644 --- a/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MssqlServer.java +++ b/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MssqlServer.java @@ -23,6 +23,7 @@ import org.junit.Assume; import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.MSSQLServerContainer; +import org.testcontainers.containers.wait.strategy.Wait; import java.util.Properties; @@ -35,7 +36,8 @@ public class MssqlServer implements SharedTestLifeCycle { public Properties beforeAll() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); - container = new MSSQLServerContainer(); + container = new MSSQLServerContainer("sqlserver:2017-CU12"); + container.waitingFor(Wait.forListeningPort()); container.withInitScript("mssql-init.sql"); container.start(); diff --git a/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MysqlServer.java b/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MysqlServer.java index 9596d111ad94..e47b0e1873c0 100644 --- a/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MysqlServer.java +++ b/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/MysqlServer.java @@ -24,6 +24,7 @@ import org.junit.Assume; import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.MySQLContainer; +import org.testcontainers.containers.wait.strategy.Wait; import java.util.Properties; @@ -36,7 +37,8 @@ public class MysqlServer implements SharedTestLifeCycle { public Properties beforeAll() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); - container = new MySQLContainer(); + container = new MySQLContainer("mysql:5.7.34"); + container.waitingFor(Wait.forListeningPort()); container.withInitScript("mysql-init.sql"); container.start(); diff --git a/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/PostgreSqlServer.java b/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/PostgreSqlServer.java index 95304fa6c63f..4e7c882de2b3 100644 --- a/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/PostgreSqlServer.java +++ b/plugins-it/spring-data-r2dbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/r2dbc/PostgreSqlServer.java @@ -35,7 +35,7 @@ public class PostgreSqlServer implements SharedTestLifeCycle { public Properties beforeAll() { Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); - postgreSql = new PostgreSQLContainer(); + postgreSql = new PostgreSQLContainer("postgres:9.6.12"); postgreSql.withInitScript("postgresql-init.sql"); postgreSql.start(); diff --git a/pom.xml b/pom.xml index 453fcd9aadf5..0b9a7cfd5c6a 100644 --- a/pom.xml +++ b/pom.xml @@ -200,7 +200,7 @@ 4.8.1 1.12.18 - 1.17.2 + 1.17.6 3.8.1 diff --git a/web/src/test/java/com/navercorp/pinpoint/web/cluster/zookeeper/ZookeeperClusterTest.java b/web/src/test/java/com/navercorp/pinpoint/web/cluster/zookeeper/ZookeeperClusterTest.java index f3ab8843993d..5881f5109e01 100644 --- a/web/src/test/java/com/navercorp/pinpoint/web/cluster/zookeeper/ZookeeperClusterTest.java +++ b/web/src/test/java/com/navercorp/pinpoint/web/cluster/zookeeper/ZookeeperClusterTest.java @@ -41,6 +41,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import org.springframework.test.util.TestSocketUtils; import org.springframework.util.SocketUtils; import java.util.List; @@ -76,8 +77,8 @@ private ConditionFactory awaitility() { @BeforeAll public static void setUp() throws Exception { - int acceptorPort = SocketUtils.findAvailableTcpPort(); - zookeeperPort = SocketUtils.findAvailableTcpPort(acceptorPort + 1); + int acceptorPort = TestSocketUtils.findAvailableTcpPort(); + zookeeperPort = TestSocketUtils.findAvailableTcpPort(); CLUSTER_NODE_PATH = ZKPaths.makePath(ZookeeperConstants.DEFAULT_CLUSTER_ZNODE_ROOT_PATH, ZookeeperConstants.WEB_LEAF_PATH, DEFAULT_IP + ":" + acceptorPort); diff --git a/web/src/test/java/com/navercorp/pinpoint/web/util/PinpointWebTestUtils.java b/web/src/test/java/com/navercorp/pinpoint/web/util/PinpointWebTestUtils.java index 0a74d42b947b..8a2eef0c26fd 100644 --- a/web/src/test/java/com/navercorp/pinpoint/web/util/PinpointWebTestUtils.java +++ b/web/src/test/java/com/navercorp/pinpoint/web/util/PinpointWebTestUtils.java @@ -16,6 +16,7 @@ package com.navercorp.pinpoint.web.util; +import java.net.InetAddress; import java.util.List; import org.apache.logging.log4j.Logger; @@ -41,12 +42,25 @@ public static String getRepresentationLocalV4Ip() { } // local ip addresses with all LOOPBACK addresses removed - List ipList = NetUtils.getLocalV4IpList(); - if (!ipList.isEmpty()) { - return ipList.get(0); - } + final List ipList = NetUtils.getLocalV4IpList(); + return findReachableIp(ipList); + } + private static String findReachableIp(List ips) { + for (final String ip: ips) { + if (isReachable(ip)) { + return ip; + } + } return NetUtils.LOOPBACK_ADDRESS_V4; } + + private static boolean isReachable(String ip) { + try { + return InetAddress.getByName(ip).isReachable(3); + } catch (Throwable ignored) { + return false; + } + } }