use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class ApplicationMappingH2UIDAO method load.
@Override
public List<ApplicationMapping> load(Step step, long startTimeBucket, long endTimeBucket) {
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMappingTable.TABLE);
H2Client client = getClient();
String sql = SqlBuilder.buildSql(APPLICATION_MAPPING_SQL, ApplicationMappingTable.COLUMN_APPLICATION_ID, ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, tableName, ApplicationMappingTable.COLUMN_TIME_BUCKET);
List<ApplicationMapping> applicationMappings = new LinkedList<>();
Object[] params = new Object[] { startTimeBucket, endTimeBucket };
try (ResultSet rs = client.executeQuery(sql, params)) {
while (rs.next()) {
int applicationId = rs.getInt(ApplicationMappingTable.COLUMN_APPLICATION_ID);
int addressId = rs.getInt(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID);
ApplicationMapping applicationMapping = new ApplicationMapping();
applicationMapping.setApplicationId(applicationId);
applicationMapping.setMappingApplicationId(addressId);
applicationMappings.add(applicationMapping);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
logger.debug("node mapping data: {}", applicationMappings.toString());
return applicationMappings;
}
use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class GCMetricH2UIDAO method getGCTrend.
private List<Integer> getGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints, int gcPhrase) {
String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE);
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_GC_METRIC_SQL, tableName, GCMetricTable.COLUMN_ID);
List<Integer> gcTrends = new LinkedList<>();
durationPoints.forEach(durationPoint -> {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase;
try (ResultSet rs = client.executeQuery(sql, new String[] { id })) {
if (rs.next()) {
long count = rs.getLong(GCMetricTable.COLUMN_COUNT);
long times = rs.getLong(GCMetricTable.COLUMN_TIMES);
gcTrends.add((int) (count / times));
} else {
gcTrends.add(0);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
});
return gcTrends;
}
use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class InstanceMetricH2UIDAO method getResponseTimeTrend.
@Override
public List<Integer> getResponseTimeTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
H2Client client = getClient();
String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE);
String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, tableName, InstanceMetricTable.COLUMN_ID);
List<Integer> responseTimeTrends = new LinkedList<>();
durationPoints.forEach(durationPoint -> {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue();
try (ResultSet rs = client.executeQuery(sql, new Object[] { id })) {
if (rs.next()) {
long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS);
long durationSum = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
responseTimeTrends.add((int) (durationSum / callTimes));
} else {
responseTimeTrends.add(0);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
});
return responseTimeTrends;
}
use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class ApplicationRegisterH2DAO method save.
@Override
public void save(Application application) {
H2Client client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(ApplicationTable.COLUMN_ID, application.getId());
source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode());
source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId());
source.put(ApplicationTable.COLUMN_ADDRESS_ID, application.getAddressId());
source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress());
String sql = SqlBuilder.buildBatchInsertSql(ApplicationTable.TABLE, source.keySet());
Object[] params = source.values().toArray(new Object[0]);
try {
client.execute(sql, params);
} catch (H2ClientException e) {
logger.error(e.getMessage(), e);
}
}
use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class NetworkAddressRegisterH2DAO method update.
@Override
public void update(String id, int spanLayer, int serverType) {
H2Client client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(NetworkAddressTable.COLUMN_SPAN_LAYER, spanLayer);
source.put(NetworkAddressTable.COLUMN_SERVER_TYPE, serverType);
String sql = SqlBuilder.buildBatchUpdateSql(InstanceTable.TABLE, source.keySet(), InstanceTable.COLUMN_INSTANCE_ID);
Object[] params = source.values().toArray(new Object[] { id });
try {
client.execute(sql, params);
} catch (H2ClientException e) {
logger.error(e.getMessage(), e);
}
}
Aggregations