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 2019/03/23 18:30:32 UTC
[incubator-skywalking] branch master updated: Downstream command
protocol example. (#2380)
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/incubator-skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 32c4bce Downstream command protocol example. (#2380)
32c4bce is described below
commit 32c4bced8a7e055003d6e4bea0fd8f8361bec8e5
Author: 彭勇升 pengys <80...@qq.com>
AuthorDate: Sun Mar 24 02:30:22 2019 +0800
Downstream command protocol example. (#2380)
* Downstream command protocol example.
* Add wait seconds arguments into meta data reset command.
* Style consistent issue fixed.
* Add serialNumber arguments for agent to check if the command duplicate.
* Command separate.
* Update TraceIgnoreCommand.java
Keep TraceIgnoreCommand just named `TraceIgnore`
---
.../trace/component/command/BaseCommand.java | 56 ++++++++++++++++++++++
.../trace/component/command/Deserializable.java | 28 +++++++++++
.../component/command/EndpointResetCommand.java | 45 +++++++++++++++++
.../component/command/InstanceResetCommand.java | 37 ++++++++++++++
.../component/command/NetworkResetCommand.java | 45 +++++++++++++++++
.../trace/component/command/Serializable.java | 28 +++++++++++
.../component/command/ServiceResetCommand.java | 37 ++++++++++++++
.../component/command/TraceIgnoreCommand.java | 44 +++++++++++++++++
8 files changed, 320 insertions(+)
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/BaseCommand.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/BaseCommand.java
new file mode 100644
index 0000000..0e98338
--- /dev/null
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/BaseCommand.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.apm.network.trace.component.command;
+
+import org.apache.skywalking.apm.network.common.*;
+
+/**
+ * @author peng-yongsheng
+ */
+public abstract class BaseCommand {
+
+ private final String command;
+ private final String serialNumber;
+ private final Command.Builder commandBuilder;
+
+ BaseCommand(String command, String serialNumber) {
+ this.command = command;
+ this.serialNumber = serialNumber;
+ this.commandBuilder = Command.newBuilder();
+
+ KeyStringValuePair.Builder arguments = KeyStringValuePair.newBuilder();
+ arguments.setKey("SerialNumber");
+ arguments.setValue(serialNumber);
+
+ this.commandBuilder.setCommand(command);
+ this.commandBuilder.addArgs(arguments);
+ }
+
+ Command.Builder commandBuilder() {
+ return commandBuilder;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public String getSerialNumber() {
+ return serialNumber;
+ }
+}
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/Deserializable.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/Deserializable.java
new file mode 100644
index 0000000..5c3635d
--- /dev/null
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/Deserializable.java
@@ -0,0 +1,28 @@
+/*
+ * 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.apm.network.trace.component.command;
+
+import org.apache.skywalking.apm.network.common.Command;
+
+/**
+ * @author peng-yongsheng
+ */
+public interface Deserializable {
+ void deserialize(Command command);
+}
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/EndpointResetCommand.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/EndpointResetCommand.java
new file mode 100644
index 0000000..83fc129
--- /dev/null
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/EndpointResetCommand.java
@@ -0,0 +1,45 @@
+/*
+ * 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.apm.network.trace.component.command;
+
+import org.apache.skywalking.apm.network.common.*;
+
+/**
+ * Remove the specified endpoint names from endpoint metadata cache, and re-register it.
+ * If not specified, clear whole endpoint metadata cache.
+ *
+ * @author peng-yongsheng
+ */
+public class EndpointResetCommand extends BaseCommand implements Serializable {
+
+ public EndpointResetCommand(String serialNumber) {
+ super("EndpointMetadataReset", serialNumber);
+ }
+
+ @Override public Command.Builder serialize() {
+ return commandBuilder();
+ }
+
+ public void addSpecifiedEndpointName(String endpointName) {
+ KeyStringValuePair.Builder arguments = KeyStringValuePair.newBuilder();
+ arguments.setKey("EndpointName");
+ arguments.setValue(endpointName);
+ commandBuilder().addArgs(arguments);
+ }
+}
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/InstanceResetCommand.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/InstanceResetCommand.java
new file mode 100644
index 0000000..7c06828
--- /dev/null
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/InstanceResetCommand.java
@@ -0,0 +1,37 @@
+/*
+ * 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.apm.network.trace.component.command;
+
+import org.apache.skywalking.apm.network.common.Command;
+
+/**
+ * Clear the service instance metadata cache, and re-register it.
+ *
+ * @author peng-yongsheng
+ */
+public class InstanceResetCommand extends BaseCommand implements Serializable {
+
+ public InstanceResetCommand(String serialNumber) {
+ super("InstanceMetadataReset", serialNumber);
+ }
+
+ @Override public Command.Builder serialize() {
+ return commandBuilder();
+ }
+}
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/NetworkResetCommand.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/NetworkResetCommand.java
new file mode 100644
index 0000000..2faca48
--- /dev/null
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/NetworkResetCommand.java
@@ -0,0 +1,45 @@
+/*
+ * 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.apm.network.trace.component.command;
+
+import org.apache.skywalking.apm.network.common.*;
+
+/**
+ * Remove the specified network addresses from network address metadata cache, and re-register it.
+ * If not specified, clear whole network address metadata cache.
+ *
+ * @author peng-yongsheng
+ */
+public class NetworkResetCommand extends BaseCommand implements Serializable {
+
+ public NetworkResetCommand(String serialNumber) {
+ super("NetworkAddressMetadataReset", serialNumber);
+ }
+
+ @Override public Command.Builder serialize() {
+ return commandBuilder();
+ }
+
+ public void addSpecifiedNetworkAddress(String networkAddress) {
+ KeyStringValuePair.Builder arguments = KeyStringValuePair.newBuilder();
+ arguments.setKey("NetworkAddress");
+ arguments.setValue(networkAddress);
+ commandBuilder().addArgs(arguments);
+ }
+}
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/Serializable.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/Serializable.java
new file mode 100644
index 0000000..9aaae54
--- /dev/null
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/Serializable.java
@@ -0,0 +1,28 @@
+/*
+ * 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.apm.network.trace.component.command;
+
+import org.apache.skywalking.apm.network.common.Command;
+
+/**
+ * @author peng-yongsheng
+ */
+public interface Serializable {
+ Command.Builder serialize();
+}
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/ServiceResetCommand.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/ServiceResetCommand.java
new file mode 100644
index 0000000..382e51e
--- /dev/null
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/ServiceResetCommand.java
@@ -0,0 +1,37 @@
+/*
+ * 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.apm.network.trace.component.command;
+
+import org.apache.skywalking.apm.network.common.Command;
+
+/**
+ * Clear the service metadata cache and other metadata caches belong to it, and re-register them.
+ *
+ * @author peng-yongsheng
+ */
+public class ServiceResetCommand extends BaseCommand implements Serializable {
+
+ public ServiceResetCommand(String serialNumber) {
+ super("ServiceMetadataReset", serialNumber);
+ }
+
+ @Override public Command.Builder serialize() {
+ return commandBuilder();
+ }
+}
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/TraceIgnoreCommand.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/TraceIgnoreCommand.java
new file mode 100644
index 0000000..0a074f6
--- /dev/null
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/command/TraceIgnoreCommand.java
@@ -0,0 +1,44 @@
+/*
+ * 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.apm.network.trace.component.command;
+
+import org.apache.skywalking.apm.network.common.*;
+
+/**
+ * Trace ignore sync, each configuration downstream is the full amount of data related to the received agent.
+ *
+ * @author peng-yongsheng
+ */
+public class TraceIgnoreCommand extends BaseCommand implements Serializable {
+
+ public TraceIgnoreCommand(String serialNumber) {
+ super("TraceIgnore", serialNumber);
+ }
+
+ @Override public Command.Builder serialize() {
+ return commandBuilder();
+ }
+
+ public void addRule(String path) {
+ KeyStringValuePair.Builder arguments = KeyStringValuePair.newBuilder();
+ arguments.setKey("Path");
+ arguments.setValue(path);
+ commandBuilder().addArgs(arguments);
+ }
+}