Search in sources :

Example 6 with Instance

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;
}
Also used : Instance(org.apache.skywalking.apm.collector.storage.table.register.Instance)

Example 7 with Instance

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;
}
Also used : Instance(org.apache.skywalking.apm.collector.storage.table.register.Instance)

Example 8 with Instance

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;
}
Also used : H2Client(org.apache.skywalking.apm.collector.client.h2.H2Client) Instance(org.apache.skywalking.apm.collector.storage.table.register.Instance) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) H2ClientException(org.apache.skywalking.apm.collector.client.h2.H2ClientException)

Example 9 with Instance

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;
    }
}
Also used : Instance(org.apache.skywalking.apm.collector.storage.table.register.Instance) GetResponse(org.elasticsearch.action.get.GetResponse)

Example 10 with Instance

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;
}
Also used : AppServerInfo(org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo) Instance(org.apache.skywalking.apm.collector.storage.table.register.Instance) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint)

Aggregations

Instance (org.apache.skywalking.apm.collector.storage.table.register.Instance)12 JsonObject (com.google.gson.JsonObject)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 H2Client (org.apache.skywalking.apm.collector.client.h2.H2Client)2 H2ClientException (org.apache.skywalking.apm.collector.client.h2.H2ClientException)2 GetResponse (org.elasticsearch.action.get.GetResponse)2 HashMap (java.util.HashMap)1 Alarm (org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm)1 AppServerInfo (org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo)1 DurationPoint (org.apache.skywalking.apm.collector.storage.utils.DurationPoint)1 GetRequestBuilder (org.elasticsearch.action.get.GetRequestBuilder)1