use of org.apache.skywalking.apm.collector.storage.table.register.Instance in project incubator-skywalking by apache.
the class InstanceIDService method getOrCreateByAgentUUID.
@Override
public int getOrCreateByAgentUUID(int applicationId, String agentUUID, long registerTime, String osInfo) {
logger.debug("get or getOrCreate instance id by agent UUID, application id: {}, agentUUID: {}, registerTime: {}, osInfo: {}", applicationId, agentUUID, registerTime, osInfo);
int instanceId = getInstanceCacheService().getInstanceIdByAgentUUID(applicationId, agentUUID);
if (instanceId == 0) {
Instance instance = new Instance();
instance.setId("0");
instance.setApplicationId(applicationId);
instance.setApplicationCode(getApplicationCacheService().getApplicationById(applicationId).getApplicationCode());
instance.setAgentUUID(agentUUID);
instance.setRegisterTime(registerTime);
instance.setHeartBeatTime(registerTime);
instance.setInstanceId(0);
instance.setOsInfo(osInfo);
instance.setIsAddress(BooleanUtils.FALSE);
instance.setAddressId(Const.NONE);
getInstanceRegisterGraph().start(instance);
}
return instanceId;
}
use of org.apache.skywalking.apm.collector.storage.table.register.Instance in project incubator-skywalking by apache.
the class InstanceIDService method getOrCreateByAddressId.
@Override
public int getOrCreateByAddressId(int applicationId, int addressId, long registerTime) {
logger.debug("get or getOrCreate instance id by address id, application id: {}, address id: {}, registerTime: {}", applicationId, addressId, registerTime);
int instanceId = getInstanceCacheService().getInstanceIdByAddressId(applicationId, addressId);
if (instanceId == 0) {
Instance instance = new Instance();
instance.setId("0");
instance.setApplicationId(applicationId);
instance.setApplicationCode(getApplicationCacheService().getApplicationById(applicationId).getApplicationCode());
instance.setAgentUUID(Const.EMPTY_STRING);
instance.setRegisterTime(registerTime);
instance.setHeartBeatTime(registerTime);
instance.setInstanceId(0);
instance.setOsInfo(Const.EMPTY_STRING);
instance.setIsAddress(BooleanUtils.TRUE);
instance.setAddressId(addressId);
getInstanceRegisterGraph().start(instance);
}
return instanceId;
}
use of org.apache.skywalking.apm.collector.storage.table.register.Instance in project incubator-skywalking by apache.
the class InstanceH2UIDAO method getInstance.
@Override
public Instance getInstance(int instanceId) {
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_INSTANCE_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID);
Object[] params = new Object[] { instanceId };
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
Instance instance = new Instance();
instance.setId(rs.getString(InstanceTable.COLUMN_ID));
instance.setApplicationId(rs.getInt(InstanceTable.COLUMN_APPLICATION_ID));
instance.setAgentUUID(rs.getString(InstanceTable.COLUMN_AGENT_UUID));
instance.setRegisterTime(rs.getLong(InstanceTable.COLUMN_REGISTER_TIME));
instance.setHeartBeatTime(rs.getLong(InstanceTable.COLUMN_HEARTBEAT_TIME));
instance.setOsInfo(rs.getString(InstanceTable.COLUMN_OS_INFO));
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 InstanceHeartBeatEsPersistenceDAO method get.
@Override
public Instance get(String id) {
GetResponse getResponse = getClient().prepareGet(InstanceTable.TABLE, id).get();
if (getResponse.isExists()) {
Map<String, Object> source = getResponse.getSource();
Instance instance = new Instance();
instance.setId(id);
instance.setInstanceId(((Number) source.get(InstanceTable.COLUMN_INSTANCE_ID)).intValue());
instance.setHeartBeatTime(((Number) source.get(InstanceTable.COLUMN_HEARTBEAT_TIME)).longValue());
logger.debug("getApplicationId: {} is exists", id);
return instance;
} else {
logger.debug("getApplicationId: {} is not exists", id);
return null;
}
}
use of org.apache.skywalking.apm.collector.storage.table.register.Instance in project incubator-skywalking by apache.
the class ServerService method getServerThroughput.
public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long startTimeBucket, long endTimeBucket, long startSecondTimeBucket, long endSecondTimeBucket, Integer topN) throws ParseException {
int secondBetween = secondBetweenService.calculate(applicationId, startSecondTimeBucket, endSecondTimeBucket);
List<AppServerInfo> serverThroughput = instanceMetricUIDAO.getServerThroughput(applicationId, step, startTimeBucket, endTimeBucket, secondBetween, topN, MetricSource.Callee);
serverThroughput.forEach(appServerInfo -> {
appServerInfo.setApplicationId(instanceCacheService.getApplicationId(appServerInfo.getId()));
String applicationCode = applicationCacheService.getApplicationById(appServerInfo.getApplicationId()).getApplicationCode();
appServerInfo.setApplicationCode(applicationCode);
Instance instance = instanceUIDAO.getInstance(appServerInfo.getId());
appServerInfo.setOsInfo(instance.getOsInfo());
});
buildAppServerInfo(serverThroughput);
return serverThroughput;
}
Aggregations