falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajayyad...@apache.org
Subject falcon git commit: FALCON-1608 Base framework for Spring Shell based shell for Falcon. Contributed by Rajat Khandelwal.
Date Fri, 27 Nov 2015 19:20:20 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 50b020965 -> 17a4fcbd6


FALCON-1608 Base framework for Spring Shell based shell for Falcon. Contributed by Rajat Khandelwal.


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

Branch: refs/heads/master
Commit: 17a4fcbd6a300cc39ffc6ed2ef2d3efc95e4d01f
Parents: 50b0209
Author: Ajay Yadava <ajaynsit@gmail.com>
Authored: Fri Nov 27 23:23:03 2015 +0530
Committer: Ajay Yadava <ajaynsit@gmail.com>
Committed: Sat Nov 28 00:39:13 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |   3 +
 cli/pom.xml                                     | 207 +++++++++++++++++++
 .../falcon/cli/FalconCLIRuntimeException.java   |  37 ++++
 .../falcon/cli/commands/BaseFalconCommands.java | 136 ++++++++++++
 .../cli/commands/FalconConnectionCommands.java  |  56 +++++
 .../cli/commands/FalconEntityCommands.java      |  26 +++
 .../cli/commands/FalconInstanceCommands.java    |  26 +++
 .../apache/falcon/cli/skel/FalconBanner.java    |  61 ++++++
 .../cli/skel/FalconHistoryFileProvider.java     |  46 +++++
 .../falcon/cli/skel/FalconPromptProvider.java   |  47 +++++
 .../META-INF/spring/spring-shell-plugin.xml     |  40 ++++
 client/pom.xml                                  |   4 +-
 pom.xml                                         |  21 ++
 13 files changed, 708 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 780a5bd..028842c 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,9 @@ Trunk (Unreleased)
   INCOMPATIBLE CHANGES
 
   NEW FEATURES
+    FALCON-1596 Spring shell based CLI for Falcon
+	FALCON-1608 Base framework for Spring Shell based shell for Falcon (Rajat Khandelwal via
Ajay Yadava)
+ 
     FALCON-1480 Gather data transfer details of Hive DR. (Peeyush Bishnoi via Ajay Yadava)
     
     FALCON-1234 State Store for instances scheduled by Falcon (Pavan Kolamuri via Pallavi
Rao)

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/pom.xml
----------------------------------------------------------------------
diff --git a/cli/pom.xml b/cli/pom.xml
new file mode 100644
index 0000000..541a95a
--- /dev/null
+++ b/cli/pom.xml
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.falcon</groupId>
+        <artifactId>falcon-main</artifactId>
+        <version>0.9-SNAPSHOT</version>
+    </parent>
+    <artifactId>falcon-cli</artifactId>
+    <description>Apache Falcon CLI client</description>
+    <name>Apache Falcon CLI client</name>
+    <packaging>jar</packaging>
+
+    <profiles>
+        <profile>
+            <id>hadoop-2</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.hadoop</groupId>
+                    <artifactId>hadoop-auth</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.hadoop</groupId>
+                    <artifactId>hadoop-client</artifactId>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.falcon</groupId>
+            <artifactId>falcon-client</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-net</groupId>
+            <artifactId>commons-net</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-client</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-core</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-json</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>jline</groupId>
+            <artifactId>jline</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.stephenc.findbugs</groupId>
+            <artifactId>findbugs-annotations</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.shell</groupId>
+            <artifactId>spring-shell</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+            <version>4.0.3.RELEASE</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <!-- make the jar executable by adding a Main-Class and Class-Path to the
manifest -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>2.4.1</version>
+                <configuration>
+                    <shadedArtifactAttached>false</shadedArtifactAttached>
+                    <createDependencyReducedPom>false</createDependencyReducedPom>
+                    <artifactSet>
+                        <includes>
+                            <include>org.apache.hadoop:hadoop-auth</include>
+                            <include>org.apache.falcon:*</include>
+                            <include>org.apache.commons:*</include>
+                            <include>commons-logging:*</include>
+                            <include>commons-net:*</include>
+                            <include>commons-codec:*</include>
+                            <include>commons-io:*</include>
+                            <include>jline:*</include>
+                            <include>org.slf4j:*</include>
+                            <include>log4j:*</include>
+                            <include>com.sun.jersey:*</include>
+                            <include>org.springframework:*</include>
+                            <include>org.springframework.shell:*</include>
+                        </includes>
+                    </artifactSet>
+                    <filters>
+                        <filter>
+                            <artifact>*:*</artifact>
+                            <excludes>
+                                <exclude>META-INF/*.SF</exclude>
+                                <exclude>META-INF/*.DSA</exclude>
+                                <exclude>META-INF/*.RSA</exclude>
+                            </excludes>
+                        </filter>
+                    </filters>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <transformers>
+                                <transformer
+                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+                                <transformer
+                                        implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
+                                <transformer
+                                        implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer"/>
+                            </transformers>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/src/main/java/org/apache/falcon/cli/FalconCLIRuntimeException.java
----------------------------------------------------------------------
diff --git a/cli/src/main/java/org/apache/falcon/cli/FalconCLIRuntimeException.java b/cli/src/main/java/org/apache/falcon/cli/FalconCLIRuntimeException.java
new file mode 100644
index 0000000..b7fa4cd
--- /dev/null
+++ b/cli/src/main/java/org/apache/falcon/cli/FalconCLIRuntimeException.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.falcon.cli;
+
+/**
+ * Runtime exception in CLI. Since most methods are invoked through reflection, checked exceptions
+ * end up being thrown as UndeclaredThrowableException. Instead of that, let's throw our
own RuntimeException.
+ */
+public class FalconCLIRuntimeException extends RuntimeException {
+    public FalconCLIRuntimeException(Throwable e) {
+        super(e);
+    }
+
+    public FalconCLIRuntimeException(String message) {
+        super(message);
+    }
+
+    public FalconCLIRuntimeException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/src/main/java/org/apache/falcon/cli/commands/BaseFalconCommands.java
----------------------------------------------------------------------
diff --git a/cli/src/main/java/org/apache/falcon/cli/commands/BaseFalconCommands.java b/cli/src/main/java/org/apache/falcon/cli/commands/BaseFalconCommands.java
new file mode 100644
index 0000000..dbd28fb
--- /dev/null
+++ b/cli/src/main/java/org/apache/falcon/cli/commands/BaseFalconCommands.java
@@ -0,0 +1,136 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.falcon.cli.commands;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.falcon.cli.FalconCLIRuntimeException;
+import org.apache.falcon.client.FalconCLIException;
+import org.apache.falcon.client.FalconClient;
+import org.springframework.shell.core.ExecutionProcessor;
+import org.springframework.shell.event.ParseResult;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Common code for all falcon command classes.
+ */
+public class BaseFalconCommands implements ExecutionProcessor {
+    private static final String FALCON_URL = "FALCON_URL";
+    private static final String FALCON_URL_PROPERTY = "falcon.url";
+    private static final String DO_AS = "DO_AS";
+    private static final String DO_AS_PROPERTY = "do.as";
+    private static final String CLIENT_PROPERTIES = "/client.properties";
+    private static Properties clientProperties;
+    private static Properties backupProperties = new Properties();
+    private static FalconClient client;
+
+    protected static Properties getClientProperties() {
+        if (clientProperties == null) {
+            InputStream inputStream = null;
+            Properties prop = new Properties(System.getProperties());
+            prop.putAll(backupProperties);
+            try {
+                inputStream = BaseFalconCommands.class.getResourceAsStream(CLIENT_PROPERTIES);
+                if (inputStream != null) {
+                    try {
+                        prop.load(inputStream);
+                    } catch (IOException e) {
+                        throw new FalconCLIRuntimeException(e);
+                    }
+                }
+            } finally {
+                IOUtils.closeQuietly(inputStream);
+            }
+            String urlOverride = System.getenv(FALCON_URL);
+            if (urlOverride != null) {
+                prop.setProperty(FALCON_URL_PROPERTY, urlOverride);
+            }
+            if (prop.getProperty(FALCON_URL_PROPERTY) == null) {
+                throw new FalconCLIRuntimeException("Failed to get falcon url from environment
or client properties");
+            }
+            String doAsOverride = System.getenv(DO_AS);
+            if (doAsOverride != null) {
+                prop.setProperty(DO_AS_PROPERTY, doAsOverride);
+            }
+            clientProperties = prop;
+            backupProperties.clear();
+        }
+        return clientProperties;
+    }
+
+    static void setClientProperty(String key, String value) {
+        Properties props;
+        try {
+            props = getClientProperties();
+        } catch (FalconCLIRuntimeException e) {
+            props = backupProperties;
+        }
+        if (StringUtils.isBlank(value)) {
+            props.remove(key);
+        } else {
+            props.setProperty(key, value);
+        }
+        // Re-load client in the next call
+        client = null;
+    }
+
+    public static FalconClient getFalconClient() {
+        if (client == null) {
+            try {
+                client = new FalconClient(getClientProperties().getProperty(FALCON_URL_PROPERTY),
+                        getClientProperties());
+            } catch (FalconCLIException e) {
+                throw new FalconCLIRuntimeException(e.getMessage(), e.getCause());
+            }
+        }
+        return client;
+    }
+
+    @Override
+    public ParseResult beforeInvocation(ParseResult parseResult) {
+        Object[] args = parseResult.getArguments();
+        if (args != null) {
+            boolean allEqual = true;
+            for (int i = 1; i < args.length; i++) {
+                allEqual &= args[0].equals(args[i]);
+            }
+            if (allEqual) {
+                if (args[0] instanceof String) {
+                    String[] split = ((String) args[0]).split("\\s+");
+                    Object[] newArgs = new String[args.length];
+                    System.arraycopy(split, 0, newArgs, 0, split.length);
+                    parseResult = new ParseResult(parseResult.getMethod(), parseResult.getInstance(),
newArgs);
+                }
+            }
+        }
+        return parseResult;
+    }
+
+    @Override
+    public void afterReturningInvocation(ParseResult parseResult, Object o) {
+
+    }
+
+    @Override
+    public void afterThrowingInvocation(ParseResult parseResult, Throwable throwable) {
+    }
+}

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/src/main/java/org/apache/falcon/cli/commands/FalconConnectionCommands.java
----------------------------------------------------------------------
diff --git a/cli/src/main/java/org/apache/falcon/cli/commands/FalconConnectionCommands.java
b/cli/src/main/java/org/apache/falcon/cli/commands/FalconConnectionCommands.java
new file mode 100644
index 0000000..cabe5a8
--- /dev/null
+++ b/cli/src/main/java/org/apache/falcon/cli/commands/FalconConnectionCommands.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.falcon.cli.commands;
+
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Connection Commands.
+ */
+public class FalconConnectionCommands extends BaseFalconCommands {
+
+    @CliCommand(value = "get", help = "get properties")
+    public String getParameter(@CliOption(key = {"", "key"}, mandatory = false, help = "<key>")
final String key) {
+        if (StringUtils.isBlank(key)) {
+            return getClientProperties().toString();
+        }
+        return getClientProperties().getProperty(key);
+    }
+
+    @CliCommand(value = "set", help = "set properties")
+    public void setParameter(@CliOption(key = {"", "keyval"}, mandatory = true, help = "<key-val>")
+                             @Nonnull final String keyVal) {
+        String[] kvArray = keyVal.split("=");
+        String key = "";
+        String value = "";
+        if (kvArray.length > 0) {
+            key = kvArray[0];
+        }
+        if (kvArray.length > 1) {
+            value = kvArray[1];
+        }
+        setClientProperty(key, value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/src/main/java/org/apache/falcon/cli/commands/FalconEntityCommands.java
----------------------------------------------------------------------
diff --git a/cli/src/main/java/org/apache/falcon/cli/commands/FalconEntityCommands.java b/cli/src/main/java/org/apache/falcon/cli/commands/FalconEntityCommands.java
new file mode 100644
index 0000000..6e091ef
--- /dev/null
+++ b/cli/src/main/java/org/apache/falcon/cli/commands/FalconEntityCommands.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.falcon.cli.commands;
+
+/**
+ * Entity Commands.
+ */
+public class FalconEntityCommands extends BaseFalconCommands {
+
+}

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/src/main/java/org/apache/falcon/cli/commands/FalconInstanceCommands.java
----------------------------------------------------------------------
diff --git a/cli/src/main/java/org/apache/falcon/cli/commands/FalconInstanceCommands.java
b/cli/src/main/java/org/apache/falcon/cli/commands/FalconInstanceCommands.java
new file mode 100644
index 0000000..8f3a2fc
--- /dev/null
+++ b/cli/src/main/java/org/apache/falcon/cli/commands/FalconInstanceCommands.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.falcon.cli.commands;
+
+/**
+ * Instance commands.
+ */
+public class FalconInstanceCommands extends BaseFalconCommands {
+
+}

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/src/main/java/org/apache/falcon/cli/skel/FalconBanner.java
----------------------------------------------------------------------
diff --git a/cli/src/main/java/org/apache/falcon/cli/skel/FalconBanner.java b/cli/src/main/java/org/apache/falcon/cli/skel/FalconBanner.java
new file mode 100644
index 0000000..03c56c9
--- /dev/null
+++ b/cli/src/main/java/org/apache/falcon/cli/skel/FalconBanner.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.falcon.cli.skel;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.shell.plugin.support.DefaultBannerProvider;
+import org.springframework.shell.support.util.OsUtils;
+import org.springframework.stereotype.Component;
+
+/**
+ * The Class FalconBanner.
+ */
+@Component
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class FalconBanner extends DefaultBannerProvider {
+
+    @Override
+    public String getBanner() {
+        return new StringBuilder()
+                .append("=======================================").append(OsUtils.LINE_SEPARATOR)
+                .append("*                                     *").append(OsUtils.LINE_SEPARATOR)
+                .append("*            Falcon CLI               *").append(OsUtils.LINE_SEPARATOR)
+                .append("*                                     *").append(OsUtils.LINE_SEPARATOR)
+                .append("=======================================").append(OsUtils.LINE_SEPARATOR)
+                .toString();
+
+    }
+
+    @Override
+    public String getWelcomeMessage() {
+        return "Welcome to Falcon CLI";
+    }
+
+    @Override
+    public String getVersion() {
+        return getClass().getPackage().getImplementationVersion();
+    }
+
+    @Override
+    public String getProviderName() {
+        return "Falcon CLI";
+    }
+}

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/src/main/java/org/apache/falcon/cli/skel/FalconHistoryFileProvider.java
----------------------------------------------------------------------
diff --git a/cli/src/main/java/org/apache/falcon/cli/skel/FalconHistoryFileProvider.java b/cli/src/main/java/org/apache/falcon/cli/skel/FalconHistoryFileProvider.java
new file mode 100644
index 0000000..74d003a
--- /dev/null
+++ b/cli/src/main/java/org/apache/falcon/cli/skel/FalconHistoryFileProvider.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.falcon.cli.skel;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.shell.plugin.support.DefaultHistoryFileNameProvider;
+import org.springframework.stereotype.Component;
+
+/**
+ * The Class FalconHistoryFileProvider.
+ */
+@Component
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class FalconHistoryFileProvider extends DefaultHistoryFileNameProvider {
+
+    public String getHistoryFileName() {
+        return "falcon-cli-hist.log";
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.springframework.shell.plugin.support.DefaultHistoryFileNameProvider#name()
+     */
+    @Override
+    public String getProviderName() {
+        return "falcon client history provider";
+    }
+}

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/src/main/java/org/apache/falcon/cli/skel/FalconPromptProvider.java
----------------------------------------------------------------------
diff --git a/cli/src/main/java/org/apache/falcon/cli/skel/FalconPromptProvider.java b/cli/src/main/java/org/apache/falcon/cli/skel/FalconPromptProvider.java
new file mode 100644
index 0000000..d8ead5b
--- /dev/null
+++ b/cli/src/main/java/org/apache/falcon/cli/skel/FalconPromptProvider.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.falcon.cli.skel;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.shell.plugin.support.DefaultPromptProvider;
+import org.springframework.stereotype.Component;
+
+/**
+ * The Class FalconPromptProvider.
+ */
+@Component
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class FalconPromptProvider extends DefaultPromptProvider {
+
+    @Override
+    public String getPrompt() {
+        return "falcon-shell>";
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.springframework.shell.plugin.support.DefaultPromptProvider#name()
+     */
+    @Override
+    public String getProviderName() {
+        return "falcon prompt provider";
+    }
+}

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/cli/src/main/resources/META-INF/spring/spring-shell-plugin.xml
----------------------------------------------------------------------
diff --git a/cli/src/main/resources/META-INF/spring/spring-shell-plugin.xml b/cli/src/main/resources/META-INF/spring/spring-shell-plugin.xml
new file mode 100644
index 0000000..bd0fed4
--- /dev/null
+++ b/cli/src/main/resources/META-INF/spring/spring-shell-plugin.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
+
+    <context:component-scan base-package="org.apache.falcon.cli"/>
+
+    <bean id="falconConnectionCommands"
+          class="org.apache.falcon.cli.commands.FalconConnectionCommands">
+    </bean>
+    <bean id="falconEntityCommands"
+          class="org.apache.falcon.cli.commands.FalconEntityCommands">
+    </bean>
+    <bean id="falconInstanceCommands"
+          class="org.apache.falcon.cli.commands.FalconInstanceCommands">
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index d54fabf..902d319 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -28,8 +28,8 @@
         <version>0.9-SNAPSHOT</version>
     </parent>
     <artifactId>falcon-client</artifactId>
-    <description>Apache Falcon CLI client</description>
-    <name>Apache Falcon CLI client</name>
+    <description>Apache Falcon Java client</description>
+    <name>Apache Falcon Java client</name>
     <packaging>jar</packaging>
 
     <profiles>

http://git-wip-us.apache.org/repos/asf/falcon/blob/17a4fcbd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 678c87c..3ad8789 100644
--- a/pom.xml
+++ b/pom.xml
@@ -430,6 +430,7 @@
         <module>checkstyle</module>
         <module>build-tools</module>
         <module>client</module>
+        <module>cli</module>
         <module>metrics</module>
         <module>common</module>
         <module>test-util</module>
@@ -1094,7 +1095,27 @@
                 <artifactId>titan-berkeleyje-jre6</artifactId>
                 <version>0.4.2</version>
             </dependency>
+
+            <dependency>
+                <groupId>org.springframework.shell</groupId>
+                <artifactId>spring-shell</artifactId>
+                <version>1.1.0.RELEASE</version>
+            </dependency>
+
+            <dependency>
+                <groupId>jline</groupId>
+                <artifactId>jline</artifactId>
+                <version>2.12</version>
+            </dependency>
+
+            <dependency>
+                <groupId>commons-logging</groupId>
+                <artifactId>commons-logging</artifactId>
+                <version>1.1.3</version>
+            </dependency>
+
         </dependencies>
+
     </dependencyManagement>
 
     <build>


Mime
View raw message