Search in sources :

Example 16 with H2Client

use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.

the class InstanceRegisterH2DAO method updateHeartbeatTime.

@Override
public void updateHeartbeatTime(int instanceId, long heartbeatTime) {
    H2Client client = getClient();
    String sql = SqlBuilder.buildSql(UPDATE_HEARTBEAT_TIME_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_ID);
    Object[] params = new Object[] { TimeBucketUtils.INSTANCE.getSecondTimeBucket(heartbeatTime), instanceId };
    try {
        client.execute(sql, params);
    } catch (H2ClientException e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : H2Client(org.apache.skywalking.apm.collector.client.h2.H2Client) H2ClientException(org.apache.skywalking.apm.collector.client.h2.H2ClientException)

Example 17 with H2Client

use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.

the class InstanceRegisterH2DAO method save.

@Override
public void save(Instance instance) {
    H2Client client = getClient();
    Map<String, Object> source = new HashMap<>();
    source.put(InstanceTable.COLUMN_ID, instance.getId());
    source.put(InstanceTable.COLUMN_INSTANCE_ID, instance.getInstanceId());
    source.put(InstanceTable.COLUMN_APPLICATION_ID, instance.getApplicationId());
    source.put(InstanceTable.COLUMN_APPLICATION_CODE, instance.getApplicationCode());
    source.put(InstanceTable.COLUMN_AGENT_UUID, instance.getAgentUUID());
    source.put(InstanceTable.COLUMN_REGISTER_TIME, TimeBucketUtils.INSTANCE.getSecondTimeBucket(instance.getRegisterTime()));
    source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, TimeBucketUtils.INSTANCE.getSecondTimeBucket(instance.getHeartBeatTime()));
    source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo());
    source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId());
    source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress());
    String sql = SqlBuilder.buildBatchInsertSql(InstanceTable.TABLE, source.keySet());
    Object[] params = source.values().toArray(new Object[0]);
    try {
        client.execute(sql, params);
    } catch (H2ClientException e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : H2Client(org.apache.skywalking.apm.collector.client.h2.H2Client) HashMap(java.util.HashMap) H2ClientException(org.apache.skywalking.apm.collector.client.h2.H2ClientException)

Example 18 with H2Client

use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.

the class ServiceNameRegisterH2DAO method save.

@Override
public void save(ServiceName serviceName) {
    logger.debug("save service name register info, application getApplicationId: {}, service name: {}", serviceName.getId(), serviceName.getServiceName());
    H2Client client = getClient();
    Map<String, Object> source = new HashMap<>();
    source.put(ServiceNameTable.COLUMN_ID, serviceName.getId());
    source.put(ServiceNameTable.COLUMN_SERVICE_ID, serviceName.getServiceId());
    source.put(ServiceNameTable.COLUMN_APPLICATION_ID, serviceName.getApplicationId());
    source.put(ServiceNameTable.COLUMN_SERVICE_NAME, serviceName.getServiceName());
    source.put(ServiceNameTable.COLUMN_SRC_SPAN_TYPE, serviceName.getSrcSpanType());
    String sql = SqlBuilder.buildBatchInsertSql(ServiceNameTable.TABLE, source.keySet());
    Object[] params = source.values().toArray(new Object[0]);
    try {
        client.execute(sql, params);
    } catch (H2ClientException e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : H2Client(org.apache.skywalking.apm.collector.client.h2.H2Client) HashMap(java.util.HashMap) H2ClientException(org.apache.skywalking.apm.collector.client.h2.H2ClientException)

Example 19 with H2Client

use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.

the class NetworkAddressRegisterH2DAO method save.

@Override
public void save(NetworkAddress networkAddress) {
    H2Client client = getClient();
    Map<String, Object> source = new HashMap<>();
    source.put(NetworkAddressTable.COLUMN_ID, networkAddress.getId());
    source.put(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, networkAddress.getNetworkAddress());
    source.put(NetworkAddressTable.COLUMN_ADDRESS_ID, networkAddress.getAddressId());
    source.put(NetworkAddressTable.COLUMN_SPAN_LAYER, networkAddress.getSpanLayer());
    source.put(NetworkAddressTable.COLUMN_SERVER_TYPE, networkAddress.getServerType());
    String sql = SqlBuilder.buildBatchInsertSql(NetworkAddressTable.TABLE, source.keySet());
    Object[] params = source.values().toArray(new Object[0]);
    try {
        client.execute(sql, params);
    } catch (H2ClientException e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : H2Client(org.apache.skywalking.apm.collector.client.h2.H2Client) HashMap(java.util.HashMap) H2ClientException(org.apache.skywalking.apm.collector.client.h2.H2ClientException)

Example 20 with H2Client

use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.

the class InstanceMetricH2UIDAO method getServerTPSTrend.

@Override
public List<Integer> getServerTPSTrend(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> throughputTrend = 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);
                throughputTrend.add((int) (callTimes / durationPoint.getSecondsBetween()));
            } else {
                throughputTrend.add(0);
            }
        } catch (SQLException | H2ClientException e) {
            logger.error(e.getMessage(), e);
        }
    });
    return throughputTrend;
}
Also used : H2Client(org.apache.skywalking.apm.collector.client.h2.H2Client) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) H2ClientException(org.apache.skywalking.apm.collector.client.h2.H2ClientException) LinkedList(java.util.LinkedList)

Aggregations

H2Client (org.apache.skywalking.apm.collector.client.h2.H2Client)41 H2ClientException (org.apache.skywalking.apm.collector.client.h2.H2ClientException)40 ResultSet (java.sql.ResultSet)32 SQLException (java.sql.SQLException)32 LinkedList (java.util.LinkedList)10 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)3 StorageInstallException (org.apache.skywalking.apm.collector.storage.StorageInstallException)2 Instance (org.apache.skywalking.apm.collector.storage.table.register.Instance)2 JsonObject (com.google.gson.JsonObject)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 StandaloneModuleListenerService (org.apache.skywalking.apm.collector.cluster.standalone.service.StandaloneModuleListenerService)1 StandaloneModuleRegisterService (org.apache.skywalking.apm.collector.cluster.standalone.service.StandaloneModuleRegisterService)1 StorageException (org.apache.skywalking.apm.collector.storage.StorageException)1 BatchH2DAO (org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO)1 H2StorageInstaller (org.apache.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller)1 Application (org.apache.skywalking.apm.collector.storage.table.register.Application)1 NetworkAddress (org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress)1 ServiceName (org.apache.skywalking.apm.collector.storage.table.register.ServiceName)1 Application (org.apache.skywalking.apm.collector.storage.ui.application.Application)1