falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajayyad...@apache.org
Subject falcon git commit: FALCON-1329 Falcon's idempotent behaviour breaks in some cases. Contributed by Ajay Yadava.
Date Tue, 28 Jul 2015 09:46:34 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 6e7634e8b -> 4cda54073


FALCON-1329 Falcon's idempotent behaviour breaks in some cases. Contributed by Ajay Yadava.


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

Branch: refs/heads/master
Commit: 4cda54073f1a4389378c8e7365bca59c9728a424
Parents: 6e7634e
Author: Ajay Yadava <ajaynsit@gmail.com>
Authored: Tue Jul 28 14:42:48 2015 +0530
Committer: Ajay Yadava <ajaynsit@gmail.com>
Committed: Tue Jul 28 14:42:48 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                              |  2 ++
 .../org/apache/falcon/resource/channel/HTTPChannel.java  | 11 ++++++++++-
 .../resource/proxy/SchedulableEntityManagerProxy.java    | 10 ++++++----
 3 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/4cda5407/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 548325f..6017dbc 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -65,6 +65,8 @@ Trunk (Unreleased)
     (Suhas Vasu)
 
   BUG FIXES
+    FALCON-1329 Falcon's idempotent behaviour breaks in some cases(Ajay Yadava)
+
     FALCON-1282 Incorrect hdfs servers property for feed replication in secured environment(Venkat
Ranganathan via Ajay Yadava)
 
     FALCON-1311 Instance dependency API produces inconsistent results in some scenarios(Pragya
Mittal via Ajay Yadava)

http://git-wip-us.apache.org/repos/asf/falcon/blob/4cda5407/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java b/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java
index 3d3a58a..78f68ba 100644
--- a/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java
+++ b/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java
@@ -81,13 +81,14 @@ public class HTTPChannel extends AbstractChannel {
     @SuppressWarnings("unchecked")
     @Override
     public <T> T invoke(String methodName, Object... args) throws FalconException {
+        HttpServletRequest incomingRequest = null;
         try {
             Method method = getMethod(service, methodName, args);
             String urlPrefix = getFalconEndPoint();
             String url = urlPrefix + "/" + pathValue(method, args);
             LOG.debug("Executing {}", url);
 
-            HttpServletRequest incomingRequest = getIncomingRequest(args);
+            incomingRequest = getIncomingRequest(args);
             incomingRequest.getInputStream().reset();
             String httpMethod = getHttpMethod(method);
             String mimeType = getConsumes(method);
@@ -116,6 +117,14 @@ public class HTTPChannel extends AbstractChannel {
         } catch (Throwable e) {
             LOG.error("Request failed", e);
             throw new FalconException(e);
+        } finally {
+            try {
+                if (incomingRequest != null) {
+                    incomingRequest.getInputStream().reset();
+                }
+            } catch (Exception ignore) {
+                // nothing to be done;
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/falcon/blob/4cda5407/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
index b9aef71..b49d6f8 100644
--- a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
+++ b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
@@ -230,7 +230,8 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
             }
         }.execute());
 
-        if (!embeddedMode) {
+        // delete only if deleted from everywhere
+        if (!embeddedMode && results.get(FALCON_TAG).getStatus() == APIResult.Status.SUCCEEDED)
{
             results.put(PRISM_TAG, super.delete(bufferedRequest, type, entity, currentColo));
         }
         return consolidateResult(results, APIResult.class);
@@ -298,7 +299,8 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
             }.execute());
         }
 
-        if (!embeddedMode) {
+        // update only if all are updated
+        if (!embeddedMode && results.get(FALCON_TAG).getStatus() == APIResult.Status.SUCCEEDED)
{
             results.put(PRISM_TAG, super.update(bufferedRequest, type, entityName, currentColo));
         }
 
@@ -558,14 +560,14 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
             for (String colo : colos) {
                 try {
                     results.put(colo, doExecute(colo));
-                } catch (FalconException e) {
+                } catch (Throwable e) {
                     results.put(colo, getResultInstance(APIResult.Status.FAILED, e.getClass().getName()
+ "::"
                             + e.getMessage()));
                 }
             }
 
             T finalResult = consolidateResult(results, clazz);
-            if (finalResult.getStatus() != APIResult.Status.SUCCEEDED) {
+            if (finalResult.getStatus() == APIResult.Status.FAILED) {
                 throw FalconWebException.newException(finalResult, Response.Status.BAD_REQUEST);
             } else {
                 return finalResult;


Mime
View raw message