falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From venkat...@apache.org
Subject incubator-falcon git commit: FALCON-829 Better error message for cluster submission failure. Contributed by Karan Kumar
Date Sat, 15 Nov 2014 02:11:33 GMT
Repository: incubator-falcon
Updated Branches:
  refs/heads/master bb04ee4b8 -> 03ba46be9


FALCON-829 Better error message for cluster submission failure. Contributed by Karan Kumar


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

Branch: refs/heads/master
Commit: 03ba46be93ee2e51b2445463d19c5ee30fe9959d
Parents: bb04ee4
Author: Venkatesh Seetharam <venkatesh@apache.org>
Authored: Fri Nov 14 17:46:15 2014 -0800
Committer: Venkatesh Seetharam <venkatesh@apache.org>
Committed: Fri Nov 14 17:46:15 2014 -0800

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 +
 .../entity/parser/ClusterEntityParser.java      | 14 ++---
 .../entity/parser/ClusterEntityParserTest.java  | 66 +++++++++++++++++---
 3 files changed, 69 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/03ba46be/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c1c8b2c..e42db3f 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -144,6 +144,9 @@ Trunk (Unreleased)
   OPTIMIZATIONS
 
   BUG FIXES
+   FALCON-829 Better error message for cluster submission failure
+   (Karan Kumar via Venkatesh Seetharam)
+
    FALCON-824 Remove usage of Hadoop incompatible API
    (Shwetha G S via Venkatesh Seetharam)
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/03ba46be/common/src/main/java/org/apache/falcon/entity/parser/ClusterEntityParser.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/parser/ClusterEntityParser.java
b/common/src/main/java/org/apache/falcon/entity/parser/ClusterEntityParser.java
index 6eb5c30..87b61a4 100644
--- a/common/src/main/java/org/apache/falcon/entity/parser/ClusterEntityParser.java
+++ b/common/src/main/java/org/apache/falcon/entity/parser/ClusterEntityParser.java
@@ -23,7 +23,6 @@ import org.apache.falcon.FalconException;
 import org.apache.falcon.catalog.CatalogServiceFactory;
 import org.apache.falcon.entity.ClusterHelper;
 import org.apache.falcon.entity.EntityUtil;
-import org.apache.falcon.entity.store.StoreAccessException;
 import org.apache.falcon.entity.v0.EntityType;
 import org.apache.falcon.entity.v0.cluster.ACL;
 import org.apache.falcon.entity.v0.cluster.Cluster;
@@ -59,7 +58,7 @@ public class ClusterEntityParser extends EntityParser<Cluster> {
     }
 
     @Override
-    public void validate(Cluster cluster) throws StoreAccessException, ValidationException
{
+    public void validate(Cluster cluster) throws ValidationException {
         // validating scheme in light of fail-early
         validateScheme(cluster, Interfacetype.READONLY);
         validateScheme(cluster, Interfacetype.WRITE);
@@ -140,7 +139,7 @@ public class ClusterEntityParser extends EntityParser<Cluster> {
         }
     }
 
-    private void validateWorkflowInterface(Cluster cluster) throws ValidationException {
+    protected void validateWorkflowInterface(Cluster cluster) throws ValidationException
{
         final String workflowUrl = ClusterHelper.getOozieUrl(cluster);
         LOG.info("Validating workflow interface: {}", workflowUrl);
 
@@ -153,7 +152,7 @@ public class ClusterEntityParser extends EntityParser<Cluster> {
         }
     }
 
-    private void validateMessagingInterface(Cluster cluster) throws ValidationException {
+    protected void validateMessagingInterface(Cluster cluster) throws ValidationException
{
         final String messagingUrl = ClusterHelper.getMessageBrokerUrl(cluster);
         final String implementation = StartupProperties.get().getProperty(
                 "broker.impl.class", "org.apache.activemq.ActiveMQConnectionFactory");
@@ -172,7 +171,7 @@ public class ClusterEntityParser extends EntityParser<Cluster> {
         }
     }
 
-    private void validateRegistryInterface(Cluster cluster) throws ValidationException {
+    protected void validateRegistryInterface(Cluster cluster) throws ValidationException
{
         final boolean isCatalogRegistryEnabled = CatalogServiceFactory.isEnabled();
         if (!isCatalogRegistryEnabled) {
             return;  // ignore the registry interface for backwards compatibility
@@ -260,8 +259,9 @@ public class ClusterEntityParser extends EntityParser<Cluster> {
                                 ? HadoopClientFactory.ALL_PERMISSION
                                 : HadoopClientFactory.READ_EXECUTE_PERMISSION);
             } catch (IOException e) {
-                throw new ValidationException("Unable to validate the location "
-                        + location.getName() + " for cluster " + cluster.getName(), e);
+                throw new ValidationException("Unable to validate the location of name: "
+                        + location.getName() + " with path:" + location.getPath()
+                        + " for cluster " + cluster.getName(), e);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/03ba46be/common/src/test/java/org/apache/falcon/entity/parser/ClusterEntityParserTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/falcon/entity/parser/ClusterEntityParserTest.java
b/common/src/test/java/org/apache/falcon/entity/parser/ClusterEntityParserTest.java
index 709e597..a807e80 100644
--- a/common/src/test/java/org/apache/falcon/entity/parser/ClusterEntityParserTest.java
+++ b/common/src/test/java/org/apache/falcon/entity/parser/ClusterEntityParserTest.java
@@ -18,13 +18,6 @@
 
 package org.apache.falcon.entity.parser;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-
 import org.apache.falcon.FalconException;
 import org.apache.falcon.catalog.CatalogServiceFactory;
 import org.apache.falcon.cluster.util.EmbeddedCluster;
@@ -34,13 +27,22 @@ import org.apache.falcon.entity.v0.EntityType;
 import org.apache.falcon.entity.v0.cluster.Cluster;
 import org.apache.falcon.entity.v0.cluster.Interface;
 import org.apache.falcon.entity.v0.cluster.Interfacetype;
+import org.apache.falcon.entity.v0.cluster.Location;
+import org.apache.falcon.entity.v0.cluster.Locations;
 import org.apache.falcon.hadoop.HadoopClientFactory;
 import org.apache.falcon.util.StartupProperties;
+import org.mockito.Mockito;
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+
 
 /**
  * Test for validating cluster entity parsing.
@@ -192,6 +194,56 @@ public class ClusterEntityParserTest extends AbstractTestBase {
         }
     }
 
+    /**
+     * A lightweight unit test for a cluster where location paths are not instantiated .
+     * Extensive tests are found in ClusterEntityValidationIT.
+     *
+     * @throws ValidationException
+     */
+    @Test(expectedExceptions = ValidationException.class)
+    public void testClusterWithoutLocationsPaths() throws ValidationException {
+        ClusterEntityParser clusterEntityParser = Mockito.spy(
+                (ClusterEntityParser) EntityParserFactory.getParser(EntityType.CLUSTER));
+        Cluster cluster = this.dfsCluster.getCluster();
+        Mockito.doNothing().when(clusterEntityParser).validateWorkflowInterface(cluster);
+        Mockito.doNothing().when(clusterEntityParser).validateMessagingInterface(cluster);
+        Mockito.doNothing().when(clusterEntityParser).validateRegistryInterface(cluster);
+        clusterEntityParser.validate(cluster);
+        Assert.fail("Should have thrown a validation exception");
+    }
+
+    /**
+     * A lightweight unit test for a cluster where location paths are invalid.
+     * Extensive tests are found in ClusterEntityValidationIT.
+     *
+     * @throws ValidationException
+     */
+    @Test(expectedExceptions = ValidationException.class)
+    public void testClusterWithInvalidLocationsPaths() throws ValidationException {
+        ClusterEntityParser clusterEntityParser = Mockito.spy(
+                (ClusterEntityParser) EntityParserFactory.getParser(EntityType.CLUSTER));
+        Cluster cluster = this.dfsCluster.getCluster();
+        Location location = new Location();
+        location.setName("TestName");
+        location.setPath("/apps/non/existent/path");
+        Locations locations = new Locations();
+        locations.getLocations().add(location);
+        cluster.setLocations(locations);
+        Mockito.doNothing().when(clusterEntityParser).validateWorkflowInterface(cluster);
+        Mockito.doNothing().when(clusterEntityParser).validateMessagingInterface(cluster);
+        Mockito.doNothing().when(clusterEntityParser).validateRegistryInterface(cluster);
+        try {
+            clusterEntityParser.validate(cluster);
+        } catch (ValidationException e) {
+            String errorMessage = "Location " + location.getPath() + " for cluster "
+                    + cluster.getName() + " must exist.";
+            Assert.assertEquals(e.getMessage(), errorMessage);
+            throw e;
+        }
+        Assert.fail("Should have thrown a validation exception");
+    }
+
+
     @BeforeClass
     public void init() throws Exception {
         this.dfsCluster = EmbeddedCluster.newCluster("testCluster");


Mime
View raw message