use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class ApplicationComponentH2UIDAO method load.
@Override
public List<ApplicationComponent> load(Step step, long startTimeBucket, long endTimeBucket) {
H2Client client = getClient();
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE);
List<ApplicationComponent> applicationComponents = new LinkedList<>();
String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, ApplicationComponentTable.COLUMN_COMPONENT_ID, ApplicationComponentTable.COLUMN_APPLICATION_ID, tableName, ApplicationComponentTable.COLUMN_TIME_BUCKET);
Object[] params = new Object[] { startTimeBucket, endTimeBucket };
try (ResultSet rs = client.executeQuery(sql, params)) {
while (rs.next()) {
int applicationId = rs.getInt(ApplicationComponentTable.COLUMN_APPLICATION_ID);
int componentId = rs.getInt(ApplicationComponentTable.COLUMN_COMPONENT_ID);
ApplicationComponent applicationComponent = new ApplicationComponent();
applicationComponent.setComponentId(componentId);
applicationComponent.setApplicationId(applicationId);
applicationComponents.add(applicationComponent);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return applicationComponents;
}
use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class MemoryPoolMetricH2UIDAO method getMetric.
@Override
public JsonObject getMetric(int instanceId, long timeBucket, int poolType) {
H2Client client = getClient();
String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType;
String sql = SqlBuilder.buildSql(GET_MEMORY_POOL_METRIC_SQL, MemoryPoolMetricTable.TABLE, MemoryPoolMetricTable.COLUMN_ID);
Object[] params = new Object[] { id };
JsonObject metric = new JsonObject();
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
metric.addProperty("max", rs.getInt(MemoryPoolMetricTable.COLUMN_MAX));
metric.addProperty("init", rs.getInt(MemoryPoolMetricTable.COLUMN_INIT));
metric.addProperty("used", rs.getInt(MemoryPoolMetricTable.COLUMN_USED));
} else {
metric.addProperty("max", 0);
metric.addProperty("init", 0);
metric.addProperty("used", 0);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return metric;
}
Aggregations