oozie-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rkan...@apache.org
Subject git commit: OOZIE-1677 Add Oozie servers to instrumentation info (rkanter)
Date Tue, 26 Aug 2014 19:26:55 GMT
Repository: oozie
Updated Branches:
  refs/heads/master a26f45738 -> 55d98f80d


OOZIE-1677 Add Oozie servers to instrumentation info (rkanter)


Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/55d98f80
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/55d98f80
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/55d98f80

Branch: refs/heads/master
Commit: 55d98f80d384951508a56ddcbff3a7e38fb809a2
Parents: a26f457
Author: Robert Kanter <rkanter@cloudera.com>
Authored: Tue Aug 26 12:26:11 2014 -0700
Committer: Robert Kanter <rkanter@cloudera.com>
Committed: Tue Aug 26 12:26:11 2014 -0700

----------------------------------------------------------------------
 .../oozie/service/JobsConcurrencyService.java   | 15 +++++++-
 .../oozie/service/ZKJobsConcurrencyService.java |  2 +-
 .../service/TestJobsConcurrencyService.java     | 15 +++++++-
 .../service/TestZKJobsConcurrencyService.java   | 37 ++++++++++++++++++++
 release-log.txt                                 |  2 ++
 5 files changed, 68 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/55d98f80/core/src/main/java/org/apache/oozie/service/JobsConcurrencyService.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/service/JobsConcurrencyService.java b/core/src/main/java/org/apache/oozie/service/JobsConcurrencyService.java
index 7508b21..0faa5dd 100644
--- a/core/src/main/java/org/apache/oozie/service/JobsConcurrencyService.java
+++ b/core/src/main/java/org/apache/oozie/service/JobsConcurrencyService.java
@@ -21,6 +21,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.oozie.util.ConfigUtils;
 import org.apache.oozie.util.Instrumentable;
 import org.apache.oozie.util.Instrumentation;
@@ -70,7 +71,19 @@ public class JobsConcurrencyService implements Service, Instrumentable
{
      */
     @Override
     public void instrument(Instrumentation instr) {
-        // nothing to instrument
+        instr.addVariable("oozie", "servers", new Instrumentation.Variable<String>()
{
+            @Override
+            public String getValue() {
+                String str;
+                Map<String, String> serverUrls = getServerUrls();
+                if (serverUrls.isEmpty()) {
+                    str = "(unavailable)";
+                } else {
+                    str = StringUtils.join(serverUrls.entrySet(), ",");
+                }
+                return str;
+            }
+        });
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/oozie/blob/55d98f80/core/src/main/java/org/apache/oozie/service/ZKJobsConcurrencyService.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/service/ZKJobsConcurrencyService.java b/core/src/main/java/org/apache/oozie/service/ZKJobsConcurrencyService.java
index 270253f..202d58b 100644
--- a/core/src/main/java/org/apache/oozie/service/ZKJobsConcurrencyService.java
+++ b/core/src/main/java/org/apache/oozie/service/ZKJobsConcurrencyService.java
@@ -92,7 +92,7 @@ public class ZKJobsConcurrencyService extends JobsConcurrencyService implements
     }
 
     /**
-     * Instruments the memory locks service.
+     * Instruments the zk jobs concurrency service.
      *
      * @param instr instance to instrument the zookeeper jobs concurrency service to.
      */

http://git-wip-us.apache.org/repos/asf/oozie/blob/55d98f80/core/src/test/java/org/apache/oozie/service/TestJobsConcurrencyService.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/service/TestJobsConcurrencyService.java b/core/src/test/java/org/apache/oozie/service/TestJobsConcurrencyService.java
index 473e120..7ca6258 100644
--- a/core/src/test/java/org/apache/oozie/service/TestJobsConcurrencyService.java
+++ b/core/src/test/java/org/apache/oozie/service/TestJobsConcurrencyService.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import org.apache.oozie.client.rest.RestConstants;
 import org.apache.oozie.test.XTestCase;
 import org.apache.oozie.util.ConfigUtils;
+import org.apache.oozie.util.Instrumentation;
 
 public class TestJobsConcurrencyService extends XTestCase {
 
@@ -111,4 +112,16 @@ public class TestJobsConcurrencyService extends XTestCase {
         }
     }
 
-}
\ No newline at end of file
+    public void testInstrumentation() throws Exception {
+        JobsConcurrencyService jcs = new JobsConcurrencyService();
+        Instrumentation instr = new Instrumentation();
+        try {
+            jcs.init(Services.get());
+            jcs.instrument(instr);
+            String servers = System.getProperty("oozie.instance.id") + "=" + ConfigUtils.getOozieEffectiveUrl();
+            assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
+        } finally {
+            jcs.destroy();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/oozie/blob/55d98f80/core/src/test/java/org/apache/oozie/service/TestZKJobsConcurrencyService.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/service/TestZKJobsConcurrencyService.java
b/core/src/test/java/org/apache/oozie/service/TestZKJobsConcurrencyService.java
index 529e15c..149f00f 100644
--- a/core/src/test/java/org/apache/oozie/service/TestZKJobsConcurrencyService.java
+++ b/core/src/test/java/org/apache/oozie/service/TestZKJobsConcurrencyService.java
@@ -21,10 +21,12 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import static junit.framework.Assert.assertEquals;
 
 import org.apache.oozie.client.rest.RestConstants;
 import org.apache.oozie.test.ZKXTestCase;
 import org.apache.oozie.util.ConfigUtils;
+import org.apache.oozie.util.Instrumentation;
 import org.apache.oozie.util.ZKUtils;
 
 public class TestZKJobsConcurrencyService extends ZKXTestCase {
@@ -302,4 +304,39 @@ public class TestZKJobsConcurrencyService extends ZKXTestCase {
             zkjcs.destroy();
         }
     }
+
+    public void testInstrumentation() throws Exception {
+        ZKJobsConcurrencyService zkjcs = new ZKJobsConcurrencyService();
+        // We'll use some DummyZKXOozies here to pretend to be other Oozie servers that will
influence the instrumentation
+        // once they are running in that the there will be other Oozie "servers"
+        DummyZKOozie dummyOozie = null;
+        DummyZKOozie dummyOozie2 = null;
+        Instrumentation instr = new Instrumentation();
+        try {
+            zkjcs.init(Services.get());
+            zkjcs.instrument(instr);
+            String servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false);
+            assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
+            dummyOozie = new DummyZKOozie("0000", "http://blah1");
+            servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false) + ",0000=http://blah1";
+            assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
+            dummyOozie2 = new DummyZKOozie("z", "http://blah2");
+            servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false) + ",0000=http://blah1"
+ ",z=http://blah2";
+            assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
+            dummyOozie.teardown();
+            servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false) + ",z=http://blah2";
+            assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
+            dummyOozie2.teardown();
+            servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false);
+            assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
+        } finally {
+            zkjcs.destroy();
+            if (dummyOozie != null) {
+                dummyOozie.teardown();
+            }
+            if (dummyOozie2 != null) {
+                dummyOozie2.teardown();
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/oozie/blob/55d98f80/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 2f1548e..0b7eeb0 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,4 +1,6 @@
 -- Oozie 4.2.0 release (trunk - unreleased)
+
+OOZIE-1677 Add Oozie servers to instrumentation info (rkanter)
 OOZIE-1968 Building modules independently (shwethags)
 OOZIE-1939 Incorrect job information is set while logging (seoeun25 via shwethags)
 OOZIE-1846 Convert CoordActionMaterializeCommand to an XCommand and remove Command (seoeun25
via shwethags)


Mime
View raw message