You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@falcon.apache.org by ve...@apache.org on 2014/05/01 20:21:01 UTC
[2/4] git commit: FALCON-398 Null pointer Exception on submitting
HCat Feed. Contributed by Sowmya Ramesh
FALCON-398 Null pointer Exception on submitting HCat Feed. Contributed by Sowmya Ramesh
Project: http://git-wip-us.apache.org/repos/asf/incubator-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-falcon/commit/b765d32e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-falcon/tree/b765d32e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-falcon/diff/b765d32e
Branch: refs/heads/master
Commit: b765d32e822e640a6d4a5657135f3f5e5b274500
Parents: 49593f1
Author: Venkatesh Seetharam <ve...@apache.org>
Authored: Thu May 1 11:16:58 2014 -0700
Committer: Venkatesh Seetharam <ve...@apache.org>
Committed: Thu May 1 11:16:58 2014 -0700
----------------------------------------------------------------------
CHANGES.txt | 3 ++
.../falcon/entity/parser/FeedEntityParser.java | 15 +++++++
.../entity/parser/FeedEntityParserTest.java | 43 ++++++++++++++++++++
3 files changed, 61 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/b765d32e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8b19e29..10cfc0f 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -116,6 +116,9 @@ Trunk (Unreleased)
FALCON-123 Improve build speeds in falcon. (Srikanth Sundarrajan via Shwetha GS)
BUG FIXES
+ FALCON-398 Null pointer Exception on submitting HCat Feed. (Sowmya Ramesh
+ via Venkatesh Seetharam)
+
FALCON-390 falcon HCatProcess tests are failing in secure clusters
(Venkatesh Seetharam)
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/b765d32e/common/src/main/java/org/apache/falcon/entity/parser/FeedEntityParser.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/parser/FeedEntityParser.java b/common/src/main/java/org/apache/falcon/entity/parser/FeedEntityParser.java
index d138179..8911b33 100644
--- a/common/src/main/java/org/apache/falcon/entity/parser/FeedEntityParser.java
+++ b/common/src/main/java/org/apache/falcon/entity/parser/FeedEntityParser.java
@@ -73,6 +73,7 @@ public class FeedEntityParser extends EntityParser<Feed> {
validateEntityExists(EntityType.CLUSTER, cluster.getName());
validateClusterValidity(cluster.getValidity().getStart(), cluster.getValidity().getEnd(),
cluster.getName());
+ validateClusterHasRegistry(feed, cluster);
validateFeedCutOffPeriod(feed, cluster);
}
@@ -338,6 +339,20 @@ public class FeedEntityParser extends EntityParser<Feed> {
}
}
+ private void validateClusterHasRegistry(Feed feed, Cluster cluster) throws FalconException {
+ Storage.TYPE feedClusterStorageType = FeedHelper.getStorageType(feed, cluster);
+
+ if (feedClusterStorageType != Storage.TYPE.TABLE) {
+ return;
+ }
+
+ org.apache.falcon.entity.v0.cluster.Cluster clusterEntity = EntityUtil.getEntity(EntityType.CLUSTER,
+ cluster.getName());
+ if (ClusterHelper.getRegistryEndPoint(clusterEntity) == null) {
+ throw new ValidationException("Cluster should have registry interface defined: " + clusterEntity.getName());
+ }
+ }
+
private void validatePartitions(Feed feed, Storage.TYPE storageType) throws FalconException {
if (storageType == Storage.TYPE.TABLE && feed.getPartitions() != null) {
throw new ValidationException("Partitions are not supported for feeds with table storage. "
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/b765d32e/common/src/test/java/org/apache/falcon/entity/parser/FeedEntityParserTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/falcon/entity/parser/FeedEntityParserTest.java b/common/src/test/java/org/apache/falcon/entity/parser/FeedEntityParserTest.java
index b90713e..62a5afa 100644
--- a/common/src/test/java/org/apache/falcon/entity/parser/FeedEntityParserTest.java
+++ b/common/src/test/java/org/apache/falcon/entity/parser/FeedEntityParserTest.java
@@ -20,12 +20,15 @@ package org.apache.falcon.entity.parser;
import org.apache.falcon.FalconException;
import org.apache.falcon.entity.AbstractTestBase;
+import org.apache.falcon.entity.ClusterHelper;
+import org.apache.falcon.entity.EntityUtil;
import org.apache.falcon.entity.FeedHelper;
import org.apache.falcon.entity.store.ConfigurationStore;
import org.apache.falcon.entity.v0.EntityType;
import org.apache.falcon.entity.v0.Frequency;
import org.apache.falcon.entity.v0.SchemaHelper;
import org.apache.falcon.entity.v0.cluster.Cluster;
+import org.apache.falcon.entity.v0.cluster.Interfacetype;
import org.apache.falcon.entity.v0.feed.*;
import org.apache.falcon.group.FeedGroupMapTest;
import org.testng.Assert;
@@ -480,4 +483,44 @@ public class FeedEntityParserTest extends AbstractTestBase {
parser.validate(feed);
Assert.fail("An exception should have been thrown:Partitions are not supported for feeds with table storage");
}
+
+ @Test(expectedExceptions = ValidationException.class)
+ public void testValidateClusterHasRegistryWithNoRegistryInterfaceEndPoint() throws Exception {
+ final InputStream inputStream = getClass().getResourceAsStream("/config/feed/hive-table-feed.xml");
+ Feed feedWithTable = parser.parse(inputStream);
+
+ org.apache.falcon.entity.v0.cluster.Cluster clusterEntity = EntityUtil.getEntity(EntityType.CLUSTER,
+ feedWithTable.getClusters().getClusters().get(0).getName());
+ ClusterHelper.getInterface(clusterEntity, Interfacetype.REGISTRY).setEndpoint(null);
+
+ parser.validate(feedWithTable);
+ Assert.fail("An exception should have been thrown: Cluster should have registry interface defined with table "
+ + "storage");
+ }
+
+ @Test(expectedExceptions = ValidationException.class)
+ public void testValidateClusterHasRegistryWithNoRegistryInterface() throws Exception {
+ Unmarshaller unmarshaller = EntityType.CLUSTER.getUnmarshaller();
+ Cluster cluster = (Cluster) unmarshaller.unmarshal(this.getClass()
+ .getResourceAsStream(("/config/cluster/cluster-no-registry.xml")));
+ cluster.setName("badTestCluster");
+ ConfigurationStore.get().publish(EntityType.CLUSTER, cluster);
+
+
+ final InputStream inputStream = getClass().getResourceAsStream("/config/feed/hive-table-feed.xml");
+ Feed feedWithTable = parser.parse(inputStream);
+ Validity validity = modifiableFeed.getClusters().getClusters().get(0)
+ .getValidity();
+ feedWithTable.getClusters().getClusters().clear();
+
+ org.apache.falcon.entity.v0.feed.Cluster feedCluster =
+ new org.apache.falcon.entity.v0.feed.Cluster();
+ feedCluster.setName(cluster.getName());
+ feedCluster.setValidity(validity);
+ feedWithTable.getClusters().getClusters().add(feedCluster);
+
+ parser.validate(feedWithTable);
+ Assert.fail("An exception should have been thrown: Cluster should have registry interface defined with table"
+ + " storage");
+ }
}