Add all of the entity remote data classes.

This commit is contained in:
peng-yongsheng 2017-11-01 00:53:32 +08:00
parent 9f6f23846d
commit dbbf1587ae
12 changed files with 487 additions and 10 deletions

View File

@ -22,5 +22,5 @@ package org.skywalking.apm.collector.remote;
* @author peng-yongsheng
*/
public enum RemoteDataMapping {
InstPerformance
InstPerformance, NodeComponent, NodeMapping, NodeReference, Application, Instance, ServiceName, ServiceEntry, ServiceReference
}

View File

@ -11,7 +11,15 @@ import org.skywalking.apm.collector.grpc.manager.GRPCManagerModule;
import org.skywalking.apm.collector.grpc.manager.service.GRPCManagerService;
import org.skywalking.apm.collector.remote.RemoteDataMappingContainer;
import org.skywalking.apm.collector.remote.RemoteModule;
import org.skywalking.apm.collector.remote.grpc.data.instance.InstPerformanceData;
import org.skywalking.apm.collector.remote.grpc.data.instance.InstPerformanceRemoteData;
import org.skywalking.apm.collector.remote.grpc.data.node.NodeComponentRemoteData;
import org.skywalking.apm.collector.remote.grpc.data.node.NodeMappingRemoteData;
import org.skywalking.apm.collector.remote.grpc.data.noderef.NodeReferenceRemoteData;
import org.skywalking.apm.collector.remote.grpc.data.register.ApplicationRemoteData;
import org.skywalking.apm.collector.remote.grpc.data.register.InstanceRemoteData;
import org.skywalking.apm.collector.remote.grpc.data.register.ServiceNameRemoteData;
import org.skywalking.apm.collector.remote.grpc.data.service.ServiceEntryRemoteData;
import org.skywalking.apm.collector.remote.grpc.data.serviceref.ServiceReferenceRemoteData;
import org.skywalking.apm.collector.remote.grpc.handler.RemoteCommonServiceHandler;
import org.skywalking.apm.collector.remote.grpc.service.GRPCRemoteClientService;
import org.skywalking.apm.collector.remote.grpc.service.GRPCRemoteServerService;
@ -39,7 +47,7 @@ public class RemoteModuleGRPCProvider extends ModuleProvider {
}
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
container = loadMapping();
container = loadRemoteData();
this.registerServiceImplementation(RemoteServerService.class, new GRPCRemoteServerService(listener));
this.registerServiceImplementation(RemoteClientService.class, new GRPCRemoteClientService(container));
}
@ -68,9 +76,17 @@ public class RemoteModuleGRPCProvider extends ModuleProvider {
return new String[] {ClusterModule.NAME, GRPCManagerModule.NAME};
}
private RemoteDataMappingContainer loadMapping() {
private RemoteDataMappingContainer loadRemoteData() {
RemoteDataMappingContainer container = new RemoteDataMappingContainer();
container.addMapping(new InstPerformanceData());
container.addMapping(new InstPerformanceRemoteData());
container.addMapping(new NodeComponentRemoteData());
container.addMapping(new NodeMappingRemoteData());
container.addMapping(new NodeReferenceRemoteData());
container.addMapping(new ApplicationRemoteData());
container.addMapping(new InstanceRemoteData());
container.addMapping(new ServiceNameRemoteData());
container.addMapping(new ServiceEntryRemoteData());
container.addMapping(new ServiceReferenceRemoteData());
return container;
}
}

View File

@ -18,16 +18,16 @@
package org.skywalking.apm.collector.remote.grpc.data;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
import org.skywalking.apm.collector.remote.service.SerializableAndDeserialize;
/**
* @author peng-yongsheng
*/
public abstract class GRPCData implements SerializableAndDeserialize<RemoteData, RemoteData.Builder> {
public abstract class GRPCRemoteData implements SerializableAndDeserialize<RemoteData, RemoteData.Builder> {
protected Data build(RemoteData remoteData) {
protected final Data build(RemoteData remoteData) {
return new Data(remoteData.getDataStrings(0), remoteData.getStringCapacity(), remoteData.getLongCapacity(), remoteData.getDoubleCapacity(), remoteData.getIntegerCapacity(), remoteData.getBooleanCapacity(), remoteData.getByteCapacity());
}
}

View File

@ -19,14 +19,14 @@
package org.skywalking.apm.collector.remote.grpc.data.instance;
import org.skywalking.apm.collector.remote.RemoteDataMapping;
import org.skywalking.apm.collector.remote.grpc.data.GRPCData;
import org.skywalking.apm.collector.remote.grpc.data.GRPCRemoteData;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
import org.skywalking.apm.collector.core.data.Data;
/**
* @author peng-yongsheng
*/
public class InstPerformanceData extends GRPCData {
public class InstPerformanceRemoteData extends GRPCRemoteData {
@Override public RemoteDataMapping mapping() {
return RemoteDataMapping.InstPerformance;

View File

@ -0,0 +1,55 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.remote.grpc.data.node;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.remote.RemoteDataMapping;
import org.skywalking.apm.collector.remote.grpc.data.GRPCRemoteData;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
/**
* @author peng-yongsheng
*/
public class NodeComponentRemoteData extends GRPCRemoteData {
@Override public RemoteDataMapping mapping() {
return RemoteDataMapping.NodeComponent;
}
@Override public RemoteData.Builder serialize(Data data) {
RemoteData.Builder builder = RemoteData.newBuilder();
builder.addDataStrings(data.getDataString(0));
builder.addDataIntegers(data.getDataInteger(0));
builder.addDataStrings(data.getDataString(1));
builder.addDataIntegers(data.getDataInteger(1));
builder.addDataStrings(data.getDataString(2));
builder.addDataLongs(data.getDataLong(0));
return builder;
}
@Override public Data deserialize(RemoteData remoteData) {
Data data = build(remoteData);
data.setDataInteger(0, remoteData.getDataIntegers(0));
data.setDataString(1, remoteData.getDataStrings(1));
data.setDataInteger(1, remoteData.getDataIntegers(1));
data.setDataString(2, remoteData.getDataStrings(2));
data.setDataLong(0, remoteData.getDataLongs(0));
return data;
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.remote.grpc.data.node;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.remote.RemoteDataMapping;
import org.skywalking.apm.collector.remote.grpc.data.GRPCRemoteData;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
/**
* @author peng-yongsheng
*/
public class NodeMappingRemoteData extends GRPCRemoteData {
@Override public RemoteDataMapping mapping() {
return RemoteDataMapping.NodeMapping;
}
@Override public RemoteData.Builder serialize(Data data) {
RemoteData.Builder builder = RemoteData.newBuilder();
builder.addDataStrings(data.getDataString(0));
builder.addDataIntegers(data.getDataInteger(0));
builder.addDataIntegers(data.getDataInteger(1));
builder.addDataStrings(data.getDataString(1));
builder.addDataLongs(data.getDataLong(0));
return builder;
}
@Override public Data deserialize(RemoteData remoteData) {
Data data = build(remoteData);
data.setDataInteger(0, remoteData.getDataIntegers(0));
data.setDataInteger(1, remoteData.getDataIntegers(1));
data.setDataString(1, remoteData.getDataStrings(1));
data.setDataLong(0, remoteData.getDataLongs(0));
return data;
}
}

View File

@ -0,0 +1,65 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.remote.grpc.data.noderef;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.remote.RemoteDataMapping;
import org.skywalking.apm.collector.remote.grpc.data.GRPCRemoteData;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
/**
* @author peng-yongsheng
*/
public class NodeReferenceRemoteData extends GRPCRemoteData {
@Override public RemoteDataMapping mapping() {
return RemoteDataMapping.NodeReference;
}
@Override public RemoteData.Builder serialize(Data data) {
RemoteData.Builder builder = RemoteData.newBuilder();
builder.addDataStrings(data.getDataString(0));
builder.addDataIntegers(data.getDataInteger(0));
builder.addDataIntegers(data.getDataInteger(1));
builder.addDataStrings(data.getDataString(1));
builder.addDataIntegers(data.getDataInteger(2));
builder.addDataIntegers(data.getDataInteger(3));
builder.addDataIntegers(data.getDataInteger(4));
builder.addDataIntegers(data.getDataInteger(5));
builder.addDataIntegers(data.getDataInteger(6));
builder.addDataIntegers(data.getDataInteger(7));
builder.addDataLongs(data.getDataLong(0));
return builder;
}
@Override public Data deserialize(RemoteData remoteData) {
Data data = build(remoteData);
data.setDataInteger(0, remoteData.getDataIntegers(0));
data.setDataInteger(1, remoteData.getDataIntegers(1));
data.setDataString(1, remoteData.getDataStrings(1));
data.setDataInteger(2, remoteData.getDataIntegers(2));
data.setDataInteger(3, remoteData.getDataIntegers(3));
data.setDataInteger(4, remoteData.getDataIntegers(4));
data.setDataInteger(5, remoteData.getDataIntegers(5));
data.setDataInteger(6, remoteData.getDataIntegers(6));
data.setDataInteger(7, remoteData.getDataIntegers(7));
data.setDataLong(0, remoteData.getDataLongs(0));
return data;
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.remote.grpc.data.register;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.remote.RemoteDataMapping;
import org.skywalking.apm.collector.remote.grpc.data.GRPCRemoteData;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
/**
* @author peng-yongsheng
*/
public class ApplicationRemoteData extends GRPCRemoteData {
@Override public RemoteDataMapping mapping() {
return RemoteDataMapping.Application;
}
@Override public RemoteData.Builder serialize(Data data) {
RemoteData.Builder builder = RemoteData.newBuilder();
builder.addDataStrings(data.getDataString(0));
builder.addDataStrings(data.getDataString(1));
builder.addDataIntegers(data.getDataInteger(0));
return builder;
}
@Override public Data deserialize(RemoteData remoteData) {
Data data = build(remoteData);
data.setDataString(0, remoteData.getDataStrings(0));
data.setDataString(1, remoteData.getDataStrings(1));
data.setDataInteger(0, remoteData.getDataIntegers(0));
return data;
}
}

View File

@ -0,0 +1,58 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.remote.grpc.data.register;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.remote.RemoteDataMapping;
import org.skywalking.apm.collector.remote.grpc.data.GRPCRemoteData;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
/**
* @author peng-yongsheng
*/
public class InstanceRemoteData extends GRPCRemoteData {
@Override public RemoteDataMapping mapping() {
return RemoteDataMapping.Instance;
}
@Override public RemoteData.Builder serialize(Data data) {
RemoteData.Builder builder = RemoteData.newBuilder();
builder.addDataStrings(data.getDataString(0));
builder.addDataIntegers(data.getDataInteger(0));
builder.addDataStrings(data.getDataString(1));
builder.addDataIntegers(data.getDataInteger(1));
builder.addDataLongs(data.getDataLong(0));
builder.addDataLongs(data.getDataLong(1));
builder.addDataStrings(data.getDataString(2));
return builder;
}
@Override public Data deserialize(RemoteData remoteData) {
Data data = build(remoteData);
data.setDataString(0, remoteData.getDataStrings(0));
data.setDataInteger(0, remoteData.getDataIntegers(0));
data.setDataString(1, remoteData.getDataStrings(1));
data.setDataInteger(1, remoteData.getDataIntegers(1));
data.setDataLong(0, remoteData.getDataLongs(0));
data.setDataLong(1, remoteData.getDataLongs(1));
data.setDataString(2, remoteData.getDataStrings(2));
return data;
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.remote.grpc.data.register;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.remote.RemoteDataMapping;
import org.skywalking.apm.collector.remote.grpc.data.GRPCRemoteData;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
/**
* @author peng-yongsheng
*/
public class ServiceNameRemoteData extends GRPCRemoteData {
@Override public RemoteDataMapping mapping() {
return RemoteDataMapping.ServiceName;
}
@Override public RemoteData.Builder serialize(Data data) {
RemoteData.Builder builder = RemoteData.newBuilder();
builder.addDataStrings(data.getDataString(0));
builder.addDataStrings(data.getDataString(1));
builder.addDataIntegers(data.getDataInteger(0));
builder.addDataIntegers(data.getDataInteger(1));
return builder;
}
@Override public Data deserialize(RemoteData remoteData) {
Data data = build(remoteData);
data.setDataString(0, remoteData.getDataStrings(0));
data.setDataString(1, remoteData.getDataStrings(1));
data.setDataInteger(0, remoteData.getDataIntegers(0));
data.setDataInteger(1, remoteData.getDataIntegers(1));
return data;
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.remote.grpc.data.service;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.remote.RemoteDataMapping;
import org.skywalking.apm.collector.remote.grpc.data.GRPCRemoteData;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
/**
* @author peng-yongsheng
*/
public class ServiceEntryRemoteData extends GRPCRemoteData {
@Override public RemoteDataMapping mapping() {
return RemoteDataMapping.ServiceEntry;
}
@Override public RemoteData.Builder serialize(Data data) {
RemoteData.Builder builder = RemoteData.newBuilder();
builder.addDataStrings(data.getDataString(0));
builder.addDataIntegers(data.getDataInteger(0));
builder.addDataIntegers(data.getDataInteger(1));
builder.addDataStrings(data.getDataString(1));
builder.addDataLongs(data.getDataLong(0));
builder.addDataLongs(data.getDataLong(1));
return builder;
}
@Override public Data deserialize(RemoteData remoteData) {
Data data = build(remoteData);
data.setDataInteger(0, remoteData.getDataIntegers(0));
data.setDataInteger(1, remoteData.getDataIntegers(1));
data.setDataString(1, remoteData.getDataStrings(1));
data.setDataLong(0, remoteData.getDataLongs(0));
data.setDataLong(1, remoteData.getDataLongs(1));
return data;
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.remote.grpc.data.serviceref;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.remote.RemoteDataMapping;
import org.skywalking.apm.collector.remote.grpc.data.GRPCRemoteData;
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
/**
* @author peng-yongsheng
*/
public class ServiceReferenceRemoteData extends GRPCRemoteData {
@Override public RemoteDataMapping mapping() {
return RemoteDataMapping.ServiceReference;
}
@Override public RemoteData.Builder serialize(Data data) {
RemoteData.Builder builder = RemoteData.newBuilder();
builder.addDataStrings(data.getDataString(0));
builder.addDataIntegers(data.getDataInteger(0));
builder.addDataStrings(data.getDataString(1));
builder.addDataIntegers(data.getDataInteger(1));
builder.addDataStrings(data.getDataString(2));
builder.addDataIntegers(data.getDataInteger(2));
builder.addDataStrings(data.getDataString(3));
builder.addDataLongs(data.getDataLong(0));
builder.addDataLongs(data.getDataLong(1));
builder.addDataLongs(data.getDataLong(2));
builder.addDataLongs(data.getDataLong(3));
builder.addDataLongs(data.getDataLong(4));
builder.addDataLongs(data.getDataLong(5));
builder.addDataLongs(data.getDataLong(6));
builder.addDataLongs(data.getDataLong(7));
return builder;
}
@Override public Data deserialize(RemoteData remoteData) {
Data data = build(remoteData);
data.setDataInteger(0, remoteData.getDataIntegers(0));
data.setDataString(1, remoteData.getDataStrings(1));
data.setDataInteger(1, remoteData.getDataIntegers(1));
data.setDataString(2, remoteData.getDataStrings(2));
data.setDataInteger(2, remoteData.getDataIntegers(2));
data.setDataString(3, remoteData.getDataStrings(3));
data.setDataLong(0, remoteData.getDataLongs(0));
data.setDataLong(1, remoteData.getDataLongs(1));
data.setDataLong(2, remoteData.getDataLongs(2));
data.setDataLong(3, remoteData.getDataLongs(3));
data.setDataLong(4, remoteData.getDataLongs(4));
data.setDataLong(5, remoteData.getDataLongs(5));
data.setDataLong(6, remoteData.getDataLongs(6));
data.setDataLong(7, remoteData.getDataLongs(7));
return data;
}
}