You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by rk...@apache.org on 2016/09/30 19:58:12 UTC
oozie git commit: OOZIE-2634 Queue dump command message is confusing
when the queue is empty (andras.piros via rkanter)
Repository: oozie
Updated Branches:
refs/heads/master 9fc2e68d7 -> b24477a3e
OOZIE-2634 Queue dump command message is confusing when the queue is empty (andras.piros via rkanter)
Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/b24477a3
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/b24477a3
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/b24477a3
Branch: refs/heads/master
Commit: b24477a3ee8c12f268a1edc084fe1abb8cec5d97
Parents: 9fc2e68
Author: Robert Kanter <rk...@cloudera.com>
Authored: Fri Sep 30 12:57:58 2016 -0700
Committer: Robert Kanter <rk...@cloudera.com>
Committed: Fri Sep 30 12:57:58 2016 -0700
----------------------------------------------------------------------
.../org/apache/oozie/client/OozieClient.java | 86 ++++++++++++--------
.../org/apache/oozie/client/TestOozieCLI.java | 10 ++-
release-log.txt | 2 +
3 files changed, 64 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/oozie/blob/b24477a3/client/src/main/java/org/apache/oozie/client/OozieClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/oozie/client/OozieClient.java b/client/src/main/java/org/apache/oozie/client/OozieClient.java
index a882cab..a2021fe 100644
--- a/client/src/main/java/org/apache/oozie/client/OozieClient.java
+++ b/client/src/main/java/org/apache/oozie/client/OozieClient.java
@@ -18,6 +18,7 @@
package org.apache.oozie.client;
+import com.google.common.collect.Lists;
import org.apache.oozie.BuildInfo;
import org.apache.oozie.client.rest.JsonTags;
import org.apache.oozie.client.rest.JsonToBean;
@@ -2317,44 +2318,63 @@ public class OozieClient {
@Override
protected List<String> call(HttpURLConnection conn) throws IOException, OozieClientException {
- if ((conn.getResponseCode() == HttpURLConnection.HTTP_OK)) {
- Reader reader = new InputStreamReader(conn.getInputStream());
- JSONObject json = (JSONObject) JSONValue.parse(reader);
- JSONArray queueDumpArray = (JSONArray) json.get(JsonTags.QUEUE_DUMP);
-
- List<String> list = new ArrayList<String>();
- list.add("[Server Queue Dump]:");
- for (Object o : queueDumpArray) {
- JSONObject entry = (JSONObject) o;
- if (entry.get(JsonTags.CALLABLE_DUMP) != null) {
- String value = (String) entry.get(JsonTags.CALLABLE_DUMP);
- list.add(value);
- }
- }
- if (queueDumpArray.size() == 0) {
- list.add("Queue dump is null!");
- }
+ if ((conn.getResponseCode() != HttpURLConnection.HTTP_OK)) {
+ handleError(conn);
+ return null;
+ }
- list.add("******************************************");
- list.add("[Server Uniqueness Map Dump]:");
+ Reader reader = new InputStreamReader(conn.getInputStream());
+ JSONObject json = (JSONObject) JSONValue.parse(reader);
+ List<String> queueDumpMessages = Lists.newArrayList();
- JSONArray uniqueDumpArray = (JSONArray) json.get(JsonTags.UNIQUE_MAP_DUMP);
- for (Object o : uniqueDumpArray) {
- JSONObject entry = (JSONObject) o;
- if (entry.get(JsonTags.UNIQUE_ENTRY_DUMP) != null) {
- String value = (String) entry.get(JsonTags.UNIQUE_ENTRY_DUMP);
- list.add(value);
- }
- }
- if (uniqueDumpArray.size() == 0) {
- list.add("Uniqueness dump is null!");
+ addSeparator(queueDumpMessages);
+
+ addQueueMessages(json,
+ queueDumpMessages,
+ JsonTags.QUEUE_DUMP,
+ JsonTags.CALLABLE_DUMP,
+ "[Server Queue Dump]:",
+ "The queue dump is empty, nothing to display.");
+
+ addSeparator(queueDumpMessages);
+
+ addQueueMessages(json,
+ queueDumpMessages,
+ JsonTags.UNIQUE_MAP_DUMP,
+ JsonTags.UNIQUE_ENTRY_DUMP,
+ "[Server Uniqueness Map Dump]:",
+ "The uniqueness map dump is empty, nothing to display.");
+
+ addSeparator(queueDumpMessages);
+
+ return queueDumpMessages;
+ }
+
+ private void addQueueMessages(JSONObject json,
+ List<String> queueMessages,
+ String queueName,
+ String queueValue,
+ String headerMessage,
+ String emptyMessage) {
+
+ JSONArray queueDumpArray = (JSONArray) json.get(queueName);
+ queueMessages.add(headerMessage);
+
+ for (Object o : queueDumpArray) {
+ JSONObject entry = (JSONObject) o;
+ if (entry.get(queueValue) != null) {
+ String value = (String) entry.get(queueValue);
+ queueMessages.add(value);
}
- return list;
}
- else {
- handleError(conn);
+
+ if (queueDumpArray.isEmpty()) {
+ queueMessages.add(emptyMessage);
}
- return null;
+ }
+
+ private void addSeparator(List<String> list) {
+ list.add("******************************************");
}
}
http://git-wip-us.apache.org/repos/asf/oozie/blob/b24477a3/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java b/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java
index a30baaa..ce95ff3 100644
--- a/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java
+++ b/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java
@@ -1163,7 +1163,15 @@ public class TestOozieCLI extends DagServletTestCase {
String oozieUrl = getContextURL();
String[] args = new String[]{"admin", "-queuedump", "-oozie", oozieUrl};
String out = runOozieCLIAndGetStdout(args);
- assertTrue(out.contains("Server Queue Dump"));
+
+ assertTrue("Queue dump",
+ out.contains("Server Queue Dump"));
+ assertTrue("Queue dump empty message",
+ out.contains("The queue dump is empty, nothing to display."));
+ assertTrue("Uniqueness map dump",
+ out.contains("Server Uniqueness Map Dump"));
+ assertTrue("Uniqueness dump empty message",
+ out.contains("The uniqueness map dump is empty, nothing to display."));
return null;
}
http://git-wip-us.apache.org/repos/asf/oozie/blob/b24477a3/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 4803c1c..f30396e 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,7 @@
-- Oozie 4.4.0 release (trunk - unreleased)
+OOZIE-2634 Queue dump command message is confusing when the queue is empty (andras.piros via rkanter)
+
-- Oozie 4.3.0 release