use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class ApplicationH2CacheDAO method getApplicationIdByAddressId.
@Override
public int getApplicationIdByAddressId(int addressId) {
logger.info("get the application id with address id = {}", addressId);
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, ApplicationTable.COLUMN_APPLICATION_ID, ApplicationTable.TABLE, ApplicationTable.COLUMN_ADDRESS_ID, ApplicationTable.COLUMN_IS_ADDRESS);
Object[] params = new Object[] { addressId, true };
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
return rs.getInt(1);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return 0;
}
use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class ApplicationH2CacheDAO method getApplication.
@Override
public Application getApplication(int applicationId) {
logger.debug("get application code, applicationId: {}", applicationId);
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_APPLICATION_SQL, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.COLUMN_IS_ADDRESS, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID);
Object[] params = new Object[] { applicationId };
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
Application application = new Application();
application.setApplicationId(applicationId);
application.setApplicationCode(rs.getString(1));
application.setIsAddress(rs.getInt(2));
return application;
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return null;
}
use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class NetworkAddressH2CacheDAO method getAddressById.
@Override
public String getAddressById(int addressId) {
logger.debug("get network address, address id: {}", addressId);
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_ADDRESS_ID_OR_CODE_SQL, NetworkAddressTable.COLUMN_NETWORK_ADDRESS, NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_ADDRESS_ID);
Object[] params = new Object[] { addressId };
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
return rs.getString(1);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return Const.EMPTY_STRING;
}
use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class StorageModuleH2Provider method start.
@Override
public void start(Properties config) throws ServiceNotProvidedException {
try {
h2Client.initialize();
H2StorageInstaller installer = new H2StorageInstaller();
installer.install(h2Client);
} catch (H2ClientException | StorageException e) {
logger.error(e.getMessage(), e);
}
}
use of org.apache.skywalking.apm.collector.client.h2.H2Client in project incubator-skywalking by apache.
the class StorageModuleH2Provider method prepare.
@Override
public void prepare(Properties config) throws ServiceNotProvidedException {
String url = config.getProperty(URL);
String userName = config.getProperty(USER_NAME);
String password = config.getProperty(PASSWORD);
h2Client = new H2Client(url, userName, password);
this.registerServiceImplementation(IBatchDAO.class, new BatchH2DAO(h2Client));
registerCacheDAO();
registerRegisterDAO();
registerPersistenceDAO();
registerUiDAO();
registerAlarmDAO();
}
Aggregations