Search in sources :

Example 1 with H2Client

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;
}
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)

Example 2 with H2Client

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

Example 3 with H2Client

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;
}
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)

Example 4 with H2Client

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);
    }
}
Also used : H2ClientException(org.apache.skywalking.apm.collector.client.h2.H2ClientException) StorageException(org.apache.skywalking.apm.collector.storage.StorageException) H2StorageInstaller(org.apache.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller)

Example 5 with H2Client

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();
}
Also used : H2Client(org.apache.skywalking.apm.collector.client.h2.H2Client) BatchH2DAO(org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO)

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