Instance mapping pyramid aggregate.

This commit is contained in:
peng-yongsheng 2018-01-07 20:58:36 +08:00
parent b18df84d64
commit 7effeccc5b
28 changed files with 727 additions and 136 deletions

View File

@ -82,6 +82,16 @@ public class MetricWorkerIdDefine {
public static final int APPLICATION_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4607;
public static final int APPLICATION_MONTH_METRIC_TRANSFORM_NODE_ID = 4608;
public static final int INSTANCE_MINUTE_MAPPING_AGGREGATION_WORKER_ID = 4700;
public static final int INSTANCE_MINUTE_MAPPING_REMOTE_WORKER_ID = 4701;
public static final int INSTANCE_MINUTE_MAPPING_PERSISTENCE_WORKER_ID = 4702;
public static final int INSTANCE_HOUR_MAPPING_PERSISTENCE_WORKER_ID = 4703;
public static final int INSTANCE_HOUR_MAPPING_TRANSFORM_NODE_ID = 4704;
public static final int INSTANCE_DAY_MAPPING_PERSISTENCE_WORKER_ID = 4705;
public static final int INSTANCE_DAY_MAPPING_TRANSFORM_NODE_ID = 4706;
public static final int INSTANCE_MONTH_MAPPING_PERSISTENCE_WORKER_ID = 4707;
public static final int INSTANCE_MONTH_MAPPING_TRANSFORM_NODE_ID = 4708;
public static final int APPLICATION_COMPONENT_AGGREGATION_WORKER_ID = 418;
public static final int APPLICATION_COMPONENT_REMOTE_WORKER_ID = 419;
public static final int APPLICATION_COMPONENT_PERSISTENCE_WORKER_ID = 420;
@ -103,7 +113,4 @@ public class MetricWorkerIdDefine {
public static final int INSTANCE_METRIC_GRAPH_BRIDGE_WORKER_ID = 432;
public static final int APPLICATION_METRIC_GRAPH_BRIDGE_WORKER_ID = 433;
public static final int INSTANCE_MAPPING_AGGREGATION_WORKER_ID = 434;
public static final int INSTANCE_MAPPING_REMOTE_WORKER_ID = 435;
public static final int INSTANCE_MAPPING_PERSISTENCE_WORKER_ID = 436;
}

View File

@ -28,8 +28,8 @@ import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.appli
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric.ApplicationReferenceMetricGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceSpanListener;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.InstanceMappingGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.InstanceMappingSpanListener;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingSpanListener;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric.InstanceMetricGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.refmetric.InstanceReferenceMetricGraph;
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentCostGraph;

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance;
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider;
@ -34,7 +34,7 @@ public class InstanceMappingAggregationWorker extends AggregationWorker<Instance
}
@Override public int id() {
return MetricWorkerIdDefine.INSTANCE_MAPPING_AGGREGATION_WORKER_ID;
return MetricWorkerIdDefine.INSTANCE_MINUTE_MAPPING_AGGREGATION_WORKER_ID;
}
public static class Factory extends AbstractLocalAsyncWorkerProvider<InstanceMapping, InstanceMapping, InstanceMappingAggregationWorker> {

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance;
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
@ -24,20 +24,20 @@ import org.apache.skywalking.apm.collector.analysis.worker.model.impl.Persistenc
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMappingPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingDayPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public class InstanceMappingPersistenceWorker extends PersistenceWorker<InstanceMapping> {
public class InstanceMappingDayPersistenceWorker extends PersistenceWorker<InstanceMapping> {
InstanceMappingPersistenceWorker(ModuleManager moduleManager) {
InstanceMappingDayPersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return MetricWorkerIdDefine.INSTANCE_MAPPING_PERSISTENCE_WORKER_ID;
return MetricWorkerIdDefine.INSTANCE_DAY_MAPPING_PERSISTENCE_WORKER_ID;
}
@Override protected boolean needMergeDBData() {
@ -46,17 +46,17 @@ public class InstanceMappingPersistenceWorker extends PersistenceWorker<Instance
@SuppressWarnings("unchecked")
@Override protected IPersistenceDAO<?, ?, InstanceMapping> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IInstanceMappingPersistenceDAO.class);
return getModuleManager().find(StorageModule.NAME).getService(IInstanceMappingDayPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<InstanceMapping, InstanceMappingPersistenceWorker> {
public static class Factory extends PersistenceWorkerProvider<InstanceMapping, InstanceMappingDayPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public InstanceMappingPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMappingPersistenceWorker(moduleManager);
@Override public InstanceMappingDayPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMappingDayPersistenceWorker(moduleManager);
}
@Override

View File

@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.core.graph.Next;
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public class InstanceMappingDayTransformNode implements NodeProcessor<InstanceMapping, InstanceMapping> {
@Override public int id() {
return MetricWorkerIdDefine.INSTANCE_DAY_MAPPING_TRANSFORM_NODE_ID;
}
@Override public void process(InstanceMapping instanceMapping, Next<InstanceMapping> next) {
long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(instanceMapping.getTimeBucket());
instanceMapping.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceMapping.getMetricId());
instanceMapping.setTimeBucket(timeBucket);
next.execute(instanceMapping);
}
}

View File

@ -16,11 +16,12 @@
*
*/
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance;
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
import org.apache.skywalking.apm.collector.core.graph.Node;
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;
@ -42,9 +43,19 @@ public class InstanceMappingGraph {
public void create() {
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.INSTANCE_MAPPING_GRAPH_ID, InstanceMapping.class)
Node<InstanceMapping, InstanceMapping> remoteNode = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.INSTANCE_MAPPING_GRAPH_ID, InstanceMapping.class)
.addNode(new InstanceMappingAggregationWorker.Factory(moduleManager).create(workerCreateListener))
.addNext(new InstanceMappingRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.INSTANCE_MAPPING_GRAPH_ID).create(workerCreateListener))
.addNext(new InstanceMappingPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
.addNext(new InstanceMappingRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.INSTANCE_MAPPING_GRAPH_ID).create(workerCreateListener));
remoteNode.addNext(new InstanceMappingMinutePersistenceWorker.Factory(moduleManager).create(workerCreateListener));
remoteNode.addNext(new InstanceMappingHourTransformNode())
.addNext(new InstanceMappingHourPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
remoteNode.addNext(new InstanceMappingDayTransformNode())
.addNext(new InstanceMappingDayPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
remoteNode.addNext(new InstanceMappingMonthTransformNode())
.addNext(new InstanceMappingMonthPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingHourPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public class InstanceMappingHourPersistenceWorker extends PersistenceWorker<InstanceMapping> {
InstanceMappingHourPersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return MetricWorkerIdDefine.INSTANCE_HOUR_MAPPING_PERSISTENCE_WORKER_ID;
}
@Override protected boolean needMergeDBData() {
return true;
}
@SuppressWarnings("unchecked")
@Override protected IPersistenceDAO<?, ?, InstanceMapping> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IInstanceMappingHourPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<InstanceMapping, InstanceMappingHourPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public InstanceMappingHourPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMappingHourPersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.core.graph.Next;
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public class InstanceMappingHourTransformNode implements NodeProcessor<InstanceMapping, InstanceMapping> {
@Override public int id() {
return MetricWorkerIdDefine.INSTANCE_HOUR_MAPPING_TRANSFORM_NODE_ID;
}
@Override public void process(InstanceMapping instanceMapping, Next<InstanceMapping> next) {
long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(instanceMapping.getTimeBucket());
instanceMapping.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceMapping.getMetricId());
instanceMapping.setTimeBucket(timeBucket);
next.execute(instanceMapping);
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public class InstanceMappingMinutePersistenceWorker extends PersistenceWorker<InstanceMapping> {
InstanceMappingMinutePersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return MetricWorkerIdDefine.INSTANCE_MINUTE_MAPPING_PERSISTENCE_WORKER_ID;
}
@Override protected boolean needMergeDBData() {
return true;
}
@SuppressWarnings("unchecked")
@Override protected IPersistenceDAO<?, ?, InstanceMapping> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IInstanceMappingMinutePersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<InstanceMapping, InstanceMappingMinutePersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public InstanceMappingMinutePersistenceWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMappingMinutePersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMonthPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public class InstanceMappingMonthPersistenceWorker extends PersistenceWorker<InstanceMapping> {
InstanceMappingMonthPersistenceWorker(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public int id() {
return MetricWorkerIdDefine.INSTANCE_MONTH_MAPPING_PERSISTENCE_WORKER_ID;
}
@Override protected boolean needMergeDBData() {
return true;
}
@SuppressWarnings("unchecked")
@Override protected IPersistenceDAO<?, ?, InstanceMapping> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IInstanceMappingMonthPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<InstanceMapping, InstanceMappingMonthPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public InstanceMappingMonthPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new InstanceMappingMonthPersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.core.graph.Next;
import org.apache.skywalking.apm.collector.core.graph.NodeProcessor;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public class InstanceMappingMonthTransformNode implements NodeProcessor<InstanceMapping, InstanceMapping> {
@Override public int id() {
return MetricWorkerIdDefine.INSTANCE_MONTH_MAPPING_TRANSFORM_NODE_ID;
}
@Override public void process(InstanceMapping instanceMapping, Next<InstanceMapping> next) {
long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(instanceMapping.getTimeBucket());
instanceMapping.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + instanceMapping.getMetricId());
instanceMapping.setTimeBucket(timeBucket);
next.execute(instanceMapping);
}
}

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance;
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker;
@ -37,7 +37,7 @@ public class InstanceMappingRemoteWorker extends AbstractRemoteWorker<InstanceMa
}
@Override public int id() {
return MetricWorkerIdDefine.INSTANCE_MAPPING_REMOTE_WORKER_ID;
return MetricWorkerIdDefine.INSTANCE_MINUTE_MAPPING_REMOTE_WORKER_ID;
}
@Override protected void onWork(InstanceMapping instanceMapping) throws WorkerException {

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance;
package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping;
import java.util.LinkedList;
import java.util.List;
@ -49,7 +49,7 @@ public class InstanceMappingSpanListener implements FirstSpanListener, EntrySpan
logger.debug("instance mapping listener parse reference");
if (spanDecorator.getRefsCount() > 0) {
for (int i = 0; i < spanDecorator.getRefsCount(); i++) {
InstanceMapping instanceMapping = new InstanceMapping(Const.EMPTY_STRING);
InstanceMapping instanceMapping = new InstanceMapping();
instanceMapping.setApplicationId(applicationId);
instanceMapping.setInstanceId(instanceId);
instanceMapping.setAddressId(spanDecorator.getRefs(i).getNetworkAddressId());

View File

@ -45,7 +45,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IInstanceAlarmListPersist
import org.apache.skywalking.apm.collector.storage.dao.IInstanceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMappingPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceAlarmListPersistenceDAO;
@ -132,7 +132,7 @@ public class StorageModule extends Module {
classes.add(IInstanceMinuteMetricPersistenceDAO.class);
classes.add(IInstanceReferenceMinuteMetricPersistenceDAO.class);
classes.add(IInstanceMappingPersistenceDAO.class);
classes.add(IInstanceMappingMinutePersistenceDAO.class);
classes.add(IInstanceHeartBeatPersistenceDAO.class);
}

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.collector.storage.dao;
package org.apache.skywalking.apm.collector.storage.dao.impp;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
@ -24,5 +24,5 @@ import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappin
/**
* @author peng-yongsheng
*/
public interface IInstanceMappingPersistenceDAO<Insert, Update, DataImpl extends InstanceMapping> extends IPersistenceDAO<Insert, Update, DataImpl> {
public interface IInstanceMappingDayPersistenceDAO<INSERT, UPDATE, STREAM_DATA extends InstanceMapping> extends IPersistenceDAO<INSERT, UPDATE, STREAM_DATA> {
}

View File

@ -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.storage.dao.impp;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public interface IInstanceMappingHourPersistenceDAO<INSERT, UPDATE, STREAM_DATA extends InstanceMapping> extends IPersistenceDAO<INSERT, UPDATE, STREAM_DATA> {
}

View File

@ -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.storage.dao.impp;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public interface IInstanceMappingMinutePersistenceDAO<INSERT, UPDATE, STREAM_DATA extends InstanceMapping> extends IPersistenceDAO<INSERT, UPDATE, STREAM_DATA> {
}

View File

@ -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.storage.dao.impp;
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
/**
* @author peng-yongsheng
*/
public interface IInstanceMappingMonthPersistenceDAO<INSERT, UPDATE, STREAM_DATA extends InstanceMapping> extends IPersistenceDAO<INSERT, UPDATE, STREAM_DATA> {
}

View File

@ -19,17 +19,18 @@
package org.apache.skywalking.apm.collector.storage.table.instance;
import org.apache.skywalking.apm.collector.core.data.Column;
import org.apache.skywalking.apm.collector.core.data.AbstractData;
import org.apache.skywalking.apm.collector.core.data.StreamData;
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
/**
* @author peng-yongsheng
*/
public class InstanceMapping extends AbstractData {
public class InstanceMapping extends StreamData {
private static final Column[] STRING_COLUMNS = {
new Column(InstanceMappingTable.COLUMN_ID, new NonOperation()),
new Column(InstanceMappingTable.COLUMN_METRIC_ID, new NonOperation()),
};
private static final Column[] LONG_COLUMNS = {
@ -48,8 +49,24 @@ public class InstanceMapping extends AbstractData {
private static final Column[] BYTE_COLUMNS = {};
public InstanceMapping(String id) {
super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS);
public InstanceMapping() {
super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS);
}
@Override public String getId() {
return getDataString(0);
}
@Override public void setId(String id) {
setDataString(0, id);
}
@Override public String getMetricId() {
return getDataString(1);
}
@Override public void setMetricId(String metricId) {
setDataString(1, metricId);
}
public int getApplicationId() {

View File

@ -54,7 +54,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IInstanceAlarmListPersist
import org.apache.skywalking.apm.collector.storage.dao.IInstanceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMappingPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceAlarmListPersistenceDAO;
@ -110,7 +110,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.InstanceEsCacheDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.InstanceEsRegisterDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.InstanceEsUIDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.InstanceHeartBeatEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.InstanceMappingEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.impp.InstanceMappingMinuteEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.imp.InstanceMinuteMetricEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.InstanceMetricEsUIDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.InstanceReferenceAlarmEsPersistenceDAO;
@ -245,7 +245,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
this.registerServiceImplementation(IInstanceMinuteMetricPersistenceDAO.class, new InstanceMinuteMetricEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IInstanceReferenceMinuteMetricPersistenceDAO.class, new InstanceReferenceMinuteMetricEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IInstanceMappingPersistenceDAO.class, new InstanceMappingEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IInstanceMappingMinutePersistenceDAO.class, new InstanceMappingMinuteEsPersistenceDAO(elasticSearchClient));
this.registerServiceImplementation(IInstanceHeartBeatPersistenceDAO.class, new InstanceHeartBeatEsPersistenceDAO(elasticSearchClient));
}

View File

@ -1,94 +0,0 @@
/*
* 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.storage.es.dao;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMappingPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.update.UpdateRequestBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public class InstanceMappingEsPersistenceDAO extends EsDAO implements IInstanceMappingPersistenceDAO<IndexRequestBuilder, UpdateRequestBuilder, InstanceMapping> {
private final Logger logger = LoggerFactory.getLogger(InstanceMappingEsPersistenceDAO.class);
public InstanceMappingEsPersistenceDAO(ElasticSearchClient client) {
super(client);
}
@Override public InstanceMapping get(String id) {
GetResponse getResponse = getClient().prepareGet(InstanceMappingTable.TABLE, id).get();
if (getResponse.isExists()) {
InstanceMapping instanceMapping = new InstanceMapping(id);
Map<String, Object> source = getResponse.getSource();
instanceMapping.setApplicationId(((Number)source.get(InstanceMappingTable.COLUMN_APPLICATION_ID)).intValue());
instanceMapping.setInstanceId(((Number)source.get(InstanceMappingTable.COLUMN_INSTANCE_ID)).intValue());
instanceMapping.setAddressId(((Number)source.get(InstanceMappingTable.COLUMN_ADDRESS_ID)).intValue());
instanceMapping.setTimeBucket(((Number)source.get(InstanceMappingTable.COLUMN_TIME_BUCKET)).longValue());
return instanceMapping;
} else {
return null;
}
}
@Override public IndexRequestBuilder prepareBatchInsert(InstanceMapping data) {
Map<String, Object> source = new HashMap<>();
source.put(InstanceMappingTable.COLUMN_APPLICATION_ID, data.getApplicationId());
source.put(InstanceMappingTable.COLUMN_INSTANCE_ID, data.getInstanceId());
source.put(InstanceMappingTable.COLUMN_ADDRESS_ID, data.getAddressId());
source.put(InstanceMappingTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
return getClient().prepareIndex(InstanceMappingTable.TABLE, data.getId()).setSource(source);
}
@Override public UpdateRequestBuilder prepareBatchUpdate(InstanceMapping data) {
Map<String, Object> source = new HashMap<>();
source.put(InstanceMappingTable.COLUMN_APPLICATION_ID, data.getApplicationId());
source.put(InstanceMappingTable.COLUMN_INSTANCE_ID, data.getInstanceId());
source.put(InstanceMappingTable.COLUMN_ADDRESS_ID, data.getAddressId());
source.put(InstanceMappingTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
return getClient().prepareUpdate(InstanceMappingTable.TABLE, data.getId()).setDoc(source);
}
@Override public void deleteHistory(Long startTimestamp, Long endTimestamp) {
long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp);
long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp);
BulkByScrollResponse response = getClient().prepareDelete()
.filter(QueryBuilders.rangeQuery(InstanceMappingTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket))
.source(InstanceMappingTable.TABLE)
.get();
long deleted = response.getDeleted();
logger.info("Delete {} rows history from {} index.", deleted, InstanceMappingTable.TABLE);
}
}

View File

@ -0,0 +1,65 @@
/*
* 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.storage.es.dao.impp;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable;
/**
* @author peng-yongsheng
*/
public abstract class AbstractInstanceMappingEsPersistenceDAO extends AbstractPersistenceEsDAO<InstanceMapping> {
AbstractInstanceMappingEsPersistenceDAO(ElasticSearchClient client) {
super(client);
}
@Override protected final String timeBucketColumnNameForDelete() {
return InstanceMappingTable.COLUMN_TIME_BUCKET;
}
@Override protected final InstanceMapping esDataToStreamData(Map<String, Object> source) {
InstanceMapping instanceMapping = new InstanceMapping();
instanceMapping.setId((String)source.get(InstanceMappingTable.COLUMN_ID));
instanceMapping.setMetricId((String)source.get(InstanceMappingTable.COLUMN_METRIC_ID));
instanceMapping.setApplicationId(((Number)source.get(InstanceMappingTable.COLUMN_APPLICATION_ID)).intValue());
instanceMapping.setInstanceId(((Number)source.get(InstanceMappingTable.COLUMN_INSTANCE_ID)).intValue());
instanceMapping.setAddressId(((Number)source.get(InstanceMappingTable.COLUMN_ADDRESS_ID)).intValue());
instanceMapping.setTimeBucket(((Number)source.get(InstanceMappingTable.COLUMN_TIME_BUCKET)).longValue());
return instanceMapping;
}
@Override protected final Map<String, Object> esStreamDataToEsData(InstanceMapping streamData) {
Map<String, Object> source = new HashMap<>();
source.put(InstanceMappingTable.COLUMN_ID, streamData.getId());
source.put(InstanceMappingTable.COLUMN_METRIC_ID, streamData.getMetricId());
source.put(InstanceMappingTable.COLUMN_APPLICATION_ID, streamData.getApplicationId());
source.put(InstanceMappingTable.COLUMN_INSTANCE_ID, streamData.getInstanceId());
source.put(InstanceMappingTable.COLUMN_ADDRESS_ID, streamData.getAddressId());
source.put(InstanceMappingTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket());
return source;
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.storage.es.dao.impp;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.core.storage.TimePyramid;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingDayPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.update.UpdateRequestBuilder;
/**
* @author peng-yongsheng
*/
public class InstanceMappingDayEsPersistenceDAO extends AbstractInstanceMappingEsPersistenceDAO implements IInstanceMappingDayPersistenceDAO<IndexRequestBuilder, UpdateRequestBuilder, InstanceMapping> {
public InstanceMappingDayEsPersistenceDAO(ElasticSearchClient client) {
super(client);
}
@Override protected String tableName() {
return InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName();
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.storage.es.dao.impp;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.core.storage.TimePyramid;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingHourPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.update.UpdateRequestBuilder;
/**
* @author peng-yongsheng
*/
public class InstanceMappingHourEsPersistenceDAO extends AbstractInstanceMappingEsPersistenceDAO implements IInstanceMappingHourPersistenceDAO<IndexRequestBuilder, UpdateRequestBuilder, InstanceMapping> {
public InstanceMappingHourEsPersistenceDAO(ElasticSearchClient client) {
super(client);
}
@Override protected String tableName() {
return InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName();
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.storage.es.dao.impp;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.core.storage.TimePyramid;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.update.UpdateRequestBuilder;
/**
* @author peng-yongsheng
*/
public class InstanceMappingMinuteEsPersistenceDAO extends AbstractInstanceMappingEsPersistenceDAO implements IInstanceMappingMinutePersistenceDAO<IndexRequestBuilder, UpdateRequestBuilder, InstanceMapping> {
public InstanceMappingMinuteEsPersistenceDAO(ElasticSearchClient client) {
super(client);
}
@Override protected String tableName() {
return InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName();
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.storage.es.dao.impp;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.core.storage.TimePyramid;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMonthPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMappingTable;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.update.UpdateRequestBuilder;
/**
* @author peng-yongsheng
*/
public class InstanceMappingMonthEsPersistenceDAO extends AbstractInstanceMappingEsPersistenceDAO implements IInstanceMappingMonthPersistenceDAO<IndexRequestBuilder, UpdateRequestBuilder, InstanceMapping> {
public InstanceMappingMonthEsPersistenceDAO(ElasticSearchClient client) {
super(client);
}
@Override protected String tableName() {
return InstanceMappingTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName();
}
}

View File

@ -50,7 +50,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IInstanceAlarmListPersist
import org.apache.skywalking.apm.collector.storage.dao.IInstanceAlarmPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMappingPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceReferenceAlarmListPersistenceDAO;
@ -106,7 +106,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2CacheDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2RegisterDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMappingH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMappingH2MinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMinuteMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceReferenceAlarmH2PersistenceDAO;
@ -223,7 +223,7 @@ public class StorageModuleH2Provider extends ModuleProvider {
this.registerServiceImplementation(IInstanceMinuteMetricPersistenceDAO.class, new InstanceMinuteMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceReferenceMinuteMetricPersistenceDAO.class, new InstanceReferenceMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceMappingPersistenceDAO.class, new InstanceMappingH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceMappingMinutePersistenceDAO.class, new InstanceMappingH2MinutePersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceHeartBeatPersistenceDAO.class, new InstanceHeartBeatH2PersistenceDAO(h2Client));
}

View File

@ -27,7 +27,7 @@ import java.util.Map;
import org.apache.skywalking.apm.collector.client.h2.H2Client;
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.apache.skywalking.apm.collector.storage.dao.IInstanceMappingPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.impp.IInstanceMappingMinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity;
import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping;
@ -38,12 +38,12 @@ import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public class InstanceMappingH2PersistenceDAO extends H2DAO implements IInstanceMappingPersistenceDAO<H2SqlEntity, H2SqlEntity, InstanceMapping> {
public class InstanceMappingH2MinutePersistenceDAO extends H2DAO implements IInstanceMappingMinutePersistenceDAO<H2SqlEntity, H2SqlEntity, InstanceMapping> {
private final Logger logger = LoggerFactory.getLogger(InstanceMappingH2PersistenceDAO.class);
private final Logger logger = LoggerFactory.getLogger(InstanceMappingH2MinutePersistenceDAO.class);
private static final String GET_SQL = "select * from {0} where {1} = ?";
public InstanceMappingH2PersistenceDAO(H2Client client) {
public InstanceMappingH2MinutePersistenceDAO(H2Client client) {
super(client);
}