diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeComponentH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeComponentH2UIDAO.java index b1b577a81a85c2798f2f2acda15e40f52affb4b0..caa4d521c057d93924030488a36d8366bea6b277 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeComponentH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeComponentH2UIDAO.java @@ -19,6 +19,7 @@ package org.skywalking.apm.collector.storage.h2.dao; import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.sql.ResultSet; import java.sql.SQLException; import org.skywalking.apm.collector.client.h2.H2Client; @@ -27,7 +28,6 @@ import org.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.skywalking.apm.collector.storage.dao.INodeComponentUIDAO; import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.skywalking.apm.collector.storage.table.node.NodeComponentTable; -import org.skywalking.apm.network.trace.component.ComponentsDefine; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory; public class NodeComponentH2UIDAO extends H2DAO implements INodeComponentUIDAO { private final Logger logger = LoggerFactory.getLogger(NodeComponentH2UIDAO.class); - private static final String AGGREGATE_COMPONENT_SQL = "select {0}, {1}, {2} from {3} where {4} >= ? and {4} <= ? group by {0}, {1}, {2} limit 100"; + private static final String AGGREGATE_COMPONENT_SQL = "select {0}, {1} from {2} where {3} >= ? and {3} <= ? group by {0}, {1} limit 100"; public NodeComponentH2UIDAO(H2Client client) { super(client); @@ -53,19 +53,17 @@ public class NodeComponentH2UIDAO extends H2DAO implements INodeComponentUIDAO { H2Client client = getClient(); JsonArray nodeComponentArray = new JsonArray(); - String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, NodeComponentTable.COLUMN_COMPONENT_ID, + String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, NodeComponentTable.COLUMN_COMPONENT_ID, NodeComponentTable.COLUMN_PEER_ID, NodeComponentTable.TABLE, NodeComponentTable.COLUMN_TIME_BUCKET); Object[] params = new Object[] {startTime, endTime}; try (ResultSet rs = client.executeQuery(sql, params)) { while (rs.next()) { int peerId = rs.getInt(NodeComponentTable.COLUMN_PEER_ID); int componentId = rs.getInt(NodeComponentTable.COLUMN_COMPONENT_ID); - String componentName = ComponentsDefine.getInstance().getComponentName(componentId); - if (peerId != 0) { - //TODO ApplicationCache -// String peer = ApplicationCache.get(peerId); -// nodeComponentArray.add(buildNodeComponent(peer, componentName)); - } + JsonObject nodeComponentObj = new JsonObject(); + nodeComponentObj.addProperty(NodeComponentTable.COLUMN_COMPONENT_ID, componentId); + nodeComponentObj.addProperty(NodeComponentTable.COLUMN_PEER_ID, peerId); + nodeComponentArray.add(nodeComponentObj); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeMappingH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeMappingH2UIDAO.java index 2787b22c1e663c8aac01908bd72b7cf6c66b0f18..d38b6ccdd41af214f84308a26c77dd6831e4ea92 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeMappingH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeMappingH2UIDAO.java @@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory; public class NodeMappingH2UIDAO extends H2DAO implements INodeMappingUIDAO { private final Logger logger = LoggerFactory.getLogger(NodeMappingH2UIDAO.class); - private static final String NODE_MAPPING_SQL = "select {0}, {1}, {2} from {3} where {4} >= ? and {4} <= ? group by {0}, {1}, {2} limit 100"; + private static final String NODE_MAPPING_SQL = "select {0}, {1} from {2} where {3} >= ? and {3} <= ? group by {0}, {1} limit 100"; public NodeMappingH2UIDAO(H2Client client) { super(client); @@ -53,13 +53,10 @@ public class NodeMappingH2UIDAO extends H2DAO implements INodeMappingUIDAO { try (ResultSet rs = client.executeQuery(sql, params)) { while (rs.next()) { int applicationId = rs.getInt(NodeMappingTable.COLUMN_APPLICATION_ID); - //TODO ApplicationCache -// String applicationCode = ApplicationCache.get(applicationId); int addressId = rs.getInt(NodeMappingTable.COLUMN_ADDRESS_ID); -// String address = ApplicationCache.get(addressId); JsonObject nodeMappingObj = new JsonObject(); -// nodeMappingObj.addProperty("applicationCode", applicationCode); -// nodeMappingObj.addProperty("address", address); + nodeMappingObj.addProperty(NodeMappingTable.COLUMN_APPLICATION_ID, applicationId); + nodeMappingObj.addProperty(NodeMappingTable.COLUMN_ADDRESS_ID, addressId); nodeMappingArray.add(nodeMappingObj); } } catch (SQLException | H2ClientException e) { diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeReferenceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeReferenceH2UIDAO.java index ac176e3a27d2afd3e6b04e137d2e88959652b5e0..98b8ddf56390bc839fa2ed5f40a50733e08dacb3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeReferenceH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeReferenceH2UIDAO.java @@ -24,6 +24,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import org.skywalking.apm.collector.client.h2.H2Client; import org.skywalking.apm.collector.client.h2.H2ClientException; +import org.skywalking.apm.collector.core.util.ColumnNameUtils; import org.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.skywalking.apm.collector.storage.dao.INodeReferenceUIDAO; import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO; @@ -37,8 +38,8 @@ import org.slf4j.LoggerFactory; public class NodeReferenceH2UIDAO extends H2DAO implements INodeReferenceUIDAO { private final Logger logger = LoggerFactory.getLogger(NodeReferenceH2UIDAO.class); - private static final String NODE_REFERENCE_SQL = "select {8}, {9}, {10}, sum({0}) as {0}, sum({1}) as {1}, sum({2}) as {2}, " + - "sum({3}) as {3}, sum({4}) as {4}, sum({5}) as {5} from {6} where {7} >= ? and {7} <= ? group by {8}, {9}, {10} limit 100"; + private static final String NODE_REFERENCE_SQL = "select {8}, {9}, sum({0}) as {0}, sum({1}) as {1}, sum({2}) as {2}, " + + "sum({3}) as {3}, sum({4}) as {4}, sum({5}) as {5} from {6} where {7} >= ? and {7} <= ? group by {8}, {9} limit 100"; public NodeReferenceH2UIDAO(H2Client client) { super(client); @@ -56,24 +57,18 @@ public class NodeReferenceH2UIDAO extends H2DAO implements INodeReferenceUIDAO { Object[] params = new Object[] {startTime, endTime}; try (ResultSet rs = client.executeQuery(sql, params)) { while (rs.next()) { - int applicationId = rs.getInt(NodeReferenceTable.COLUMN_FRONT_APPLICATION_ID); - //TODO ApplicationCache -// String applicationCode = ApplicationCache.get(applicationId); + int frontApplicationId = rs.getInt(NodeReferenceTable.COLUMN_FRONT_APPLICATION_ID); int behindApplicationId = rs.getInt(NodeReferenceTable.COLUMN_BEHIND_APPLICATION_ID); - if (behindApplicationId != 0) { -// String behindApplicationCode = ApplicationCache.get(behindApplicationId); - - JsonObject nodeRefResSumObj = new JsonObject(); -// nodeRefResSumObj.addProperty("front", applicationCode); -// nodeRefResSumObj.addProperty("behind", behindApplicationCode); - nodeRefResSumObj.addProperty(NodeReferenceTable.COLUMN_S1_LTE, rs.getDouble(NodeReferenceTable.COLUMN_S1_LTE)); - nodeRefResSumObj.addProperty(NodeReferenceTable.COLUMN_S3_LTE, rs.getDouble(NodeReferenceTable.COLUMN_S3_LTE)); - nodeRefResSumObj.addProperty(NodeReferenceTable.COLUMN_S5_LTE, rs.getDouble(NodeReferenceTable.COLUMN_S5_LTE)); - nodeRefResSumObj.addProperty(NodeReferenceTable.COLUMN_S5_GT, rs.getDouble(NodeReferenceTable.COLUMN_S5_GT)); - nodeRefResSumObj.addProperty(NodeReferenceTable.COLUMN_ERROR, rs.getDouble(NodeReferenceTable.COLUMN_ERROR)); - nodeRefResSumObj.addProperty(NodeReferenceTable.COLUMN_SUMMARY, rs.getDouble(NodeReferenceTable.COLUMN_SUMMARY)); - nodeRefResSumArray.add(nodeRefResSumObj); - } + JsonObject nodeRefResSumObj = new JsonObject(); + nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(NodeReferenceTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId); + nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(NodeReferenceTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId); + nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(NodeReferenceTable.COLUMN_S1_LTE), rs.getDouble(NodeReferenceTable.COLUMN_S1_LTE)); + nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(NodeReferenceTable.COLUMN_S3_LTE), rs.getDouble(NodeReferenceTable.COLUMN_S3_LTE)); + nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(NodeReferenceTable.COLUMN_S5_LTE), rs.getDouble(NodeReferenceTable.COLUMN_S5_LTE)); + nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(NodeReferenceTable.COLUMN_S5_GT), rs.getDouble(NodeReferenceTable.COLUMN_S5_GT)); + nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(NodeReferenceTable.COLUMN_ERROR), rs.getDouble(NodeReferenceTable.COLUMN_ERROR)); + nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(NodeReferenceTable.COLUMN_SUMMARY), rs.getDouble(NodeReferenceTable.COLUMN_SUMMARY)); + nodeRefResSumArray.add(nodeRefResSumObj); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e);