Search in sources :

Example 1 with SQLJob

use of io.mycat.sqlengine.SQLJob in project Mycat-Server by MyCATApache.

the class MySQLConsistencyChecker method checkRecordCout.

public void checkRecordCout() {
    // ["db3","db2","db1"]
    lock.lock();
    try {
        this.jobCount.set(0);
        beginTime = new Date().getTime();
        String[] physicalSchemas = source.getDbPool().getSchemas();
        for (String dbName : physicalSchemas) {
            MySQLConsistencyHelper detector = new MySQLConsistencyHelper(this, null);
            OneRawSQLQueryResultHandler resultHandler = new OneRawSQLQueryResultHandler(new String[] { GlobalTableUtil.COUNT_COLUMN }, detector);
            SQLJob sqlJob = new SQLJob(this.getCountSQL(), dbName, resultHandler, source);
            detector.setSqlJob(sqlJob);
            sqlJob.run();
            this.jobCount.incrementAndGet();
        }
    } finally {
        lock.unlock();
    }
}
Also used : OneRawSQLQueryResultHandler(io.mycat.sqlengine.OneRawSQLQueryResultHandler) SQLJob(io.mycat.sqlengine.SQLJob) Date(java.util.Date)

Example 2 with SQLJob

use of io.mycat.sqlengine.SQLJob in project Mycat-Server by MyCATApache.

the class MySQLDetector method close.

public void close(String msg) {
    SQLJob curJob = sqlJob;
    if (curJob != null && !curJob.isFinished()) {
        curJob.teminate(msg);
        sqlJob = null;
    }
}
Also used : SQLJob(io.mycat.sqlengine.SQLJob)

Example 3 with SQLJob

use of io.mycat.sqlengine.SQLJob 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 4 with SQLJob

use of io.mycat.sqlengine.SQLJob in project Mycat-Server by MyCATApache.

the class MySQLTableStructureDetector method run.

@Override
public void run() {
    for (SchemaConfig schema : MycatServer.getInstance().getConfig().getSchemas().values()) {
        for (TableConfig table : schema.getTables().values()) {
            for (String dataNode : table.getDataNodes()) {
                try {
                    table.getReentrantReadWriteLock().writeLock().lock();
                    ConcurrentHashMap<String, List<String>> map = new ConcurrentHashMap<>();
                    table.setDataNodeTableStructureSQLMap(map);
                } finally {
                    table.getReentrantReadWriteLock().writeLock().unlock();
                }
                OneRawSQLQueryResultHandler resultHandler = new OneRawSQLQueryResultHandler(MYSQL_SHOW_CREATE_TABLE_COLMS, new MySQLTableStructureListener(dataNode, table));
                resultHandler.setMark("Table Structure");
                PhysicalDBNode dn = MycatServer.getInstance().getConfig().getDataNodes().get(dataNode);
                SQLJob sqlJob = new SQLJob(sqlPrefix + table.getName(), dn.getDatabase(), resultHandler, dn.getDbPool().getSource());
                sqlJob.run();
            }
        }
    }
}
Also used : OneRawSQLQueryResultHandler(io.mycat.sqlengine.OneRawSQLQueryResultHandler) PhysicalDBNode(io.mycat.backend.datasource.PhysicalDBNode) SchemaConfig(io.mycat.config.model.SchemaConfig) SQLJob(io.mycat.sqlengine.SQLJob) TableConfig(io.mycat.config.model.TableConfig) List(java.util.List) LinkedList(java.util.LinkedList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 5 with SQLJob

use of io.mycat.sqlengine.SQLJob in project Mycat-Server by MyCATApache.

the class SqlExecuteListener method close.

public void close(String msg) {
    SQLJob curJob = sqlJob;
    if (curJob != null) {
        curJob.teminate(msg);
        sqlJob = null;
    }
}
Also used : SQLJob(io.mycat.sqlengine.SQLJob)

Aggregations

SQLJob (io.mycat.sqlengine.SQLJob)11 OneRawSQLQueryResultHandler (io.mycat.sqlengine.OneRawSQLQueryResultHandler)7 Date (java.util.Date)3 PhysicalDBNode (io.mycat.backend.datasource.PhysicalDBNode)2 SchemaConfig (io.mycat.config.model.SchemaConfig)2 TableConfig (io.mycat.config.model.TableConfig)2 MySQLDataSource (io.mycat.backend.mysql.nio.MySQLDataSource)1 CoordinatorLogEntry (io.mycat.backend.mysql.xa.CoordinatorLogEntry)1 ParticipantLogEntry (io.mycat.backend.mysql.xa.ParticipantLogEntry)1 XARollbackCallback (io.mycat.backend.mysql.xa.XARollbackCallback)1 PostgreSQLDataSource (io.mycat.backend.postgresql.PostgreSQLDataSource)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1