提交 32c4bced 编写于 作者: 彭勇升 pengys 提交者: wu-sheng

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`
上级 f38aea3d
/*
* 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;
}
}
/*
* 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);
}
/*
* 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);
}
}
/*
* 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();
}
}
/*
* 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);
}
}
/*
* 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();
}
/*
* 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();
}
}
/*
* 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);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册