From 3bd9e5b75d13bc3a28bb50a15dee28fdd2c05945 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Thu, 11 Jan 2018 19:39:29 +0800 Subject: [PATCH] Application component pyramid aggregate by h2 storage test successful. --- .../agent/jetty/provider/SegmentPost.java | 14 +-- .../AnalysisMetricModuleProvider.java | 10 +- .../parser/provider/parser/SegmentParse.java | 2 +- .../apm/collector/core/data/AbstractData.java | 26 +---- .../apm/collector/core/data/Data.java | 6 -- .../apm/collector/core/data/StreamData.java | 4 +- .../apm/collector/core/util/BooleanUtils.java | 48 ++++++++++ .../service/GRPCRemoteDeserializeService.java | 3 - .../service/GRPCRemoteSerializeService.java | 6 -- .../apm/collector/storage/StorageModule.java | 14 ++- .../storage/table/alarm/ApplicationAlarm.java | 4 +- .../table/alarm/ApplicationAlarmList.java | 4 +- .../alarm/ApplicationReferenceAlarm.java | 4 +- .../alarm/ApplicationReferenceAlarmList.java | 4 +- .../storage/table/alarm/InstanceAlarm.java | 4 +- .../table/alarm/InstanceAlarmList.java | 4 +- .../table/alarm/InstanceReferenceAlarm.java | 4 +- .../alarm/InstanceReferenceAlarmList.java | 4 +- .../storage/table/alarm/ServiceAlarm.java | 4 +- .../storage/table/alarm/ServiceAlarmList.java | 4 +- .../table/alarm/ServiceReferenceAlarm.java | 4 +- .../alarm/ServiceReferenceAlarmList.java | 4 +- .../application/ApplicationComponent.java | 4 +- .../table/application/ApplicationMapping.java | 4 +- .../table/application/ApplicationMetric.java | 4 +- .../ApplicationReferenceMetric.java | 4 +- .../storage/table/global/GlobalTrace.java | 5 +- .../table/instance/InstanceMapping.java | 4 +- .../table/instance/InstanceMetric.java | 4 +- .../instance/InstanceReferenceMetric.java | 4 +- .../storage/table/jvm/CpuMetric.java | 3 +- .../collector/storage/table/jvm/GCMetric.java | 3 +- .../storage/table/jvm/MemoryMetric.java | 23 +++-- .../storage/table/jvm/MemoryPoolMetric.java | 4 +- .../storage/table/register/Application.java | 10 +- .../storage/table/register/Instance.java | 10 +- .../table/register/NetworkAddress.java | 4 +- .../storage/table/register/ServiceName.java | 5 +- .../storage/table/segment/Segment.java | 5 +- .../storage/table/segment/SegmentCost.java | 13 +-- .../storage/table/service/ServiceMetric.java | 4 +- .../table/service/ServiceReferenceMetric.java | 4 +- .../define/ElasticSearchColumnDefine.java | 3 +- .../es/dao/cache/ApplicationEsCacheDAO.java | 5 +- .../es/dao/cache/InstanceEsCacheDAO.java | 5 +- .../es/define/SegmentCostEsTableDefine.java | 2 +- .../AbstractMemoryMetricEsTableDefine.java | 2 +- .../register/ApplicationEsTableDefine.java | 2 +- .../register/InstanceEsTableDefine.java | 2 +- .../storage/h2/StorageModuleH2Provider.java | 23 ++++- .../h2/base/define/H2ColumnDefine.java | 3 +- ...emoryPoolSecondMetricH2PersistenceDAO.java | 69 -------------- .../MemorySecondMetricH2PersistenceDAO.java | 69 -------------- ...tApplicationComponentH2PersistenceDAO.java | 60 ++++++++++++ ...plicationComponentDayH2PersistenceDAO.java | 41 ++++++++ ...licationComponentHourH2PersistenceDAO.java | 41 ++++++++ ...cationComponentMinuteH2PersistenceDAO.java | 41 ++++++++ ...icationComponentMonthH2PersistenceDAO.java | 41 ++++++++ .../h2/dao/cache/ApplicationH2CacheDAO.java | 94 +++++++++++++++++++ .../h2/dao/cache/InstanceH2CacheDAO.java | 93 ++++++++++++++++++ .../dao/cache/NetworkAddressH2CacheDAO.java | 77 +++++++++++++++ .../h2/dao/cache/ServiceNameH2CacheDAO.java | 79 ++++++++++++++++ .../define/MemoryPoolMetricH2TableDefine.java | 45 --------- .../h2/define/SegmentCostH2TableDefine.java | 5 +- ...ractApplicationComponentH2TableDefine.java | 41 ++++++++ .../ApplicationComponentDayH2TableDefine.java | 33 +++++++ ...ApplicationComponentHourH2TableDefine.java | 33 +++++++ ...plicationComponentMinuteH2TableDefine.java | 33 +++++++ ...pplicationComponentMonthH2TableDefine.java | 33 +++++++ .../AbstractMemoryMetricH2TableDefine.java | 2 +- .../register/ApplicationH2TableDefine.java | 2 +- .../register/InstanceH2TableDefine.java | 2 +- .../resources/META-INF/defines/storage.define | 7 +- 73 files changed, 914 insertions(+), 376 deletions(-) create mode 100644 apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/BooleanUtils.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolSecondMetricH2PersistenceDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemorySecondMetricH2PersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentDayH2PersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentHourH2PersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentMinuteH2PersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentMonthH2PersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/InstanceH2CacheDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/NetworkAddressH2CacheDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/MemoryPoolMetricH2TableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentDayH2TableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentHourH2TableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentMinuteH2TableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentMonthH2TableDefine.java diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/agent/jetty/provider/SegmentPost.java b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/agent/jetty/provider/SegmentPost.java index dc296cc64..6f6a108be 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/agent/jetty/provider/SegmentPost.java +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/agent/jetty/provider/SegmentPost.java @@ -39,12 +39,12 @@ public class SegmentPost { serviceNameRegisterPost.send("json/servicename-register-consumer.json"); serviceNameRegisterPost.send("json/servicename-register-provider.json"); -// JsonElement provider = JsonFileReader.INSTANCE.read("json/dubbox-provider.json"); -// JsonElement consumer = JsonFileReader.INSTANCE.read("json/dubbox-consumer.json"); -// -// for (int i = 0; i < 1; i++) { -// HttpClientTools.INSTANCE.post("http://localhost:12800/segments", provider.toString()); -// HttpClientTools.INSTANCE.post("http://localhost:12800/segments", consumer.toString()); -// } + JsonElement provider = JsonFileReader.INSTANCE.read("json/dubbox-provider.json"); + JsonElement consumer = JsonFileReader.INSTANCE.read("json/dubbox-consumer.json"); + + for (int i = 0; i < 1; i++) { + HttpClientTools.INSTANCE.post("http://localhost:12800/segments", provider.toString()); + HttpClientTools.INSTANCE.post("http://localhost:12800/segments", consumer.toString()); + } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java index be6c3d3ee..4fb61d2d5 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java @@ -88,12 +88,12 @@ public class AnalysisMetricModuleProvider extends ModuleProvider { private void segmentParserListenerRegister() { ISegmentParserListenerRegister segmentParserListenerRegister = getManager().find(AnalysisSegmentParserModule.NAME).getService(ISegmentParserListenerRegister.class); - segmentParserListenerRegister.register(new ServiceReferenceMetricSpanListener.Factory()); +// segmentParserListenerRegister.register(new ServiceReferenceMetricSpanListener.Factory()); segmentParserListenerRegister.register(new ApplicationComponentSpanListener.Factory()); - segmentParserListenerRegister.register(new ApplicationMappingSpanListener.Factory()); - segmentParserListenerRegister.register(new InstanceMappingSpanListener.Factory()); - segmentParserListenerRegister.register(new GlobalTraceSpanListener.Factory()); - segmentParserListenerRegister.register(new SegmentCostSpanListener.Factory()); +// segmentParserListenerRegister.register(new ApplicationMappingSpanListener.Factory()); +// segmentParserListenerRegister.register(new InstanceMappingSpanListener.Factory()); +// segmentParserListenerRegister.register(new GlobalTraceSpanListener.Factory()); +// segmentParserListenerRegister.register(new SegmentCostSpanListener.Factory()); } private void graphCreate(WorkerCreateListener workerCreateListener) { diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java index 060bb88a4..a48c5024b 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java @@ -167,7 +167,7 @@ public class SegmentParse { segment.setDataBinary(dataBinary); segment.setTimeBucket(timeBucket); Graph graph = GraphManager.INSTANCE.findGraph(GraphIdDefine.SEGMENT_PERSISTENCE_GRAPH_ID, Segment.class); - graph.start(segment); +// graph.start(segment); } private void writeToBufferFile(String id, UpstreamSegment upstreamSegment) { diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractData.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractData.java index 51f2a3f08..6524dc9ed 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractData.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/AbstractData.java @@ -26,28 +26,24 @@ public abstract class AbstractData { private Long[] dataLongs; private Double[] dataDoubles; private Integer[] dataIntegers; - private Boolean[] dataBooleans; private byte[][] dataBytes; private final Column[] stringColumns; private final Column[] longColumns; private final Column[] doubleColumns; private final Column[] integerColumns; - private final Column[] booleanColumns; private final Column[] byteColumns; public AbstractData(Column[] stringColumns, Column[] longColumns, Column[] doubleColumns, - Column[] integerColumns, Column[] booleanColumns, Column[] byteColumns) { + Column[] integerColumns, Column[] byteColumns) { this.dataStrings = new String[stringColumns.length]; this.dataLongs = new Long[longColumns.length]; this.dataDoubles = new Double[doubleColumns.length]; this.dataIntegers = new Integer[integerColumns.length]; - this.dataBooleans = new Boolean[booleanColumns.length]; this.dataBytes = new byte[byteColumns.length][]; this.stringColumns = stringColumns; this.longColumns = longColumns; this.doubleColumns = doubleColumns; this.integerColumns = integerColumns; - this.booleanColumns = booleanColumns; this.byteColumns = byteColumns; } @@ -67,10 +63,6 @@ public abstract class AbstractData { return dataIntegers.length; } - public final int getDataBooleansCount() { - return dataBooleans.length; - } - public final int getDataBytesCount() { return dataBytes.length; } @@ -91,10 +83,6 @@ public abstract class AbstractData { dataIntegers[position] = value; } - public final void setDataBoolean(int position, Boolean value) { - dataBooleans[position] = value; - } - public final void setDataBytes(int position, byte[] dataBytes) { this.dataBytes[position] = dataBytes; } @@ -133,10 +121,6 @@ public abstract class AbstractData { } } - public final Boolean getDataBoolean(int position) { - return dataBooleans[position]; - } - public final byte[] getDataBytes(int position) { return dataBytes[position]; } @@ -158,10 +142,6 @@ public abstract class AbstractData { Integer integerData = integerColumns[i].getOperation().operate(newData.getDataInteger(i), this.getDataInteger(i)); this.dataIntegers[i] = integerData; } - for (int i = 0; i < booleanColumns.length; i++) { - Boolean booleanData = booleanColumns[i].getOperation().operate(newData.getDataBoolean(i), this.getDataBoolean(i)); - this.dataBooleans[i] = booleanData; - } for (int i = 0; i < byteColumns.length; i++) { byte[] byteData = byteColumns[i].getOperation().operate(newData.getDataBytes(i), this.getDataBytes(i)); this.dataBytes[i] = byteData; @@ -186,10 +166,6 @@ public abstract class AbstractData { for (Integer dataInteger : dataIntegers) { dataStr.append(dataInteger).append(","); } - dataStr.append("], boolean: ["); - for (Boolean dataBoolean : dataBooleans) { - dataStr.append(dataBoolean).append(","); - } dataStr.append("]"); return dataStr.toString(); } diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/Data.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/Data.java index f93b68f07..862615433 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/Data.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/Data.java @@ -30,8 +30,6 @@ public interface Data { int getDataIntegersCount(); - int getDataBooleansCount(); - int getDataBytesCount(); void setDataString(int position, String value); @@ -42,8 +40,6 @@ public interface Data { void setDataInteger(int position, Integer value); - void setDataBoolean(int position, Boolean value); - void setDataBytes(int position, byte[] dataBytes); String getDataString(int position); @@ -54,7 +50,5 @@ public interface Data { Integer getDataInteger(int position); - Boolean getDataBoolean(int position); - byte[] getDataBytes(int position); } diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/StreamData.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/StreamData.java index f5fb8eade..faf127eb5 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/StreamData.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/data/StreamData.java @@ -36,8 +36,8 @@ public abstract class StreamData extends AbstractData implements RemoteData, Que } public StreamData(Column[] stringColumns, Column[] longColumns, Column[] doubleColumns, - Column[] integerColumns, Column[] booleanColumns, Column[] byteColumns) { - super(stringColumns, longColumns, doubleColumns, integerColumns, booleanColumns, byteColumns); + Column[] integerColumns, Column[] byteColumns) { + super(stringColumns, longColumns, doubleColumns, integerColumns, byteColumns); } @Override public final String selectKey() { diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/BooleanUtils.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/BooleanUtils.java new file mode 100644 index 000000000..24341aea0 --- /dev/null +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/BooleanUtils.java @@ -0,0 +1,48 @@ +/* + * 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.core.util; + +import org.apache.skywalking.apm.collector.core.UnexpectedException; + +/** + * @author peng-yongsheng + */ +public class BooleanUtils { + + public static final Integer TRUE = 1; + public static final Integer FALSE = 0; + + public static boolean valueToBoolean(Integer value) { + if (TRUE.equals(value)) { + return true; + } else if (FALSE.equals(value)) { + return false; + } else { + throw new UnexpectedException("Boolean value error, must be 0 or 1"); + } + } + + public static Integer booleanToValue(Boolean booleanValue) { + if (booleanValue) { + return TRUE; + } else { + return FALSE; + } + } +} diff --git a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteDeserializeService.java b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteDeserializeService.java index 4ef7e5eed..47aecad03 100644 --- a/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteDeserializeService.java +++ b/apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/remote/grpc/service/GRPCRemoteDeserializeService.java @@ -37,9 +37,6 @@ public class GRPCRemoteDeserializeService implements RemoteDeserializeService { - - public MemoryPoolSecondMetricH2PersistenceDAO(H2Client client) { - super(client); - } - - @Override public MemoryPoolMetric get(String id) { - return null; - } - - @Override public H2SqlEntity prepareBatchInsert(MemoryPoolMetric data) { - H2SqlEntity entity = new H2SqlEntity(); - Map source = new HashMap<>(); - source.put(MemoryPoolMetricTable.COLUMN_ID, data.getId()); - source.put(MemoryPoolMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId()); - source.put(MemoryPoolMetricTable.COLUMN_POOL_TYPE, data.getPoolType()); - source.put(MemoryPoolMetricTable.COLUMN_INIT, data.getInit()); - source.put(MemoryPoolMetricTable.COLUMN_MAX, data.getMax()); - source.put(MemoryPoolMetricTable.COLUMN_USED, data.getUsed()); - source.put(MemoryPoolMetricTable.COLUMN_COMMITTED, data.getCommitted()); - source.put(MemoryPoolMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - String sql = SqlBuilder.buildBatchInsertSql(MemoryPoolMetricTable.TABLE, source.keySet()); - entity.setSql(sql); - entity.setParams(source.values().toArray(new Object[0])); - return entity; - } - - @Override public H2SqlEntity prepareBatchUpdate(MemoryPoolMetric data) { - return null; - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemorySecondMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemorySecondMetricH2PersistenceDAO.java deleted file mode 100644 index b5115d43a..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemorySecondMetricH2PersistenceDAO.java +++ /dev/null @@ -1,69 +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.h2.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.memorymp.IMemorySecondMetricPersistenceDAO; -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.jvm.MemoryMetric; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; - -/** - * @author peng-yongsheng, clevertension - */ -public class MemorySecondMetricH2PersistenceDAO extends H2DAO implements IMemorySecondMetricPersistenceDAO { - - public MemorySecondMetricH2PersistenceDAO(H2Client client) { - super(client); - } - - @Override public MemoryMetric get(String id) { - return null; - } - - @Override public H2SqlEntity prepareBatchInsert(MemoryMetric data) { - H2SqlEntity entity = new H2SqlEntity(); - Map source = new HashMap<>(); - source.put(MemoryMetricTable.COLUMN_ID, data.getId()); - source.put(MemoryMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId()); - source.put(MemoryMetricTable.COLUMN_IS_HEAP, data.getIsHeap()); - source.put(MemoryMetricTable.COLUMN_INIT, data.getInit()); - source.put(MemoryMetricTable.COLUMN_MAX, data.getMax()); - source.put(MemoryMetricTable.COLUMN_USED, data.getUsed()); - source.put(MemoryMetricTable.COLUMN_COMMITTED, data.getCommitted()); - source.put(MemoryMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - String sql = SqlBuilder.buildBatchInsertSql(MemoryMetricTable.TABLE, source.keySet()); - entity.setSql(sql); - entity.setParams(source.values().toArray(new Object[0])); - return entity; - } - - @Override public H2SqlEntity prepareBatchUpdate(MemoryMetric data) { - return null; - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java new file mode 100644 index 000000000..c08156682 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java @@ -0,0 +1,60 @@ +/* + * 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.h2.dao.acp; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.AbstractPersistenceH2DAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractApplicationComponentH2PersistenceDAO extends AbstractPersistenceH2DAO { + + AbstractApplicationComponentH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected final ApplicationComponent h2DataToStreamData(ResultSet resultSet) throws SQLException { + ApplicationComponent applicationComponent = new ApplicationComponent(); + applicationComponent.setId(resultSet.getString(ApplicationComponentTable.COLUMN_ID)); + applicationComponent.setMetricId(resultSet.getString(ApplicationComponentTable.COLUMN_METRIC_ID)); + + applicationComponent.setComponentId(resultSet.getInt(ApplicationComponentTable.COLUMN_COMPONENT_ID)); + applicationComponent.setPeerId(resultSet.getInt(ApplicationComponentTable.COLUMN_PEER_ID)); + applicationComponent.setTimeBucket(resultSet.getLong(ApplicationComponentTable.COLUMN_TIME_BUCKET)); + return applicationComponent; + } + + @Override protected final Map streamDataToH2Data(ApplicationComponent streamData) { + Map source = new HashMap<>(); + source.put(ApplicationComponentTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(ApplicationComponentTable.COLUMN_COMPONENT_ID, streamData.getComponentId()); + source.put(ApplicationComponentTable.COLUMN_PEER_ID, streamData.getPeerId()); + source.put(ApplicationComponentTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentDayH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentDayH2PersistenceDAO.java new file mode 100644 index 000000000..292af6c73 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentDayH2PersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.h2.dao.acp; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +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.acp.IApplicationComponentDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationComponentDayH2PersistenceDAO extends AbstractApplicationComponentH2PersistenceDAO implements IApplicationComponentDayPersistenceDAO { + + public ApplicationComponentDayH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentHourH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentHourH2PersistenceDAO.java new file mode 100644 index 000000000..f83827ccd --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentHourH2PersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.h2.dao.acp; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +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.acp.IApplicationComponentHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationComponentHourH2PersistenceDAO extends AbstractApplicationComponentH2PersistenceDAO implements IApplicationComponentHourPersistenceDAO { + + public ApplicationComponentHourH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentMinuteH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentMinuteH2PersistenceDAO.java new file mode 100644 index 000000000..592ae3431 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentMinuteH2PersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.h2.dao.acp; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +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.acp.IApplicationComponentMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationComponentMinuteH2PersistenceDAO extends AbstractApplicationComponentH2PersistenceDAO implements IApplicationComponentMinutePersistenceDAO { + + public ApplicationComponentMinuteH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentMonthH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentMonthH2PersistenceDAO.java new file mode 100644 index 000000000..11aa6707f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/ApplicationComponentMonthH2PersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.h2.dao.acp; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +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.acp.IApplicationComponentMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponent; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationComponentMonthH2PersistenceDAO extends AbstractApplicationComponentH2PersistenceDAO implements IApplicationComponentMonthPersistenceDAO { + + public ApplicationComponentMonthH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java new file mode 100644 index 000000000..051eb91ff --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java @@ -0,0 +1,94 @@ +/* + * 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.h2.dao.cache; + +import java.sql.ResultSet; +import java.sql.SQLException; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationH2CacheDAO.class); + + private static final String GET_APPLICATION_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ?"; + private static final String GET_APPLICATION_CODE_SQL = "select {0} from {1} where {2} = ?"; + + public ApplicationH2CacheDAO(H2Client client) { + super(client); + } + + @Override + public int getApplicationIdByCode(String applicationCode) { + logger.info("get the application id with application code = {}", applicationCode); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, ApplicationTable.COLUMN_APPLICATION_ID, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.COLUMN_IS_ADDRESS); + + Object[] params = new Object[] {applicationCode, false}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } + + @Override public String getApplicationCode(int applicationId) { + logger.debug("get application code, applicationId: {}", applicationId); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_APPLICATION_CODE_SQL, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID); + Object[] params = new Object[] {applicationId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getString(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return Const.EMPTY_STRING; + } + + @Override public int getApplicationIdByAddressId(int addressId) { + logger.info("get the application id with address id = {}", addressId); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, ApplicationTable.COLUMN_APPLICATION_ID, ApplicationTable.TABLE, ApplicationTable.COLUMN_ADDRESS_ID, ApplicationTable.COLUMN_IS_ADDRESS); + + Object[] params = new Object[] {addressId, true}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/InstanceH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/InstanceH2CacheDAO.java new file mode 100644 index 000000000..2a0411f77 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/InstanceH2CacheDAO.java @@ -0,0 +1,93 @@ +/* + * 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.h2.dao.cache; + +import java.sql.ResultSet; +import java.sql.SQLException; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.cache.IInstanceCacheDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceH2CacheDAO extends H2DAO implements IInstanceCacheDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceH2CacheDAO.class); + + private static final String GET_APPLICATION_ID_SQL = "select {0} from {1} where {2} = ?"; + private static final String GET_INSTANCE_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ? and {4} = ?"; + + public InstanceH2CacheDAO(H2Client client) { + super(client); + } + + @Override public int getApplicationId(int instanceId) { + logger.info("get the application id by instance id = {}", instanceId); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, InstanceTable.COLUMN_APPLICATION_ID, InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID); + Object[] params = new Object[] {instanceId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(InstanceTable.COLUMN_APPLICATION_ID); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } + + @Override public int getInstanceIdByAgentUUID(int applicationId, String agentUUID) { + logger.info("get the instance id by application id = {}, agentUUID = {}", applicationId, agentUUID); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_INSTANCE_ID_SQL, InstanceTable.COLUMN_INSTANCE_ID, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID, + InstanceTable.COLUMN_AGENT_UUID, InstanceTable.COLUMN_IS_ADDRESS); + Object[] params = new Object[] {applicationId, agentUUID, BooleanUtils.FALSE}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(InstanceTable.COLUMN_INSTANCE_ID); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } + + @Override public int getInstanceIdByAddressId(int applicationId, int addressId) { + logger.info("get the instance id by application id = {}, address id = {}", applicationId, addressId); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_INSTANCE_ID_SQL, InstanceTable.COLUMN_INSTANCE_ID, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID, + InstanceTable.COLUMN_ADDRESS_ID, InstanceTable.COLUMN_IS_ADDRESS); + Object[] params = new Object[] {applicationId, addressId, BooleanUtils.TRUE}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(InstanceTable.COLUMN_INSTANCE_ID); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/NetworkAddressH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/NetworkAddressH2CacheDAO.java new file mode 100644 index 000000000..d9aca53a0 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/NetworkAddressH2CacheDAO.java @@ -0,0 +1,77 @@ +/* + * 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.h2.dao.cache; + +import java.sql.ResultSet; +import java.sql.SQLException; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.cache.INetworkAddressCacheDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class NetworkAddressH2CacheDAO extends H2DAO implements INetworkAddressCacheDAO { + + private final Logger logger = LoggerFactory.getLogger(NetworkAddressH2CacheDAO.class); + + private static final String GET_ADDRESS_ID_OR_CODE_SQL = "select {0} from {1} where {2} = ?"; + + public NetworkAddressH2CacheDAO(H2Client client) { + super(client); + } + + @Override + public int getAddressId(String networkAddress) { + logger.info("get the address id with network address = {}", networkAddress); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_ADDRESS_ID_OR_CODE_SQL, NetworkAddressTable.COLUMN_ADDRESS_ID, NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_NETWORK_ADDRESS); + + Object[] params = new Object[] {networkAddress}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } + + @Override public String getAddress(int addressId) { + logger.debug("get network address, address id: {}", addressId); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_ADDRESS_ID_OR_CODE_SQL, NetworkAddressTable.COLUMN_NETWORK_ADDRESS, NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_ADDRESS_ID); + Object[] params = new Object[] {addressId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getString(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return Const.EMPTY_STRING; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java new file mode 100644 index 000000000..dd5de4ab7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java @@ -0,0 +1,79 @@ +/* + * 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.h2.dao.cache; + +import java.sql.ResultSet; +import java.sql.SQLException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +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.dao.cache.IServiceNameCacheDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class ServiceNameH2CacheDAO extends H2DAO implements IServiceNameCacheDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceNameH2CacheDAO.class); + + private static final String GET_SERVICE_NAME_SQL = "select {0},{1} from {2} where {3} = ?"; + private static final String GET_SERVICE_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ? limit 1"; + + public ServiceNameH2CacheDAO(H2Client client) { + super(client); + } + + @Override public String getServiceName(int serviceId) { + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_SERVICE_NAME_SQL, ServiceNameTable.COLUMN_APPLICATION_ID, ServiceNameTable.COLUMN_SERVICE_NAME, + ServiceNameTable.TABLE, ServiceNameTable.COLUMN_SERVICE_ID); + Object[] params = new Object[] {serviceId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + String serviceName = rs.getString(ServiceNameTable.COLUMN_SERVICE_NAME); + int applicationId = rs.getInt(ServiceNameTable.COLUMN_APPLICATION_ID); + return applicationId + Const.ID_SPLIT + serviceName; + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return Const.EMPTY_STRING; + } + + @Override public int getServiceId(int applicationId, String serviceName) { + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_SERVICE_ID_SQL, ServiceNameTable.COLUMN_SERVICE_ID, + ServiceNameTable.TABLE, ServiceNameTable.COLUMN_APPLICATION_ID, ServiceNameTable.COLUMN_SERVICE_NAME); + Object[] params = new Object[] {applicationId, serviceName}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt(ServiceNameTable.COLUMN_SERVICE_ID); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/MemoryPoolMetricH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/MemoryPoolMetricH2TableDefine.java deleted file mode 100644 index f15f17b5f..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/MemoryPoolMetricH2TableDefine.java +++ /dev/null @@ -1,45 +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.h2.define; - -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; - -/** - * @author peng-yongsheng - */ -public class MemoryPoolMetricH2TableDefine extends H2TableDefine { - - public MemoryPoolMetricH2TableDefine() { - super(MemoryPoolMetricTable.TABLE); - } - - @Override public void initialize() { - addColumn(new H2ColumnDefine(MemoryPoolMetricTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); - addColumn(new H2ColumnDefine(MemoryPoolMetricTable.COLUMN_INSTANCE_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(MemoryPoolMetricTable.COLUMN_POOL_TYPE, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(MemoryPoolMetricTable.COLUMN_INIT, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(MemoryPoolMetricTable.COLUMN_MAX, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(MemoryPoolMetricTable.COLUMN_USED, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(MemoryPoolMetricTable.COLUMN_COMMITTED, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(MemoryPoolMetricTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentCostH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentCostH2TableDefine.java index c0724d563..bc51a2d56 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentCostH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentCostH2TableDefine.java @@ -16,11 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.define; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; /** @@ -40,7 +39,7 @@ public class SegmentCostH2TableDefine extends H2TableDefine { addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_COST, H2ColumnDefine.Type.Bigint.name())); addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_START_TIME, H2ColumnDefine.Type.Bigint.name())); addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_END_TIME, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_IS_ERROR, H2ColumnDefine.Type.Boolean.name())); + addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_IS_ERROR, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java new file mode 100644 index 000000000..570dcc7f7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java @@ -0,0 +1,41 @@ +/* + * 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.h2.define.appcomp; + +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractApplicationComponentH2TableDefine extends H2TableDefine { + + AbstractApplicationComponentH2TableDefine(String name) { + super(name); + } + + @Override public final void initialize() { + addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_METRIC_ID, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_COMPONENT_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_PEER_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentDayH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentDayH2TableDefine.java new file mode 100644 index 000000000..3701b831e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentDayH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.h2.define.appcomp; + +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.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentDayH2TableDefine extends AbstractApplicationComponentH2TableDefine { + + public ApplicationComponentDayH2TableDefine() { + super(ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentHourH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentHourH2TableDefine.java new file mode 100644 index 000000000..a28292f5e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentHourH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.h2.define.appcomp; + +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.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentHourH2TableDefine extends AbstractApplicationComponentH2TableDefine { + + public ApplicationComponentHourH2TableDefine() { + super(ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentMinuteH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentMinuteH2TableDefine.java new file mode 100644 index 000000000..62412d3eb --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentMinuteH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.h2.define.appcomp; + +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.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentMinuteH2TableDefine extends AbstractApplicationComponentH2TableDefine { + + public ApplicationComponentMinuteH2TableDefine() { + super(ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentMonthH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentMonthH2TableDefine.java new file mode 100644 index 000000000..e4c7f2c7b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/ApplicationComponentMonthH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.h2.define.appcomp; + +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.table.application.ApplicationComponentTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentMonthH2TableDefine extends AbstractApplicationComponentH2TableDefine { + + public ApplicationComponentMonthH2TableDefine() { + super(ApplicationComponentTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/memory/AbstractMemoryMetricH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/memory/AbstractMemoryMetricH2TableDefine.java index cecb25861..d836756ba 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/memory/AbstractMemoryMetricH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/memory/AbstractMemoryMetricH2TableDefine.java @@ -35,7 +35,7 @@ public abstract class AbstractMemoryMetricH2TableDefine extends H2TableDefine { addColumn(new H2ColumnDefine(MemoryMetricTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(MemoryMetricTable.COLUMN_METRIC_ID, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(MemoryMetricTable.COLUMN_INSTANCE_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(MemoryMetricTable.COLUMN_IS_HEAP, H2ColumnDefine.Type.Boolean.name())); + addColumn(new H2ColumnDefine(MemoryMetricTable.COLUMN_IS_HEAP, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(MemoryMetricTable.COLUMN_INIT, H2ColumnDefine.Type.Bigint.name())); addColumn(new H2ColumnDefine(MemoryMetricTable.COLUMN_MAX, H2ColumnDefine.Type.Bigint.name())); addColumn(new H2ColumnDefine(MemoryMetricTable.COLUMN_USED, H2ColumnDefine.Type.Bigint.name())); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/ApplicationH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/ApplicationH2TableDefine.java index 6936ed032..62ef7fd27 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/ApplicationH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/ApplicationH2TableDefine.java @@ -36,6 +36,6 @@ public class ApplicationH2TableDefine extends H2TableDefine { addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_CODE, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Boolean.name())); + addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Int.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/InstanceH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/InstanceH2TableDefine.java index 38a49db3c..2b763d17f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/InstanceH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/InstanceH2TableDefine.java @@ -40,6 +40,6 @@ public class InstanceH2TableDefine extends H2TableDefine { addColumn(new H2ColumnDefine(InstanceTable.COLUMN_HEARTBEAT_TIME, H2ColumnDefine.Type.Bigint.name())); addColumn(new H2ColumnDefine(InstanceTable.COLUMN_OS_INFO, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(InstanceTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(InstanceTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Boolean.name())); + addColumn(new H2ColumnDefine(InstanceTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Int.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define index 2d97a3887..ae74743e6 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define @@ -25,4 +25,9 @@ org.apache.skywalking.apm.collector.storage.h2.define.mpool.MemoryPoolSecondMetr org.apache.skywalking.apm.collector.storage.h2.define.mpool.MemoryPoolMinuteMetricH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.mpool.MemoryPoolHourMetricH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.mpool.MemoryPoolDayMetricH2TableDefine -org.apache.skywalking.apm.collector.storage.h2.define.mpool.MemoryPoolMonthMetricH2TableDefine \ No newline at end of file +org.apache.skywalking.apm.collector.storage.h2.define.mpool.MemoryPoolMonthMetricH2TableDefine + +org.apache.skywalking.apm.collector.storage.h2.define.appcomp.ApplicationComponentMinuteH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.appcomp.ApplicationComponentHourH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.appcomp.ApplicationComponentDayH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.appcomp.ApplicationComponentMonthH2TableDefine \ No newline at end of file