GetQueryStatusRequest.Builder builder = GetQueryStatusRequest.newBuilder();
builder.setQueryId(queryId.getProto());
GetQueryStatusResponse res = null;
if(queryMasterMap.containsKey(queryId)) {
NettyClientBase qmClient = null;
try {
qmClient = connPool.getConnection(queryMasterMap.get(queryId),
QueryMasterClientProtocol.class, false);
QueryMasterClientProtocolService.BlockingInterface queryMasterService = qmClient.getStub();
res = queryMasterService.getQueryStatus(null, builder.build());
} catch (Exception e) {
throw new ServiceException(e.getMessage(), e);
} finally {
connPool.releaseConnection(qmClient);
}
} else {
NettyClientBase tmClient = null;
try {
tmClient = connPool.getConnection(tajoMasterAddr, TajoMasterClientProtocol.class, false);
checkSessionAndGet(tmClient);
builder.setSessionId(sessionId);
TajoMasterClientProtocolService.BlockingInterface tajoMasterService = tmClient.getStub();
res = tajoMasterService.getQueryStatus(null, builder.build());
String queryMasterHost = res.getQueryMasterHost();
if(queryMasterHost != null && !queryMasterHost.isEmpty()) {
NettyClientBase qmClient = null;
try {
InetSocketAddress qmAddr = NetUtils.createSocketAddr(queryMasterHost, res.getQueryMasterPort());
qmClient = connPool.getConnection(
qmAddr, QueryMasterClientProtocol.class, false);
QueryMasterClientProtocolService.BlockingInterface queryMasterService = qmClient.getStub();
res = queryMasterService.getQueryStatus(null, builder.build());
queryMasterMap.put(queryId, qmAddr);
} catch (Exception e) {
throw new ServiceException(e.getMessage(), e);