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`
This commit is contained in:
parent
f38aea3d97
commit
32c4bced8a
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue