You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/02/11 09:27:17 UTC

[skywalking-agent-test-tool] branch master updated: introduce grpc compat service (#28)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-agent-test-tool.git


The following commit(s) were added to refs/heads/master by this push:
     new 8db606f  introduce grpc compat service (#28)
8db606f is described below

commit 8db606f3470cce75c1b013ae498ac93b862b75b7
Author: Rei Shimizu <Sh...@gmail.com>
AuthorDate: Thu Feb 11 18:27:11 2021 +0900

    introduce grpc compat service (#28)
---
 mock-collector/pom.xml                             |  2 +-
 .../skywalking/plugin/test/mockcollector/Main.java | 11 +++++
 .../MockCLRMetricReportServiceCompat.java          | 32 +++++++++++++
 .../MockJVMMetricReportServiceCompat.java          | 32 +++++++++++++
 .../compat-grpc/MockManagementServiceCompat.java   | 41 ++++++++++++++++
 .../compat-grpc/MockMeterReportServiceCompat.java  | 52 ++++++++++++++++++++
 .../compat-grpc/MockTraceSegmentServiceCompat.java | 56 ++++++++++++++++++++++
 7 files changed, 225 insertions(+), 1 deletion(-)

diff --git a/mock-collector/pom.xml b/mock-collector/pom.xml
index ae497af..cb40639 100644
--- a/mock-collector/pom.xml
+++ b/mock-collector/pom.xml
@@ -34,7 +34,7 @@
     <url>http://maven.apache.org</url>
 
     <properties>
-        <protocol.version>345d9edac842179e61504999c91bf2bec6ae0ff7</protocol.version>
+        <protocol.version>c3abc7e3d245ca8002dcc1f9bc93d45bc10bd382</protocol.version>
         <protocol.workingDirectory>${project.basedir}/target/protocol</protocol.workingDirectory>
         <protocol.repos>https://github.com/apache/skywalking-data-collect-protocol.git</protocol.repos>
         <protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java
index 2ba7756..881cb97 100644
--- a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java
@@ -24,6 +24,11 @@ import org.apache.skywalking.plugin.test.mockcollector.mock.MockJVMMetricReportS
 import org.apache.skywalking.plugin.test.mockcollector.mock.MockManagementService;
 import org.apache.skywalking.plugin.test.mockcollector.mock.MockMeterReportService;
 import org.apache.skywalking.plugin.test.mockcollector.mock.MockTraceSegmentService;
+import org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc.MockCLRMetricReportServiceCompat;
+import org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc.MockJVMMetricReportServiceCompat;
+import org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc.MockManagementServiceCompat;
+import org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc.MockMeterReportServiceCompat;
+import org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc.MockTraceSegmentServiceCompat;
 import org.apache.skywalking.plugin.test.mockcollector.mock.rest.MockManagementServiceKeepAliveHandler;
 import org.apache.skywalking.plugin.test.mockcollector.mock.rest.MockManagementServiceReportPropertiesHandler;
 import org.apache.skywalking.plugin.test.mockcollector.mock.rest.MockTraceSegmentListCollectServletHandler;
@@ -49,6 +54,12 @@ public class Main {
                           .addService(new MockManagementService())
                           .addService(new MockTraceSegmentService())
                           .addService(new MockMeterReportService())
+                          .addService(new MockCLRMetricReportServiceCompat())
+                          .addService(new MockJVMMetricReportServiceCompat())
+                          .addService(new MockManagementServiceCompat())
+                          .addService(new MockTraceSegmentServiceCompat())
+                          .addService(new MockMeterReportServiceCompat())
+                          
                           .build()
                           .start();
 
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockCLRMetricReportServiceCompat.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockCLRMetricReportServiceCompat.java
new file mode 100644
index 0000000..bce0ad0
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockCLRMetricReportServiceCompat.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.skywalking.apm.network.common.v3.Commands;
+import org.apache.skywalking.apm.network.language.agent.v3.CLRMetricCollection;
+import org.apache.skywalking.apm.network.language.agent.v3.compat.CLRMetricReportServiceGrpc;
+
+public class MockCLRMetricReportServiceCompat extends CLRMetricReportServiceGrpc.CLRMetricReportServiceImplBase {
+
+    @Override
+    public void collect(CLRMetricCollection request, StreamObserver<Commands> responseObserver) {
+        responseObserver.onNext(Commands.newBuilder().build());
+        responseObserver.onCompleted();
+    }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockJVMMetricReportServiceCompat.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockJVMMetricReportServiceCompat.java
new file mode 100644
index 0000000..b8f99f3
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockJVMMetricReportServiceCompat.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.skywalking.apm.network.common.v3.Commands;
+import org.apache.skywalking.apm.network.language.agent.v3.JVMMetricCollection;
+import org.apache.skywalking.apm.network.language.agent.v3.compat.JVMMetricReportServiceGrpc;
+
+public class MockJVMMetricReportServiceCompat extends JVMMetricReportServiceGrpc.JVMMetricReportServiceImplBase {
+
+    @Override
+    public void collect(JVMMetricCollection request, StreamObserver<Commands> responseObserver) {
+        responseObserver.onNext(Commands.newBuilder().build());
+        responseObserver.onCompleted();
+    }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockManagementServiceCompat.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockManagementServiceCompat.java
new file mode 100644
index 0000000..4ff9613
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockManagementServiceCompat.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.skywalking.apm.network.common.v3.Commands;
+import org.apache.skywalking.apm.network.management.v3.InstancePingPkg;
+import org.apache.skywalking.apm.network.management.v3.InstanceProperties;
+import org.apache.skywalking.apm.network.management.v3.compat.ManagementServiceGrpc;
+
+public class MockManagementServiceCompat extends ManagementServiceGrpc.ManagementServiceImplBase {
+
+    @Override
+    public void reportInstanceProperties(InstanceProperties request, StreamObserver<Commands> responseObserver) {
+        responseObserver.onNext(Commands.newBuilder().build());
+        responseObserver.onCompleted();
+    }
+
+    @Override
+    public void keepAlive(InstancePingPkg request, StreamObserver<Commands> responseObserver) {
+        responseObserver.onNext(Commands.newBuilder().build());
+        responseObserver.onCompleted();
+    }
+
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockMeterReportServiceCompat.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockMeterReportServiceCompat.java
new file mode 100644
index 0000000..778d897
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockMeterReportServiceCompat.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc;
+
+import io.grpc.stub.StreamObserver;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.apm.network.common.v3.Commands;
+import org.apache.skywalking.apm.network.language.agent.v3.MeterData;
+import org.apache.skywalking.apm.network.language.agent.v3.compat.MeterReportServiceGrpc;
+import org.apache.skywalking.plugin.test.mockcollector.util.MeterHandler;
+
+@Slf4j
+public class MockMeterReportServiceCompat extends MeterReportServiceGrpc.MeterReportServiceImplBase {
+
+    @Override
+    public StreamObserver<MeterData> collect(StreamObserver<Commands> responseObserver) {
+        final MeterHandler.Parser parser = MeterHandler.createParser();
+        return new StreamObserver<MeterData>() {
+            @Override
+            public void onNext(MeterData meterData) {
+                parser.parse(meterData);
+            }
+
+            @Override
+            public void onError(Throwable throwable) {
+                log.error(throwable.getMessage(), throwable);
+                responseObserver.onCompleted();
+            }
+
+            @Override
+            public void onCompleted() {
+                responseObserver.onNext(Commands.newBuilder().build());
+                responseObserver.onCompleted();
+            }
+        };
+    }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockTraceSegmentServiceCompat.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockTraceSegmentServiceCompat.java
new file mode 100644
index 0000000..00c611a
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/compat-grpc/MockTraceSegmentServiceCompat.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.plugin.test.mockcollector.mock.compatgrpc;
+
+import io.grpc.stub.StreamObserver;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.apm.network.common.v3.Commands;
+import org.apache.skywalking.apm.network.language.agent.v3.SegmentObject;
+import org.apache.skywalking.apm.network.language.agent.v3.compat.TraceSegmentReportServiceGrpc;
+import org.apache.skywalking.plugin.test.mockcollector.util.TraceSegmentHandler;
+
+@Slf4j
+public class MockTraceSegmentServiceCompat extends TraceSegmentReportServiceGrpc.TraceSegmentReportServiceImplBase {
+
+    @Override
+    public StreamObserver<SegmentObject> collect(StreamObserver<Commands> responseObserver) {
+        return new StreamObserver<SegmentObject>() {
+            @Override
+            public void onNext(SegmentObject segmentObject) {
+                if (segmentObject.getSpansList().size() == 0) {
+                    return;
+                }
+
+                TraceSegmentHandler.parseSegment(segmentObject);
+            }
+
+            @Override
+            public void onError(Throwable throwable) {
+                log.error(throwable.getMessage(), throwable);
+                responseObserver.onCompleted();
+            }
+
+            @Override
+            public void onCompleted() {
+                responseObserver.onNext(Commands.newBuilder().build());
+                responseObserver.onCompleted();
+            }
+        };
+    }
+
+}