use of org.apache.skywalking.apm.collector.storage.table.register.Instance 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.storage.table.register.Instance in project incubator-skywalking by apache.
the class InstanceMetricAlarmAssertWorker method generateAlarmContent.
@Override
protected void generateAlarmContent(InstanceAlarm alarm, double threshold) {
Instance instance = instanceDAO.getInstance(alarm.getInstanceId());
JsonObject osInfo = gson.fromJson(instance.getOsInfo(), JsonObject.class);
String serverName = Const.UNKNOWN;
if (osInfo.has("hostName")) {
serverName = osInfo.get("hostName").getAsString();
}
String clientOrServer = "server";
if (MetricSource.Caller.getValue() == alarm.getSourceValue()) {
clientOrServer = "client";
}
if (AlarmType.ERROR_RATE.getValue() == alarm.getAlarmType()) {
alarm.setAlarmContent("The success rate of " + serverName + ", detected from " + clientOrServer + " side, is lower than " + threshold + " rate.");
} else if (AlarmType.SLOW_RTT.getValue() == alarm.getAlarmType()) {
alarm.setAlarmContent("Response time of " + serverName + ", detected from " + clientOrServer + " side, is slower than " + threshold + " ms.");
}
}
Aggregations