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 000000000..0e98338ed --- /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 000000000..5c3635d8d --- /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 000000000..83fc129cb --- /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 000000000..7c06828dc --- /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 000000000..2faca4854 --- /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 000000000..9aaae541c --- /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 000000000..382e51e23 --- /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 000000000..0a074f6e2 --- /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); + } +}