From e77043605b44b34737f0547e0f4a96e6cc5d287d Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Mon, 18 Dec 2017 19:33:09 +0800 Subject: [PATCH] Analysis register module finished. --- .../register/define/graph/GraphIdDefine.java | 28 +++++++++++ .../register/define/graph/WorkerIdDefine.java | 31 +++++++++++++ .../register-provider/pom.xml | 15 ++++++ .../AnalysisRegisterModuleProvider.java | 10 ++++ .../register/ApplicationRegisterGraph.java | 46 +++++++++++++++++++ .../ApplicationRegisterRemoteWorker.java | 14 +++--- .../ApplicationRegisterSerialWorker.java | 26 +++++------ .../provider/register}/IdAutoIncrement.java | 2 +- .../register/InstanceRegisterGraph.java | 46 +++++++++++++++++++ .../InstanceRegisterRemoteWorker.java | 12 ++--- .../InstanceRegisterSerialWorker.java | 15 +++--- .../register/ServiceNameRegisterGraph.java | 46 +++++++++++++++++++ .../ServiceNameRegisterRemoteWorker.java | 12 ++--- .../ServiceNameRegisterSerialWorker.java | 20 ++++---- .../service/ApplicationIDService.java | 4 +- .../provider/service/InstanceIDService.java | 4 +- .../provider/service/ServiceNameService.java | 4 +- .../base/AbstractRemoteWorkerProvider.java | 2 +- 18 files changed, 280 insertions(+), 57 deletions(-) create mode 100644 apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/GraphIdDefine.java create mode 100644 apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/WorkerIdDefine.java create mode 100644 apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterGraph.java rename apm-collector/{apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker => apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider}/register/ApplicationRegisterRemoteWorker.java (91%) rename apm-collector/{apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker => apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider}/register/ApplicationRegisterSerialWorker.java (91%) rename apm-collector/{apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream => apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register}/IdAutoIncrement.java (94%) create mode 100644 apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/InstanceRegisterGraph.java rename apm-collector/{apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker => apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider}/register/InstanceRegisterRemoteWorker.java (91%) rename apm-collector/{apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker => apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider}/register/InstanceRegisterSerialWorker.java (92%) create mode 100644 apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterGraph.java rename apm-collector/{apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker => apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider}/register/ServiceNameRegisterRemoteWorker.java (91%) rename apm-collector/{apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker => apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider}/register/ServiceNameRegisterSerialWorker.java (91%) diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/GraphIdDefine.java b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/GraphIdDefine.java new file mode 100644 index 000000000..787c18931 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/GraphIdDefine.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.analysis.register.define.graph; + +/** + * @author peng-yongsheng + */ +public class GraphIdDefine { + public static final int APPLICATION_REGISTER_GRAPH_ID = 200; + public static final int INSTANCE_REGISTER_GRAPH_ID = 201; + public static final int SERVICE_NAME_REGISTER_GRAPH_ID = 202; +} diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/WorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/WorkerIdDefine.java new file mode 100644 index 000000000..b16dfc0ae --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/graph/WorkerIdDefine.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.analysis.register.define.graph; + +/** + * @author peng-yongsheng + */ +public class WorkerIdDefine { + public static final int APPLICATION_REGISTER_REMOTE_WORKER = 200; + public static final int APPLICATION_REGISTER_SERIAL_WORKER = 201; + public static final int INSTANCE_REGISTER_REMOTE_WORKER = 202; + public static final int INSTANCE_REGISTER_SERIAL_WORKER = 203; + public static final int SERVICE_NAME_REGISTER_REMOTE_WORKER = 204; + public static final int SERVICE_NAME_REGISTER_SERIAL_WORKER = 205; +} diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/pom.xml b/apm-collector/apm-collector-analysis/analysis-register/register-provider/pom.xml index 5c23d3c7c..80ee62ebf 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/pom.xml +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/pom.xml @@ -36,5 +36,20 @@ register-define ${project.version} + + org.apache.skywalking + collector-cache-define + ${project.version} + + + org.apache.skywalking + collector-storage-define + ${project.version} + + + org.apache.skywalking + analysis-worker-model + ${project.version} + \ No newline at end of file diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/AnalysisRegisterModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/AnalysisRegisterModuleProvider.java index 6d602ce31..269c2e2d1 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/AnalysisRegisterModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/AnalysisRegisterModuleProvider.java @@ -23,6 +23,9 @@ import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegi import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService; import org.apache.skywalking.apm.collector.analysis.register.define.service.IInstanceIDService; import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService; +import org.apache.skywalking.apm.collector.analysis.register.provider.register.ApplicationRegisterGraph; +import org.apache.skywalking.apm.collector.analysis.register.provider.register.InstanceRegisterGraph; +import org.apache.skywalking.apm.collector.analysis.register.provider.register.ServiceNameRegisterGraph; import org.apache.skywalking.apm.collector.analysis.register.provider.service.ApplicationIDService; import org.apache.skywalking.apm.collector.analysis.register.provider.service.InstanceIDService; import org.apache.skywalking.apm.collector.analysis.register.provider.service.ServiceNameService; @@ -52,7 +55,14 @@ public class AnalysisRegisterModuleProvider extends ModuleProvider { } @Override public void start(Properties config) throws ServiceNotProvidedException { + ApplicationRegisterGraph applicationRegisterGraph = new ApplicationRegisterGraph(getManager()); + applicationRegisterGraph.create(); + InstanceRegisterGraph instanceRegisterGraph = new InstanceRegisterGraph(getManager()); + instanceRegisterGraph.create(); + + ServiceNameRegisterGraph serviceNameRegisterGraph = new ServiceNameRegisterGraph(getManager()); + serviceNameRegisterGraph.create(); } @Override public void notifyAfterCompleted() throws ServiceNotProvidedException { diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterGraph.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterGraph.java new file mode 100644 index 000000000..2ea8b37f7 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterGraph.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.analysis.register.provider.register; + +import org.apache.skywalking.apm.collector.analysis.register.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.core.graph.GraphManager; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.remote.RemoteModule; +import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; +import org.apache.skywalking.apm.collector.storage.table.register.Application; + +/** + * @author peng-yongsheng + */ +public class ApplicationRegisterGraph { + + private final ModuleManager moduleManager; + + public ApplicationRegisterGraph(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + public void create() { + RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); + + GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.APPLICATION_REGISTER_GRAPH_ID, Application.class) + .addNode(new ApplicationRegisterRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.APPLICATION_REGISTER_GRAPH_ID).create(null)) + .addNext(new ApplicationRegisterSerialWorker.Factory(moduleManager).create(null)); + } +} diff --git a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker/register/ApplicationRegisterRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterRemoteWorker.java similarity index 91% rename from apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker/register/ApplicationRegisterRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterRemoteWorker.java index 757cfc991..4b8cba545 100644 --- a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker/register/ApplicationRegisterRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ApplicationRegisterRemoteWorker.java @@ -16,16 +16,16 @@ * */ +package org.apache.skywalking.apm.collector.analysis.register.provider.register; -package org.apache.skywalking.apm.collector.agent.stream.worker.register; - +import org.apache.skywalking.apm.collector.analysis.register.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; -import org.apache.skywalking.apm.collector.storage.table.register.Application; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider; import org.apache.skywalking.apm.collector.remote.service.Selector; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; +import org.apache.skywalking.apm.collector.storage.table.register.Application; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +41,7 @@ public class ApplicationRegisterRemoteWorker extends AbstractRemoteWorker { - public Factory(ModuleManager moduleManager, QueueCreatorService queueCreatorService) { - super(moduleManager, queueCreatorService); + public Factory(ModuleManager moduleManager) { + super(moduleManager); } @Override public ApplicationRegisterSerialWorker workerInstance(ModuleManager moduleManager) { diff --git a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/IdAutoIncrement.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/IdAutoIncrement.java similarity index 94% rename from apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/IdAutoIncrement.java rename to apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/IdAutoIncrement.java index c54cca5dd..b41067777 100644 --- a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/IdAutoIncrement.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/IdAutoIncrement.java @@ -17,7 +17,7 @@ */ -package org.apache.skywalking.apm.collector.agent.stream; +package org.apache.skywalking.apm.collector.analysis.register.provider.register; /** * @author peng-yongsheng diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/InstanceRegisterGraph.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/InstanceRegisterGraph.java new file mode 100644 index 000000000..0fbeb0c3b --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/InstanceRegisterGraph.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.analysis.register.provider.register; + +import org.apache.skywalking.apm.collector.analysis.register.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.core.graph.GraphManager; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.remote.RemoteModule; +import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; +import org.apache.skywalking.apm.collector.storage.table.register.Instance; + +/** + * @author peng-yongsheng + */ +public class InstanceRegisterGraph { + + private final ModuleManager moduleManager; + + public InstanceRegisterGraph(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + public void create() { + RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); + + GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.INSTANCE_REGISTER_GRAPH_ID, Instance.class) + .addNode(new InstanceRegisterRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.INSTANCE_REGISTER_GRAPH_ID).create(null)) + .addNext(new InstanceRegisterSerialWorker.Factory(moduleManager).create(null)); + } +} diff --git a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker/register/InstanceRegisterRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/InstanceRegisterRemoteWorker.java similarity index 91% rename from apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker/register/InstanceRegisterRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/InstanceRegisterRemoteWorker.java index 77a4d1127..e37286037 100644 --- a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker/register/InstanceRegisterRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/InstanceRegisterRemoteWorker.java @@ -16,16 +16,16 @@ * */ +package org.apache.skywalking.apm.collector.analysis.register.provider.register; -package org.apache.skywalking.apm.collector.agent.stream.worker.register; - +import org.apache.skywalking.apm.collector.analysis.register.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; import org.apache.skywalking.apm.collector.remote.service.Selector; import org.apache.skywalking.apm.collector.storage.table.register.Instance; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +37,7 @@ public class InstanceRegisterRemoteWorker extends AbstractRemoteWorker { - public Factory(ModuleManager moduleManager, QueueCreatorService queueCreatorService) { - super(moduleManager, queueCreatorService); + public Factory(ModuleManager moduleManager) { + super(moduleManager); } @Override public InstanceRegisterSerialWorker workerInstance(ModuleManager moduleManager) { diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterGraph.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterGraph.java new file mode 100644 index 000000000..5badae954 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterGraph.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.collector.analysis.register.provider.register; + +import org.apache.skywalking.apm.collector.analysis.register.define.graph.GraphIdDefine; +import org.apache.skywalking.apm.collector.core.graph.GraphManager; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.remote.RemoteModule; +import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; + +/** + * @author peng-yongsheng + */ +public class ServiceNameRegisterGraph { + + private final ModuleManager moduleManager; + + public ServiceNameRegisterGraph(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + public void create() { + RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); + + GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.SERVICE_NAME_REGISTER_GRAPH_ID, ServiceName.class) + .addNode(new ServiceNameRegisterRemoteWorker.Factory(moduleManager, remoteSenderService, GraphIdDefine.SERVICE_NAME_REGISTER_GRAPH_ID).create(null)) + .addNext(new ServiceNameRegisterSerialWorker.Factory(moduleManager).create(null)); + } +} diff --git a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker/register/ServiceNameRegisterRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterRemoteWorker.java similarity index 91% rename from apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker/register/ServiceNameRegisterRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterRemoteWorker.java index 053951eb0..ecb77da08 100644 --- a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/apache/skywalking/apm/collector/agent/stream/worker/register/ServiceNameRegisterRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/ServiceNameRegisterRemoteWorker.java @@ -16,16 +16,16 @@ * */ +package org.apache.skywalking.apm.collector.analysis.register.provider.register; -package org.apache.skywalking.apm.collector.agent.stream.worker.register; - +import org.apache.skywalking.apm.collector.analysis.register.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider; import org.apache.skywalking.apm.collector.remote.service.Selector; import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +41,7 @@ public class ServiceNameRegisterRemoteWorker extends AbstractRemoteWorker { - public Factory(ModuleManager moduleManager, QueueCreatorService queueCreatorService) { - super(moduleManager, queueCreatorService); + public Factory(ModuleManager moduleManager) { + super(moduleManager); } @Override public ServiceNameRegisterSerialWorker workerInstance(ModuleManager moduleManager) { diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ApplicationIDService.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ApplicationIDService.java index 884af29b9..58e6a73e9 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ApplicationIDService.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ApplicationIDService.java @@ -18,10 +18,12 @@ package org.apache.skywalking.apm.collector.analysis.register.provider.service; +import org.apache.skywalking.apm.collector.analysis.register.define.graph.GraphIdDefine; import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService; import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.core.graph.Graph; +import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.table.register.Application; @@ -45,7 +47,7 @@ public class ApplicationIDService implements IApplicationIDService { private Graph getApplicationRegisterGraph() { if (ObjectUtils.isEmpty(applicationRegisterGraph)) { -// this.applicationRegisterGraph = GraphManager.INSTANCE.createIfAbsent(RegisterStreamGraphDefine.APPLICATION_REGISTER_GRAPH_ID, Application.class); + this.applicationRegisterGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.APPLICATION_REGISTER_GRAPH_ID, Application.class); } return this.applicationRegisterGraph; } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/InstanceIDService.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/InstanceIDService.java index e239f3717..38a83e782 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/InstanceIDService.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/InstanceIDService.java @@ -18,10 +18,12 @@ package org.apache.skywalking.apm.collector.analysis.register.provider.service; +import org.apache.skywalking.apm.collector.analysis.register.define.graph.GraphIdDefine; import org.apache.skywalking.apm.collector.analysis.register.define.service.IInstanceIDService; import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService; import org.apache.skywalking.apm.collector.core.graph.Graph; +import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; @@ -55,7 +57,7 @@ public class InstanceIDService implements IInstanceIDService { private Graph getInstanceRegisterGraph() { if (ObjectUtils.isEmpty(instanceRegisterGraph)) { -// this.instanceRegisterGraph = GraphManager.INSTANCE.createIfAbsent(RegisterStreamGraphDefine.INSTANCE_REGISTER_GRAPH_ID, Instance.class); + this.instanceRegisterGraph = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.INSTANCE_REGISTER_GRAPH_ID, Instance.class); } return instanceRegisterGraph; } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ServiceNameService.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ServiceNameService.java index a9d8f304b..7e85e77ad 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ServiceNameService.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/ServiceNameService.java @@ -18,10 +18,12 @@ package org.apache.skywalking.apm.collector.analysis.register.provider.service; +import org.apache.skywalking.apm.collector.analysis.register.define.graph.GraphIdDefine; import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService; import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cache.service.ServiceIdCacheService; import org.apache.skywalking.apm.collector.core.graph.Graph; +import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; @@ -52,7 +54,7 @@ public class ServiceNameService implements IServiceNameService { private Graph getServiceNameRegisterGraph() { if (ObjectUtils.isEmpty(serviceNameRegisterGraph)) { -// this.serviceNameRegisterGraph = GraphManager.INSTANCE.createIfAbsent(RegisterStreamGraphDefine.SERVICE_NAME_REGISTER_GRAPH_ID, ServiceName.class); + this.serviceNameRegisterGraph = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.SERVICE_NAME_REGISTER_GRAPH_ID, ServiceName.class); } return serviceNameRegisterGraph; } diff --git a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorkerProvider.java b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorkerProvider.java index 899f3ffc4..0742bbf6e 100644 --- a/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorkerProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-worker-model/src/main/java/org/apache/skywalking/apm/collector/analysis/worker/model/base/AbstractRemoteWorkerProvider.java @@ -48,7 +48,7 @@ public abstract class AbstractRemoteWorkerProvider create(WorkerCreateListener workerCreateListener) { WORKER_TYPE remoteWorker = workerInstance(getModuleManager()); workerCreateListener.addWorker(remoteWorker); return new RemoteWorkerRef<>(remoteWorker, remoteSenderService, graphId);