You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by ji...@apache.org on 2014/03/14 05:08:57 UTC
git commit: TAJO-553: Add a method to the TajoClient to get finished
query lists. (Ilhyun Suh via jihoon)
Repository: incubator-tajo
Updated Branches:
refs/heads/master bd063cd4d -> 016b1c658
TAJO-553: Add a method to the TajoClient to get finished query lists. (Ilhyun Suh via jihoon)
Project: http://git-wip-us.apache.org/repos/asf/incubator-tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tajo/commit/016b1c65
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tajo/tree/016b1c65
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tajo/diff/016b1c65
Branch: refs/heads/master
Commit: 016b1c658e8dbd0e190c2347ee20b38bf453674b
Parents: bd063cd
Author: Jihoon Son <ji...@apache.org>
Authored: Fri Mar 14 13:06:56 2014 +0900
Committer: Jihoon Son <ji...@apache.org>
Committed: Fri Mar 14 13:08:04 2014 +0900
----------------------------------------------------------------------
CHANGES.txt | 3 ++
.../java/org/apache/tajo/client/TajoAdmin.java | 4 +--
.../java/org/apache/tajo/client/TajoClient.java | 17 ++++++++--
.../main/proto/TajoMasterClientProtocol.proto | 3 +-
.../tajo/master/TajoMasterClientService.java | 35 +++++++++++++++++++-
.../org/apache/tajo/client/TestTajoClient.java | 21 ++++++++++++
6 files changed, 77 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/016b1c65/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1e5f747..6b397c2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -130,6 +130,9 @@ Release 0.8.0 - unreleased
IMPROVEMENTS
+ TAJO-553: Add a method to the TajoClient to get finished query lists.
+ (Ilhyun Suh via jihoon)
+
TAJO-670: Change daemon's hostname to canonical hostname
(hyoungjunkim via hyunsik)
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/016b1c65/tajo-client/src/main/java/org/apache/tajo/client/TajoAdmin.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/client/TajoAdmin.java b/tajo-client/src/main/java/org/apache/tajo/client/TajoAdmin.java
index e6fe88f..0cc8110 100644
--- a/tajo-client/src/main/java/org/apache/tajo/client/TajoAdmin.java
+++ b/tajo-client/src/main/java/org/apache/tajo/client/TajoAdmin.java
@@ -172,7 +172,7 @@ public class TajoAdmin {
public static void processDesc(Writer writer, TajoClient client) throws ParseException, IOException,
ServiceException, SQLException {
- List<BriefQueryInfo> queryList = client.getQueryList();
+ List<BriefQueryInfo> queryList = client.getRunningQueryList();
SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT);
int id = 1;
for (BriefQueryInfo queryInfo : queryList) {
@@ -375,7 +375,7 @@ public class TajoAdmin {
public static void processList(Writer writer, TajoClient client) throws ParseException, IOException,
ServiceException, SQLException {
- List<BriefQueryInfo> queryList = client.getQueryList();
+ List<BriefQueryInfo> queryList = client.getRunningQueryList();
SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT);
String fmt = "%1$-20s %2$-7s %3$-20s %4$-30s%n";
String line = String.format(fmt, "QueryId", "State",
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/016b1c65/tajo-client/src/main/java/org/apache/tajo/client/TajoClient.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/client/TajoClient.java b/tajo-client/src/main/java/org/apache/tajo/client/TajoClient.java
index 7ee4694..7fc6780 100644
--- a/tajo-client/src/main/java/org/apache/tajo/client/TajoClient.java
+++ b/tajo-client/src/main/java/org/apache/tajo/client/TajoClient.java
@@ -400,14 +400,27 @@ public class TajoClient {
}
- public List<BriefQueryInfo> getQueryList() throws ServiceException {
+ public List<BriefQueryInfo> getRunningQueryList() throws ServiceException {
return new ServerCallable<List<BriefQueryInfo>>(connPool, tajoMasterAddr,
TajoMasterClientProtocol.class, false, true) {
public List<BriefQueryInfo> call(NettyClientBase client) throws ServiceException {
TajoMasterClientProtocolService.BlockingInterface tajoMasterService = client.getStub();
GetQueryListRequest.Builder builder = GetQueryListRequest.newBuilder();
- GetQueryListResponse res = tajoMasterService.getQueryList(null, builder.build());
+ GetQueryListResponse res = tajoMasterService.getRunningQueryList(null, builder.build());
+ return res.getQueryListList();
+ }
+ }.withRetries();
+ }
+
+ public List<BriefQueryInfo> getFinishedQueryList() throws ServiceException {
+ return new ServerCallable<List<BriefQueryInfo>>(connPool, tajoMasterAddr,
+ TajoMasterClientProtocol.class, false, true) {
+ public List<BriefQueryInfo> call(NettyClientBase client) throws ServiceException {
+ TajoMasterClientProtocolService.BlockingInterface tajoMasterService = client.getStub();
+
+ GetQueryListRequest.Builder builder = GetQueryListRequest.newBuilder();
+ GetQueryListResponse res = tajoMasterService.getFinishedQueryList(null, builder.build());
return res.getQueryListList();
}
}.withRetries();
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/016b1c65/tajo-client/src/main/proto/TajoMasterClientProtocol.proto
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/proto/TajoMasterClientProtocol.proto b/tajo-client/src/main/proto/TajoMasterClientProtocol.proto
index 9feecdb..93e5af9 100644
--- a/tajo-client/src/main/proto/TajoMasterClientProtocol.proto
+++ b/tajo-client/src/main/proto/TajoMasterClientProtocol.proto
@@ -34,7 +34,8 @@ service TajoMasterClientProtocolService {
rpc updateQuery(QueryRequest) returns (UpdateQueryResponse);
rpc explainQuery(ExplainQueryRequest) returns (ExplainQueryResponse);
rpc getQueryResult(GetQueryResultRequest) returns (GetQueryResultResponse);
- rpc getQueryList(GetQueryListRequest) returns (GetQueryListResponse);
+ rpc getRunningQueryList(GetQueryListRequest) returns (GetQueryListResponse);
+ rpc getFinishedQueryList(GetQueryListRequest) returns (GetQueryListResponse);
rpc getQueryStatus(GetQueryStatusRequest) returns (GetQueryStatusResponse);
rpc killQuery(QueryIdProto) returns (BoolProto);
rpc getClusterInfo(GetClusterInfoRequest) returns (GetClusterInfoResponse);
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/016b1c65/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/TajoMasterClientService.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/TajoMasterClientService.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/TajoMasterClientService.java
index 60f705f..dc70f23 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/TajoMasterClientService.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/TajoMasterClientService.java
@@ -224,7 +224,7 @@ public class TajoMasterClientService extends AbstractService {
}
@Override
- public GetQueryListResponse getQueryList(RpcController controller,
+ public GetQueryListResponse getRunningQueryList(RpcController controller,
GetQueryListRequest request)
throws ServiceException {
GetQueryListResponse.Builder builder
@@ -257,6 +257,39 @@ public class TajoMasterClientService extends AbstractService {
}
@Override
+ public GetQueryListResponse getFinishedQueryList(RpcController controller,
+ GetQueryListRequest request)
+ throws ServiceException {
+ GetQueryListResponse.Builder builder
+ = GetQueryListResponse.newBuilder();
+
+ Collection<QueryInProgress> queries
+ = context.getQueryJobManager().getFinishedQueries();
+
+ BriefQueryInfo.Builder infoBuilder = BriefQueryInfo.newBuilder();
+
+ for (QueryInProgress queryInProgress : queries) {
+ QueryInfo queryInfo = queryInProgress.getQueryInfo();
+
+ infoBuilder.setQueryId(queryInfo.getQueryId().getProto());
+ infoBuilder.setState(queryInfo.getQueryState());
+ infoBuilder.setQuery(queryInfo.getSql());
+ infoBuilder.setStartTime(queryInfo.getStartTime());
+ long endTime = (queryInfo.getFinishTime() == 0) ?
+ System.currentTimeMillis() : queryInfo.getFinishTime();
+ infoBuilder.setFinishTime(endTime);
+ infoBuilder.setProgress(queryInfo.getProgress());
+ infoBuilder.setQueryMasterPort(queryInfo.getQueryMasterPort());
+ infoBuilder.setQueryMasterHost(queryInfo.getQueryMasterHost());
+
+ builder.addQueryList(infoBuilder.build());
+ }
+
+ GetQueryListResponse result = builder.build();
+ return result;
+ }
+
+ @Override
public GetQueryStatusResponse getQueryStatus(RpcController controller,
GetQueryStatusRequest request)
throws ServiceException {
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/016b1c65/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java
index ee03bd6..3dac2f1 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java
@@ -37,6 +37,7 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.io.IOException;
+import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
@@ -458,4 +459,24 @@ public class TestTajoClient {
functions = client.getFunctions(null);
assertEquals(catalogFunctions.size(), functions.size());
}
+
+ @Test
+ public final void testGetFinishedQueryList() throws IOException,
+ ServiceException, SQLException {
+ final String tableName = "testGetFinishedQueryList";
+ String sql = "create table " + tableName + " (deptname text, score int4)";
+
+ client.updateQuery(sql);
+ assertTrue(client.existTable(tableName));
+
+ int numFinishedQueries = client.getFinishedQueryList().size();
+ ResultSet resultSet = client.executeQueryAndGetResult("select * from " + tableName);
+ assertNotNull(resultSet);
+
+ resultSet = client.executeQueryAndGetResult("select * from " + tableName);
+ assertNotNull(resultSet);
+ assertEquals(numFinishedQueries + 2, client.getFinishedQueryList().size());
+
+ resultSet.close();
+ }
}