use of com.actiontech.dble.statistic.stat.QueryResult in project dble by actiontech.
the class MultiNodeQueryHandler method doSqlStat.
protected void doSqlStat(ServerConnection source) {
if (DbleServer.getInstance().getConfig().getSystem().getUseSqlStat() == 1) {
int resultSize = source.getWriteQueue().size() * DbleServer.getInstance().getConfig().getSystem().getBufferPoolPageSize();
if (rrs != null && rrs.getStatement() != null) {
netInBytes += rrs.getStatement().getBytes().length;
}
assert rrs != null;
QueryResult queryResult = new QueryResult(session.getSource().getUser(), rrs.getSqlType(), rrs.getStatement(), selectRows, netInBytes, netOutBytes, startTime, System.currentTimeMillis(), resultSize);
QueryResultDispatcher.dispatchQuery(queryResult);
}
}
use of com.actiontech.dble.statistic.stat.QueryResult in project dble by actiontech.
the class TestConcurrentSafety method testQueryConditionAnalyzer.
@Test
@Ignore
public void testQueryConditionAnalyzer() throws InterruptedException {
final QueryResult qr = new QueryResult("zhuam", ServerParse.SELECT, sql, 0, 0, 0, 0, 0, 0);
final QueryResult qr2 = new QueryResult("zhuam", ServerParse.SELECT, sql2, 0, 0, 0, 0, 0, 0);
final QueryResult qr3 = new QueryResult("zhuam", ServerParse.SELECT, sql3, 0, 0, 0, 0, 0, 0);
final QueryConditionAnalyzer analyzer = QueryConditionAnalyzer.getInstance();
analyzer.setCf("dynamic&fnum");
Thread[] thread = new Thread[THREAD_COUNT];
Thread[] thread2 = new Thread[THREAD_COUNT];
Thread[] thread3 = new Thread[THREAD_COUNT];
for (int i = 0; i < THREAD_COUNT; i++) {
thread[i] = new Thread() {
@Override
public void run() {
for (int j = 0; j < LOOP_COUNT; j++) {
analyzer.onQueryResult(qr);
}
}
};
thread2[i] = new Thread() {
@Override
public void run() {
for (int j = 0; j < LOOP_COUNT; j++) {
analyzer.onQueryResult(qr2);
}
}
};
thread3[i] = new Thread() {
@Override
public void run() {
for (int j = 0; j < LOOP_COUNT; j++) {
analyzer.onQueryResult(qr3);
}
}
};
}
for (int i = 0; i < THREAD_COUNT; i++) {
thread[i].start();
thread2[i].start();
thread3[i].start();
}
for (int i = 0; i < THREAD_COUNT; i++) {
thread[i].join();
thread2[i].join();
thread3[i].join();
}
List<Map.Entry<Object, AtomicLong>> list = analyzer.getValues();
Assert.assertTrue((list.get(0).getValue().get() == (long) THREAD_COUNT * LOOP_COUNT));
Assert.assertTrue((list.get(1).getValue().get() == (long) THREAD_COUNT * LOOP_COUNT));
Assert.assertTrue((list.get(2).getValue().get() == (long) THREAD_COUNT * LOOP_COUNT));
}
use of com.actiontech.dble.statistic.stat.QueryResult in project dble by actiontech.
the class SingleNodeHandler method rowEofResponse.
/**
* select
* <p>
* write EOF to Queue
*/
@Override
public void rowEofResponse(byte[] eof, boolean isLeft, BackendConnection conn) {
this.netOutBytes += eof.length;
ServerConnection source = session.getSource();
// if it's call statement,it will not release connection
if (!rrs.isCallStatement() || rrs.getProcedure().isResultSimpleValue()) {
session.releaseConnectionIfSafe(conn, false);
}
eof[3] = ++packetId;
buffer = source.writeToBuffer(eof, allocBuffer());
int resultSize = source.getWriteQueue().size() * DbleServer.getInstance().getConfig().getSystem().getBufferPoolPageSize();
resultSize = resultSize + buffer.position();
session.setResponseTime();
source.write(buffer);
waitingResponse = false;
if (DbleServer.getInstance().getConfig().getSystem().getUseSqlStat() == 1) {
if (rrs.getStatement() != null) {
netInBytes += rrs.getStatement().getBytes().length;
}
QueryResult queryResult = new QueryResult(session.getSource().getUser(), rrs.getSqlType(), rrs.getStatement(), selectRows, netInBytes, netOutBytes, startTime, System.currentTimeMillis(), resultSize);
QueryResultDispatcher.dispatchQuery(queryResult);
}
}
Aggregations