You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@falcon.apache.org by sr...@apache.org on 2013/04/26 17:50:42 UTC
[26/47] git commit: Check style fixes relating to common module
Check style fixes relating to common module
Project: http://git-wip-us.apache.org/repos/asf/incubator-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-falcon/commit/bdadf2ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-falcon/tree/bdadf2ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-falcon/diff/bdadf2ed
Branch: refs/heads/master
Commit: bdadf2ed680b338d3ec48cb179300f50db69fee0
Parents: b1fcaac
Author: srikanth.sundarrajan <sr...@inmobi.com>
Authored: Wed Apr 17 14:59:49 2013 +0530
Committer: srikanth.sundarrajan <sr...@inmobi.com>
Committed: Wed Apr 17 14:59:49 2013 +0530
----------------------------------------------------------------------
.../org/apache/falcon/FalconRuntimException.java | 2 +-
.../falcon/cleanup/AbstractCleanupHandler.java | 28 +-
.../apache/falcon/cleanup/FeedCleanupHandler.java | 3 +
.../falcon/cleanup/ProcessCleanupHandler.java | 3 +
.../org/apache/falcon/entity/ClusterHelper.java | 3 +
.../apache/falcon/entity/ColoClusterRelation.java | 27 +-
.../entity/EntityNotRegisteredException.java | 3 +
.../java/org/apache/falcon/entity/EntityUtil.java | 271 ++++++++-------
.../java/org/apache/falcon/entity/ExternalId.java | 3 +
.../java/org/apache/falcon/entity/FeedHelper.java | 11 +-
.../org/apache/falcon/entity/ProcessHelper.java | 8 +-
.../apache/falcon/entity/WorkflowNameBuilder.java | 11 +-
.../apache/falcon/entity/common/Configuration.java | 3 +
.../apache/falcon/entity/common/FeedDataPath.java | 10 +-
.../falcon/entity/parser/ClusterEntityParser.java | 3 +
.../entity/parser/CrossEntityValidations.java | 8 +-
.../apache/falcon/entity/parser/EntityParser.java | 13 +-
.../falcon/entity/parser/EntityParserFactory.java | 18 +-
.../falcon/entity/parser/FeedEntityParser.java | 21 +-
.../falcon/entity/parser/ValidationException.java | 2 +-
.../falcon/entity/store/ConfigurationStore.java | 34 +-
.../entity/store/EntityAlreadyExistsException.java | 3 +
.../falcon/entity/store/StoreAccessException.java | 3 +
.../org/apache/falcon/entity/v0/EntityGraph.java | 38 ++-
.../falcon/entity/v0/EntityIntegrityChecker.java | 19 +-
.../apache/falcon/expression/ExpressionHelper.java | 47 ++--
.../java/org/apache/falcon/group/FeedGroupMap.java | 11 +-
.../org/apache/falcon/security/CurrentUser.java | 18 +-
.../apache/falcon/security/FalconLoginModule.java | 7 +-
.../apache/falcon/security/FalconPrincipal.java | 3 +
.../security/FalconSecurityConfiguration.java | 3 +
.../apache/falcon/security/SecurityConstants.java | 7 +-
.../service/ConfigurationChangeListener.java | 3 +
.../org/apache/falcon/service/FalconService.java | 3 +
.../apache/falcon/service/LogCleanupService.java | 7 +-
.../apache/falcon/service/ServiceInitializer.java | 5 +-
.../java/org/apache/falcon/service/Services.java | 22 +-
.../org/apache/falcon/update/UpdateHelper.java | 87 ++---
.../apache/falcon/util/ApplicationProperties.java | 11 +-
.../org/apache/falcon/util/BuildProperties.java | 17 +-
.../apache/falcon/util/DeploymentProperties.java | 17 +-
.../org/apache/falcon/util/DeploymentUtil.java | 29 +-
.../org/apache/falcon/util/ReflectionUtils.java | 5 +
.../org/apache/falcon/util/RuntimeProperties.java | 23 +-
.../org/apache/falcon/util/StartupProperties.java | 16 +-
.../apache/falcon/workflow/WorkflowBuilder.java | 6 +-
.../falcon/workflow/WorkflowEngineFactory.java | 8 +-
.../workflow/engine/AbstractWorkflowEngine.java | 10 +-
.../engine/WorkflowEngineActionListener.java | 4 +
.../falcon/cleanup/LogCleanupServiceTest.java | 56 ++--
.../org/apache/falcon/entity/AbstractTestBase.java | 46 ++--
.../falcon/entity/ColoClusterRelationTest.java | 3 +
.../org/apache/falcon/entity/EntityTypeTest.java | 3 +
.../org/apache/falcon/entity/EntityUtilTest.java | 3 +
.../org/apache/falcon/entity/FeedHelperTest.java | 3 +
.../falcon/entity/TestWorkflowNameBuilder.java | 5 +-
.../entity/parser/ClusterEntityParserTest.java | 3 +
.../falcon/entity/parser/FeedEntityParserTest.java | 21 +-
.../falcon/entity/parser/FeedUpdateTest.java | 10 +-
.../entity/parser/ProcessEntityParserTest.java | 14 +-
.../entity/store/ConfigurationStoreTest.java | 5 +-
.../apache/falcon/entity/v0/EntityGraphTest.java | 11 +-
.../org/apache/falcon/group/FeedGroupMapTest.java | 3 +
.../apache/falcon/security/CurrentUserTest.java | 3 +
.../org/apache/falcon/update/UpdateHelperTest.java | 9 +-
.../apache/falcon/util/StartupPropertiesTest.java | 3 +
.../org/apache/falcon/logging/LogProvider.java | 8 +-
.../apache/falcon/converter/AbstractTestBase.java | 34 +-
.../falcon/rerun/handler/LateRerunHandler.java | 2 +-
69 files changed, 671 insertions(+), 491 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/FalconRuntimException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/FalconRuntimException.java b/common/src/main/java/org/apache/falcon/FalconRuntimException.java
index b603fbf..e465f09 100644
--- a/common/src/main/java/org/apache/falcon/FalconRuntimException.java
+++ b/common/src/main/java/org/apache/falcon/FalconRuntimException.java
@@ -19,7 +19,7 @@
package org.apache.falcon;
/**
- * Runtime Execption class for Falcon application
+ * Runtime Exception class for Falcon application.
*/
public class FalconRuntimException extends RuntimeException {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/cleanup/AbstractCleanupHandler.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/cleanup/AbstractCleanupHandler.java b/common/src/main/java/org/apache/falcon/cleanup/AbstractCleanupHandler.java
index 264ea28..49662d1 100644
--- a/common/src/main/java/org/apache/falcon/cleanup/AbstractCleanupHandler.java
+++ b/common/src/main/java/org/apache/falcon/cleanup/AbstractCleanupHandler.java
@@ -38,20 +38,25 @@ import javax.servlet.jsp.el.ELException;
import javax.servlet.jsp.el.ExpressionEvaluator;
import java.io.IOException;
+/**
+ * Falcon cleanup handler for cleaning up work, temp and log files
+ * left behind by falcon.
+ */
public abstract class AbstractCleanupHandler {
protected static final Logger LOG = Logger
.getLogger(AbstractCleanupHandler.class);
- protected final ConfigurationStore STORE = ConfigurationStore.get();
+ protected static final ConfigurationStore STORE = ConfigurationStore.get();
public static final ExpressionEvaluator EVALUATOR = new ExpressionEvaluatorImpl();
- public static final ExpressionHelper resolver = ExpressionHelper.get();
+ public static final ExpressionHelper RESOLVER = ExpressionHelper.get();
protected long getRetention(Entity entity, TimeUnit timeUnit)
- throws FalconException {
+ throws FalconException {
+
String retention = getRetentionValue(timeUnit);
try {
return (Long) EVALUATOR.evaluate("${" + retention + "}",
- Long.class, resolver, resolver);
+ Long.class, RESOLVER, RESOLVER);
} catch (ELException e) {
throw new FalconException("Unable to evalue retention limit: "
+ retention + " for entity: " + entity.getName());
@@ -64,9 +69,9 @@ public abstract class AbstractCleanupHandler {
}
- protected FileStatus[] getAllLogs(
- org.apache.falcon.entity.v0.cluster.Cluster cluster, Entity entity)
- throws FalconException {
+ protected FileStatus[] getAllLogs(org.apache.falcon.entity.v0.cluster.Cluster cluster, Entity entity)
+ throws FalconException {
+
String stagingPath = ClusterHelper.getLocation(cluster, "staging");
Path logPath = getLogPath(entity, stagingPath);
FileSystem fs = getFileSystem(cluster);
@@ -79,9 +84,8 @@ public abstract class AbstractCleanupHandler {
return paths;
}
- private FileSystem getFileSystem(
- org.apache.falcon.entity.v0.cluster.Cluster cluster)
- throws FalconException {
+ private FileSystem getFileSystem(org.apache.falcon.entity.v0.cluster.Cluster cluster)
+ throws FalconException {
FileSystem fs;
try {
@@ -94,7 +98,7 @@ public abstract class AbstractCleanupHandler {
}
protected void delete(Cluster cluster, Entity entity, long retention)
- throws FalconException {
+ throws FalconException {
FileStatus[] logs = getAllLogs(cluster, entity);
long now = System.currentTimeMillis();
@@ -104,7 +108,7 @@ public abstract class AbstractCleanupHandler {
try {
boolean isDeleted = getFileSystem(cluster).delete(
log.getPath(), true);
- if (isDeleted == false) {
+ if (!isDeleted) {
LOG.error("Unable to delete path: " + log.getPath());
} else {
LOG.info("Deleted path: " + log.getPath());
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/cleanup/FeedCleanupHandler.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/cleanup/FeedCleanupHandler.java b/common/src/main/java/org/apache/falcon/cleanup/FeedCleanupHandler.java
index 37fc653..0c8cf82 100644
--- a/common/src/main/java/org/apache/falcon/cleanup/FeedCleanupHandler.java
+++ b/common/src/main/java/org/apache/falcon/cleanup/FeedCleanupHandler.java
@@ -26,6 +26,9 @@ import org.apache.hadoop.fs.Path;
import java.util.Collection;
+/**
+ * Cleanup files relating to feed management workflows.
+ */
public class FeedCleanupHandler extends AbstractCleanupHandler {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/cleanup/ProcessCleanupHandler.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/cleanup/ProcessCleanupHandler.java b/common/src/main/java/org/apache/falcon/cleanup/ProcessCleanupHandler.java
index 9b96879..add1237 100644
--- a/common/src/main/java/org/apache/falcon/cleanup/ProcessCleanupHandler.java
+++ b/common/src/main/java/org/apache/falcon/cleanup/ProcessCleanupHandler.java
@@ -26,6 +26,9 @@ import org.apache.hadoop.fs.Path;
import java.util.Collection;
+/**
+ * Handler to cleanup files left behind by falcon relating to process.
+ */
public class ProcessCleanupHandler extends AbstractCleanupHandler {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/ClusterHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/ClusterHelper.java b/common/src/main/java/org/apache/falcon/entity/ClusterHelper.java
index 3d77887..e332aba 100644
--- a/common/src/main/java/org/apache/falcon/entity/ClusterHelper.java
+++ b/common/src/main/java/org/apache/falcon/entity/ClusterHelper.java
@@ -22,6 +22,9 @@ import org.apache.falcon.entity.v0.cluster.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
+/**
+ * Helper to get end points relating to the cluster.
+ */
public final class ClusterHelper {
public static final String DEFAULT_BROKER_IMPL_CLASS = "org.apache.activemq.ActiveMQConnectionFactory";
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/ColoClusterRelation.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/ColoClusterRelation.java b/common/src/main/java/org/apache/falcon/entity/ColoClusterRelation.java
index 6c5d885..72dd952 100644
--- a/common/src/main/java/org/apache/falcon/entity/ColoClusterRelation.java
+++ b/common/src/main/java/org/apache/falcon/entity/ColoClusterRelation.java
@@ -28,21 +28,24 @@ import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-public class ColoClusterRelation implements ConfigurationChangeListener {
- private static final ConcurrentHashMap<String, Set<String>> coloClusterMap
- = new ConcurrentHashMap<String, Set<String>>();
- private static final ColoClusterRelation instance = new ColoClusterRelation();
+/**
+ * Map of clusters in each colocation/ datacenter.
+ */
+public final class ColoClusterRelation implements ConfigurationChangeListener {
+ private static final ConcurrentHashMap<String, Set<String>> COLO_CLUSTER_MAP =
+ new ConcurrentHashMap<String, Set<String>>();
+ private static final ColoClusterRelation INSTANCE = new ColoClusterRelation();
private ColoClusterRelation() {
}
public static ColoClusterRelation get() {
- return instance;
+ return INSTANCE;
}
public Set<String> getClusters(String colo) {
- if (coloClusterMap.containsKey(colo)) {
- return coloClusterMap.get(colo);
+ if (COLO_CLUSTER_MAP.containsKey(colo)) {
+ return COLO_CLUSTER_MAP.get(colo);
}
return new HashSet<String>();
}
@@ -54,8 +57,8 @@ public class ColoClusterRelation implements ConfigurationChangeListener {
}
Cluster cluster = (Cluster) entity;
- coloClusterMap.putIfAbsent(cluster.getColo(), new HashSet<String>());
- coloClusterMap.get(cluster.getColo()).add(cluster.getName());
+ COLO_CLUSTER_MAP.putIfAbsent(cluster.getColo(), new HashSet<String>());
+ COLO_CLUSTER_MAP.get(cluster.getColo()).add(cluster.getName());
}
@Override
@@ -65,9 +68,9 @@ public class ColoClusterRelation implements ConfigurationChangeListener {
}
Cluster cluster = (Cluster) entity;
- coloClusterMap.get(cluster.getColo()).remove(cluster.getName());
- if (coloClusterMap.get(cluster.getColo()).isEmpty()) {
- coloClusterMap.remove(cluster.getColo());
+ COLO_CLUSTER_MAP.get(cluster.getColo()).remove(cluster.getName());
+ if (COLO_CLUSTER_MAP.get(cluster.getColo()).isEmpty()) {
+ COLO_CLUSTER_MAP.remove(cluster.getColo());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/EntityNotRegisteredException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/EntityNotRegisteredException.java b/common/src/main/java/org/apache/falcon/entity/EntityNotRegisteredException.java
index db922a4..40f83e4 100644
--- a/common/src/main/java/org/apache/falcon/entity/EntityNotRegisteredException.java
+++ b/common/src/main/java/org/apache/falcon/entity/EntityNotRegisteredException.java
@@ -20,6 +20,9 @@ package org.apache.falcon.entity;
import org.apache.falcon.FalconException;
+/**
+ * Exception thrown by falcon when entity is not registered already in config store.
+ */
public class EntityNotRegisteredException extends FalconException {
public EntityNotRegisteredException(String message) {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/EntityUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/EntityUtil.java b/common/src/main/java/org/apache/falcon/entity/EntityUtil.java
index f0ef515..ba086f8 100644
--- a/common/src/main/java/org/apache/falcon/entity/EntityUtil.java
+++ b/common/src/main/java/org/apache/falcon/entity/EntityUtil.java
@@ -44,12 +44,17 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
-public class EntityUtil {
+/**
+ * Helper to get entity object.
+ */
+public final class EntityUtil {
private static final long MINUTE_IN_MS = 60000L;
private static final long HOUR_IN_MS = 3600000L;
private static final long DAY_IN_MS = 86400000L;
private static final long MONTH_IN_MS = 2592000000L;
+ private EntityUtil() {}
+
public static <T extends Entity> T getEntity(EntityType type, String entityName) throws FalconException {
ConfigurationStore configStore = ConfigurationStore.get();
T entity = configStore.get(type, entityName);
@@ -233,19 +238,19 @@ public class EntityUtil {
int count = 0;
switch (frequency.getTimeUnit()) {
- case months:
- count = (int) ((now.getTime() - startTime.getTime()) / MONTH_IN_MS);
- break;
- case days:
- count = (int) ((now.getTime() - startTime.getTime()) / DAY_IN_MS);
- break;
- case hours:
- count = (int) ((now.getTime() - startTime.getTime()) / HOUR_IN_MS);
- break;
- case minutes:
- count = (int) ((now.getTime() - startTime.getTime()) / MINUTE_IN_MS);
- break;
- default:
+ case months:
+ count = (int) ((now.getTime() - startTime.getTime()) / MONTH_IN_MS);
+ break;
+ case days:
+ count = (int) ((now.getTime() - startTime.getTime()) / DAY_IN_MS);
+ break;
+ case hours:
+ count = (int) ((now.getTime() - startTime.getTime()) / HOUR_IN_MS);
+ break;
+ case minutes:
+ count = (int) ((now.getTime() - startTime.getTime()) / MINUTE_IN_MS);
+ break;
+ default:
}
if (count > 2) {
@@ -268,19 +273,19 @@ public class EntityUtil {
int count = 0;
switch (frequency.getTimeUnit()) {
- case months:
- count = (int) ((instanceTime.getTime() - startTime.getTime()) / MONTH_IN_MS);
- break;
- case days:
- count = (int) ((instanceTime.getTime() - startTime.getTime()) / DAY_IN_MS);
- break;
- case hours:
- count = (int) ((instanceTime.getTime() - startTime.getTime()) / HOUR_IN_MS);
- break;
- case minutes:
- count = (int) ((instanceTime.getTime() - startTime.getTime()) / MINUTE_IN_MS);
- break;
- default:
+ case months:
+ count = (int) ((instanceTime.getTime() - startTime.getTime()) / MONTH_IN_MS);
+ break;
+ case days:
+ count = (int) ((instanceTime.getTime() - startTime.getTime()) / DAY_IN_MS);
+ break;
+ case hours:
+ count = (int) ((instanceTime.getTime() - startTime.getTime()) / HOUR_IN_MS);
+ break;
+ case minutes:
+ count = (int) ((instanceTime.getTime() - startTime.getTime()) / MINUTE_IN_MS);
+ break;
+ default:
}
if (count > 2) {
@@ -340,7 +345,8 @@ public class EntityUtil {
@SuppressWarnings("rawtypes")
private static void mapToProperties(Object obj, String name, Map<String, String> propMap, String[] filterProps)
- throws FalconException {
+ throws FalconException {
+
if (obj == null) {
return;
}
@@ -429,36 +435,38 @@ public class EntityUtil {
public static <T extends Entity> T getClusterView(T entity, String clusterName) {
switch (entity.getEntityType()) {
- case CLUSTER:
- return entity;
-
- case FEED:
- Feed feed = (Feed) entity.clone();
- Cluster feedCluster = FeedHelper.getCluster(feed, clusterName);
- Iterator<Cluster> itr = feed.getClusters().getClusters().iterator();
- while (itr.hasNext()) {
- Cluster cluster = itr.next();
- //In addition to retaining the required clster, retain the sources clusters if this is the target
- // cluster
- //1. Retain cluster if cluster n
- if (!(cluster.getName().equals(clusterName) ||
- (feedCluster.getType() == ClusterType.TARGET && cluster.getType() == ClusterType.SOURCE))) {
- itr.remove();
- }
+ case CLUSTER:
+ return entity;
+
+ case FEED:
+ Feed feed = (Feed) entity.copy();
+ Cluster feedCluster = FeedHelper.getCluster(feed, clusterName);
+ Iterator<Cluster> itr = feed.getClusters().getClusters().iterator();
+ while (itr.hasNext()) {
+ Cluster cluster = itr.next();
+ //In addition to retaining the required clster, retain the sources clusters if this is the target
+ // cluster
+ //1. Retain cluster if cluster n
+ if (!(cluster.getName().equals(clusterName)
+ || (feedCluster.getType() == ClusterType.TARGET
+ && cluster.getType() == ClusterType.SOURCE))) {
+ itr.remove();
}
- return (T) feed;
-
- case PROCESS:
- Process process = (Process) entity.clone();
- Iterator<org.apache.falcon.entity.v0.process.Cluster> procItr
- = process.getClusters().getClusters().iterator();
- while (procItr.hasNext()) {
- org.apache.falcon.entity.v0.process.Cluster cluster = procItr.next();
- if (!cluster.getName().equals(clusterName)) {
- procItr.remove();
- }
+ }
+ return (T) feed;
+
+ case PROCESS:
+ Process process = (Process) entity.copy();
+ Iterator<org.apache.falcon.entity.v0.process.Cluster> procItr =
+ process.getClusters().getClusters().iterator();
+ while (procItr.hasNext()) {
+ org.apache.falcon.entity.v0.process.Cluster cluster = procItr.next();
+ if (!cluster.getName().equals(clusterName)) {
+ procItr.remove();
}
- return (T) process;
+ }
+ return (T) process;
+ default:
}
throw new UnsupportedOperationException("Not supported for entity type " + entity.getEntityType());
}
@@ -466,23 +474,24 @@ public class EntityUtil {
public static Set<String> getClustersDefined(Entity entity) {
Set<String> clusters = new HashSet<String>();
switch (entity.getEntityType()) {
- case CLUSTER:
- clusters.add(entity.getName());
- break;
-
- case FEED:
- Feed feed = (Feed) entity;
- for (Cluster cluster : feed.getClusters().getClusters()) {
- clusters.add(cluster.getName());
- }
- break;
+ case CLUSTER:
+ clusters.add(entity.getName());
+ break;
+
+ case FEED:
+ Feed feed = (Feed) entity;
+ for (Cluster cluster : feed.getClusters().getClusters()) {
+ clusters.add(cluster.getName());
+ }
+ break;
- case PROCESS:
- Process process = (Process) entity;
- for (org.apache.falcon.entity.v0.process.Cluster cluster : process.getClusters().getClusters()) {
- clusters.add(cluster.getName());
- }
- break;
+ case PROCESS:
+ Process process = (Process) entity;
+ for (org.apache.falcon.entity.v0.process.Cluster cluster : process.getClusters().getClusters()) {
+ clusters.add(cluster.getName());
+ }
+ break;
+ default:
}
return clusters;
}
@@ -503,9 +512,33 @@ public class EntityUtil {
return applicableClusters;
}
- public static Path getStagingPath(
- org.apache.falcon.entity.v0.cluster.Cluster cluster, Entity entity)
- throws FalconException {
+ public static Retry getRetry(Entity entity) throws FalconException {
+ switch (entity.getEntityType()) {
+ case FEED:
+ if (!RuntimeProperties.get()
+ .getProperty("feed.retry.allowed", "true")
+ .equalsIgnoreCase("true")) {
+ return null;
+ }
+ Retry retry = new Retry();
+ retry.setAttempts(Integer.parseInt(RuntimeProperties.get()
+ .getProperty("feed.retry.attempts", "3")));
+ retry.setDelay(new Frequency(RuntimeProperties.get().getProperty(
+ "feed.retry.frequency", "minutes(5)")));
+ retry.setPolicy(PolicyType.fromValue(RuntimeProperties.get()
+ .getProperty("feed.retry.policy", "exp-backoff")));
+ return retry;
+ case PROCESS:
+ Process process = (Process) entity;
+ return process.getRetry();
+ default:
+ throw new FalconException("Cannot create Retry for entity:" + entity.getName());
+ }
+ }
+
+ public static Path getStagingPath(org.apache.falcon.entity.v0.cluster.Cluster cluster, Entity entity)
+ throws FalconException {
+
try {
return new Path(ClusterHelper.getLocation(cluster, "staging"),
EntityUtil.getStagingPath(entity));
@@ -514,67 +547,43 @@ public class EntityUtil {
}
}
- public static Retry getRetry(Entity entity) throws FalconException {
- switch (entity.getEntityType()) {
- case FEED:
- if (!RuntimeProperties.get()
- .getProperty("feed.retry.allowed", "true")
- .equalsIgnoreCase("true")) {
- return null;
- }
- Retry retry = new Retry();
- retry.setAttempts(Integer.parseInt(RuntimeProperties.get()
- .getProperty("feed.retry.attempts", "3")));
- retry.setDelay(new Frequency(RuntimeProperties.get().getProperty(
- "feed.retry.frequency", "minutes(5)")));
- retry.setPolicy(PolicyType.fromValue(RuntimeProperties.get()
- .getProperty("feed.retry.policy", "exp-backoff")));
- return retry;
- case PROCESS:
- Process process = (Process) entity;
- return process.getRetry();
- default:
- throw new FalconException("Cannot create Retry for entity:" + entity.getName());
- }
- }
-
public static LateProcess getLateProcess(Entity entity)
- throws FalconException {
+ throws FalconException {
+
switch (entity.getEntityType()) {
- case FEED:
- if (!RuntimeProperties.get()
- .getProperty("feed.late.allowed", "true")
- .equalsIgnoreCase("true")) {
- return null;
- }
- LateProcess lateProcess = new LateProcess();
- lateProcess.setDelay(new Frequency(RuntimeProperties.get()
- .getProperty("feed.late.frequency", "hours(3)")));
- lateProcess.setPolicy(PolicyType.fromValue(RuntimeProperties.get()
- .getProperty("feed.late.policy", "exp-backoff")));
- LateInput lateInput = new LateInput();
- lateInput.setInput(entity.getName());
- //TODO - Assuming the late workflow is not used
- lateInput.setWorkflowPath("ignore.xml");
- lateProcess.getLateInputs().add(lateInput);
- return lateProcess;
- case PROCESS:
- Process process = (Process) entity;
- return process.getLateProcess();
- default:
- throw new FalconException("Cannot create Late Process for entity:" + entity.getName());
- }
- }
-
- public static Path getLogPath(
- org.apache.falcon.entity.v0.cluster.Cluster cluster, Entity entity)
- throws FalconException {
- Path logPath = new Path(ClusterHelper.getLocation(cluster,
+ case FEED:
+ if (!RuntimeProperties.get()
+ .getProperty("feed.late.allowed", "true")
+ .equalsIgnoreCase("true")) {
+ return null;
+ }
+ LateProcess lateProcess = new LateProcess();
+ lateProcess.setDelay(new Frequency(RuntimeProperties.get()
+ .getProperty("feed.late.frequency", "hours(3)")));
+ lateProcess.setPolicy(PolicyType.fromValue(RuntimeProperties.get()
+ .getProperty("feed.late.policy", "exp-backoff")));
+ LateInput lateInput = new LateInput();
+ lateInput.setInput(entity.getName());
+ //TODO - Assuming the late workflow is not used
+ lateInput.setWorkflowPath("ignore.xml");
+ lateProcess.getLateInputs().add(lateInput);
+ return lateProcess;
+ case PROCESS:
+ Process process = (Process) entity;
+ return process.getLateProcess();
+ default:
+ throw new FalconException("Cannot create Late Process for entity:" + entity.getName());
+ }
+ }
+
+ public static Path getLogPath(org.apache.falcon.entity.v0.cluster.Cluster cluster, Entity entity)
+ throws FalconException {
+
+ return new Path(ClusterHelper.getLocation(cluster,
"staging"), EntityUtil.getStagingPath(entity) + "/../logs");
- return logPath;
}
- public static String UTCtoURIDate(String utc) throws FalconException {
+ public static String fromUTCtoURIDate(String utc) throws FalconException {
DateFormat utcFormat = new SimpleDateFormat(
"yyyy'-'MM'-'dd'T'HH':'mm'Z'");
Date utcDate;
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/ExternalId.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/ExternalId.java b/common/src/main/java/org/apache/falcon/entity/ExternalId.java
index cb865d2..c53d83a 100644
--- a/common/src/main/java/org/apache/falcon/entity/ExternalId.java
+++ b/common/src/main/java/org/apache/falcon/entity/ExternalId.java
@@ -25,6 +25,9 @@ import org.apache.falcon.entity.v0.SchemaHelper;
import java.util.Date;
+/**
+ * External id as represented by workflow engine.
+ */
public class ExternalId {
private static final String SEPARATOR = "/";
private String id;
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/FeedHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/FeedHelper.java b/common/src/main/java/org/apache/falcon/entity/FeedHelper.java
index 4a39d8c..c96120d 100644
--- a/common/src/main/java/org/apache/falcon/entity/FeedHelper.java
+++ b/common/src/main/java/org/apache/falcon/entity/FeedHelper.java
@@ -28,7 +28,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-public class FeedHelper {
+/**
+ * Feed entity helper methods.
+ */
+public final class FeedHelper {
+
+ private FeedHelper() {}
+
public static Cluster getCluster(Feed feed, String clusterName) {
for (Cluster cluster : feed.getClusters().getClusters()) {
if (cluster.getName().equals(clusterName)) {
@@ -93,7 +99,8 @@ public class FeedHelper {
}
public static String evaluateClusterExp(org.apache.falcon.entity.v0.cluster.Cluster clusterEntity, String exp)
- throws FalconException {
+ throws FalconException {
+
Properties properties = loadClusterProperties(clusterEntity);
ExpressionHelper expHelp = ExpressionHelper.get();
expHelp.setPropertiesForVariable(properties);
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/ProcessHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/ProcessHelper.java b/common/src/main/java/org/apache/falcon/entity/ProcessHelper.java
index 598f26e..dc5ae7a 100644
--- a/common/src/main/java/org/apache/falcon/entity/ProcessHelper.java
+++ b/common/src/main/java/org/apache/falcon/entity/ProcessHelper.java
@@ -21,7 +21,13 @@ package org.apache.falcon.entity;
import org.apache.falcon.entity.v0.process.Cluster;
import org.apache.falcon.entity.v0.process.Process;
-public class ProcessHelper {
+/**
+ * Helper methods for accessing process members.
+ */
+public final class ProcessHelper {
+
+ private ProcessHelper() {}
+
public static Cluster getCluster(Process process, String clusterName) {
for (Cluster cluster : process.getClusters().getClusters()) {
if (cluster.getName().equals(clusterName)) {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/WorkflowNameBuilder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/WorkflowNameBuilder.java b/common/src/main/java/org/apache/falcon/entity/WorkflowNameBuilder.java
index 4a636cd..a1216e7 100644
--- a/common/src/main/java/org/apache/falcon/entity/WorkflowNameBuilder.java
+++ b/common/src/main/java/org/apache/falcon/entity/WorkflowNameBuilder.java
@@ -26,10 +26,14 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * Convenient builder for workflow name.
+ * @param <T>
+ */
public class WorkflowNameBuilder<T extends Entity> {
private static final String PREFIX = "FALCON";
- T entity;
+ private T entity;
private Tag tag;
private List<String> suffixes;
@@ -37,6 +41,7 @@ public class WorkflowNameBuilder<T extends Entity> {
this.entity = entity;
}
+ //SUSPEND CHECKSTYLE CHECK
public void setTag(Tag tag) {
this.tag = tag;
}
@@ -44,6 +49,7 @@ public class WorkflowNameBuilder<T extends Entity> {
public void setSuffixes(List<String> suffixes) {
this.suffixes = suffixes;
}
+ //RESUME CHECKSTYLE CHECK
public WorkflowName getWorkflowName() {
return new WorkflowName(PREFIX, entity.getEntityType().name(),
@@ -61,6 +67,9 @@ public class WorkflowNameBuilder<T extends Entity> {
: WorkflowName.getTagAndSuffixes(entity, workflowName).second;
}
+ /**
+ * Workflow name.
+ */
public static class WorkflowName {
private static final String SEPARATOR = "_";
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/common/Configuration.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/common/Configuration.java b/common/src/main/java/org/apache/falcon/entity/common/Configuration.java
index 0e7e8f1..2e0e426 100644
--- a/common/src/main/java/org/apache/falcon/entity/common/Configuration.java
+++ b/common/src/main/java/org/apache/falcon/entity/common/Configuration.java
@@ -23,6 +23,9 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
+/**
+ * Property k/v.
+ */
public class Configuration implements Iterable<Map.Entry<String, String>>, Cloneable {
private final Map<String, String> properties;
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/common/FeedDataPath.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/common/FeedDataPath.java b/common/src/main/java/org/apache/falcon/entity/common/FeedDataPath.java
index 470c98a..4031e14 100644
--- a/common/src/main/java/org/apache/falcon/entity/common/FeedDataPath.java
+++ b/common/src/main/java/org/apache/falcon/entity/common/FeedDataPath.java
@@ -19,8 +19,16 @@ package org.apache.falcon.entity.common;
import java.util.regex.Pattern;
-public class FeedDataPath {
+/**
+ * Helper to map feed path and the time component.
+ */
+public final class FeedDataPath {
+
+ private FeedDataPath() {}
+ /**
+ * Standard variables for feed time components.
+ */
public static enum VARS {
YEAR("yyyy"), MONTH("MM"), DAY("dd"), HOUR("HH"), MINUTE("mm");
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/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 c6ef988..8011dce 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
@@ -27,6 +27,9 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.log4j.Logger;
+/**
+ * Parser that parses cluster entity definition.
+ */
public class ClusterEntityParser extends EntityParser<Cluster> {
private static final Logger LOG = Logger.getLogger(ProcessEntityParser.class);
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/parser/CrossEntityValidations.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/parser/CrossEntityValidations.java b/common/src/main/java/org/apache/falcon/entity/parser/CrossEntityValidations.java
index 09aed24..d8d3d78 100644
--- a/common/src/main/java/org/apache/falcon/entity/parser/CrossEntityValidations.java
+++ b/common/src/main/java/org/apache/falcon/entity/parser/CrossEntityValidations.java
@@ -28,8 +28,13 @@ import org.apache.falcon.expression.ExpressionHelper;
import java.util.Date;
+/**
+ * Validation helper functions to validate across process, feed and cluster definitions.
+ */
public final class CrossEntityValidations {
+ private CrossEntityValidations() {}
+
public static void validateInstanceRange(Process process, Input input, Feed feed) throws FalconException {
try {
@@ -78,7 +83,8 @@ public final class CrossEntityValidations {
}
public static void validateFeedRetentionPeriod(String startInstance, Feed feed, String clusterName)
- throws FalconException {
+ throws FalconException {
+
String feedRetention = FeedHelper.getCluster(feed, clusterName).getRetention().getLimit().toString();
ExpressionHelper evaluator = ExpressionHelper.get();
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/parser/EntityParser.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/parser/EntityParser.java b/common/src/main/java/org/apache/falcon/entity/parser/EntityParser.java
index 6b06cc4..d24fafc 100644
--- a/common/src/main/java/org/apache/falcon/entity/parser/EntityParser.java
+++ b/common/src/main/java/org/apache/falcon/entity/parser/EntityParser.java
@@ -31,10 +31,10 @@ import java.io.InputStream;
import java.util.List;
/**
- * Generic Abstract Entity Parser, the concrete FEED, PROCESS and CLUSTER
- * Should extend this parser to implement specific parsing.
+ * Generic Abstract Entity Parser, the concrete FEED, PROCESS and CLUSTER should extend this parser
+ * to implement specific parsing.
*
- * @param <T>
+ * @param <T> of type Entity
*/
public abstract class EntityParser<T extends Entity> {
@@ -42,11 +42,6 @@ public abstract class EntityParser<T extends Entity> {
private final EntityType entityType;
- /**
- * Constructor
- *
- * @param entityType - can be FEED or PROCESS
- */
protected EntityParser(EntityType entityType) {
this.entityType = entityType;
}
@@ -69,7 +64,7 @@ public abstract class EntityParser<T extends Entity> {
}
/**
- * Parses xml stream
+ * Parses xml stream.
*
* @param xmlStream
* @return entity
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/parser/EntityParserFactory.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/parser/EntityParserFactory.java b/common/src/main/java/org/apache/falcon/entity/parser/EntityParserFactory.java
index 43542c3..5a33201 100644
--- a/common/src/main/java/org/apache/falcon/entity/parser/EntityParserFactory.java
+++ b/common/src/main/java/org/apache/falcon/entity/parser/EntityParserFactory.java
@@ -33,20 +33,20 @@ public final class EntityParserFactory {
* unmarshalled easily by concrete classes based on the class type using
* JAXB.
*
- * @param entityType
+ * @param entityType - entity type
* @return concrete parser based on entity type
*/
public static EntityParser getParser(final EntityType entityType) {
switch (entityType) {
- case PROCESS:
- return new ProcessEntityParser();
- case FEED:
- return new FeedEntityParser();
- case CLUSTER:
- return new ClusterEntityParser();
- default:
- throw new IllegalArgumentException("Unhandled entity type: " + entityType);
+ case PROCESS:
+ return new ProcessEntityParser();
+ case FEED:
+ return new FeedEntityParser();
+ case CLUSTER:
+ return new ClusterEntityParser();
+ default:
+ throw new IllegalArgumentException("Unhandled entity type: " + entityType);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/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 475384e..1c323fd 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
@@ -43,6 +43,9 @@ import java.util.HashSet;
import java.util.Set;
import java.util.TimeZone;
+/**
+ * Parser that parses feed entity definition.
+ */
public class FeedEntityParser extends EntityParser<Feed> {
private static final Logger LOG = Logger.getLogger(FeedEntityParser.class);
@@ -112,20 +115,16 @@ public class FeedEntityParser extends EntityParser<Feed> {
cluster.getName()).getPath()).equals(
FeedGroup.getDatePattern(defaultPath))) {
throw new ValidationException("Feeds default path pattern: "
- + FeedHelper.getLocation(feed, LocationType.DATA)
- .getPath()
+ + FeedHelper.getLocation(feed, LocationType.DATA).getPath()
+ ", does not match with cluster: "
+ cluster.getName()
+ " path pattern: "
- + FeedHelper.getLocation(feed, LocationType.DATA,
- cluster.getName()).getPath());
+ + FeedHelper.getLocation(feed, LocationType.DATA, cluster.getName()).getPath());
}
}
for (String groupName : groupNames) {
FeedGroup group = FeedGroupMap.get().getGroupsMapping().get(groupName);
- if (group == null || group.canContainFeed(feed)) {
- continue;
- } else {
+ if (group != null && !group.canContainFeed(feed)) {
throw new ValidationException(
"Feed " + feed.getName() + "'s frequency: " + feed.getFrequency().toString()
+ ", path pattern: " + FeedHelper.getLocation(feed, LocationType.DATA).getPath()
@@ -242,8 +241,8 @@ public class FeedEntityParser extends EntityParser<Feed> {
String part = FeedHelper.normalizePartitionExpression(cluster.getPartition());
if (StringUtils.split(part, '/').length == 0) {
throw new ValidationException(
- "Partition expression has to be specified for cluster " + cluster.getName() +
- " as there are more than one source clusters");
+ "Partition expression has to be specified for cluster " + cluster.getName()
+ + " as there are more than one source clusters");
}
validateClusterExpDefined(cluster);
@@ -256,8 +255,8 @@ public class FeedEntityParser extends EntityParser<Feed> {
int numParts = StringUtils.split(part, '/').length;
if (numParts > feedParts) {
throw new ValidationException(
- "Partition for " + src.getName() + " and " + cluster.getName() +
- "clusters is more than the number of partitions defined in feed");
+ "Partition for " + src.getName() + " and " + cluster.getName()
+ + "clusters is more than the number of partitions defined in feed");
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/parser/ValidationException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/parser/ValidationException.java b/common/src/main/java/org/apache/falcon/entity/parser/ValidationException.java
index e01a378..98f1cb9 100644
--- a/common/src/main/java/org/apache/falcon/entity/parser/ValidationException.java
+++ b/common/src/main/java/org/apache/falcon/entity/parser/ValidationException.java
@@ -21,7 +21,7 @@ package org.apache.falcon.entity.parser;
import org.apache.falcon.FalconException;
/**
- * ValidationException during parsing
+ * ValidationException during parsing.
*/
public class ValidationException extends FalconException {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/store/ConfigurationStore.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/store/ConfigurationStore.java b/common/src/main/java/org/apache/falcon/entity/store/ConfigurationStore.java
index 8fd3775..4897c25 100644
--- a/common/src/main/java/org/apache/falcon/entity/store/ConfigurationStore.java
+++ b/common/src/main/java/org/apache/falcon/entity/store/ConfigurationStore.java
@@ -37,27 +37,35 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLDecoder;
import java.net.URLEncoder;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-public class ConfigurationStore implements FalconService {
+/**
+ * Persistent store for falcon entities.
+ */
+public final class ConfigurationStore implements FalconService {
private static final Logger LOG = Logger.getLogger(ConfigurationStore.class);
private static final Logger AUDIT = Logger.getLogger("AUDIT");
private static final String UTF_8 = "UTF-8";
- private static final ConfigurationStore store = new ConfigurationStore();
+ private static final ConfigurationStore STORE = new ConfigurationStore();
private Set<ConfigurationChangeListener> listeners = new LinkedHashSet<ConfigurationChangeListener>();
private ThreadLocal<Entity> updatesInProgress = new ThreadLocal<Entity>();
public static ConfigurationStore get() {
- return store;
+ return STORE;
}
private final Map<EntityType, ConcurrentHashMap<String, Entity>> dictionary
- = new HashMap<EntityType, ConcurrentHashMap<String, Entity>>();
+ = new HashMap<EntityType, ConcurrentHashMap<String, Entity>>();
private final FileSystem fs;
private final Path storePath;
@@ -69,15 +77,9 @@ public class ConfigurationStore implements FalconService {
}
};
- @SuppressWarnings("unchecked")
private ConfigurationStore() {
- Class<? extends Entity>[] entityClasses = new Class[EntityType.values().length];
-
- int index = 0;
-
for (EntityType type : EntityType.values()) {
dictionary.put(type, new ConcurrentHashMap<String, Entity>());
- entityClasses[index++] = type.getEntityClass();
}
String uri = StartupProperties.get().getProperty("config.store.uri");
@@ -221,7 +223,7 @@ public class ConfigurationStore implements FalconService {
T entity = (T) entityMap.get(name);
if (entity == NULL) { // Object equality being checked
try {
- entity = this.<T>restore(type, name);
+ entity = this.restore(type, name);
} catch (IOException e) {
throw new StoreAccessException(e);
}
@@ -240,7 +242,7 @@ public class ConfigurationStore implements FalconService {
}
/**
- * Remove an entity which is already stored in the config store
+ * Remove an entity which is already stored in the config store.
*
* @param type - Entity type being removed
* @param name - Name of the entity object being removed
@@ -283,7 +285,7 @@ public class ConfigurationStore implements FalconService {
* @return - Array of entity types
*/
public Entity[] search(EntityType type, String... keywords) {
- return null;// TODO
+ return null;
}
/**
@@ -310,7 +312,7 @@ public class ConfigurationStore implements FalconService {
}
/**
- * Archive removed configuration in the persistent store
+ * Archive removed configuration in the persistent store.
*
* @param type - Entity type to archive
* @param name - name
@@ -335,7 +337,7 @@ public class ConfigurationStore implements FalconService {
*/
@SuppressWarnings("unchecked")
private synchronized <T extends Entity> T restore(EntityType type, String name)
- throws IOException, FalconException {
+ throws IOException, FalconException {
InputStream in = fs.open(new Path(storePath, type + Path.SEPARATOR + URLEncoder.encode(name, UTF_8) + ".xml"));
try {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/store/EntityAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/store/EntityAlreadyExistsException.java b/common/src/main/java/org/apache/falcon/entity/store/EntityAlreadyExistsException.java
index ce550d4..28c5ac0 100644
--- a/common/src/main/java/org/apache/falcon/entity/store/EntityAlreadyExistsException.java
+++ b/common/src/main/java/org/apache/falcon/entity/store/EntityAlreadyExistsException.java
@@ -20,6 +20,9 @@ package org.apache.falcon.entity.store;
import org.apache.falcon.FalconException;
+/**
+ * Exception to thrown when entity being sought for addition is already present in config store.
+ */
public class EntityAlreadyExistsException extends FalconException {
public EntityAlreadyExistsException(Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/store/StoreAccessException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/store/StoreAccessException.java b/common/src/main/java/org/apache/falcon/entity/store/StoreAccessException.java
index a231242..318dc2e 100644
--- a/common/src/main/java/org/apache/falcon/entity/store/StoreAccessException.java
+++ b/common/src/main/java/org/apache/falcon/entity/store/StoreAccessException.java
@@ -20,6 +20,9 @@ package org.apache.falcon.entity.store;
import org.apache.falcon.FalconException;
+/**
+ * Exception when there in issue accessing the persistent store.
+ */
public class StoreAccessException extends FalconException {
/**
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/v0/EntityGraph.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/v0/EntityGraph.java b/common/src/main/java/org/apache/falcon/entity/v0/EntityGraph.java
index f2b66e5..803fa9e 100644
--- a/common/src/main/java/org/apache/falcon/entity/v0/EntityGraph.java
+++ b/common/src/main/java/org/apache/falcon/entity/v0/EntityGraph.java
@@ -34,9 +34,12 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-public class EntityGraph implements ConfigurationChangeListener {
+/**
+ * An in-memory graph of entities and relationship among themselves.
+ */
+public final class EntityGraph implements ConfigurationChangeListener {
- private static Logger LOG = Logger.getLogger(EntityGraph.class);
+ private static final Logger LOG = Logger.getLogger(EntityGraph.class);
private static EntityGraph instance = new EntityGraph();
@@ -69,12 +72,13 @@ public class EntityGraph implements ConfigurationChangeListener {
public void onAdd(Entity entity) throws FalconException {
Map<Node, Set<Node>> nodeEdges = null;
switch (entity.getEntityType()) {
- case PROCESS:
- nodeEdges = getEdgesFor((Process) entity);
- break;
- case FEED:
- nodeEdges = getEdgesFor((Feed) entity);
- break;
+ case PROCESS:
+ nodeEdges = getEdgesFor((Process) entity);
+ break;
+ case FEED:
+ nodeEdges = getEdgesFor((Feed) entity);
+ break;
+ default:
}
if (nodeEdges == null) {
return;
@@ -95,12 +99,13 @@ public class EntityGraph implements ConfigurationChangeListener {
public void onRemove(Entity entity) throws FalconException {
Map<Node, Set<Node>> nodeEdges = null;
switch (entity.getEntityType()) {
- case PROCESS:
- nodeEdges = getEdgesFor((Process) entity);
- break;
- case FEED:
- nodeEdges = getEdgesFor((Feed) entity);
- break;
+ case PROCESS:
+ nodeEdges = getEdgesFor((Process) entity);
+ break;
+ case FEED:
+ nodeEdges = getEdgesFor((Feed) entity);
+ break;
+ default:
}
if (nodeEdges == null) {
return;
@@ -178,7 +183,10 @@ public class EntityGraph implements ConfigurationChangeListener {
return nodeEdges;
}
- private static class Node {
+ /**
+ * Node element in the graph.
+ */
+ private static final class Node {
private final EntityType type;
private final String name;
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/entity/v0/EntityIntegrityChecker.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/entity/v0/EntityIntegrityChecker.java b/common/src/main/java/org/apache/falcon/entity/v0/EntityIntegrityChecker.java
index b523c8b..bd32852 100644
--- a/common/src/main/java/org/apache/falcon/entity/v0/EntityIntegrityChecker.java
+++ b/common/src/main/java/org/apache/falcon/entity/v0/EntityIntegrityChecker.java
@@ -26,7 +26,12 @@ import java.util.Arrays;
import java.util.List;
import java.util.Set;
-public class EntityIntegrityChecker {
+/**
+ * Helper methods to check integrity of entity.
+ */
+public final class EntityIntegrityChecker {
+
+ private EntityIntegrityChecker() {}
public static Pair<String, EntityType>[] referencedBy(Entity entity) throws FalconException {
Set<Entity> deps = EntityGraph.get().getDependents(entity);
@@ -35,14 +40,14 @@ public class EntityIntegrityChecker {
}
switch (entity.getEntityType()) {
- case CLUSTER:
- return filter(deps, EntityType.FEED, EntityType.PROCESS);
+ case CLUSTER:
+ return filter(deps, EntityType.FEED, EntityType.PROCESS);
- case FEED:
- return filter(deps, EntityType.PROCESS);
+ case FEED:
+ return filter(deps, EntityType.PROCESS);
- default:
- return null;
+ default:
+ return null;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/expression/ExpressionHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/expression/ExpressionHelper.java b/common/src/main/java/org/apache/falcon/expression/ExpressionHelper.java
index f57ef95..5d70933 100644
--- a/common/src/main/java/org/apache/falcon/expression/ExpressionHelper.java
+++ b/common/src/main/java/org/apache/falcon/expression/ExpressionHelper.java
@@ -34,19 +34,22 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * Helper for evaluating expressions.
+ */
public final class ExpressionHelper implements FunctionMapper, VariableResolver {
- private static final ExpressionHelper instance = new ExpressionHelper();
+ private static final ExpressionHelper INSTANCE = new ExpressionHelper();
private ThreadLocal<Properties> threadVariables = new ThreadLocal<Properties>();
- private static final Pattern sysPropertyPattern = Pattern.compile("\\$\\{[A-Za-z0-9_.]+\\}");
+ private static final Pattern SYS_PROPERTY_PATTERN = Pattern.compile("\\$\\{[A-Za-z0-9_.]+\\}");
private static final ExpressionEvaluator EVALUATOR = new ExpressionEvaluatorImpl();
- private static final ExpressionHelper resolver = ExpressionHelper.get();
+ private static final ExpressionHelper RESOLVER = ExpressionHelper.get();
public static ExpressionHelper get() {
- return instance;
+ return INSTANCE;
}
private ExpressionHelper() {
@@ -59,7 +62,7 @@ public final class ExpressionHelper implements FunctionMapper, VariableResolver
@SuppressWarnings("unchecked")
public <T> T evaluateFullExpression(String expression, Class<T> clazz) throws FalconException {
try {
- return (T) EVALUATOR.evaluate(expression, clazz, resolver, resolver);
+ return (T) EVALUATOR.evaluate(expression, clazz, RESOLVER, RESOLVER);
} catch (ELException e) {
throw new FalconException("Unable to evaluate " + expression, e);
}
@@ -94,21 +97,21 @@ public final class ExpressionHelper implements FunctionMapper, VariableResolver
Calendar dsInstanceCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
dsInstanceCal.setTime(date);
switch (boundary) {
- case Calendar.YEAR:
- dsInstanceCal.set(Calendar.MONTH, 0);
- case Calendar.MONTH:
- dsInstanceCal.set(Calendar.DAY_OF_MONTH, 1);
- case Calendar.DAY_OF_MONTH:
- dsInstanceCal.set(Calendar.HOUR_OF_DAY, 0);
- case Calendar.HOUR:
- dsInstanceCal.set(Calendar.MINUTE, 0);
- dsInstanceCal.set(Calendar.SECOND, 0);
- dsInstanceCal.set(Calendar.MILLISECOND, 0);
- break;
- case Calendar.SECOND:
- break;
- default:
- throw new IllegalArgumentException("Invalid boundary " + boundary);
+ case Calendar.YEAR:
+ dsInstanceCal.set(Calendar.MONTH, 0);
+ case Calendar.MONTH:
+ dsInstanceCal.set(Calendar.DAY_OF_MONTH, 1);
+ case Calendar.DAY_OF_MONTH:
+ dsInstanceCal.set(Calendar.HOUR_OF_DAY, 0);
+ case Calendar.HOUR:
+ dsInstanceCal.set(Calendar.MINUTE, 0);
+ dsInstanceCal.set(Calendar.SECOND, 0);
+ dsInstanceCal.set(Calendar.MILLISECOND, 0);
+ break;
+ case Calendar.SECOND:
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid boundary " + boundary);
}
dsInstanceCal.add(Calendar.YEAR, 0);
@@ -182,7 +185,7 @@ public final class ExpressionHelper implements FunctionMapper, VariableResolver
}
public static String substitute(String originalValue, Properties properties) {
- Matcher envVarMatcher = sysPropertyPattern.matcher(originalValue);
+ Matcher envVarMatcher = SYS_PROPERTY_PATTERN.matcher(originalValue);
while (envVarMatcher.find()) {
String envVar = originalValue.substring(envVarMatcher.start() + 2,
envVarMatcher.end() - 1);
@@ -191,7 +194,7 @@ public final class ExpressionHelper implements FunctionMapper, VariableResolver
envVar = "\\$\\{" + envVar + "\\}";
if (envVal != null) {
originalValue = originalValue.replaceAll(envVar, Matcher.quoteReplacement(envVal));
- envVarMatcher = sysPropertyPattern.matcher(originalValue);
+ envVarMatcher = SYS_PROPERTY_PATTERN.matcher(originalValue);
}
}
return originalValue;
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/group/FeedGroupMap.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/group/FeedGroupMap.java b/common/src/main/java/org/apache/falcon/group/FeedGroupMap.java
index 532392f..ed44b48 100644
--- a/common/src/main/java/org/apache/falcon/group/FeedGroupMap.java
+++ b/common/src/main/java/org/apache/falcon/group/FeedGroupMap.java
@@ -34,11 +34,11 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
- * Has 2 way mappings from feed to group and group to feed
+ * Has 2 way mappings from feed to group and group to feed.
*/
-public class FeedGroupMap implements ConfigurationChangeListener {
+public final class FeedGroupMap implements ConfigurationChangeListener {
- private static final FeedGroupMap instance = new FeedGroupMap();
+ private static final FeedGroupMap INSTANCE = new FeedGroupMap();
private Map<String, FeedGroup> groupsMapping = new ConcurrentHashMap<String, FeedGroup>();
private FeedGroupMap() {
@@ -46,7 +46,7 @@ public class FeedGroupMap implements ConfigurationChangeListener {
}
public static FeedGroupMap get() {
- return instance;
+ return INSTANCE;
}
public Map<String, FeedGroup> getGroupsMapping() {
@@ -88,7 +88,8 @@ public class FeedGroupMap implements ConfigurationChangeListener {
@Override
public void onChange(Entity oldEntity, Entity newEntity)
- throws FalconException {
+ throws FalconException {
+
onRemove(oldEntity);
onAdd(newEntity);
}
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/security/CurrentUser.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/security/CurrentUser.java b/common/src/main/java/org/apache/falcon/security/CurrentUser.java
index 9a3086c..4d2299e 100644
--- a/common/src/main/java/org/apache/falcon/security/CurrentUser.java
+++ b/common/src/main/java/org/apache/falcon/security/CurrentUser.java
@@ -22,14 +22,19 @@ import org.apache.log4j.Logger;
import javax.security.auth.Subject;
+/**
+ * Current authenticated user via REST.
+ */
public final class CurrentUser {
- private static Logger LOG = Logger.getLogger(CurrentUser.class);
+ private static final Logger LOG = Logger.getLogger(CurrentUser.class);
+
+ private static final CurrentUser INSTANCE = new CurrentUser();
- private static final CurrentUser instance = new CurrentUser();
+ private CurrentUser() {}
public static CurrentUser get() {
- return instance;
+ return INSTANCE;
}
private final ThreadLocal<Subject> currentSubject =
@@ -37,8 +42,7 @@ public final class CurrentUser {
public static void authenticate(String user) {
if (user == null || user.isEmpty()) {
- throw new IllegalStateException
- ("Bad user name sent for authentication");
+ throw new IllegalStateException("Bad user name sent for authentication");
}
if (user.equals(getUserInternal())) {
return;
@@ -47,11 +51,11 @@ public final class CurrentUser {
Subject subject = new Subject();
subject.getPrincipals().add(new FalconPrincipal(user));
LOG.info("Logging in " + user);
- instance.currentSubject.set(subject);
+ INSTANCE.currentSubject.set(subject);
}
public static Subject getSubject() {
- return instance.currentSubject.get();
+ return INSTANCE.currentSubject.get();
}
public static String getUser() {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/security/FalconLoginModule.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/security/FalconLoginModule.java b/common/src/main/java/org/apache/falcon/security/FalconLoginModule.java
index a27a342..4f4542c 100644
--- a/common/src/main/java/org/apache/falcon/security/FalconLoginModule.java
+++ b/common/src/main/java/org/apache/falcon/security/FalconLoginModule.java
@@ -29,8 +29,11 @@ import javax.security.auth.spi.LoginModule;
import java.security.Principal;
import java.util.Map;
+/**
+ * Falcon JAAS login module.
+ */
public class FalconLoginModule implements LoginModule {
- private static Logger LOG = Logger.getLogger(FalconLoginModule.class);
+ private static final Logger LOG = Logger.getLogger(FalconLoginModule.class);
private Subject subject;
@@ -62,11 +65,13 @@ public class FalconLoginModule implements LoginModule {
throw new LoginException("No such user " + subject);
}
+ //SUSPEND CHECKSTYLE CHECK
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler,
Map<String, ?> sharedState, Map<String, ?> options) {
this.subject = subject;
}
+ //RESUME CHECKSTYLE CHECK
@Override
public boolean login() throws LoginException {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/security/FalconPrincipal.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/security/FalconPrincipal.java b/common/src/main/java/org/apache/falcon/security/FalconPrincipal.java
index bd27e23..ab93e1a 100644
--- a/common/src/main/java/org/apache/falcon/security/FalconPrincipal.java
+++ b/common/src/main/java/org/apache/falcon/security/FalconPrincipal.java
@@ -20,6 +20,9 @@ package org.apache.falcon.security;
import java.security.Principal;
+/**
+ * Falcon JAAS principal object.
+ */
public class FalconPrincipal implements Principal {
private final String user;
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/security/FalconSecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/security/FalconSecurityConfiguration.java b/common/src/main/java/org/apache/falcon/security/FalconSecurityConfiguration.java
index 20ec8df..7689672 100644
--- a/common/src/main/java/org/apache/falcon/security/FalconSecurityConfiguration.java
+++ b/common/src/main/java/org/apache/falcon/security/FalconSecurityConfiguration.java
@@ -22,6 +22,9 @@ import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.Configuration;
import java.util.HashMap;
+/**
+ * Falcon JAAS security configuration.
+ */
public class FalconSecurityConfiguration extends Configuration {
private static final AppConfigurationEntry OS_SPECIFIC_LOGIN =
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/security/SecurityConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/security/SecurityConstants.java b/common/src/main/java/org/apache/falcon/security/SecurityConstants.java
index b4f060f..8f7ba4a 100644
--- a/common/src/main/java/org/apache/falcon/security/SecurityConstants.java
+++ b/common/src/main/java/org/apache/falcon/security/SecurityConstants.java
@@ -22,7 +22,12 @@ import com.sun.security.auth.UnixPrincipal;
import java.security.Principal;
-public class SecurityConstants {
+/**
+ * Constants for the security module.
+ */
+public final class SecurityConstants {
+
+ private SecurityConstants() {}
public static final String OS_LOGIN_MODULE_NAME =
"com.sun.security.auth.module.UnixLoginModule";
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/service/ConfigurationChangeListener.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/service/ConfigurationChangeListener.java b/common/src/main/java/org/apache/falcon/service/ConfigurationChangeListener.java
index 65621cb..56953ad 100644
--- a/common/src/main/java/org/apache/falcon/service/ConfigurationChangeListener.java
+++ b/common/src/main/java/org/apache/falcon/service/ConfigurationChangeListener.java
@@ -21,6 +21,9 @@ package org.apache.falcon.service;
import org.apache.falcon.FalconException;
import org.apache.falcon.entity.v0.Entity;
+/**
+ * Configuration change notification listener.
+ */
public interface ConfigurationChangeListener {
void onAdd(Entity entity) throws FalconException;
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/service/FalconService.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/service/FalconService.java b/common/src/main/java/org/apache/falcon/service/FalconService.java
index 049032b..a1eb8e0 100644
--- a/common/src/main/java/org/apache/falcon/service/FalconService.java
+++ b/common/src/main/java/org/apache/falcon/service/FalconService.java
@@ -20,6 +20,9 @@ package org.apache.falcon.service;
import org.apache.falcon.FalconException;
+/**
+ * Falcon service initialized at startup.
+ */
public interface FalconService {
String getName();
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/service/LogCleanupService.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/service/LogCleanupService.java b/common/src/main/java/org/apache/falcon/service/LogCleanupService.java
index 17d5926..778be11 100644
--- a/common/src/main/java/org/apache/falcon/service/LogCleanupService.java
+++ b/common/src/main/java/org/apache/falcon/service/LogCleanupService.java
@@ -33,10 +33,13 @@ import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
+/**
+ * Log cleanup service.
+ */
public class LogCleanupService implements FalconService {
private static final Logger LOG = Logger.getLogger(LogCleanupService.class);
- private final ExpressionEvaluator EVALUATOR = new ExpressionEvaluatorImpl();
+ private final ExpressionEvaluator evaluator = new ExpressionEvaluatorImpl();
private final ExpressionHelper resolver = ExpressionHelper.get();
@Override
@@ -80,7 +83,7 @@ public class LogCleanupService implements FalconService {
String delay = StartupProperties.get().getProperty(
"falcon.cleanup.service.frequency", "days(1)");
try {
- return (Long) EVALUATOR.evaluate("${" + delay + "}", Long.class,
+ return (Long) evaluator.evaluate("${" + delay + "}", Long.class,
resolver, resolver);
} catch (ELException e) {
throw new FalconException("Exception in EL evaluation", e);
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/service/ServiceInitializer.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/service/ServiceInitializer.java b/common/src/main/java/org/apache/falcon/service/ServiceInitializer.java
index 466cb81..5e0256e 100644
--- a/common/src/main/java/org/apache/falcon/service/ServiceInitializer.java
+++ b/common/src/main/java/org/apache/falcon/service/ServiceInitializer.java
@@ -23,9 +23,12 @@ import org.apache.falcon.util.ReflectionUtils;
import org.apache.falcon.util.StartupProperties;
import org.apache.log4j.Logger;
+/**
+ * Initializer that Falcon uses at startup to bring up all the falcon startup services.
+ */
public class ServiceInitializer {
- private static Logger LOG = Logger.getLogger(ServiceInitializer.class);
+ private static final Logger LOG = Logger.getLogger(ServiceInitializer.class);
private final Services services = Services.get();
public void initialize() throws FalconException {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/service/Services.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/service/Services.java b/common/src/main/java/org/apache/falcon/service/Services.java
index 955e906..6659ccd 100644
--- a/common/src/main/java/org/apache/falcon/service/Services.java
+++ b/common/src/main/java/org/apache/falcon/service/Services.java
@@ -20,34 +20,34 @@ package org.apache.falcon.service;
import org.apache.falcon.FalconException;
import org.apache.falcon.util.ReflectionUtils;
-import org.apache.log4j.Logger;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
-
+/**
+ * Repository of services initialized at startup.
+ */
public final class Services implements Iterable<FalconService> {
- private static final Logger LOG = Logger.getLogger(Services.class);
- private static Services instance = new Services();
+ private static final Services INSTANCE = new Services();
private Services() {
}
public static Services get() {
- return instance;
+ return INSTANCE;
}
private final Map<String, FalconService> services =
new LinkedHashMap<String, FalconService>();
public synchronized void register(FalconService service)
- throws FalconException {
+ throws FalconException {
+
if (services.containsKey(service.getName())) {
- throw new FalconException("Service " + service.getName() +
- " already registered");
+ throw new FalconException("Service " + service.getName() + " already registered");
} else {
services.put(service.getName(), service);
}
@@ -58,8 +58,7 @@ public final class Services implements Iterable<FalconService> {
if (services.containsKey(serviceName)) {
return (T) services.get(serviceName);
} else {
- throw new NoSuchElementException("Service " + serviceName +
- " not registered with registry");
+ throw new NoSuchElementException("Service " + serviceName + " not registered with registry");
}
}
@@ -74,8 +73,7 @@ public final class Services implements Iterable<FalconService> {
public FalconService init(String serviceName) throws FalconException {
if (isRegistered(serviceName)) {
- throw new FalconException("Service is already initialized " +
- serviceName);
+ throw new FalconException("Service is already initialized " + serviceName);
}
FalconService service = ReflectionUtils.getInstance(serviceName + ".impl");
register(service);
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/update/UpdateHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/update/UpdateHelper.java b/common/src/main/java/org/apache/falcon/update/UpdateHelper.java
index 4e199da..a9d39de 100644
--- a/common/src/main/java/org/apache/falcon/update/UpdateHelper.java
+++ b/common/src/main/java/org/apache/falcon/update/UpdateHelper.java
@@ -36,37 +36,39 @@ import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Helper methods to facilitate entity updates.
+ */
public final class UpdateHelper {
private static final Logger LOG = Logger.getLogger(UpdateHelper.class);
+
private static final String[] FEED_FIELDS = new String[]{"partitions", "groups", "lateArrival.cutOff",
"schema.location", "schema.provider",
- "ACL.group", "ACL.owner", "ACL.permission"};
+ "ACL.group", "ACL.owner", "ACL.permission", };
private static final String[] PROCESS_FIELDS = new String[]{"retry.policy", "retry.delay", "retry.attempts",
"lateProcess.policy", "lateProcess.delay",
"lateProcess.lateInputs[\\d+].input",
- "lateProcess.lateInputs[\\d+].workflowPath"};
+ "lateProcess.lateInputs[\\d+].workflowPath", };
+
+ private UpdateHelper() {}
public static boolean shouldUpdate(Entity oldEntity, Entity newEntity, String cluster) throws FalconException {
Entity oldView = EntityUtil.getClusterView(oldEntity, cluster);
Entity newView = EntityUtil.getClusterView(newEntity, cluster);
switch (oldEntity.getEntityType()) {
- case FEED:
- if (EntityUtil.equals(oldView, newView, FEED_FIELDS)) {
- return false;
- }
- return true;
+ case FEED:
+ return !EntityUtil.equals(oldView, newView, FEED_FIELDS);
- case PROCESS:
- if (EntityUtil.equals(oldView, newView, PROCESS_FIELDS)) {
- return false;
- }
- return true;
+ case PROCESS:
+ return !EntityUtil.equals(oldView, newView, PROCESS_FIELDS);
+ default:
}
throw new IllegalArgumentException("Unhandled entity type " + oldEntity.getEntityType());
}
public static boolean shouldUpdate(Entity oldEntity, Entity newEntity, Entity affectedEntity)
- throws FalconException {
+ throws FalconException {
+
if (oldEntity.getEntityType() == EntityType.FEED && affectedEntity.getEntityType() == EntityType.PROCESS) {
return shouldUpdate((Feed) oldEntity, (Feed) newEntity, (Process) affectedEntity);
} else {
@@ -77,26 +79,14 @@ public final class UpdateHelper {
}
public static boolean shouldUpdate(Feed oldFeed, Feed newFeed, Process affectedProcess) {
- if (!FeedHelper
- .getLocation(oldFeed.getLocations(), LocationType.DATA)
- .getPath()
- .equals(FeedHelper.getLocation(newFeed.getLocations(),
- LocationType.DATA).getPath())
- || !FeedHelper
- .getLocation(oldFeed.getLocations(), LocationType.META)
- .getPath()
- .equals(FeedHelper.getLocation(newFeed.getLocations(),
- LocationType.META).getPath())
- || !FeedHelper
- .getLocation(oldFeed.getLocations(), LocationType.STATS)
- .getPath()
- .equals(FeedHelper.getLocation(newFeed.getLocations(),
- LocationType.STATS).getPath())
- || !FeedHelper
- .getLocation(oldFeed.getLocations(), LocationType.TMP)
- .getPath()
- .equals(FeedHelper.getLocation(newFeed.getLocations(),
- LocationType.TMP).getPath())) {
+ if (!FeedHelper.getLocation(oldFeed.getLocations(), LocationType.DATA)
+ .getPath().equals(FeedHelper.getLocation(newFeed.getLocations(), LocationType.DATA).getPath())
+ || !FeedHelper.getLocation(oldFeed.getLocations(), LocationType.META)
+ .getPath().equals(FeedHelper.getLocation(newFeed.getLocations(), LocationType.META).getPath())
+ || !FeedHelper.getLocation(oldFeed.getLocations(), LocationType.STATS)
+ .getPath().equals(FeedHelper.getLocation(newFeed.getLocations(), LocationType.STATS).getPath())
+ || !FeedHelper.getLocation(oldFeed.getLocations(), LocationType.TMP)
+ .getPath().equals(FeedHelper.getLocation(newFeed.getLocations(), LocationType.TMP).getPath())) {
return true;
}
LOG.debug(oldFeed.toShortString() + ": Location identical. Ignoring...");
@@ -139,27 +129,16 @@ public final class UpdateHelper {
for (Cluster cluster : affectedProcess.getClusters().getClusters()) {
if (!FeedHelper
- .getCluster(oldFeed, cluster.getName())
- .getValidity()
- .getStart()
- .equals(FeedHelper.getCluster(newFeed, cluster.getName())
- .getValidity().getStart())
- || !FeedHelper.getLocation(oldFeed, LocationType.DATA,
- cluster.getName()).getPath().equals(
- FeedHelper.getLocation(newFeed, LocationType.DATA,
- cluster.getName()).getPath())
- || !FeedHelper.getLocation(oldFeed, LocationType.META,
- cluster.getName()).getPath().equals(
- FeedHelper.getLocation(newFeed, LocationType.META,
- cluster.getName()).getPath())
- || !FeedHelper.getLocation(oldFeed, LocationType.STATS,
- cluster.getName()).getPath().equals(
- FeedHelper.getLocation(newFeed, LocationType.STATS,
- cluster.getName()).getPath())
- || !FeedHelper.getLocation(oldFeed, LocationType.TMP,
- cluster.getName()).getPath().equals(
- FeedHelper.getLocation(newFeed, LocationType.TMP,
- cluster.getName()).getPath())) {
+ .getCluster(oldFeed, cluster.getName()).getValidity().getStart()
+ .equals(FeedHelper.getCluster(newFeed, cluster.getName()).getValidity().getStart())
+ || !FeedHelper.getLocation(oldFeed, LocationType.DATA, cluster.getName()).getPath()
+ .equals(FeedHelper.getLocation(newFeed, LocationType.DATA, cluster.getName()).getPath())
+ || !FeedHelper.getLocation(oldFeed, LocationType.META, cluster.getName()).getPath()
+ .equals(FeedHelper.getLocation(newFeed, LocationType.META, cluster.getName()).getPath())
+ || !FeedHelper.getLocation(oldFeed, LocationType.STATS, cluster.getName()).getPath()
+ .equals(FeedHelper.getLocation(newFeed, LocationType.STATS, cluster.getName()).getPath())
+ || !FeedHelper.getLocation(oldFeed, LocationType.TMP, cluster.getName()).getPath()
+ .equals(FeedHelper.getLocation(newFeed, LocationType.TMP, cluster.getName()).getPath())) {
return true;
}
LOG.debug(oldFeed.toShortString() + ": Feed on cluster" + cluster.getName() + " identical. Ignoring...");
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/bdadf2ed/common/src/main/java/org/apache/falcon/util/ApplicationProperties.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/falcon/util/ApplicationProperties.java b/common/src/main/java/org/apache/falcon/util/ApplicationProperties.java
index f5dbc83..5d670ef 100644
--- a/common/src/main/java/org/apache/falcon/util/ApplicationProperties.java
+++ b/common/src/main/java/org/apache/falcon/util/ApplicationProperties.java
@@ -30,9 +30,12 @@ import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
+/**
+ * Base class for reading application properties.
+ */
public abstract class ApplicationProperties extends Properties {
- private static Logger LOG = Logger.getLogger(ApplicationProperties.class);
+ private static final Logger LOG = Logger.getLogger(ApplicationProperties.class);
protected enum LocationType {
FILE, HOME, CLASSPATH
@@ -81,12 +84,10 @@ public abstract class ApplicationProperties extends Properties {
try {
if (location == LocationType.CLASSPATH) {
if (getClass().getResource(propertyFile) != null) {
- LOG.info("Property file being loaded from " +
- getClass().getResource(propertyFile));
+ LOG.info("Property file being loaded from " + getClass().getResource(propertyFile));
resource = getClass().getResourceAsStream(propertyFile);
} else {
- LOG.info("Property file being loaded from " +
- getClass().getResource("/" + propertyFile));
+ LOG.info("Property file being loaded from " + getClass().getResource("/" + propertyFile));
resource = getClass().getResourceAsStream("/" + propertyFile);
}
} else {