Search in sources :

Example 1 with SQLQueryResult

use of com.actiontech.dble.sqlengine.SQLQueryResult in project dble by actiontech.

the class ShowBinlogStatus method getQueryResult.

/**
 * getQueryResult: show master status
 *
 * @param charset
 */
private static void getQueryResult(final String charset) {
    Collection<PhysicalDBPool> allPools = DbleServer.getInstance().getConfig().getDataHosts().values();
    sourceCount = new AtomicInteger(allPools.size());
    rows = new ArrayList<>(allPools.size());
    for (PhysicalDBPool pool : allPools) {
        // if WRITE_RANDOM_NODE ,may the binlog is not ready.
        final PhysicalDatasource source = pool.getSource();
        OneRawSQLQueryResultHandler resultHandler = new OneRawSQLQueryResultHandler(FIELDS, new SQLQueryResultListener<SQLQueryResult<Map<String, String>>>() {

            @Override
            public void onResult(SQLQueryResult<Map<String, String>> result) {
                String url = source.getConfig().getUrl();
                if (!result.isSuccess()) {
                    errMsg = "Getting binlog status from this instance[" + url + "] is failed";
                } else {
                    rows.add(getRow(url, result.getResult(), charset));
                }
                sourceCount.decrementAndGet();
            }
        });
        SQLJob sqlJob = new SQLJob(SHOW_BINLOG_QUERY, pool.getSchemas()[0], resultHandler, source);
        sqlJob.run();
    }
    while (sourceCount.get() > 0) {
        LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
    }
}
Also used : OneRawSQLQueryResultHandler(com.actiontech.dble.sqlengine.OneRawSQLQueryResultHandler) SQLQueryResult(com.actiontech.dble.sqlengine.SQLQueryResult) PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool) PhysicalDatasource(com.actiontech.dble.backend.datasource.PhysicalDatasource) SQLJob(com.actiontech.dble.sqlengine.SQLJob) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)1 PhysicalDatasource (com.actiontech.dble.backend.datasource.PhysicalDatasource)1 OneRawSQLQueryResultHandler (com.actiontech.dble.sqlengine.OneRawSQLQueryResultHandler)1 SQLJob (com.actiontech.dble.sqlengine.SQLJob)1 SQLQueryResult (com.actiontech.dble.sqlengine.SQLQueryResult)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1