use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class ApplicationRegisterH2DAO method save.
@Override
public void save(Application application) {
H2Client client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(ApplicationTable.COLUMN_ID, application.getId());
source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode());
source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId());
source.put(ApplicationTable.COLUMN_ADDRESS_ID, application.getAddressId());
source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress());
String sql = SqlBuilder.buildBatchInsertSql(ApplicationTable.TABLE, source.keySet());
Object[] params = source.values().toArray(new Object[0]);
try {
client.execute(sql, params);
} catch (H2ClientException e) {
logger.error(e.getMessage(), e);
}
}
use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class NetworkAddressRegisterH2DAO method update.
@Override
public void update(String id, int spanLayer, int serverType) {
H2Client client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(NetworkAddressTable.COLUMN_SPAN_LAYER, spanLayer);
source.put(NetworkAddressTable.COLUMN_SERVER_TYPE, serverType);
String sql = SqlBuilder.buildBatchUpdateSql(InstanceTable.TABLE, source.keySet(), InstanceTable.COLUMN_INSTANCE_ID);
Object[] params = source.values().toArray(new Object[] { id });
try {
client.execute(sql, params);
} catch (H2ClientException e) {
logger.error(e.getMessage(), e);
}
}
use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class ApplicationComponentH2UIDAO method load.
@Override
public List<ApplicationComponent> load(Step step, long startTimeBucket, long endTimeBucket) {
H2Client client = getClient();
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE);
List<ApplicationComponent> applicationComponents = new LinkedList<>();
String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, ApplicationComponentTable.COLUMN_COMPONENT_ID, ApplicationComponentTable.COLUMN_APPLICATION_ID, tableName, ApplicationComponentTable.COLUMN_TIME_BUCKET);
Object[] params = new Object[] { startTimeBucket, endTimeBucket };
try (ResultSet rs = client.executeQuery(sql, params)) {
while (rs.next()) {
int applicationId = rs.getInt(ApplicationComponentTable.COLUMN_APPLICATION_ID);
int componentId = rs.getInt(ApplicationComponentTable.COLUMN_COMPONENT_ID);
ApplicationComponent applicationComponent = new ApplicationComponent();
applicationComponent.setComponentId(componentId);
applicationComponent.setApplicationId(applicationId);
applicationComponents.add(applicationComponent);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return applicationComponents;
}
use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class ServiceNameServiceH2UIDAO method getCount.
@Override
public int getCount() {
String dynamicSql = "select count({0}) as cnt from {1} where {2} = ?";
String sql = SqlBuilder.buildSql(dynamicSql, ServiceNameTable.COLUMN_SERVICE_ID, ServiceNameTable.TABLE, ServiceNameTable.COLUMN_SRC_SPAN_TYPE);
Object[] params = new Object[] { SpanType.Entry_VALUE };
try (ResultSet rs = getClient().executeQuery(sql, params)) {
if (rs.next()) {
return rs.getInt("cnt");
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return 0;
}
use of org.apache.skywalking.apm.collector.client.h2.H2ClientException in project incubator-skywalking by apache.
the class MemoryPoolMetricH2UIDAO method getMetric.
@Override
public JsonObject getMetric(int instanceId, long timeBucket, int poolType) {
H2Client client = getClient();
String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType;
String sql = SqlBuilder.buildSql(GET_MEMORY_POOL_METRIC_SQL, MemoryPoolMetricTable.TABLE, MemoryPoolMetricTable.COLUMN_ID);
Object[] params = new Object[] { id };
JsonObject metric = new JsonObject();
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
metric.addProperty("max", rs.getInt(MemoryPoolMetricTable.COLUMN_MAX));
metric.addProperty("init", rs.getInt(MemoryPoolMetricTable.COLUMN_INIT));
metric.addProperty("used", rs.getInt(MemoryPoolMetricTable.COLUMN_USED));
} else {
metric.addProperty("max", 0);
metric.addProperty("init", 0);
metric.addProperty("used", 0);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return metric;
}
Aggregations