diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteDataMapping.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteDataMapping.java new file mode 100644 index 000000000..865baa854 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteDataMapping.java @@ -0,0 +1,26 @@ +/* + * 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; + +/** + * @author peng-yongsheng + */ +public enum RemoteDataMapping { + InstPerformance +} diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteDataMappingContainer.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteDataMappingContainer.java new file mode 100644 index 000000000..60c3150a9 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteDataMappingContainer.java @@ -0,0 +1,39 @@ +/* + * 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; + +import java.util.HashMap; +import java.util.Map; +import org.skywalking.apm.collector.remote.service.SerializableAndDeserialize; + +/** + * @author peng-yongsheng + */ +public class RemoteDataMappingContainer { + + private Map mapping = new HashMap<>(); + + public void addMapping(SerializableAndDeserialize instance) { + mapping.put(instance.mapping().ordinal(), instance); + } + + public SerializableAndDeserialize get(Integer mappingId) { + return mapping.get(mappingId); + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteModule.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteModule.java index a4218ccdf..06edc0451 100644 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteModule.java +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteModule.java @@ -1,7 +1,25 @@ +/* + * 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; import org.skywalking.apm.collector.core.module.Module; -import org.skywalking.apm.collector.remote.service.DataService; +import org.skywalking.apm.collector.remote.service.RemoteServerService; /** * @author peng-yongsheng @@ -15,6 +33,6 @@ public class RemoteModule extends Module { } @Override public Class[] services() { - return new Class[] {DataService.class}; + return new Class[] {RemoteServerService.class}; } } diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataReceiver.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataReceiver.java index 16a09d65d..857c3bb42 100644 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataReceiver.java +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataReceiver.java @@ -1,8 +1,26 @@ +/* + * 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.service; /** * @author peng-yongsheng */ public interface DataReceiver { - void receive(Data data); + void receive(String roleName, Data data); } diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataReceiverRegisterListener.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataReceiverRegisterListener.java new file mode 100644 index 000000000..dcc9b4e3e --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataReceiverRegisterListener.java @@ -0,0 +1,35 @@ +/* + * 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.service; + +/** + * @author peng-yongsheng + */ +public class DataReceiverRegisterListener { + + private DataReceiver dataReceiver; + + public DataReceiver getDataReceiver() { + return dataReceiver; + } + + public void setDataReceiver(DataReceiver dataReceiver) { + this.dataReceiver = dataReceiver; + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataService.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataService.java deleted file mode 100644 index e5073e985..000000000 --- a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/DataService.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.skywalking.apm.collector.remote.service; - -import org.skywalking.apm.collector.core.module.Service; - -/** - * @author peng-yongsheng - */ -public interface DataService extends Service { - void send(Data data); - - void registerReceiver(DataReceiver receiver); -} diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteClient.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteClient.java new file mode 100644 index 000000000..f41ecd382 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteClient.java @@ -0,0 +1,28 @@ +/* + * 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.service; + +import org.skywalking.apm.collector.remote.RemoteDataMapping; + +/** + * @author peng-yongsheng + */ +public interface RemoteClient { + void send(String roleName, Data data, RemoteDataMapping mapping); +} diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteClientService.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteClientService.java new file mode 100644 index 000000000..109e9320f --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteClientService.java @@ -0,0 +1,28 @@ +/* + * 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.service; + +import org.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface RemoteClientService extends Service { + RemoteClient create(String host, int port); +} diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteServerService.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteServerService.java new file mode 100644 index 000000000..17b6febf3 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteServerService.java @@ -0,0 +1,28 @@ +/* + * 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.service; + +import org.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface RemoteServerService extends Service { + void registerReceiver(DataReceiver receiver); +} diff --git a/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/SerializableAndDeserialize.java b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/SerializableAndDeserialize.java new file mode 100644 index 000000000..c058d3df3 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/SerializableAndDeserialize.java @@ -0,0 +1,33 @@ +/* + * 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.service; + +import org.skywalking.apm.collector.remote.RemoteDataMapping; + +/** + * @author peng-yongsheng + */ +public interface SerializableAndDeserialize { + + RemoteDataMapping mapping(); + + Data deserialize(T remoteData); + + B serialize(Data data); +} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/pom.xml b/apm-collector/apm-collector-remote/collector-remote-grpc-define/pom.xml index 926be29de..fc41a17ea 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-define/pom.xml +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/pom.xml @@ -12,11 +12,66 @@ collector-remote-grpc-define jar + + UTF-8 + 1.4.0 + + org.skywalking collector-remote-define ${project.version} + + org.skywalking + collector-grpc-manager-define + ${project.version} + + + + + + kr.motd.maven + os-maven-plugin + 1.4.1.Final + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.4.3 + + ${project.build.sourceEncoding} + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.5.0 + + + com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier} + + grpc-java + io.grpc:protoc-gen-grpc-java:1.4.0:exe:${os.detected.classifier} + + + + + + compile + compile-custom + + + + + + \ No newline at end of file diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/RemoteModuleGRPCProvider.java b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/RemoteModuleGRPCProvider.java index 315a2486e..780e94f55 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/RemoteModuleGRPCProvider.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/RemoteModuleGRPCProvider.java @@ -1,18 +1,35 @@ package org.skywalking.apm.collector.remote.grpc; import java.util.Properties; +import org.skywalking.apm.collector.cluster.ClusterModule; +import org.skywalking.apm.collector.cluster.service.ModuleRegisterService; import org.skywalking.apm.collector.core.module.Module; +import org.skywalking.apm.collector.core.module.ModuleNotFoundException; import org.skywalking.apm.collector.core.module.ModuleProvider; import org.skywalking.apm.collector.core.module.ServiceNotProvidedException; +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.service.GRPCDataService; -import org.skywalking.apm.collector.remote.service.DataService; +import org.skywalking.apm.collector.remote.grpc.data.instance.InstPerformanceData; +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; +import org.skywalking.apm.collector.remote.service.DataReceiverRegisterListener; +import org.skywalking.apm.collector.remote.service.RemoteClientService; +import org.skywalking.apm.collector.remote.service.RemoteServerService; +import org.skywalking.apm.collector.server.Server; /** * @author peng-yongsheng */ public class RemoteModuleGRPCProvider extends ModuleProvider { + private static final String HOST = "host"; + private static final String PORT = "port"; + private RemoteDataMappingContainer container; + private final DataReceiverRegisterListener listener = new DataReceiverRegisterListener(); + @Override public String name() { return "gRPC"; } @@ -22,11 +39,25 @@ public class RemoteModuleGRPCProvider extends ModuleProvider { } @Override public void prepare(Properties config) throws ServiceNotProvidedException { - this.registerServiceImplementation(DataService.class, new GRPCDataService()); + container = loadMapping(); + this.registerServiceImplementation(RemoteServerService.class, new GRPCRemoteServerService(listener)); + this.registerServiceImplementation(RemoteClientService.class, new GRPCRemoteClientService(container)); } @Override public void start(Properties config) throws ServiceNotProvidedException { + String host = config.getProperty(HOST); + Integer port = (Integer)config.get(PORT); + try { + GRPCManagerService managerService = getManager().find(GRPCManagerModule.NAME).getService(GRPCManagerService.class); + Server gRPCServer = managerService.getOrCreateIfAbsent(host, port); + gRPCServer.addHandler(new RemoteCommonServiceHandler(container, listener)); + + ModuleRegisterService moduleRegisterService = getManager().find(ClusterModule.NAME).getService(ModuleRegisterService.class); + moduleRegisterService.register(RemoteModule.NAME, this.name(), new RemoteModuleGRPCRegistration(host, port)); + } catch (ModuleNotFoundException e) { + throw new ServiceNotProvidedException(e.getMessage()); + } } @Override public void notifyAfterCompleted() throws ServiceNotProvidedException { @@ -36,4 +67,10 @@ public class RemoteModuleGRPCProvider extends ModuleProvider { @Override public String[] requiredModules() { return new String[0]; } + + private RemoteDataMappingContainer loadMapping() { + RemoteDataMappingContainer container = new RemoteDataMappingContainer(); + container.addMapping(new InstPerformanceData()); + return container; + } } diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/RemoteModuleGRPCRegistration.java b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/RemoteModuleGRPCRegistration.java new file mode 100644 index 000000000..c8f5a0700 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/RemoteModuleGRPCRegistration.java @@ -0,0 +1,40 @@ +/* + * 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; + +import org.skywalking.apm.collector.cluster.ModuleRegistration; +import org.skywalking.apm.collector.core.util.Const; + +/** + * @author peng-yongsheng + */ +public class RemoteModuleGRPCRegistration extends ModuleRegistration { + + private final String host; + private final int port; + + public RemoteModuleGRPCRegistration(String host, int port) { + this.host = host; + this.port = port; + } + + @Override public Value buildValue() { + return new Value(host, port, Const.EMPTY_STRING); + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/data/GRPCData.java b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/data/GRPCData.java new file mode 100644 index 000000000..e17ef1287 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/data/GRPCData.java @@ -0,0 +1,33 @@ +/* + * 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; + +import org.skywalking.apm.collector.remote.grpc.proto.RemoteData; +import org.skywalking.apm.collector.remote.service.Data; +import org.skywalking.apm.collector.remote.service.SerializableAndDeserialize; + +/** + * @author peng-yongsheng + */ +public abstract class GRPCData implements SerializableAndDeserialize { + + protected Data build(RemoteData remoteData) { + return new Data(remoteData.getDataStrings(0), remoteData.getStringCapacity(), remoteData.getLongCapacity(), remoteData.getDoubleCapacity(), remoteData.getIntegerCapacity(), remoteData.getBooleanCapacity(), remoteData.getByteCapacity()); + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/data/instance/InstPerformanceData.java b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/data/instance/InstPerformanceData.java new file mode 100644 index 000000000..e840cc7d1 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/data/instance/InstPerformanceData.java @@ -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.instance; + +import org.skywalking.apm.collector.remote.RemoteDataMapping; +import org.skywalking.apm.collector.remote.grpc.data.GRPCData; +import org.skywalking.apm.collector.remote.grpc.proto.RemoteData; +import org.skywalking.apm.collector.remote.service.Data; + +/** + * @author peng-yongsheng + */ +public class InstPerformanceData extends GRPCData { + + @Override public RemoteDataMapping mapping() { + return RemoteDataMapping.InstPerformance; + } + + @Override public Data deserialize(RemoteData remoteData) { + Data data = build(remoteData); + data.setDataInteger(0, remoteData.getDataIntegers(0)); + data.setDataInteger(1, remoteData.getDataIntegers(1)); + data.setDataInteger(2, remoteData.getDataIntegers(2)); + data.setDataLong(0, remoteData.getDataLongs(0)); + data.setDataLong(1, remoteData.getDataLongs(1)); + return data; + } + + @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.addDataIntegers(data.getDataInteger(2)); + builder.addDataLongs(data.getDataLong(0)); + builder.addDataLongs(data.getDataLong(1)); + return builder; + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/handler/RemoteCommonServiceHandler.java b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/handler/RemoteCommonServiceHandler.java new file mode 100644 index 000000000..08f10000a --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/handler/RemoteCommonServiceHandler.java @@ -0,0 +1,64 @@ +/* + * 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.handler; + +import io.grpc.stub.StreamObserver; +import org.skywalking.apm.collector.remote.RemoteDataMappingContainer; +import org.skywalking.apm.collector.remote.grpc.proto.Empty; +import org.skywalking.apm.collector.remote.grpc.proto.RemoteCommonServiceGrpc; +import org.skywalking.apm.collector.remote.grpc.proto.RemoteData; +import org.skywalking.apm.collector.remote.grpc.proto.RemoteMessage; +import org.skywalking.apm.collector.remote.service.DataReceiverRegisterListener; +import org.skywalking.apm.collector.server.grpc.GRPCHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class RemoteCommonServiceHandler extends RemoteCommonServiceGrpc.RemoteCommonServiceImplBase implements GRPCHandler { + + private final Logger logger = LoggerFactory.getLogger(RemoteCommonServiceHandler.class); + + private final RemoteDataMappingContainer container; + private final DataReceiverRegisterListener listener; + + public RemoteCommonServiceHandler(RemoteDataMappingContainer container, DataReceiverRegisterListener listener) { + this.container = container; + this.listener = listener; + } + + @Override public StreamObserver call(StreamObserver responseObserver) { + return new StreamObserver() { + @Override public void onNext(RemoteMessage message) { + String roleName = message.getWorkerRole(); + RemoteData remoteData = message.getRemoteData(); + listener.getDataReceiver().receive(roleName, container.get(remoteData.getMappingId()).deserialize(remoteData)); + } + + @Override public void onError(Throwable throwable) { + logger.error(throwable.getMessage(), throwable); + } + + @Override public void onCompleted() { + responseObserver.onCompleted(); + } + }; + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCDataService.java b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCDataService.java deleted file mode 100644 index 402fd04ca..000000000 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCDataService.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.skywalking.apm.collector.remote.grpc.service; - -import org.skywalking.apm.collector.remote.service.Data; -import org.skywalking.apm.collector.remote.service.DataReceiver; -import org.skywalking.apm.collector.remote.service.DataService; - -/** - * @author peng-yongsheng - */ -public class GRPCDataService implements DataService { - - @Override public void send(Data data) { - - } - - @Override public void registerReceiver(DataReceiver receiver) { - - } -} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClient.java b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClient.java new file mode 100644 index 000000000..d8422bc79 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClient.java @@ -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.service; + +import io.grpc.stub.StreamObserver; +import org.skywalking.apm.collector.remote.RemoteDataMapping; +import org.skywalking.apm.collector.remote.RemoteDataMappingContainer; +import org.skywalking.apm.collector.remote.grpc.proto.RemoteData; +import org.skywalking.apm.collector.remote.grpc.proto.RemoteMessage; +import org.skywalking.apm.collector.remote.service.Data; +import org.skywalking.apm.collector.remote.service.RemoteClient; + +/** + * @author peng-yongsheng + */ +public class GRPCRemoteClient implements RemoteClient { + + private final RemoteDataMappingContainer container; + private final StreamObserver streamObserver; + + public GRPCRemoteClient(RemoteDataMappingContainer container, StreamObserver streamObserver) { + this.container = container; + this.streamObserver = streamObserver; + } + + @Override public void send(String roleName, Data data, RemoteDataMapping mapping) { + RemoteData remoteData = (RemoteData)container.get(mapping.ordinal()).serialize(data); + RemoteMessage.Builder builder = RemoteMessage.newBuilder(); + builder.setWorkerRole(roleName); + builder.setRemoteData(remoteData); + + streamObserver.onNext(builder.build()); + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClientService.java b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClientService.java new file mode 100644 index 000000000..cf1d41d7a --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteClientService.java @@ -0,0 +1,116 @@ +/* + * 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.service; + +import io.grpc.stub.StreamObserver; +import org.skywalking.apm.collector.client.ClientException; +import org.skywalking.apm.collector.client.grpc.GRPCClient; +import org.skywalking.apm.collector.remote.RemoteDataMappingContainer; +import org.skywalking.apm.collector.remote.grpc.proto.Empty; +import org.skywalking.apm.collector.remote.grpc.proto.RemoteCommonServiceGrpc; +import org.skywalking.apm.collector.remote.grpc.proto.RemoteMessage; +import org.skywalking.apm.collector.remote.service.RemoteClient; +import org.skywalking.apm.collector.remote.service.RemoteClientService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class GRPCRemoteClientService implements RemoteClientService { + + private final Logger logger = LoggerFactory.getLogger(GRPCRemoteClientService.class); + + private final RemoteDataMappingContainer container; + + public GRPCRemoteClientService(RemoteDataMappingContainer container) { + this.container = container; + } + + @Override public RemoteClient create(String host, int port) { + GRPCClient client = new GRPCClient(host, port); + try { + client.initialize(); + } catch (ClientException e) { + e.printStackTrace(); + } + RemoteCommonServiceGrpc.RemoteCommonServiceStub stub = RemoteCommonServiceGrpc.newStub(client.getChannel()); + StreamObserver streamObserver = createStreamObserver(stub); + return new GRPCRemoteClient(container, streamObserver); + } + + private StreamObserver createStreamObserver(RemoteCommonServiceGrpc.RemoteCommonServiceStub stub) { + StreamStatus status = new StreamStatus(false); + return stub.call(new StreamObserver() { + @Override public void onNext(Empty empty) { + } + + @Override public void onError(Throwable throwable) { + logger.error(throwable.getMessage(), throwable); + } + + @Override public void onCompleted() { + status.finished(); + } + }); + } + + class StreamStatus { + private volatile boolean status; + + public StreamStatus(boolean status) { + this.status = status; + } + + public boolean isFinish() { + return status; + } + + public void finished() { + this.status = true; + } + + /** + * @param maxTimeout max wait time, milliseconds. + */ + public void wait4Finish(long maxTimeout) { + long time = 0; + while (!status) { + if (time > maxTimeout) { + break; + } + try2Sleep(5); + time += 5; + } + } + + /** + * Try to sleep, and ignore the {@link InterruptedException} + * + * @param millis the length of time to sleep in milliseconds + */ + private void try2Sleep(long millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + + } + } + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteServerService.java b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteServerService.java new file mode 100644 index 000000000..93ea438ac --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteServerService.java @@ -0,0 +1,21 @@ +package org.skywalking.apm.collector.remote.grpc.service; + +import org.skywalking.apm.collector.remote.service.DataReceiver; +import org.skywalking.apm.collector.remote.service.DataReceiverRegisterListener; +import org.skywalking.apm.collector.remote.service.RemoteServerService; + +/** + * @author peng-yongsheng + */ +public class GRPCRemoteServerService implements RemoteServerService { + + private DataReceiverRegisterListener listener; + + public GRPCRemoteServerService(DataReceiverRegisterListener listener) { + this.listener = listener; + } + + @Override public void registerReceiver(DataReceiver receiver) { + listener.setDataReceiver(receiver); + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/proto/RemoteCommonService.proto b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/proto/RemoteCommonService.proto new file mode 100644 index 000000000..47e825bd8 --- /dev/null +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-define/src/main/proto/RemoteCommonService.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "org.skywalking.apm.collector.remote.grpc.proto"; + +service RemoteCommonService { + rpc call (stream RemoteMessage) returns (Empty) { + } +} + +message RemoteMessage { + string workerRole = 1; + RemoteData remoteData = 2; +} + +message RemoteData { + int32 mappingId = 1; + int32 stringCapacity = 2; + int32 longCapacity = 3; + int32 doubleCapacity = 4; + int32 integerCapacity = 5; + int32 byteCapacity = 6; + int32 booleanCapacity = 7; + repeated string dataStrings = 8; + repeated int64 dataLongs = 9; + repeated double dataDoubles = 10; + repeated int32 dataIntegers = 11; + repeated bytes dataBytes = 12; + repeated bool dataBooleans = 13; +} + +message Empty { +} \ No newline at end of file diff --git a/apm-collector/apm-collector-remote/pom.xml b/apm-collector/apm-collector-remote/pom.xml index 13b14772a..42c1efade 100644 --- a/apm-collector/apm-collector-remote/pom.xml +++ b/apm-collector/apm-collector-remote/pom.xml @@ -22,6 +22,11 @@ apm-collector-core ${project.version} + + org.skywalking + collector-cluster-define + ${project.version} + org.skywalking client-component diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageException.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageException.java index 396277d72..efb0cfeef 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageException.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageException.java @@ -1,3 +1,21 @@ +/* + * 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.storage; import org.skywalking.apm.collector.core.CollectorException; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/Attribute.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/Attribute.java new file mode 100644 index 000000000..8777f9270 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/Attribute.java @@ -0,0 +1,46 @@ +/* + * 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.storage.define; + +/** + * @author peng-yongsheng + */ +public class Attribute { + private final String name; + private final AttributeType type; + private final Operation operation; + + public Attribute(String name, AttributeType type, Operation operation) { + this.name = name; + this.type = type; + this.operation = operation; + } + + public String getName() { + return name; + } + + public AttributeType getType() { + return type; + } + + public Operation getOperation() { + return operation; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/AttributeType.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/AttributeType.java new file mode 100644 index 000000000..6727c87d1 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/AttributeType.java @@ -0,0 +1,26 @@ +/* + * 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.storage.define; + +/** + * @author peng-yongsheng + */ +public enum AttributeType { + STRING, LONG, DOUBLE, INTEGER, BYTE, BOOLEAN +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/CommonTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/CommonTable.java new file mode 100644 index 000000000..19d160b7c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/CommonTable.java @@ -0,0 +1,29 @@ +/* + * 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.storage.define; + +/** + * @author peng-yongsheng + */ +public class CommonTable { + public static final String TABLE_TYPE = "type"; + public static final String COLUMN_ID = "id"; + public static final String COLUMN_AGG = "agg"; + public static final String COLUMN_TIME_BUCKET = "time_bucket"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/DataDefine.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/DataDefine.java new file mode 100644 index 000000000..951ec9b27 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/DataDefine.java @@ -0,0 +1,107 @@ +/* + * 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.storage.define; + +import org.skywalking.apm.collector.remote.service.Data; + +/** + * @author peng-yongsheng + */ +public abstract class DataDefine { + private Attribute[] attributes; + private int stringCapacity; + private int longCapacity; + private int doubleCapacity; + private int integerCapacity; + private int booleanCapacity; + private int byteCapacity; + + public DataDefine() { + initial(); + } + + private void initial() { + attributes = new Attribute[initialCapacity()]; + attributeDefine(); + for (Attribute attribute : attributes) { + if (AttributeType.STRING.equals(attribute.getType())) { + stringCapacity++; + } else if (AttributeType.LONG.equals(attribute.getType())) { + longCapacity++; + } else if (AttributeType.DOUBLE.equals(attribute.getType())) { + doubleCapacity++; + } else if (AttributeType.INTEGER.equals(attribute.getType())) { + integerCapacity++; + } else if (AttributeType.BOOLEAN.equals(attribute.getType())) { + booleanCapacity++; + } else if (AttributeType.BYTE.equals(attribute.getType())) { + byteCapacity++; + } + } + } + + public final void addAttribute(int position, Attribute attribute) { + attributes[position] = attribute; + } + + protected abstract int initialCapacity(); + + protected abstract void attributeDefine(); + + public final Data build(String id) { + return new Data(id, stringCapacity, longCapacity, doubleCapacity, integerCapacity, booleanCapacity, byteCapacity); + } + + public void mergeData(Data newData, Data oldData) { + int stringPosition = 0; + int longPosition = 0; + int doublePosition = 0; + int integerPosition = 0; + int booleanPosition = 0; + int bytePosition = 0; + for (int i = 0; i < initialCapacity(); i++) { + Attribute attribute = attributes[i]; + if (AttributeType.STRING.equals(attribute.getType())) { + String stringData = attribute.getOperation().operate(newData.getDataString(stringPosition), oldData.getDataString(stringPosition)); + newData.setDataString(stringPosition, stringData); + stringPosition++; + } else if (AttributeType.LONG.equals(attribute.getType())) { + Long longData = attribute.getOperation().operate(newData.getDataLong(longPosition), oldData.getDataLong(longPosition)); + newData.setDataLong(longPosition, longData); + longPosition++; + } else if (AttributeType.DOUBLE.equals(attribute.getType())) { + Double doubleData = attribute.getOperation().operate(newData.getDataDouble(doublePosition), oldData.getDataDouble(doublePosition)); + newData.setDataDouble(doublePosition, doubleData); + doublePosition++; + } else if (AttributeType.INTEGER.equals(attribute.getType())) { + Integer integerData = attribute.getOperation().operate(newData.getDataInteger(integerPosition), oldData.getDataInteger(integerPosition)); + newData.setDataInteger(integerPosition, integerData); + integerPosition++; + } else if (AttributeType.BOOLEAN.equals(attribute.getType())) { + Boolean booleanData = attribute.getOperation().operate(newData.getDataBoolean(booleanPosition), oldData.getDataBoolean(booleanPosition)); + newData.setDataBoolean(booleanPosition, booleanData); + booleanPosition++; + } else if (AttributeType.BYTE.equals(attribute.getType())) { + byte[] byteData = attribute.getOperation().operate(newData.getDataBytes(bytePosition), oldData.getDataBytes(integerPosition)); + newData.setDataBytes(bytePosition, byteData); + bytePosition++; + } + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/Operation.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/Operation.java new file mode 100644 index 000000000..3f065027b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/Operation.java @@ -0,0 +1,36 @@ +/* + * 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.storage.define; + +/** + * @author peng-yongsheng + */ +public interface Operation { + String operate(String newValue, String oldValue); + + Long operate(Long newValue, Long oldValue); + + Double operate(Double newValue, Double oldValue); + + Integer operate(Integer newValue, Integer oldValue); + + Boolean operate(Boolean newValue, Boolean oldValue); + + byte[] operate(byte[] newValue, byte[] oldValue); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/Transform.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/Transform.java new file mode 100644 index 000000000..cf412f0f9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/Transform.java @@ -0,0 +1,30 @@ +/* + * 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.storage.define; + +import org.skywalking.apm.collector.remote.service.Data; + +/** + * @author peng-yongsheng + */ +public interface Transform { + Data toData(); + + T toSelf(Data data); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/operator/AddOperation.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/operator/AddOperation.java new file mode 100644 index 000000000..86ceebc9d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/operator/AddOperation.java @@ -0,0 +1,51 @@ +/* + * 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.storage.define.operator; + +import org.skywalking.apm.collector.storage.define.Operation; + +/** + * @author peng-yongsheng + */ +public class AddOperation implements Operation { + + @Override public String operate(String newValue, String oldValue) { + throw new UnsupportedOperationException("not support string addition operation"); + } + + @Override public Long operate(Long newValue, Long oldValue) { + return newValue + oldValue; + } + + @Override public Double operate(Double newValue, Double oldValue) { + return newValue + oldValue; + } + + @Override public Integer operate(Integer newValue, Integer oldValue) { + return newValue + oldValue; + } + + @Override public Boolean operate(Boolean newValue, Boolean oldValue) { + throw new UnsupportedOperationException("not support boolean addition operation"); + } + + @Override public byte[] operate(byte[] newValue, byte[] oldValue) { + throw new UnsupportedOperationException("not support byte addition operation"); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/operator/CoverOperation.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/operator/CoverOperation.java new file mode 100644 index 000000000..87fe344df --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/operator/CoverOperation.java @@ -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.storage.define.operator; + +import org.skywalking.apm.collector.storage.define.Operation; + +/** + * @author peng-yongsheng + */ +public class CoverOperation implements Operation { + @Override public String operate(String newValue, String oldValue) { + return newValue; + } + + @Override public Long operate(Long newValue, Long oldValue) { + return newValue; + } + + @Override public Double operate(Double newValue, Double oldValue) { + return newValue; + } + + @Override public Integer operate(Integer newValue, Integer oldValue) { + return newValue; + } + + @Override public Boolean operate(Boolean newValue, Boolean oldValue) { + return newValue; + } + + @Override public byte[] operate(byte[] newValue, byte[] oldValue) { + return newValue; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/operator/NonOperation.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/operator/NonOperation.java new file mode 100644 index 000000000..4930ddb0d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/operator/NonOperation.java @@ -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.storage.define.operator; + +import org.skywalking.apm.collector.storage.define.Operation; + +/** + * @author peng-yongsheng + */ +public class NonOperation implements Operation { + @Override public String operate(String newValue, String oldValue) { + return oldValue; + } + + @Override public Long operate(Long newValue, Long oldValue) { + return oldValue; + } + + @Override public Double operate(Double newValue, Double oldValue) { + return oldValue; + } + + @Override public Integer operate(Integer newValue, Integer oldValue) { + return oldValue; + } + + @Override public Boolean operate(Boolean newValue, Boolean oldValue) { + return oldValue; + } + + @Override public byte[] operate(byte[] newValue, byte[] oldValue) { + return oldValue; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/global/GlobalTraceTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/global/GlobalTraceTable.java new file mode 100644 index 000000000..ff52f9400 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/global/GlobalTraceTable.java @@ -0,0 +1,30 @@ +/* + * 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.storage.table.global; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class GlobalTraceTable extends CommonTable { + public static final String TABLE = "global_trace"; + public static final String COLUMN_SEGMENT_ID = "segment_id"; + public static final String COLUMN_GLOBAL_TRACE_ID = "global_trace_id"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/instance/InstPerformanceTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/instance/InstPerformanceTable.java new file mode 100644 index 000000000..203fc5669 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/instance/InstPerformanceTable.java @@ -0,0 +1,32 @@ +/* + * 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.storage.table.instance; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class InstPerformanceTable extends CommonTable { + public static final String TABLE = "instance_performance"; + public static final String COLUMN_APPLICATION_ID = "application_id"; + public static final String COLUMN_INSTANCE_ID = "instance_id"; + public static final String COLUMN_CALLS = "calls"; + public static final String COLUMN_COST_TOTAL = "cost_total"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/CpuMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/CpuMetricTable.java new file mode 100644 index 000000000..3e47a210d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/CpuMetricTable.java @@ -0,0 +1,30 @@ +/* + * 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.storage.table.jvm; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class CpuMetricTable extends CommonTable { + public static final String TABLE = "cpu_metric"; + public static final String COLUMN_INSTANCE_ID = "instance_id"; + public static final String COLUMN_USAGE_PERCENT = "usage_percent"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/GCMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/GCMetricTable.java new file mode 100644 index 000000000..00007b552 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/GCMetricTable.java @@ -0,0 +1,32 @@ +/* + * 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.storage.table.jvm; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class GCMetricTable extends CommonTable { + public static final String TABLE = "gc_metric"; + public static final String COLUMN_INSTANCE_ID = "instance_id"; + public static final String COLUMN_PHRASE = "phrase"; + public static final String COLUMN_COUNT = "count"; + public static final String COLUMN_TIME = "time"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/MemoryMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/MemoryMetricTable.java new file mode 100644 index 000000000..0cbd60764 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/MemoryMetricTable.java @@ -0,0 +1,34 @@ +/* + * 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.storage.table.jvm; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class MemoryMetricTable extends CommonTable { + public static final String TABLE = "memory_metric"; + public static final String COLUMN_APPLICATION_INSTANCE_ID = "application_instance_id"; + public static final String COLUMN_IS_HEAP = "is_heap"; + public static final String COLUMN_INIT = "init"; + public static final String COLUMN_MAX = "max"; + public static final String COLUMN_USED = "used"; + public static final String COLUMN_COMMITTED = "committed"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetricTable.java new file mode 100644 index 000000000..fc5915876 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/jvm/MemoryPoolMetricTable.java @@ -0,0 +1,34 @@ +/* + * 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.storage.table.jvm; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMetricTable extends CommonTable { + public static final String TABLE = "memory_pool_metric"; + public static final String COLUMN_INSTANCE_ID = "instance_id"; + public static final String COLUMN_POOL_TYPE = "pool_type"; + public static final String COLUMN_INIT = "init"; + public static final String COLUMN_MAX = "max"; + public static final String COLUMN_USED = "used"; + public static final String COLUMN_COMMITTED = "committed"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/node/NodeComponentTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/node/NodeComponentTable.java new file mode 100644 index 000000000..3693b2302 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/node/NodeComponentTable.java @@ -0,0 +1,32 @@ +/* + * 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.storage.table.node; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class NodeComponentTable extends CommonTable { + public static final String TABLE = "node_component"; + public static final String COLUMN_COMPONENT_ID = "component_id"; + public static final String COLUMN_COMPONENT_NAME = "component_name"; + public static final String COLUMN_PEER = "peer"; + public static final String COLUMN_PEER_ID = "peer_id"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/node/NodeMappingTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/node/NodeMappingTable.java new file mode 100644 index 000000000..bad6ce6cc --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/node/NodeMappingTable.java @@ -0,0 +1,31 @@ +/* + * 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.storage.table.node; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class NodeMappingTable extends CommonTable { + public static final String TABLE = "node_mapping"; + public static final String COLUMN_APPLICATION_ID = "application_id"; + public static final String COLUMN_ADDRESS_ID = "address_id"; + public static final String COLUMN_ADDRESS = "address"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/noderef/NodeReferenceTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/noderef/NodeReferenceTable.java new file mode 100644 index 000000000..2b47af19a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/noderef/NodeReferenceTable.java @@ -0,0 +1,37 @@ +/* + * 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.storage.table.noderef; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class NodeReferenceTable extends CommonTable { + public static final String TABLE = "node_reference"; + public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; + public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; + public static final String COLUMN_BEHIND_PEER = "behind_peer"; + public static final String COLUMN_S1_LTE = "s1_lte"; + public static final String COLUMN_S3_LTE = "s3_lte"; + public static final String COLUMN_S5_LTE = "s5_lte"; + public static final String COLUMN_S5_GT = "s5_gt"; + public static final String COLUMN_SUMMARY = "summary"; + public static final String COLUMN_ERROR = "error"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ApplicationTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ApplicationTable.java new file mode 100644 index 000000000..d8ed1184b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ApplicationTable.java @@ -0,0 +1,30 @@ +/* + * 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.storage.table.register; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationTable extends CommonTable { + public static final String TABLE = "application"; + public static final String COLUMN_APPLICATION_CODE = "application_code"; + public static final String COLUMN_APPLICATION_ID = "application_id"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/InstanceTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/InstanceTable.java new file mode 100644 index 000000000..bda607499 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/InstanceTable.java @@ -0,0 +1,34 @@ +/* + * 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.storage.table.register; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class InstanceTable extends CommonTable { + public static final String TABLE = "instance"; + public static final String COLUMN_APPLICATION_ID = "application_id"; + public static final String COLUMN_AGENT_UUID = "agent_uuid"; + public static final String COLUMN_REGISTER_TIME = "register_time"; + public static final String COLUMN_INSTANCE_ID = "instance_id"; + public static final String COLUMN_HEARTBEAT_TIME = "heartbeat_time"; + public static final String COLUMN_OS_INFO = "os_info"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ServiceNameTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ServiceNameTable.java new file mode 100644 index 000000000..b9c326252 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ServiceNameTable.java @@ -0,0 +1,31 @@ +/* + * 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.storage.table.register; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class ServiceNameTable extends CommonTable { + public static final String TABLE = "service_name"; + public static final String COLUMN_SERVICE_NAME = "service_name"; + public static final String COLUMN_APPLICATION_ID = "application_id"; + public static final String COLUMN_SERVICE_ID = "service_id"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/segment/SegmentCostTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/segment/SegmentCostTable.java new file mode 100644 index 000000000..a1656a6a9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/segment/SegmentCostTable.java @@ -0,0 +1,35 @@ +/* + * 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.storage.table.segment; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class SegmentCostTable extends CommonTable { + public static final String TABLE = "segment_cost"; + public static final String COLUMN_SEGMENT_ID = "segment_id"; + public static final String COLUMN_APPLICATION_ID = "application_id"; + public static final String COLUMN_START_TIME = "start_time"; + public static final String COLUMN_END_TIME = "end_time"; + public static final String COLUMN_SERVICE_NAME = "service_name"; + public static final String COLUMN_COST = "cost"; + public static final String COLUMN_IS_ERROR = "is_error"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/segment/SegmentTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/segment/SegmentTable.java new file mode 100644 index 000000000..29a933cb5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/segment/SegmentTable.java @@ -0,0 +1,29 @@ +/* + * 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.storage.table.segment; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class SegmentTable extends CommonTable { + public static final String TABLE = "segment"; + public static final String COLUMN_DATA_BINARY = "data_binary"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/service/ServiceEntryTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/service/ServiceEntryTable.java new file mode 100644 index 000000000..402a05c9b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/service/ServiceEntryTable.java @@ -0,0 +1,33 @@ +/* + * 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.storage.table.service; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class ServiceEntryTable extends CommonTable { + public static final String TABLE = "service_entry"; + public static final String COLUMN_APPLICATION_ID = "application_id"; + public static final String COLUMN_ENTRY_SERVICE_ID = "entry_service_id"; + public static final String COLUMN_ENTRY_SERVICE_NAME = "entry_service_name"; + public static final String COLUMN_REGISTER_TIME = "register_time"; + public static final String COLUMN_NEWEST_TIME = "newest_time"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/serviceref/ServiceReferenceTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/serviceref/ServiceReferenceTable.java new file mode 100644 index 000000000..587d66560 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/serviceref/ServiceReferenceTable.java @@ -0,0 +1,41 @@ +/* + * 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.storage.table.serviceref; + +import org.skywalking.apm.collector.storage.define.CommonTable; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceTable extends CommonTable { + public static final String TABLE = "service_reference"; + public static final String COLUMN_ENTRY_SERVICE_ID = "entry_service_id"; + public static final String COLUMN_ENTRY_SERVICE_NAME = "entry_service_name"; + public static final String COLUMN_FRONT_SERVICE_ID = "front_service_id"; + public static final String COLUMN_FRONT_SERVICE_NAME = "front_service_name"; + public static final String COLUMN_BEHIND_SERVICE_ID = "behind_service_id"; + public static final String COLUMN_BEHIND_SERVICE_NAME = "behind_service_name"; + public static final String COLUMN_S1_LTE = "s1_lte"; + public static final String COLUMN_S3_LTE = "s3_lte"; + public static final String COLUMN_S5_LTE = "s5_lte"; + public static final String COLUMN_S5_GT = "s5_gt"; + public static final String COLUMN_SUMMARY = "summary"; + public static final String COLUMN_COST_SUMMARY = "cost_summary"; + public static final String COLUMN_ERROR = "error"; +} diff --git a/apm-collector/apm-collector-storage/pom.xml b/apm-collector/apm-collector-storage/pom.xml index 09df89081..57d4a3c65 100644 --- a/apm-collector/apm-collector-storage/pom.xml +++ b/apm-collector/apm-collector-storage/pom.xml @@ -28,5 +28,10 @@ client-component ${project.version} + + org.skywalking + collector-remote-define + ${project.version} + \ No newline at end of file diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java index e6d7e15a2..45da0f03f 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java @@ -67,7 +67,7 @@ public class UIModuleJettyProvider extends ModuleProvider { jettyServer.addHandler(new ApplicationsGetHandler()); ModuleRegisterService moduleRegisterService = getManager().find(ClusterModule.NAME).getService(ModuleRegisterService.class); - moduleRegisterService.register(UIModule.NAME, this.name(), new UIModuleRegistration(host, port, contextPath)); + moduleRegisterService.register(UIModule.NAME, this.name(), new UIModuleJettyRegistration(host, port, contextPath)); UIJettyNamingListener namingListener = new UIJettyNamingListener(); ModuleListenerService moduleListenerService = getManager().find(ClusterModule.NAME).getService(ModuleListenerService.class); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleRegistration.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyRegistration.java similarity index 88% rename from apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleRegistration.java rename to apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyRegistration.java index ad3a67b73..7fe4187c4 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleRegistration.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyRegistration.java @@ -23,13 +23,13 @@ import org.skywalking.apm.collector.cluster.ModuleRegistration; /** * @author peng-yongsheng */ -public class UIModuleRegistration extends ModuleRegistration { +public class UIModuleJettyRegistration extends ModuleRegistration { private final String host; private final int port; private final String contextPath; - public UIModuleRegistration(String host, int port, String contextPath) { + public UIModuleJettyRegistration(String host, int port, String contextPath) { this.host = host; this.port = port; this.contextPath = contextPath;