Search in sources :

Example 1 with PostgreSQLDataSource

use of io.mycat.backend.postgresql.PostgreSQLDataSource in project Mycat-Server by MyCATApache.

the class PostgreSQLDetector method heartbeat.

public void heartbeat() {
    lastSendQryTime = System.currentTimeMillis();
    PostgreSQLDataSource ds = heartbeat.getSource();
    String databaseName = ds.getDbPool().getSchemas()[0];
    String[] fetchColms = {};
    if (heartbeat.getSource().getHostConfig().isShowSlaveSql()) {
        fetchColms = MYSQL_SLAVE_STAUTS_COLMS;
    }
    OneRawSQLQueryResultHandler resultHandler = new OneRawSQLQueryResultHandler(fetchColms, this);
    sqlJob = new SQLJob(heartbeat.getHeartbeatSQL(), databaseName, resultHandler, ds);
    sqlJob.run();
}
Also used : OneRawSQLQueryResultHandler(io.mycat.sqlengine.OneRawSQLQueryResultHandler) PostgreSQLDataSource(io.mycat.backend.postgresql.PostgreSQLDataSource) SQLJob(io.mycat.sqlengine.SQLJob)

Example 2 with PostgreSQLDataSource

use of io.mycat.backend.postgresql.PostgreSQLDataSource in project Mycat-Server by MyCATApache.

the class ConfigInitializer method createDataSource.

private PhysicalDatasource[] createDataSource(DataHostConfig conf, String hostName, String dbType, String dbDriver, DBHostConfig[] nodes, boolean isRead) {
    PhysicalDatasource[] dataSources = new PhysicalDatasource[nodes.length];
    if (dbType.equals("mysql") && dbDriver.equals("native")) {
        for (int i = 0; i < nodes.length; i++) {
            //设置最大idle时间,默认为30分钟
            nodes[i].setIdleTimeout(system.getIdleTimeout());
            MySQLDataSource ds = new MySQLDataSource(nodes[i], conf, isRead);
            dataSources[i] = ds;
        }
    } else if (dbDriver.equals("jdbc")) {
        for (int i = 0; i < nodes.length; i++) {
            nodes[i].setIdleTimeout(system.getIdleTimeout());
            JDBCDatasource ds = new JDBCDatasource(nodes[i], conf, isRead);
            dataSources[i] = ds;
        }
    } else if ("postgresql".equalsIgnoreCase(dbType) && dbDriver.equalsIgnoreCase("native")) {
        for (int i = 0; i < nodes.length; i++) {
            nodes[i].setIdleTimeout(system.getIdleTimeout());
            PostgreSQLDataSource ds = new PostgreSQLDataSource(nodes[i], conf, isRead);
            dataSources[i] = ds;
        }
    } else {
        throw new ConfigException("not supported yet !" + hostName);
    }
    return dataSources;
}
Also used : PhysicalDatasource(io.mycat.backend.datasource.PhysicalDatasource) PostgreSQLDataSource(io.mycat.backend.postgresql.PostgreSQLDataSource) MySQLDataSource(io.mycat.backend.mysql.nio.MySQLDataSource) JDBCDatasource(io.mycat.backend.jdbc.JDBCDatasource) ConfigException(io.mycat.config.util.ConfigException)

Aggregations

PostgreSQLDataSource (io.mycat.backend.postgresql.PostgreSQLDataSource)2 PhysicalDatasource (io.mycat.backend.datasource.PhysicalDatasource)1 JDBCDatasource (io.mycat.backend.jdbc.JDBCDatasource)1 MySQLDataSource (io.mycat.backend.mysql.nio.MySQLDataSource)1 ConfigException (io.mycat.config.util.ConfigException)1 OneRawSQLQueryResultHandler (io.mycat.sqlengine.OneRawSQLQueryResultHandler)1 SQLJob (io.mycat.sqlengine.SQLJob)1