use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class AbstractPersistenceH2DAO method get.
@Override
public final STREAM_DATA get(String id) {
String sql = SqlBuilder.buildSql(GET_SQL, tableName(), CommonTable.COLUMN_ID);
Object[] params = new Object[] { id };
try (ResultSet resultSet = getClient().executeQuery(sql, params)) {
if (resultSet.next()) {
return h2DataToStreamData(resultSet);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return null;
}
use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class InstanceHeartBeatH2PersistenceDAO method get.
@Override
public Instance get(String id) {
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_INSTANCE_HEARTBEAT_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID);
Object[] params = new Object[] { id };
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
Instance instance = new Instance();
instance.setId(id);
instance.setInstanceId(rs.getInt(InstanceTable.COLUMN_INSTANCE_ID));
instance.setHeartBeatTime(rs.getLong(InstanceTable.COLUMN_HEARTBEAT_TIME));
return instance;
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return null;
}
use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class GlobalTraceH2UIDAO method getSegmentIds.
@Override
public List<String> getSegmentIds(String globalTraceId) {
List<String> segmentIds = new ArrayList<>();
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_SEGMENT_IDS_SQL, GlobalTraceTable.COLUMN_SEGMENT_ID, GlobalTraceTable.TABLE, GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID);
Object[] params = new Object[] { globalTraceId };
try (ResultSet rs = client.executeQuery(sql, params)) {
while (rs.next()) {
String segmentId = rs.getString(GlobalTraceTable.COLUMN_SEGMENT_ID);
logger.debug("segmentId: {}, global trace id: {}", segmentId, globalTraceId);
segmentIds.add(segmentId);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return segmentIds;
}
use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class InstanceH2UIDAO method buildAppServerInfo.
private List<AppServerInfo> buildAppServerInfo(String sql, Object[] params) {
H2Client client = getClient();
List<AppServerInfo> appServerInfos = new LinkedList<>();
try (ResultSet rs = client.executeQuery(sql, params)) {
while (rs.next()) {
AppServerInfo appServerInfo = new AppServerInfo();
appServerInfo.setId(rs.getInt(InstanceTable.COLUMN_INSTANCE_ID));
appServerInfo.setOsInfo(rs.getString(InstanceTable.COLUMN_OS_INFO));
appServerInfos.add(appServerInfo);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return appServerInfos;
}
use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class MemoryMetricH2UIDAO method getMemoryTrend.
private Trend getMemoryTrend(int instanceId, Step step, List<DurationPoint> durationPoints, boolean isHeap) {
String tableName = TimePyramidTableNameBuilder.build(step, MemoryMetricTable.TABLE);
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_MEMORY_METRIC_SQL, tableName, MemoryMetricTable.COLUMN_ID);
Trend trend = new Trend();
durationPoints.forEach(durationPoint -> {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + BooleanUtils.booleanToValue(isHeap);
try (ResultSet rs = client.executeQuery(sql, new String[] { id })) {
if (rs.next()) {
long max = rs.getLong(MemoryMetricTable.COLUMN_MAX);
long used = rs.getLong(MemoryMetricTable.COLUMN_USED);
long times = rs.getLong(MemoryMetricTable.COLUMN_TIMES);
trend.getMetrics().add((int) (used / times));
if (max < 0) {
trend.getMaxMetrics().add((int) (used / times));
} else {
trend.getMaxMetrics().add((int) (max / times));
}
} else {
trend.getMetrics().add(0);
trend.getMaxMetrics().add(0);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
});
return trend;
}
Aggregations