falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shweth...@apache.org
Subject git commit: FALCON-566 update throwing null job id exception. Contributed by Shwetha GS
Date Fri, 08 Aug 2014 05:24:09 GMT
Repository: incubator-falcon
Updated Branches:
  refs/heads/master 5cb6afafa -> 8ed874c33


FALCON-566 update throwing null job id exception. Contributed by Shwetha GS


Project: http://git-wip-us.apache.org/repos/asf/incubator-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-falcon/commit/8ed874c3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-falcon/tree/8ed874c3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-falcon/diff/8ed874c3

Branch: refs/heads/master
Commit: 8ed874c33d90899edf1c4892a15c6e5227178c58
Parents: 5cb6afa
Author: Shwetha GS <shwetha.gs@inmobi.com>
Authored: Fri Aug 8 10:53:57 2014 +0530
Committer: Shwetha GS <shwetha.gs@inmobi.com>
Committed: Fri Aug 8 10:53:57 2014 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 .../workflow/engine/OozieWorkflowEngine.java    | 13 +++++-
 .../falcon/resource/EntityManagerJerseyIT.java  | 49 ++++++++++++++++----
 3 files changed, 53 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/8ed874c3/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d7a9598..63ce166 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -28,6 +28,8 @@ Trunk (Unreleased)
   OPTIMIZATIONS
 
   BUG FIXES
+   FALCON-566 update throwing null job id exception. (Shwetha GS)
+
    FALCON-561 Falcon jenkins failure in EntityManagerJerseyIT.
    (Shwetha GS via Suhas Vasu)
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/8ed874c3/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
----------------------------------------------------------------------
diff --git a/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
b/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
index 94286ef..fd62b84 100644
--- a/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
+++ b/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
@@ -1132,12 +1132,23 @@ public class OozieWorkflowEngine extends AbstractWorkflowEngine {
         //Validate that new entity can be scheduled
         dryRunForUpdate(cluster, newEntity, effectiveTime);
 
+        boolean suspended = BUNDLE_SUSPENDED_STATUS.contains(oldBundle.getStatus());
+
         //Set end times for old coords
         updateCoords(clusterName, oldBundle, EntityUtil.getParallel(oldEntity), effectiveTime);
 
         //schedule new entity
         String newJobId = scheduleForUpdate(newEntity, cluster, effectiveTime, user);
-        BundleJob newBundle = getBundleInfo(clusterName, newJobId);
+        BundleJob newBundle = null;
+        if (newJobId != null) {
+            newBundle = getBundleInfo(clusterName, newJobId);
+        }
+
+        //Sometimes updateCoords() resumes the suspended coords. So, if already suspended,
resume now
+        //Also suspend new bundle
+        if (suspended) {
+            doBundleAction(newEntity, BundleAction.SUSPEND, cluster.getName());
+        }
 
         return getUpdateString(newEntity, effectiveTime, oldBundle, newBundle);
     }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/8ed874c3/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java b/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
index 9d801c8..8a50005 100644
--- a/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
+++ b/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
@@ -269,6 +269,31 @@ public class EntityManagerJerseyIT {
     }
 
     @Test
+    public void testUpdateSuspendedEntity() throws Exception {
+        TestContext context = newContext();
+        context.scheduleProcess();
+        OozieTestUtils.waitForBundleStart(context, Job.Status.RUNNING);
+
+        //Suspend entity
+        Process process = (Process) getDefinition(context, EntityType.PROCESS, context.processName);
+        ClientResponse response = suspend(context, process);
+        context.assertSuccessful(response);
+
+        process.getProperties().getProperties().get(0).setName("newprop");
+        Date endTime = getEndTime();
+        process.getClusters().getClusters().get(0).getValidity().setEnd(endTime);
+        response = update(context, process, endTime);
+        context.assertSuccessful(response);
+
+        //Since the process endtime = update effective time, it shouldn't create new bundle
+        List<BundleJob> bundles = OozieTestUtils.getBundles(context);
+        Assert.assertEquals(bundles.size(), 1);
+
+        //Since the entity was suspended before update, it should still be suspended
+        Assert.assertEquals(bundles.get(0).getStatus(), Status.SUSPENDED);
+    }
+
+    @Test
     public void testProcessInputUpdate() throws Exception {
         TestContext context = newContext();
         context.scheduleProcess();
@@ -438,6 +463,18 @@ public class EntityManagerJerseyIT {
         context.assertSuccessful(clientResponse);
     }
 
+    ClientResponse suspend(TestContext context, Entity entity) {
+        return suspend(context, entity.getEntityType(), entity.getName());
+    }
+
+    private ClientResponse suspend(TestContext context, EntityType entityType, String name)
{
+        return context.service
+            .path("api/entities/suspend/" + entityType.name().toLowerCase() + "/" + name)
+            .header("Cookie", context.getAuthenticationToken())
+            .accept(MediaType.TEXT_XML).type(MediaType.TEXT_XML)
+            .post(ClientResponse.class);
+    }
+
     public void testClusterSubmitScheduleSuspendResumeDelete() throws Exception {
         TestContext context = newContext();
         ClientResponse clientResponse;
@@ -454,11 +491,7 @@ public class EntityManagerJerseyIT {
                 .post(ClientResponse.class);
         context.assertFailure(clientResponse);
 
-        clientResponse = context.service
-                .path("api/entities/suspend/cluster/" + context.clusterName)
-                .header("Cookie", context.getAuthenticationToken())
-                .accept(MediaType.TEXT_XML).type(MediaType.TEXT_XML)
-                .post(ClientResponse.class);
+        clientResponse = suspend(context, EntityType.CLUSTER, context.clusterName);
         context.assertFailure(clientResponse);
 
         clientResponse = context.service
@@ -535,11 +568,7 @@ public class EntityManagerJerseyIT {
         TestContext context = newContext();
         context.scheduleProcess();
 
-        ClientResponse clientResponse = context.service
-                .path("api/entities/suspend/process/" + context.processName)
-                .header("Cookie", context.getAuthenticationToken())
-                .accept(MediaType.TEXT_XML)
-                .post(ClientResponse.class);
+        ClientResponse clientResponse = suspend(context, EntityType.PROCESS, context.processName);
         context.assertSuccessful(clientResponse);
 
         clientResponse = context.service


Mime
View raw message