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