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:37 UTC
[21/47] git commit: Fixes for Checkstyle
Fixes for Checkstyle
Project: http://git-wip-us.apache.org/repos/asf/incubator-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-falcon/commit/a4d79f0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-falcon/tree/a4d79f0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-falcon/diff/a4d79f0c
Branch: refs/heads/master
Commit: a4d79f0c516580d92935fcded7b5d25fb89168b3
Parents: b047ce2
Author: srikanth.sundarrajan <sr...@inmobi.com>
Authored: Tue Apr 16 10:07:25 2013 +0530
Committer: srikanth.sundarrajan <sr...@inmobi.com>
Committed: Tue Apr 16 10:07:27 2013 +0530
----------------------------------------------------------------------
client/src/main/java/org/apache/falcon/Pair.java | 18 +-
.../main/java/org/apache/falcon/cli/CLIParser.java | 27 +-
.../main/java/org/apache/falcon/cli/FalconCLI.java | 1095 ++++++------
.../apache/falcon/client/FalconCLIException.java | 12 +-
.../org/apache/falcon/client/FalconClient.java | 1287 +++++++--------
.../org/apache/falcon/entity/v0/DateValidator.java | 102 +-
.../java/org/apache/falcon/entity/v0/Entity.java | 16 +-
.../org/apache/falcon/entity/v0/EntityType.java | 29 +-
.../org/apache/falcon/entity/v0/Frequency.java | 38 +-
.../org/apache/falcon/entity/v0/SchemaHelper.java | 3 +-
.../java/org/apache/falcon/resource/APIResult.java | 8 +-
.../org/apache/falcon/resource/EntityList.java | 5 +-
.../apache/falcon/resource/InstancesResult.java | 229 ++--
client/src/main/resources/cluster-0.1.xsd | 54 +-
client/src/main/resources/feed-0.1.xsd | 127 +-
client/src/main/resources/jaxb-binding.xjb | 26 +-
client/src/main/resources/process-0.1.xsd | 129 +-
.../java/org/apache/falcon/cli/TestCLIParser.java | 70 +-
.../apache/falcon/entity/v0/DateValidatorTest.java | 114 +-
.../java/org/apache/falcon/FalconException.java | 42 +-
.../org/apache/falcon/FalconRuntimException.java | 33 +-
.../falcon/cleanup/AbstractCleanupHandler.java | 221 ++--
.../apache/falcon/cleanup/FeedCleanupHandler.java | 65 +-
.../falcon/cleanup/ProcessCleanupHandler.java | 65 +-
.../org/apache/falcon/entity/ClusterHelper.java | 69 +-
.../apache/falcon/entity/ColoClusterRelation.java | 26 +-
.../entity/EntityNotRegisteredException.java | 4 +-
.../java/org/apache/falcon/entity/EntityUtil.java | 867 +++++-----
.../java/org/apache/falcon/entity/ExternalId.java | 35 +-
.../java/org/apache/falcon/entity/FeedHelper.java | 82 +-
.../org/apache/falcon/entity/ProcessHelper.java | 6 +-
.../apache/falcon/entity/WorkflowNameBuilder.java | 194 ++--
.../apache/falcon/entity/common/Configuration.java | 66 +-
.../apache/falcon/entity/common/FeedDataPath.java | 62 +-
.../falcon/entity/parser/ClusterEntityParser.java | 40 +-
.../entity/parser/CrossEntityValidations.java | 48 +-
.../apache/falcon/entity/parser/EntityParser.java | 45 +-
.../falcon/entity/parser/EntityParserFactory.java | 46 +-
.../falcon/entity/parser/FeedEntityParser.java | 165 ++-
.../falcon/entity/parser/ProcessEntityParser.java | 99 +-
.../falcon/entity/parser/ValidationException.java | 16 +-
.../falcon/entity/store/ConfigurationStore.java | 144 +-
.../falcon/entity/store/StoreAccessException.java | 18 +-
.../org/apache/falcon/entity/v0/EntityGraph.java | 32 +-
.../falcon/entity/v0/EntityIntegrityChecker.java | 21 +-
.../entity/v0/UnschedulableEntityException.java | 1 -
.../apache/falcon/expression/ExpressionHelper.java | 44 +-
.../java/org/apache/falcon/group/FeedGroup.java | 122 +-
.../java/org/apache/falcon/group/FeedGroupMap.java | 170 +-
.../org/apache/falcon/security/CurrentUser.java | 6 +-
.../apache/falcon/security/FalconLoginModule.java | 2 +-
.../security/FalconSecurityConfiguration.java | 2 +-
.../apache/falcon/service/LogCleanupService.java | 99 +-
.../apache/falcon/service/ServiceInitializer.java | 8 +-
.../java/org/apache/falcon/service/Services.java | 17 +-
.../org/apache/falcon/update/UpdateHelper.java | 129 +-
.../apache/falcon/util/ApplicationProperties.java | 24 +-
.../org/apache/falcon/util/BuildProperties.java | 22 +-
.../apache/falcon/util/DeploymentProperties.java | 22 +-
.../org/apache/falcon/util/DeploymentUtil.java | 26 +-
.../org/apache/falcon/util/ReflectionUtils.java | 4 +-
.../org/apache/falcon/util/RuntimeProperties.java | 102 +-
.../org/apache/falcon/util/StartupProperties.java | 52 +-
.../apache/falcon/workflow/WorkflowBuilder.java | 13 +-
.../falcon/workflow/WorkflowEngineFactory.java | 7 +-
.../workflow/engine/AbstractWorkflowEngine.java | 41 +-
common/src/main/resources/log4j.xml | 120 +-
.../falcon/cleanup/LogCleanupServiceTest.java | 218 ++--
.../org/apache/falcon/entity/AbstractTestBase.java | 71 +-
.../falcon/entity/ColoClusterRelationTest.java | 18 +-
.../org/apache/falcon/entity/EntityTypeTest.java | 22 +-
.../org/apache/falcon/entity/EntityUtilTest.java | 25 +-
.../org/apache/falcon/entity/FeedHelperTest.java | 7 +-
.../falcon/entity/TestWorkflowNameBuilder.java | 94 +-
.../entity/parser/ClusterEntityParserTest.java | 12 +-
.../falcon/entity/parser/FeedEntityParserTest.java | 702 ++++----
.../falcon/entity/parser/FeedUpdateTest.java | 8 +-
.../entity/parser/ProcessEntityParserTest.java | 235 ++--
.../entity/store/ConfigurationStoreTest.java | 84 +-
.../apache/falcon/entity/v0/EntityGraphTest.java | 25 +-
.../org/apache/falcon/group/FeedGroupMapTest.java | 282 ++--
.../apache/falcon/security/CurrentUserTest.java | 2 +-
.../org/apache/falcon/update/UpdateHelperTest.java | 48 +-
.../apache/falcon/util/StartupPropertiesTest.java | 5 +-
.../test/resources/config/cluster/cluster-0.1.xml | 45 +-
common/src/test/resources/config/feed/feed-0.1.xml | 41 +-
common/src/test/resources/config/feed/feed-0.2.xml | 27 +-
.../test/resources/config/process/process-0.1.xml | 24 +-
.../test/resources/config/process/process-0.2.xml | 66 +-
.../resources/config/process/process-invalid.xml | 38 +-
docs/pom.xml | 4 +-
docs/src/site/site.xml | 10 +-
.../apache/falcon/converter/OozieFeedMapper.java | 147 +-
.../falcon/workflow/OozieFeedWorkflowBuilder.java | 41 +-
.../config/coordinator/replication-coordinator.xml | 64 +-
.../config/workflow/replication-workflow.xml | 292 ++--
.../config/workflow/retention-workflow.xml | 138 +-
.../falcon/converter/OozieFeedMapperTest.java | 167 +-
feed/src/test/resources/feed.xml | 66 +-
feed/src/test/resources/src-cluster.xml | 42 +-
feed/src/test/resources/trg-cluster.xml | 42 +-
.../falcon/messaging/EntityInstanceMessage.java | 375 +++---
.../messaging/EntityInstanceMessageCreator.java | 41 +-
.../apache/falcon/messaging/MessageProducer.java | 303 ++--
messaging/src/main/resources/log4j.xml | 78 +-
.../falcon/messaging/FalconTopicProducerTest.java | 273 ++--
.../apache/falcon/messaging/FeedProducerTest.java | 312 ++--
.../falcon/messaging/ProcessProducerTest.java | 234 ++--
.../apache/falcon/aspect/AbstractFalconAspect.java | 114 +-
.../org/apache/falcon/aspect/GenericAlert.java | 132 +-
.../org/apache/falcon/aspect/ResourceMessage.java | 65 +-
.../falcon/util/ResourcesReflectionUtil.java | 167 +-
.../converter/AbstractOozieEntityMapper.java | 125 +-
.../java/org/apache/falcon/logging/LogMover.java | 334 ++--
.../org/apache/falcon/logging/LogProvider.java | 248 ++--
.../apache/falcon/service/FalconPathFilter.java | 4 +-
.../service/SharedLibraryHostingService.java | 72 +-
.../java/org/apache/falcon/util/OozieUtils.java | 4 +-
.../falcon/workflow/FalconPostProcessing.java | 359 ++--
.../falcon/workflow/OozieWorkflowBuilder.java | 40 +-
.../falcon/workflow/engine/NullBundleJob.java | 8 +-
.../falcon/workflow/engine/OozieClientFactory.java | 6 +-
.../workflow/engine/OozieHouseKeepingService.java | 14 +-
.../workflow/engine/OozieWorkflowEngine.java | 135 +-
.../org/apache/oozie/client/CustomOozieClient.java | 9 +-
oozie/src/main/resources/oozie-bundle-0.1.xsd | 2 +-
oozie/src/main/resources/oozie-workflow-0.3.xsd | 2 +-
.../oozie/bundle/BundleUnmarshallingTest.java | 12 +-
.../coordinator/CoordinatorUnmarshallingTest.java | 10 +-
.../oozie/workflow/FalconPostProcessingTest.java | 257 ++--
.../oozie/workflow/WorkflowUnmarshallingTest.java | 16 +-
.../apache/oozie/client/CustomOozieClientTest.java | 2 +-
oozie/src/test/resources/oozie/xmls/bundle.xml | 28 +-
.../src/test/resources/oozie/xmls/coordinator.xml | 74 +-
oozie/src/test/resources/oozie/xmls/workflow.xml | 2 +-
.../java/org/apache/falcon/FalconWebException.java | 9 +-
.../falcon/listener/ContextStartupListener.java | 13 +-
.../falcon/plugin/ChainableMonitoringPlugin.java | 2 +-
.../falcon/resource/AbstractEntityManager.java | 120 +-
.../falcon/resource/AbstractInstanceManager.java | 202 ++--
.../resource/AbstractSchedulableEntityManager.java | 55 +-
.../falcon/resource/channel/AbstractChannel.java | 2 +-
.../falcon/resource/channel/HTTPChannel.java | 49 +-
.../apache/falcon/resource/channel/IPCChannel.java | 18 +-
.../apache/falcon/resource/channel/MethodKey.java | 14 +-
.../resource/provider/JAXBContextResolver.java | 22 +-
.../falcon/resource/proxy/BufferedRequest.java | 2 +-
.../resource/proxy/InstanceManagerProxy.java | 109 +-
.../proxy/SchedulableEntityManagerProxy.java | 127 +-
.../apache/falcon/security/BasicAuthFilter.java | 21 +-
.../falcon/service/FalconTopicSubscriber.java | 240 ++--
.../falcon/service/ProcessSubscriberService.java | 56 +-
.../falcon/service/SLAMonitoringService.java | 18 +-
.../org/apache/falcon/util/EmbeddedServer.java | 32 +-
prism/src/main/resources/log4j.xml | 120 +-
prism/src/main/webapp/WEB-INF/web.xml | 66 +-
.../org/apache/falcon/aspect/GenericAlertTest.java | 10 +-
.../apache/falcon/aspect/LoggingAspectTest.java | 69 +-
.../apache/falcon/resource/EntityManagerTest.java | 5 +-
.../falcon/service/FalconTopicSubscriberTest.java | 151 +-
process/pom.xml | 88 +-
.../falcon/converter/OozieProcessMapper.java | 148 +-
.../workflow/OozieProcessWorkflowBuilder.java | 77 +-
.../config/workflow/process-parent-workflow.xml | 281 ++--
.../apache/falcon/converter/AbstractTestBase.java | 20 +-
.../OozieProcessMapperLateProcessTest.java | 121 +-
.../falcon/converter/OozieProcessMapperTest.java | 153 +-
.../test/resources/config/cluster/cluster-0.1.xml | 45 +-
.../src/test/resources/config/feed/feed-0.1.xml | 43 +-
.../test/resources/config/late/late-cluster.xml | 45 +-
.../src/test/resources/config/late/late-feed1.xml | 28 +-
.../src/test/resources/config/late/late-feed2.xml | 28 +-
.../src/test/resources/config/late/late-feed3.xml | 30 +-
.../test/resources/config/late/late-process1.xml | 17 +-
.../test/resources/config/late/late-process2.xml | 23 +-
.../test/resources/config/process/process-0.1.xml | 22 +-
.../falcon/replication/CustomReplicator.java | 1 +
.../apache/falcon/replication/FeedReplicator.java | 144 +-
.../falcon/replication/FilteredCopyListing.java | 33 +-
.../falcon/repliation/FeedReplicatorTest.java | 8 +-
.../replication/FilteredCopyListingTest.java | 15 +-
.../apache/falcon/latedata/LateDataHandler.java | 272 ++--
.../apache/falcon/rerun/event/LaterunEvent.java | 28 +-
.../org/apache/falcon/rerun/event/RerunEvent.java | 166 +-
.../falcon/rerun/event/RerunEventFactory.java | 79 +-
.../org/apache/falcon/rerun/event/RetryEvent.java | 68 +-
.../rerun/handler/AbstractRerunConsumer.java | 72 +-
.../falcon/rerun/handler/AbstractRerunHandler.java | 64 +-
.../falcon/rerun/handler/LateRerunConsumer.java | 209 ++--
.../falcon/rerun/handler/LateRerunHandler.java | 374 +++---
.../falcon/rerun/handler/RerunHandlerFactory.java | 32 +-
.../apache/falcon/rerun/handler/RetryConsumer.java | 132 +-
.../apache/falcon/rerun/handler/RetryHandler.java | 105 +-
.../falcon/rerun/policy/AbstractRerunPolicy.java | 28 +-
.../falcon/rerun/policy/ExpBackoffPolicy.java | 65 +-
.../apache/falcon/rerun/policy/FinalPolicy.java | 4 +-
.../apache/falcon/rerun/policy/PeriodicPolicy.java | 8 +-
.../falcon/rerun/policy/RerunPolicyFactory.java | 2 +-
.../apache/falcon/rerun/queue/ActiveMQueue.java | 243 ++--
.../apache/falcon/rerun/queue/DelayedQueue.java | 27 +-
.../apache/falcon/rerun/queue/InMemoryQueue.java | 233 ++--
.../falcon/rerun/service/LateRunService.java | 66 +-
.../apache/falcon/rerun/service/RetryService.java | 58 +-
.../falcon/rerun/AbstractRerunPolicyTest.java | 112 +-
.../apache/falcon/rerun/handler/TestLateData.java | 59 +-
.../apache/falcon/rerun/queue/ActiveMQTest.java | 65 +-
.../falcon/rerun/queue/InMemoryQueueTest.java | 2 +-
rerun/src/test/resources/cluster-template.xml | 37 +-
rerun/src/test/resources/feed-template.xml | 41 +-
rerun/src/test/resources/process-template.xml | 22 +-
rerun/src/test/resources/process-template2.xml | 46 +-
.../org/apache/falcon/retention/FeedEvictor.java | 220 ++--
.../apache/falcon/retention/FeedEvictorTest.java | 764 +++++-----
.../falcon/cluster/util/EmbeddedCluster.java | 37 +-
.../falcon/cluster/util/StandAloneCluster.java | 24 +-
webapp/src/main/java/org/apache/falcon/Debug.java | 11 +-
webapp/src/main/java/org/apache/falcon/Main.java | 6 +-
.../apache/falcon/resource/ConfigSyncService.java | 8 +-
.../apache/falcon/resource/InstanceManager.java | 64 +-
.../falcon/resource/SchedulableEntityManager.java | 14 +-
webapp/src/main/resources/log4j.xml | 120 +-
webapp/src/main/webapp/WEB-INF/distributed/web.xml | 8 +-
webapp/src/main/webapp/WEB-INF/embedded/web.xml | 66 +-
webapp/src/main/webapp/WEB-INF/web.xml | 66 +-
.../java/org/apache/falcon/cli/FalconCLITest.java | 1024 ++++++------
.../org/apache/falcon/logging/LogMoverTest.java | 218 ++--
.../org/apache/falcon/logging/LogProviderTest.java | 221 ++--
.../apache/falcon/resource/AbstractTestBase.java | 172 +-
.../falcon/resource/EntityManagerJerseyTest.java | 244 ++--
.../resource/ProcessInstanceManagerTest.java | 17 +-
.../falcon/security/BasicAuthFilterTest.java | 4 +-
.../falcon/util/ResourcesReflectionUtilTest.java | 42 +-
webapp/src/test/resources/cluster-template.xml | 41 +-
webapp/src/test/resources/feed-template1.xml | 20 +-
webapp/src/test/resources/feed-template2.xml | 20 +-
.../org/apache/falcon/logging/process.xml | 12 +-
.../org/apache/falcon/logging/workflow.xml | 48 +-
webapp/src/test/resources/process-template.xml | 14 +-
webapp/src/test/resources/process-version-0.xml | 30 +-
239 files changed, 11669 insertions(+), 11389 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/a4d79f0c/client/src/main/java/org/apache/falcon/Pair.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/Pair.java b/client/src/main/java/org/apache/falcon/Pair.java
index 5b25419..300be27 100644
--- a/client/src/main/java/org/apache/falcon/Pair.java
+++ b/client/src/main/java/org/apache/falcon/Pair.java
@@ -31,7 +31,7 @@ public class Pair<A, B> {
public static <A, B> Pair<A, B> of(A a, B b) {
return new Pair<A, B>(a, b);
}
-
+
@Override
public String toString() {
return "(" + first + "," + second + ")";
@@ -39,13 +39,21 @@ public class Pair<A, B> {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
Pair pair = (Pair) o;
- if (first != null ? !first.equals(pair.first) : pair.first != null) return false;
- if (second != null ? !second.equals(pair.second) : pair.second != null) return false;
+ if (first != null ? !first.equals(pair.first) : pair.first != null) {
+ return false;
+ }
+ if (second != null ? !second.equals(pair.second) : pair.second != null) {
+ return false;
+ }
return true;
}
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/a4d79f0c/client/src/main/java/org/apache/falcon/cli/CLIParser.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/cli/CLIParser.java b/client/src/main/java/org/apache/falcon/cli/CLIParser.java
index 733cfb8..18fc487 100644
--- a/client/src/main/java/org/apache/falcon/cli/CLIParser.java
+++ b/client/src/main/java/org/apache/falcon/cli/CLIParser.java
@@ -18,17 +18,13 @@
package org.apache.falcon.cli;
+import org.apache.commons.cli.*;
+
import java.io.PrintWriter;
import java.text.MessageFormat;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-
/**
* Cannibalized from Oozie CLIParser into Falcon
@@ -57,9 +53,9 @@ public class CLIParser {
/**
* Add a command to the parser.
*
- * @param command comand name.
- * @param argsHelp command arguments help.
- * @param commandHelp command description.
+ * @param command comand name.
+ * @param argsHelp command arguments help.
+ * @param commandHelp command description.
* @param commandOptions command options.
* @param hasArguments
*/
@@ -74,7 +70,7 @@ public class CLIParser {
/**
* Bean that represents a parsed command.
*/
- public class Command {
+ public final class Command {
private String name;
private CommandLine commandLine;
@@ -112,16 +108,14 @@ public class CLIParser {
public Command parse(String[] args) throws ParseException {
if (args.length == 0) {
throw new ParseException("missing sub-command");
- }
- else {
+ } else {
if (commands.containsKey(args[0])) {
GnuParser parser = new GnuParser();
String[] minusCommand = new String[args.length - 1];
System.arraycopy(args, 1, minusCommand, 0, minusCommand.length);
return new Command(args[0], parser.parse(commands.get(args[0]), minusCommand,
- commandWithArgs.get(args[0])));
- }
- else {
+ commandWithArgs.get(args[0])));
+ } else {
throw new ParseException(MessageFormat.format("invalid sub-command [{0}]", args[0]));
}
}
@@ -147,8 +141,7 @@ public class CLIParser {
if (entry.getValue().getOptions().size() > 0) {
pw.println(s + "<OPTIONS> " + commandsHelp.get(entry.getKey()));
formatter.printOptions(pw, 100, entry.getValue(), s.length(), 3);
- }
- else {
+ } else {
pw.println(s + commandsHelp.get(entry.getKey()));
}
pw.println();
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/a4d79f0c/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
index 92243ea..575d7a5 100644
--- a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
+++ b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
@@ -18,13 +18,7 @@
package org.apache.falcon.cli;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
+import com.sun.jersey.api.client.ClientHandlerException;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionGroup;
@@ -33,560 +27,563 @@ import org.apache.commons.cli.ParseException;
import org.apache.falcon.client.FalconCLIException;
import org.apache.falcon.client.FalconClient;
-import com.sun.jersey.api.client.ClientHandlerException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+/**
+ * Falcon Command Line Interface - wraps the RESTful API.
+ */
public class FalconCLI {
- public static PrintStream ERR_STREAM = System.err;
- public static PrintStream OUT_STREAM = System.out;
-
- public static final String FALCON_URL = "FALCON_URL";
- public static final String URL_OPTION = "url";
- public static final String VERSION_OPTION = "version";
- public static final String ADMIN_CMD = "admin";
- public static final String HELP_CMD = "help";
- private static final String VERSION_CMD = "version";
- private static final String STACK_OPTION = "stack";
-
- public static final String ENTITY_CMD = "entity";
- public static final String ENTITY_TYPE_OPT = "type";
- public static final String COLO_OPT = "colo";
- public static final String ENTITY_NAME_OPT = "name";
- public static final String FILE_PATH_OPT = "file";
- public static final String SUBMIT_OPT = "submit";
- public static final String UPDATE_OPT = "update";
- public static final String SCHEDULE_OPT = "schedule";
- public static final String SUSPEND_OPT = "suspend";
- public static final String RESUME_OPT = "resume";
- public static final String DELETE_OPT = "delete";
- public static final String SUBMIT_AND_SCHEDULE_OPT = "submitAndSchedule";
- public static final String VALIDATE_OPT = "validate";
- public static final String STATUS_OPT = "status";
- public static final String DEFINITION_OPT = "definition";
- public static final String DEPENDENCY_OPT = "dependency";
- public static final String LIST_OPT = "list";
-
- public static final String INSTANCE_CMD = "instance";
- public static final String START_OPT = "start";
- public static final String END_OPT = "end";
- public static final String RUNNING_OPT = "running";
- public static final String KILL_OPT = "kill";
- public static final String RERUN_OPT = "rerun";
- public static final String CONTINUE_OPT = "continue";
- public static final String LOG_OPT = "logs";
- public static final String RUNID_OPT = "runid";
- public static final String CLUSTERS_OPT = "clusters";
- public static final String SOURCECLUSTER_OPT = "sourceClusters";
- public static final String CURRENT_COLO = "current.colo";
- public static final String CLIENT_PROPERTIES = "/client.properties";
-
- /**
- * Entry point for the Falcon CLI when invoked from the command line. Upon
- * completion this method exits the JVM with '0' (success) or '-1'
- * (failure).
- *
- * @param args
- * options and arguments for the Falcon CLI.
- */
- public static void main(String[] args) {
- System.exit(new FalconCLI().run(args));
- }
-
- // TODO help and headers
- private static final String[] FALCON_HELP = {
- "the env variable '" + FALCON_URL
- + "' is used as default value for the '-" + URL_OPTION
- + "' option",
- "custom headers for Falcon web services can be specified using '-D"
- + FalconClient.WS_HEADER_PREFIX + "NAME=VALUE'" };
-
- /**
- * Run a CLI programmatically.
- * <p/>
- * It does not exit the JVM.
- * <p/>
- * A CLI instance can be used only once.
- *
- * @param args
- * options and arguments for the Oozie CLI.
- * @return '0' (success), '-1' (failure).
- */
- public synchronized int run(String[] args) {
-
- CLIParser parser = new CLIParser("falcon", FALCON_HELP);
-
- parser.addCommand(ADMIN_CMD, "", "admin operations",
- createAdminOptions(), true);
- parser.addCommand(HELP_CMD, "", "display usage", new Options(), false);
- parser.addCommand(VERSION_CMD, "", "show client version",
- new Options(), false);
- parser.addCommand(
- ENTITY_CMD,
- "",
- "Entity opertions like submit, suspend, resume, delete, status, defintion, submitAndSchedule",
- entityOptions(), false);
- parser.addCommand(
- INSTANCE_CMD,
- "",
- "Process instances operations like running, status, kill, suspend, resume, rerun, logs",
- instanceOptions(), false);
-
- try {
- CLIParser.Command command = parser.parse(args);
- if (command.getName().equals(HELP_CMD)) {
- parser.showHelp();
- } else if (command.getName().equals(ADMIN_CMD)) {
- adminCommand(command.getCommandLine());
- } else if (command.getName().equals(ENTITY_CMD)) {
- entityCommand(command.getCommandLine());
- } else if (command.getName().equals(INSTANCE_CMD)) {
- instanceCommand(command.getCommandLine());
- }
-
- return 0;
- } catch (FalconCLIException ex) {
- ERR_STREAM.println("Error: " + ex.getMessage());
- return -1;
- } catch (ParseException ex) {
- ERR_STREAM.println("Invalid sub-command: " + ex.getMessage());
- ERR_STREAM.println();
- ERR_STREAM.println(parser.shortHelp());
- return -1;
- } catch (ClientHandlerException ex) {
- ERR_STREAM
- .print("Unable to connect to Falcon server, please check if the URL is correct and Falcon server is up and running\n");
- ERR_STREAM.println(ex.getMessage());
- return -1;
- } catch (Exception ex) {
- ex.printStackTrace();
- ERR_STREAM.println(ex.getMessage());
- return -1;
- }
-
- }
-
- private void instanceCommand(CommandLine commandLine)
- throws FalconCLIException, IOException {
- String falconUrl = getFalconEndpoint(commandLine);
- FalconClient client = new FalconClient(falconUrl);
-
- Set<String> optionsList = new HashSet<String>();
- for (Option option : commandLine.getOptions()) {
- optionsList.add(option.getOpt());
- }
-
- String result = null;
- String type = commandLine.getOptionValue(ENTITY_TYPE_OPT);
- String entity = commandLine.getOptionValue(ENTITY_NAME_OPT);
- String start = commandLine.getOptionValue(START_OPT);
- String end = commandLine.getOptionValue(END_OPT);
- String filePath = commandLine.getOptionValue(FILE_PATH_OPT);
- String runid = commandLine.getOptionValue(RUNID_OPT);
- String colo = commandLine.getOptionValue(COLO_OPT);
- String clusters = commandLine.getOptionValue(CLUSTERS_OPT);
- String sourceClusters = commandLine.getOptionValue(SOURCECLUSTER_OPT);
-
- colo = getColo(colo);
-
- validateInstanceCommands(optionsList, entity, type, start, end,
- filePath, colo, clusters, sourceClusters);
-
- if (optionsList.contains(RUNNING_OPT)) {
- result = client.getRunningInstances(type, entity, colo);
- } else if (optionsList.contains(STATUS_OPT)) {
- result = client.getStatusOfInstances(type, entity, start, end,
- runid, colo);
- } else if (optionsList.contains(KILL_OPT)) {
- result = client.killInstances(type, entity, start, end, colo, clusters, sourceClusters);
- } else if (optionsList.contains(SUSPEND_OPT)) {
- result = client.suspendInstances(type, entity, start, end, colo, clusters, sourceClusters);
- } else if (optionsList.contains(RESUME_OPT)) {
- result = client.resumeInstances(type, entity, start, end, colo, clusters, sourceClusters);
- } else if (optionsList.contains(RERUN_OPT)) {
- result = client.rerunInstances(type, entity, start, end, filePath, colo, clusters, sourceClusters);
- } else if (optionsList.contains(CONTINUE_OPT)) {
- result = client.rerunInstances(type, entity, start, end, colo, clusters, sourceClusters);
- } else if(optionsList.contains(LOG_OPT)){
- result = client.getLogsOfInstances(type, entity, start, end, colo, runid);
- } else {
- throw new FalconCLIException("Invalid command");
- }
- OUT_STREAM.println(result);
-
- }
-
- private void validateInstanceCommands(Set<String> optionsList,
- String entity, String type, String start, String end,
- String filePath, String colo, String clusters, String sourceClusters)
- throws FalconCLIException {
-
- if (entity == null || entity.equals("")) {
- throw new FalconCLIException("Missing argument: name");
- }
-
- if (type == null || type.equals("")) {
- throw new FalconCLIException("Missing argument: type");
- }
-
- if (colo == null || colo.equals("")) {
- throw new FalconCLIException("Missing argument: colo");
- }
-
- if (!optionsList.contains(RUNNING_OPT)) {
- if (start == null || start.equals("")) {
- throw new FalconCLIException("Missing argument: start");
- }
- }
-
- if (optionsList.contains(CLUSTERS_OPT)) {
- if (optionsList.contains(RUNNING_OPT)
- || optionsList.contains(LOG_OPT)
- || optionsList.contains(STATUS_OPT)) {
- throw new FalconCLIException("Invalid argument: clusters");
- }
- }
-
- if (optionsList.contains(SOURCECLUSTER_OPT)) {
- if ( optionsList.contains(RUNNING_OPT)
- || optionsList.contains(LOG_OPT)
- || optionsList.contains(STATUS_OPT) || !type.equals("feed") ) {
- throw new FalconCLIException("Invalid argument: sourceClusters");
- }
- }
-
- }
-
- private void entityCommand(CommandLine commandLine)
- throws FalconCLIException, IOException {
- String falconUrl = getFalconEndpoint(commandLine);
- FalconClient client = new FalconClient(falconUrl);
-
- Set<String> optionsList = new HashSet<String>();
- for (Option option : commandLine.getOptions()) {
- optionsList.add(option.getOpt());
- }
-
- String result = null;
- String entityType = commandLine.getOptionValue(ENTITY_TYPE_OPT);
- String entityName = commandLine.getOptionValue(ENTITY_NAME_OPT);
- String filePath = commandLine.getOptionValue(FILE_PATH_OPT);
- String colo = commandLine.getOptionValue(COLO_OPT);
-
-
- validateEntityType(optionsList, entityType);
-
- if (optionsList.contains(SUBMIT_OPT)) {
- validateFilePath(optionsList, filePath);
- validateColo(optionsList);
- result = client.submit(entityType, filePath);
- } else if (optionsList.contains(UPDATE_OPT)) {
- validateFilePath(optionsList, filePath);
- validateColo(optionsList);
- validateEntityName(optionsList, entityName);
- result = client.update(entityType, entityName, filePath);
- } else if (optionsList.contains(SUBMIT_AND_SCHEDULE_OPT)) {
- validateFilePath(optionsList, filePath);
- validateColo(optionsList);
- result = client.submitAndSchedule(entityType, filePath);
- } else if (optionsList.contains(VALIDATE_OPT)) {
- validateFilePath(optionsList, filePath);
- validateColo(optionsList);
- result = client.validate(entityType, filePath);
- } else if (optionsList.contains(SCHEDULE_OPT)) {
- validateEntityName(optionsList, entityName);
- colo = getColo(colo);
- result = client.schedule(entityType, entityName, colo);
- } else if (optionsList.contains(SUSPEND_OPT)) {
- validateEntityName(optionsList, entityName);
- colo = getColo(colo);
- result = client.suspend(entityType, entityName, colo);
- } else if (optionsList.contains(RESUME_OPT)) {
- validateEntityName(optionsList, entityName);
- colo = getColo(colo);
- result = client.resume(entityType, entityName, colo);
- } else if (optionsList.contains(DELETE_OPT)) {
- validateColo(optionsList);
- validateEntityName(optionsList, entityName);
- result = client.delete(entityType, entityName);
- } else if (optionsList.contains(STATUS_OPT)) {
- validateEntityName(optionsList, entityName);
- colo = getColo(colo);
- result = client.getStatus(entityType, entityName, colo);
- } else if (optionsList.contains(DEFINITION_OPT)) {
- validateColo(optionsList);
- validateEntityName(optionsList, entityName);
- result = client.getDefinition(entityType, entityName);
- } else if (optionsList.contains(DEPENDENCY_OPT)) {
- validateColo(optionsList);
- validateEntityName(optionsList, entityName);
- result = client.getDependency(entityType, entityName);
- } else if (optionsList.contains(LIST_OPT)) {
- validateColo(optionsList);
- result = client.getEntityList(entityType);
- } else if (optionsList.contains(HELP_CMD)) {
- OUT_STREAM.println("Falcon Help");
- } else {
- throw new FalconCLIException("Invalid command");
- }
- OUT_STREAM.println(result);
- }
-
- private String getColo(String colo) throws FalconCLIException, IOException
- {
- if (colo == null) {
- Properties prop = getClientProperties();
- colo = prop.getProperty(CURRENT_COLO, "*");
- }
- return colo;
- }
- private void validateFilePath(Set<String> optionsList, String filePath)
- throws FalconCLIException {
- if (filePath == null || filePath.equals("")) {
- throw new FalconCLIException("Missing argument: file");
- }
- }
-
- private void validateColo(Set<String> optionsList)
- throws FalconCLIException {
- if (optionsList.contains(COLO_OPT)) {
- throw new FalconCLIException("Invalid argument : " + COLO_OPT);
- }
- }
-
- private void validateEntityName(Set<String> optionsList, String entityName)
- throws FalconCLIException {
- if (entityName == null || entityName.equals("")) {
- throw new FalconCLIException("Missing argument: name");
- }
- }
-
- private void validateEntityType(Set<String> optionsList, String entityType)
- throws FalconCLIException {
- if (entityType == null || entityType.equals("")) {
- throw new FalconCLIException("Missing argument: type");
- }
- }
-
-
- private Options createAdminOptions() {
- Options adminOptions = new Options();
- Option url = new Option(URL_OPTION, true, "Falcon URL");
- adminOptions.addOption(url);
-
- OptionGroup group = new OptionGroup();
- // Option status = new Option(STATUS_OPTION, false,
- // "show the current system status");
- Option version = new Option(VERSION_OPTION, false,
- "show Falcon server build version");
- Option help = new Option("help", false, "show Falcon help");
- group.addOption(version);
- group.addOption(help);
-
- adminOptions.addOptionGroup(group);
- return adminOptions;
- }
-
- private Options entityOptions() {
-
- Options entityOptions = new Options();
-
- Option submit = new Option(SUBMIT_OPT, false,
- "Submits an entity xml to Falcon");
- Option update = new Option(UPDATE_OPT, false,
- "Updates an existing entity xml");
- Option schedule = new Option(SCHEDULE_OPT, false,
- "Schedules a submited entity in Falcon");
- Option suspend = new Option(SUSPEND_OPT, false,
- "Suspends a running entity in Falcon");
- Option resume = new Option(RESUME_OPT, false,
- "Resumes a suspended entity in Falcon");
- Option delete = new Option(DELETE_OPT, false,
- "Deletes an entity in Falcon, and kills its instance from workflow engine");
- Option submitAndSchedule = new Option(SUBMIT_AND_SCHEDULE_OPT, false,
- "Submits and entity to Falcon and schedules it immediately");
- Option validate = new Option(VALIDATE_OPT, false,
- "Validates an entity based on the entity type");
- Option status = new Option(STATUS_OPT, false,
- "Gets the status of entity");
- Option definition = new Option(DEFINITION_OPT, false,
- "Gets the Definition of entity");
- Option dependency = new Option(DEPENDENCY_OPT, false,
- "Gets the dependencies of entity");
- Option list = new Option(LIST_OPT, false,
- "List entities registerd for a type");
-
- OptionGroup group = new OptionGroup();
- group.addOption(submit);
- group.addOption(update);
- group.addOption(schedule);
- group.addOption(suspend);
- group.addOption(resume);
- group.addOption(delete);
- group.addOption(submitAndSchedule);
- group.addOption(validate);
- group.addOption(status);
- group.addOption(definition);
- group.addOption(dependency);
- group.addOption(list);
-
- Option url = new Option(URL_OPTION, true, "Falcon URL");
- Option entityType = new Option(ENTITY_TYPE_OPT, true,
- "Entity type, can be cluster, feed or process xml");
- entityType.setRequired(true);
- Option filePath = new Option(FILE_PATH_OPT, true,
- "Path to entity xml file");
- Option entityName = new Option(ENTITY_NAME_OPT, true,
- "Entity type, can be cluster, feed or process xml");
+ public static final AtomicReference<PrintStream> ERR = new AtomicReference<PrintStream>(System.err);
+ public static final AtomicReference<PrintStream> OUT = new AtomicReference<PrintStream>(System.out);
+
+ public static final String FALCON_URL = "FALCON_URL";
+ public static final String URL_OPTION = "url";
+ public static final String VERSION_OPTION = "version";
+ public static final String ADMIN_CMD = "admin";
+ public static final String HELP_CMD = "help";
+ private static final String VERSION_CMD = "version";
+ private static final String STACK_OPTION = "stack";
+
+ public static final String ENTITY_CMD = "entity";
+ public static final String ENTITY_TYPE_OPT = "type";
+ public static final String COLO_OPT = "colo";
+ public static final String ENTITY_NAME_OPT = "name";
+ public static final String FILE_PATH_OPT = "file";
+ public static final String SUBMIT_OPT = "submit";
+ public static final String UPDATE_OPT = "update";
+ public static final String SCHEDULE_OPT = "schedule";
+ public static final String SUSPEND_OPT = "suspend";
+ public static final String RESUME_OPT = "resume";
+ public static final String DELETE_OPT = "delete";
+ public static final String SUBMIT_AND_SCHEDULE_OPT = "submitAndSchedule";
+ public static final String VALIDATE_OPT = "validate";
+ public static final String STATUS_OPT = "status";
+ public static final String DEFINITION_OPT = "definition";
+ public static final String DEPENDENCY_OPT = "dependency";
+ public static final String LIST_OPT = "list";
+
+ public static final String INSTANCE_CMD = "instance";
+ public static final String START_OPT = "start";
+ public static final String END_OPT = "end";
+ public static final String RUNNING_OPT = "running";
+ public static final String KILL_OPT = "kill";
+ public static final String RERUN_OPT = "rerun";
+ public static final String CONTINUE_OPT = "continue";
+ public static final String LOG_OPT = "logs";
+ public static final String RUNID_OPT = "runid";
+ public static final String CLUSTERS_OPT = "clusters";
+ public static final String SOURCECLUSTER_OPT = "sourceClusters";
+ public static final String CURRENT_COLO = "current.colo";
+ public static final String CLIENT_PROPERTIES = "/client.properties";
+
+ /**
+ * Entry point for the Falcon CLI when invoked from the command line. Upon
+ * completion this method exits the JVM with '0' (success) or '-1'
+ * (failure).
+ *
+ * @param args options and arguments for the Falcon CLI.
+ */
+ public static void main(final String[] args) {
+ System.exit(new FalconCLI().run(args));
+ }
+
+ // TODO help and headers
+ private static final String[] FALCON_HELP = {
+ "the env variable '" + FALCON_URL
+ + "' is used as default value for the '-" + URL_OPTION + "' option",
+ "custom headers for Falcon web services can be specified using '-D"
+ + FalconClient.WS_HEADER_PREFIX + "NAME=VALUE'"};
+
+ /**
+ * Run a CLI programmatically.
+ * <p/>
+ * It does not exit the JVM.
+ * <p/>
+ * A CLI instance can be used only once.
+ *
+ * @param args options and arguments for the Oozie CLI.
+ * @return '0' (success), '-1' (failure).
+ */
+ public synchronized int run(final String[] args) {
+
+ CLIParser parser = new CLIParser("falcon", FALCON_HELP);
+
+ parser.addCommand(ADMIN_CMD, "", "admin operations", createAdminOptions(), true);
+ parser.addCommand(HELP_CMD, "", "display usage", new Options(), false);
+ parser.addCommand(VERSION_CMD, "", "show client version", new Options(), false);
+ parser.addCommand(ENTITY_CMD,
+ "",
+ "Entity opertions like submit, suspend, resume, delete, status, defintion, submitAndSchedule",
+ entityOptions(), false);
+ parser.addCommand(INSTANCE_CMD,
+ "",
+ "Process instances operations like running, status, kill, suspend, resume, rerun, logs",
+ instanceOptions(), false);
+
+ try {
+ CLIParser.Command command = parser.parse(args);
+ if (command.getName().equals(HELP_CMD)) {
+ parser.showHelp();
+ } else if (command.getName().equals(ADMIN_CMD)) {
+ adminCommand(command.getCommandLine());
+ } else if (command.getName().equals(ENTITY_CMD)) {
+ entityCommand(command.getCommandLine());
+ } else if (command.getName().equals(INSTANCE_CMD)) {
+ instanceCommand(command.getCommandLine());
+ }
+
+ return 0;
+ } catch (FalconCLIException ex) {
+ ERR.get().println("Error: " + ex.getMessage());
+ return -1;
+ } catch (ParseException ex) {
+ ERR.get().println("Invalid sub-command: " + ex.getMessage());
+ ERR.get().println();
+ ERR.get().println(parser.shortHelp());
+ return -1;
+ } catch (ClientHandlerException ex) {
+ ERR.get().print("Unable to connect to Falcon server, "
+ + "please check if the URL is correct and Falcon server is up and running\n");
+ ERR.get().println(ex.getMessage());
+ return -1;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ ERR.get().println(ex.getMessage());
+ return -1;
+ }
+ }
+
+ private void instanceCommand(CommandLine commandLine) throws FalconCLIException, IOException {
+ String falconUrl = getFalconEndpoint(commandLine);
+ FalconClient client = new FalconClient(falconUrl);
+
+ Set<String> optionsList = new HashSet<String>();
+ for (Option option : commandLine.getOptions()) {
+ optionsList.add(option.getOpt());
+ }
+
+ String result;
+ String type = commandLine.getOptionValue(ENTITY_TYPE_OPT);
+ String entity = commandLine.getOptionValue(ENTITY_NAME_OPT);
+ String start = commandLine.getOptionValue(START_OPT);
+ String end = commandLine.getOptionValue(END_OPT);
+ String filePath = commandLine.getOptionValue(FILE_PATH_OPT);
+ String runid = commandLine.getOptionValue(RUNID_OPT);
+ String colo = commandLine.getOptionValue(COLO_OPT);
+ String clusters = commandLine.getOptionValue(CLUSTERS_OPT);
+ String sourceClusters = commandLine.getOptionValue(SOURCECLUSTER_OPT);
+
+ colo = getColo(colo);
+
+ validateInstanceCommands(optionsList, entity, type, start, end,
+ filePath, colo, clusters, sourceClusters);
+
+ if (optionsList.contains(RUNNING_OPT)) {
+ result = client.getRunningInstances(type, entity, colo);
+ } else if (optionsList.contains(STATUS_OPT)) {
+ result = client.getStatusOfInstances(type, entity, start, end,
+ runid, colo);
+ } else if (optionsList.contains(KILL_OPT)) {
+ result = client.killInstances(type, entity, start, end, colo, clusters, sourceClusters);
+ } else if (optionsList.contains(SUSPEND_OPT)) {
+ result = client.suspendInstances(type, entity, start, end, colo, clusters, sourceClusters);
+ } else if (optionsList.contains(RESUME_OPT)) {
+ result = client.resumeInstances(type, entity, start, end, colo, clusters, sourceClusters);
+ } else if (optionsList.contains(RERUN_OPT)) {
+ result = client.rerunInstances(type, entity, start, end, filePath, colo, clusters, sourceClusters);
+ } else if (optionsList.contains(CONTINUE_OPT)) {
+ result = client.rerunInstances(type, entity, start, end, colo, clusters, sourceClusters);
+ } else if (optionsList.contains(LOG_OPT)) {
+ result = client.getLogsOfInstances(type, entity, start, end, colo, runid);
+ } else {
+ throw new FalconCLIException("Invalid command");
+ }
+
+ OUT.get().println(result);
+ }
+
+ private void validateInstanceCommands(Set<String> optionsList, String entity, String type,
+ String start, String end, String filePath, String colo,
+ String clusters, String sourceClusters) throws FalconCLIException {
+
+ if (entity == null || entity.equals("")) {
+ throw new FalconCLIException("Missing argument: name");
+ }
+
+ if (type == null || type.equals("")) {
+ throw new FalconCLIException("Missing argument: type");
+ }
+
+ if (colo == null || colo.equals("")) {
+ throw new FalconCLIException("Missing argument: colo");
+ }
+
+ if (!optionsList.contains(RUNNING_OPT)) {
+ if (start == null || start.equals("")) {
+ throw new FalconCLIException("Missing argument: start");
+ }
+ }
+
+ if (optionsList.contains(CLUSTERS_OPT)) {
+ if (optionsList.contains(RUNNING_OPT)
+ || optionsList.contains(LOG_OPT)
+ || optionsList.contains(STATUS_OPT)) {
+ throw new FalconCLIException("Invalid argument: clusters");
+ }
+ }
+
+ if (optionsList.contains(SOURCECLUSTER_OPT)) {
+ if (optionsList.contains(RUNNING_OPT)
+ || optionsList.contains(LOG_OPT)
+ || optionsList.contains(STATUS_OPT) || !type.equals("feed")) {
+ throw new FalconCLIException("Invalid argument: sourceClusters");
+ }
+ }
+ }
+
+ private void entityCommand(CommandLine commandLine)
+ throws FalconCLIException, IOException {
+ String falconUrl = getFalconEndpoint(commandLine);
+ FalconClient client = new FalconClient(falconUrl);
+
+ Set<String> optionsList = new HashSet<String>();
+ for (Option option : commandLine.getOptions()) {
+ optionsList.add(option.getOpt());
+ }
+
+ String result = null;
+ String entityType = commandLine.getOptionValue(ENTITY_TYPE_OPT);
+ String entityName = commandLine.getOptionValue(ENTITY_NAME_OPT);
+ String filePath = commandLine.getOptionValue(FILE_PATH_OPT);
+ String colo = commandLine.getOptionValue(COLO_OPT);
+
+
+ validateEntityType(optionsList, entityType);
+
+ if (optionsList.contains(SUBMIT_OPT)) {
+ validateFilePath(optionsList, filePath);
+ validateColo(optionsList);
+ result = client.submit(entityType, filePath);
+ } else if (optionsList.contains(UPDATE_OPT)) {
+ validateFilePath(optionsList, filePath);
+ validateColo(optionsList);
+ validateEntityName(optionsList, entityName);
+ result = client.update(entityType, entityName, filePath);
+ } else if (optionsList.contains(SUBMIT_AND_SCHEDULE_OPT)) {
+ validateFilePath(optionsList, filePath);
+ validateColo(optionsList);
+ result = client.submitAndSchedule(entityType, filePath);
+ } else if (optionsList.contains(VALIDATE_OPT)) {
+ validateFilePath(optionsList, filePath);
+ validateColo(optionsList);
+ result = client.validate(entityType, filePath);
+ } else if (optionsList.contains(SCHEDULE_OPT)) {
+ validateEntityName(optionsList, entityName);
+ colo = getColo(colo);
+ result = client.schedule(entityType, entityName, colo);
+ } else if (optionsList.contains(SUSPEND_OPT)) {
+ validateEntityName(optionsList, entityName);
+ colo = getColo(colo);
+ result = client.suspend(entityType, entityName, colo);
+ } else if (optionsList.contains(RESUME_OPT)) {
+ validateEntityName(optionsList, entityName);
+ colo = getColo(colo);
+ result = client.resume(entityType, entityName, colo);
+ } else if (optionsList.contains(DELETE_OPT)) {
+ validateColo(optionsList);
+ validateEntityName(optionsList, entityName);
+ result = client.delete(entityType, entityName);
+ } else if (optionsList.contains(STATUS_OPT)) {
+ validateEntityName(optionsList, entityName);
+ colo = getColo(colo);
+ result = client.getStatus(entityType, entityName, colo);
+ } else if (optionsList.contains(DEFINITION_OPT)) {
+ validateColo(optionsList);
+ validateEntityName(optionsList, entityName);
+ result = client.getDefinition(entityType, entityName);
+ } else if (optionsList.contains(DEPENDENCY_OPT)) {
+ validateColo(optionsList);
+ validateEntityName(optionsList, entityName);
+ result = client.getDependency(entityType, entityName);
+ } else if (optionsList.contains(LIST_OPT)) {
+ validateColo(optionsList);
+ result = client.getEntityList(entityType);
+ } else if (optionsList.contains(HELP_CMD)) {
+ OUT.get().println("Falcon Help");
+ } else {
+ throw new FalconCLIException("Invalid command");
+ }
+ OUT.get().println(result);
+ }
+
+ private String getColo(String colo) throws FalconCLIException, IOException {
+ if (colo == null) {
+ Properties prop = getClientProperties();
+ colo = prop.getProperty(CURRENT_COLO, "*");
+ }
+ return colo;
+ }
+
+ private void validateFilePath(Set<String> optionsList, String filePath)
+ throws FalconCLIException {
+ if (filePath == null || filePath.equals("")) {
+ throw new FalconCLIException("Missing argument: file");
+ }
+ }
+
+ private void validateColo(Set<String> optionsList)
+ throws FalconCLIException {
+ if (optionsList.contains(COLO_OPT)) {
+ throw new FalconCLIException("Invalid argument : " + COLO_OPT);
+ }
+ }
+
+ private void validateEntityName(Set<String> optionsList, String entityName)
+ throws FalconCLIException {
+ if (entityName == null || entityName.equals("")) {
+ throw new FalconCLIException("Missing argument: name");
+ }
+ }
+
+ private void validateEntityType(Set<String> optionsList, String entityType)
+ throws FalconCLIException {
+ if (entityType == null || entityType.equals("")) {
+ throw new FalconCLIException("Missing argument: type");
+ }
+ }
+
+
+ private Options createAdminOptions() {
+ Options adminOptions = new Options();
+ Option url = new Option(URL_OPTION, true, "Falcon URL");
+ adminOptions.addOption(url);
+
+ OptionGroup group = new OptionGroup();
+ // Option status = new Option(STATUS_OPTION, false,
+ // "show the current system status");
+ Option version = new Option(VERSION_OPTION, false,
+ "show Falcon server build version");
+ Option help = new Option("help", false, "show Falcon help");
+ group.addOption(version);
+ group.addOption(help);
+
+ adminOptions.addOptionGroup(group);
+ return adminOptions;
+ }
+
+ private Options entityOptions() {
+
+ Options entityOptions = new Options();
+
+ Option submit = new Option(SUBMIT_OPT, false,
+ "Submits an entity xml to Falcon");
+ Option update = new Option(UPDATE_OPT, false,
+ "Updates an existing entity xml");
+ Option schedule = new Option(SCHEDULE_OPT, false,
+ "Schedules a submited entity in Falcon");
+ Option suspend = new Option(SUSPEND_OPT, false,
+ "Suspends a running entity in Falcon");
+ Option resume = new Option(RESUME_OPT, false,
+ "Resumes a suspended entity in Falcon");
+ Option delete = new Option(DELETE_OPT, false,
+ "Deletes an entity in Falcon, and kills its instance from workflow engine");
+ Option submitAndSchedule = new Option(SUBMIT_AND_SCHEDULE_OPT, false,
+ "Submits and entity to Falcon and schedules it immediately");
+ Option validate = new Option(VALIDATE_OPT, false,
+ "Validates an entity based on the entity type");
+ Option status = new Option(STATUS_OPT, false,
+ "Gets the status of entity");
+ Option definition = new Option(DEFINITION_OPT, false,
+ "Gets the Definition of entity");
+ Option dependency = new Option(DEPENDENCY_OPT, false,
+ "Gets the dependencies of entity");
+ Option list = new Option(LIST_OPT, false,
+ "List entities registerd for a type");
+
+ OptionGroup group = new OptionGroup();
+ group.addOption(submit);
+ group.addOption(update);
+ group.addOption(schedule);
+ group.addOption(suspend);
+ group.addOption(resume);
+ group.addOption(delete);
+ group.addOption(submitAndSchedule);
+ group.addOption(validate);
+ group.addOption(status);
+ group.addOption(definition);
+ group.addOption(dependency);
+ group.addOption(list);
+
+ Option url = new Option(URL_OPTION, true, "Falcon URL");
+ Option entityType = new Option(ENTITY_TYPE_OPT, true,
+ "Entity type, can be cluster, feed or process xml");
+ entityType.setRequired(true);
+ Option filePath = new Option(FILE_PATH_OPT, true,
+ "Path to entity xml file");
+ Option entityName = new Option(ENTITY_NAME_OPT, true,
+ "Entity type, can be cluster, feed or process xml");
Option colo = new Option(COLO_OPT, true,
"Colo name");
colo.setRequired(false);
- entityOptions.addOption(url);
- entityOptions.addOptionGroup(group);
- entityOptions.addOption(entityType);
- entityOptions.addOption(entityName);
- entityOptions.addOption(filePath);
- entityOptions.addOption(colo);
-
- return entityOptions;
-
- }
-
- private Options instanceOptions() {
-
- Options instanceOptions = new Options();
-
- Option running = new Option(RUNNING_OPT, false,
- "Gets running process instances for a given process");
- Option status = new Option(
- STATUS_OPT,
- false,
- "Gets status of process instances for a given process in the range start time and optional end time");
- Option kill = new Option(
- KILL_OPT,
- false,
- "Kills active process instances for a given process in the range start time and optional end time");
- Option suspend = new Option(
- SUSPEND_OPT,
- false,
- "Suspends active process instances for a given process in the range start time and optional end time");
- Option resume = new Option(
- RESUME_OPT,
- false,
- "Resumes suspended process instances for a given process in the range start time and optional end time");
- Option rerun = new Option(
- RERUN_OPT,
- false,
- "Reruns process instances for a given process in the range start time and optional end time and overrides properties present in job.properties file");
-
- Option continues = new Option(
- CONTINUE_OPT,
- false,
- "resume process instance execution for a given process in the range start time and optional end time and overrides properties present in job.properties file");
-
- Option logs = new Option(
- LOG_OPT,
- false,
- "Logs print the logs for process instances for a given process in the range start time and optional end time");
- OptionGroup group = new OptionGroup();
- group.addOption(running);
- group.addOption(status);
- group.addOption(kill);
- group.addOption(resume);
- group.addOption(suspend);
- group.addOption(resume);
- group.addOption(rerun);
- group.addOption(logs);
- group.addOption(continues);
-
- Option url = new Option(URL_OPTION, true, "Falcon URL");
- Option start = new Option(START_OPT, true,
- "Start time is required for commands, status, kill, suspend, resume and re-run");
- Option end = new Option(
- END_OPT,
- true,
- "End time is optional for commands, status, kill, suspend, resume and re-run; if not specified then current time is considered as end time");
- Option runid = new Option(RUNID_OPT, true,
- "Instance runid is optional and user can specify the runid, defaults to 0");
- Option clusters = new Option(CLUSTERS_OPT, true,
- "clusters is optional for commands kill, suspend and resume, should not be specified for other commands");
- Option sourceClusters = new Option(SOURCECLUSTER_OPT, true,
- " source cluster is optional for commands kill, suspend and resume, should not be specified for other commands (required for only feed)");
- Option filePath = new Option(
- FILE_PATH_OPT,
- true,
- "Path to job.properties file is required for rerun command, it should contain name=value pair for properties to override for rerun");
- Option entityType = new Option(ENTITY_TYPE_OPT, true,
- "Entity type, can be feed or process xml");
- Option entityName = new Option(ENTITY_NAME_OPT, true,
- "Entity type, can be feed or process xml");
+ entityOptions.addOption(url);
+ entityOptions.addOptionGroup(group);
+ entityOptions.addOption(entityType);
+ entityOptions.addOption(entityName);
+ entityOptions.addOption(filePath);
+ entityOptions.addOption(colo);
+
+ return entityOptions;
+ }
+
+ private Options instanceOptions() {
+
+ Options instanceOptions = new Options();
+
+ Option running = new Option(RUNNING_OPT, false,
+ "Gets running process instances for a given process");
+ Option status = new Option(
+ STATUS_OPT,
+ false,
+ "Gets status of process instances for a given process in the range start time and optional end time");
+ Option kill = new Option(
+ KILL_OPT,
+ false,
+ "Kills active process instances for a given process in the range start time and optional end time");
+ Option suspend = new Option(
+ SUSPEND_OPT,
+ false,
+ "Suspends active process instances for a given process in the range start time and optional end time");
+ Option resume = new Option(
+ RESUME_OPT,
+ false,
+ "Resumes suspended process instances for a given process "
+ + "in the range start time and optional end time");
+ Option rerun = new Option(
+ RERUN_OPT,
+ false,
+ "Reruns process instances for a given process in the range start time and "
+ + "optional end time and overrides properties present in job.properties file");
+
+ Option continues = new Option(
+ CONTINUE_OPT,
+ false,
+ "resume process instance execution for a given process in the range start time and "
+ + "optional end time and overrides properties present in job.properties file");
+
+ Option logs = new Option(
+ LOG_OPT,
+ false,
+ "Logs print the logs for process instances for a given process in "
+ + "the range start time and optional end time");
+
+ OptionGroup group = new OptionGroup();
+ group.addOption(running);
+ group.addOption(status);
+ group.addOption(kill);
+ group.addOption(resume);
+ group.addOption(suspend);
+ group.addOption(resume);
+ group.addOption(rerun);
+ group.addOption(logs);
+ group.addOption(continues);
+
+ Option url = new Option(URL_OPTION, true, "Falcon URL");
+ Option start = new Option(START_OPT, true,
+ "Start time is required for commands, status, kill, suspend, resume and re-run");
+ Option end = new Option(
+ END_OPT,
+ true,
+ "End time is optional for commands, status, kill, suspend, resume and re-run; "
+ + "if not specified then current time is considered as end time");
+ Option runid = new Option(RUNID_OPT, true,
+ "Instance runid is optional and user can specify the runid, defaults to 0");
+ Option clusters = new Option(CLUSTERS_OPT, true,
+ "clusters is optional for commands kill, suspend and resume, "
+ + "should not be specified for other commands");
+ Option sourceClusters = new Option(SOURCECLUSTER_OPT, true,
+ " source cluster is optional for commands kill, suspend and resume, "
+ + "should not be specified for other commands (required for only feed)");
+ Option filePath = new Option(
+ FILE_PATH_OPT,
+ true,
+ "Path to job.properties file is required for rerun command, "
+ + "it should contain name=value pair for properties to override for rerun");
+ Option entityType = new Option(ENTITY_TYPE_OPT, true,
+ "Entity type, can be feed or process xml");
+ Option entityName = new Option(ENTITY_NAME_OPT, true,
+ "Entity type, can be feed or process xml");
Option colo = new Option(COLO_OPT, true,
"Colo on which the cmd has to be executed");
- instanceOptions.addOption(url);
- instanceOptions.addOptionGroup(group);
- instanceOptions.addOption(start);
- instanceOptions.addOption(end);
- instanceOptions.addOption(filePath);
- instanceOptions.addOption(entityType);
- instanceOptions.addOption(entityName);
- instanceOptions.addOption(runid);
- instanceOptions.addOption(clusters);
- instanceOptions.addOption(sourceClusters);
- instanceOptions.addOption(colo);
-
- return instanceOptions;
-
- }
-
- protected String getFalconEndpoint(CommandLine commandLine)
- throws FalconCLIException, IOException {
- String url = commandLine.getOptionValue(URL_OPTION);
- if (url == null) {
- url = System.getenv(FALCON_URL);
- }
- if(url == null) {
+ instanceOptions.addOption(url);
+ instanceOptions.addOptionGroup(group);
+ instanceOptions.addOption(start);
+ instanceOptions.addOption(end);
+ instanceOptions.addOption(filePath);
+ instanceOptions.addOption(entityType);
+ instanceOptions.addOption(entityName);
+ instanceOptions.addOption(runid);
+ instanceOptions.addOption(clusters);
+ instanceOptions.addOption(sourceClusters);
+ instanceOptions.addOption(colo);
+
+ return instanceOptions;
+ }
+
+ protected String getFalconEndpoint(CommandLine commandLine) throws FalconCLIException, IOException {
+ String url = commandLine.getOptionValue(URL_OPTION);
+ if (url == null) {
+ url = System.getenv(FALCON_URL);
+ }
+ if (url == null) {
Properties prop = getClientProperties();
- if (prop.containsKey("falcon.url"))
+ if (prop.containsKey("falcon.url")) {
url = prop.getProperty("falcon.url");
- }
- if(url == null)
- throw new FalconCLIException("Failed to get falcon url from cmdline, or environment or client properties");
- return url;
- }
-
- private void adminCommand(CommandLine commandLine) throws FalconCLIException, IOException {
- String result;
- String falconUrl = getFalconEndpoint(commandLine);
- FalconClient client = new FalconClient(falconUrl);
-
- Set<String> optionsList = new HashSet<String>();
- for (Option option : commandLine.getOptions()) {
- optionsList.add(option.getOpt());
- }
-
- if(optionsList.contains(STACK_OPTION)){
- result = client.getThreadDump();
- OUT_STREAM.println(result);
- }
- if (optionsList.contains(VERSION_OPTION)) {
- result = client.getVersion();
- OUT_STREAM.println("Falcon server build version: " + result);
- }
-
- else if (optionsList.contains(HELP_CMD)) {
- OUT_STREAM.println("Falcon Help");
- }
- }
-
- private Properties getClientProperties() throws IOException
- {
+ }
+ }
+ if (url == null) {
+ throw new FalconCLIException("Failed to get falcon url from cmdline, or environment or client properties");
+ }
+
+ return url;
+ }
+
+ private void adminCommand(CommandLine commandLine) throws FalconCLIException, IOException {
+ String result;
+ String falconUrl = getFalconEndpoint(commandLine);
+ FalconClient client = new FalconClient(falconUrl);
+
+ Set<String> optionsList = new HashSet<String>();
+ for (Option option : commandLine.getOptions()) {
+ optionsList.add(option.getOpt());
+ }
+
+ if (optionsList.contains(STACK_OPTION)) {
+ result = client.getThreadDump();
+ OUT.get().println(result);
+ }
+ if (optionsList.contains(VERSION_OPTION)) {
+ result = client.getVersion();
+ OUT.get().println("Falcon server build version: " + result);
+ } else if (optionsList.contains(HELP_CMD)) {
+ OUT.get().println("Falcon Help");
+ }
+ }
+
+ private Properties getClientProperties() throws IOException {
Properties prop = new Properties();
InputStream input = FalconCLI.class.getResourceAsStream(CLIENT_PROPERTIES);
- if (input != null) {
- prop.load(input);
- }
- return prop;
- }
-
+ if (input != null) {
+ prop.load(input);
+ }
+ return prop;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/a4d79f0c/client/src/main/java/org/apache/falcon/client/FalconCLIException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/client/FalconCLIException.java b/client/src/main/java/org/apache/falcon/client/FalconCLIException.java
index 367f5f5..ad13b4b 100644
--- a/client/src/main/java/org/apache/falcon/client/FalconCLIException.java
+++ b/client/src/main/java/org/apache/falcon/client/FalconCLIException.java
@@ -18,15 +18,15 @@
package org.apache.falcon.client;
-import java.io.IOException;
-import java.io.InputStream;
-
import com.sun.jersey.api.client.ClientResponse;
import org.apache.falcon.resource.APIResult;
import org.apache.falcon.resource.InstancesResult;
+import java.io.IOException;
+import java.io.InputStream;
+
/**
- * Exception thrown by FalconClient
+ * Exception thrown by FalconClient.
*/
public class FalconCLIException extends Exception {
@@ -40,9 +40,9 @@ public class FalconCLIException extends Exception {
super(msg, throwable);
}
- public static FalconCLIException fromReponse(ClientResponse clientResponse) {
+ public static FalconCLIException fromReponse(ClientResponse clientResponse) {
return new FalconCLIException(getMessage(clientResponse));
- }
+ }
private static String getMessage(ClientResponse clientResponse) {
String message;