Skip to content
This repository
Browse code

add CLI plugins

  • Loading branch information...
commit 47891ff8fa4320e01195b06bdcb8140e90c04d42 1 parent 719f4cf
Jarred Li authored July 03, 2012

Showing 56 changed files with 2,278 additions and 29 deletions. Show diff stats Hide diff stats

  1. 27  CLI/common/build.gradle
  2. 9  CLI/common/gradle.properties
  3. 0  CLI/{ → common}/src/main/java/org/springframework/data/hadoop/admin/cli/util/Log.java
  4. 0  CLI/{ → common}/src/main/java/org/springframework/data/hadoop/admin/cli/util/PropertyUtil.java
  5. 0  CLI/{ → common}/src/main/resources/META-INF/spring/spring-shell-plugin.xml
  6. 0  CLI/{ → common}/src/main/resources/rest-context.xml
  7. 0  CLI/{ → common}/src/test/java/org/springframework/data/hadoop/admin/cli/util/PropertyUtilTest.java
  8. 0  CLI/{ → plugin-admin}/README.txt
  9. 9  CLI/{ → plugin-admin}/build.gradle
  10. 0  CLI/{ → plugin-admin}/gradle.properties
  11. 0  CLI/{ → plugin-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/commands/BaseCommand.java
  12. 1  ...rarr; plugin-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/commands/ExecutionsCommand.java
  13. 0  CLI/{ → plugin-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/commands/InfoCommand.java
  14. 1  CLI/{ → plugin-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/commands/JobsCommand.java
  15. 2  ...{ → plugin-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/commands/ProjectCommand.java
  16. 0  CLI/{ → plugin-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/commands/ProjectType.java
  17. 13  CLI/{ → plugin-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/commands/TargetCommand.java
  18. 1  ... → plugin-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/commands/TemplateCommand.java
  19. 1  ... → plugin-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/commands/WorkflowCommand.java
  20. 2  ...-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminBannerProvider.java
  21. 2  ...rc/main/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminHistoryFileNameProvider.java
  22. 2  ...-admin}/src/main/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminPromptProvider.java
  23. 12  CLI/plugin-admin/src/main/resources/META-INF/spring/spring-shell-plugin.xml
  24. 23  CLI/plugin-admin/src/main/resources/rest-context.xml
  25. 3  ... → plugin-admin}/src/test/java/org/springframework/data/hadoop/admin/cli/commands/BaseCommandTest.java
  26. 9  ... → plugin-admin}/src/test/java/org/springframework/data/hadoop/admin/cli/commands/FileCommandTest.java
  27. 1  ...arr; plugin-admin}/src/test/java/org/springframework/data/hadoop/admin/cli/commands/ProjectCommandTest.java
  28. 0  ...in}/src/test/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminBannerProviderTest.java
  29. 0  ...est/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminHistoryFileNameProviderTest.java
  30. 0  ...in}/src/test/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminPromptProviderTest.java
  31. 24  CLI/plugin-hdfs/build.gradle
  32. 7  CLI/plugin-hdfs/gradle.properties
  33. 2  ...arr; plugin-hdfs/src/main/java/org/springframework/data/hadoop/admin/cli/hdfs}/commands/FsShellCommand.java
  34. 49  CLI/plugin-hdfs/src/main/java/org/springframework/data/hadoop/admin/cli/hdfs/commands/HdfsTargetCommand.java
  35. 75  ...ugin-hdfs/src/main/java/org/springframework/data/hadoop/admin/cli/hdfs/plugin/HDFSPluginBannerProvider.java
  36. 43  .../src/main/java/org/springframework/data/hadoop/admin/cli/hdfs/plugin/HDFSPluginHistoryFileNameProvider.java
  37. 45  ...ugin-hdfs/src/main/java/org/springframework/data/hadoop/admin/cli/hdfs/plugin/HDFSPluginPromptProvider.java
  38. 12  CLI/plugin-hdfs/src/main/resources/META-INF/spring/spring-shell-plugin.xml
  39. 87  ...dfs/src/test/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminBannerProviderTest.java
  40. 65  ...est/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminHistoryFileNameProviderTest.java
  41. 66  ...dfs/src/test/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminPromptProviderTest.java
  42. 23  CLI/plugin-mapreduce/build.gradle
  43. 7  CLI/plugin-mapreduce/gradle.properties
  44. 40  ...ugin-mapreduce/src/main/java/org/springframework/data/hadoop/admin/cli/mapreduce/commands/MRJobCommand.java
  45. 75  ...src/main/java/org/springframework/data/hadoop/admin/cli/mapreduce/plugin/MapReducePluginBannerProvider.java
  46. 43  ...java/org/springframework/data/hadoop/admin/cli/mapreduce/plugin/MapReducePluginHistoryFileNameProvider.java
  47. 45  ...src/main/java/org/springframework/data/hadoop/admin/cli/mapreduce/plugin/MapReducePluginPromptProvider.java
  48. 12  CLI/plugin-mapreduce/src/main/resources/META-INF/spring/spring-shell-plugin.xml
  49. 87  ...uce/src/test/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminBannerProviderTest.java
  50. 65  ...est/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminHistoryFileNameProviderTest.java
  51. 66  ...uce/src/test/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminPromptProviderTest.java
  52. 3  build.gradle
  53. 3  scalable-service/master/build.gradle
  54. 1,236  scalable-service/master/example.log
  55. 2  service/build.gradle
  56. 7  settings.gradle
27  CLI/common/build.gradle
... ...
@@ -0,0 +1,27 @@
  1
+
  2
+description = 'Spring Hadoop Admin CLI common'
  3
+apply plugin: 'eclipse'
  4
+
  5
+repositories {
  6
+	maven { url "http://spring-roo-repository.springsource.org/release" }
  7
+}
  8
+
  9
+dependencies {
  10
+	compile "org.springframework.shell:spring-shell:$springShellVersion"
  11
+	compile "commons-configuration:commons-configuration:$commonsConfigurationVersion"
  12
+	compile "commons-logging:commons-logging:$commonsLoggingVersion"
  13
+}
  14
+
  15
+jar {
  16
+	baseName "cli-common"
  17
+}
  18
+
  19
+
  20
+eclipse {
  21
+	project {
  22
+		name = "cli-common"
  23
+	}
  24
+}
  25
+
  26
+
  27
+defaultTasks 'clean', 'build'
9  CLI/common/gradle.properties
... ...
@@ -0,0 +1,9 @@
  1
+springVersion = 3.1.1.RELEASE
  2
+springShellVersion = 1.0.0.BUILD-SNAPSHOT
  3
+commonsConfigurationVersion = 1.8
  4
+commonsLoggingVersion = 1.1.1
  5
+
  6
+
  7
+
  8
+
  9
+
0  ...ringframework/data/hadoop/admin/cli/util/Log.java → ...ringframework/data/hadoop/admin/cli/util/Log.java
File renamed without changes
0  ...work/data/hadoop/admin/cli/util/PropertyUtil.java → ...work/data/hadoop/admin/cli/util/PropertyUtil.java
File renamed without changes
0  ...resources/META-INF/spring/spring-shell-plugin.xml → ...resources/META-INF/spring/spring-shell-plugin.xml
File renamed without changes
0  CLI/src/main/resources/rest-context.xml → CLI/common/src/main/resources/rest-context.xml
File renamed without changes
0  .../data/hadoop/admin/cli/util/PropertyUtilTest.java → .../data/hadoop/admin/cli/util/PropertyUtilTest.java
File renamed without changes
0  CLI/README.txt → CLI/plugin-admin/README.txt
File renamed without changes
9  CLI/build.gradle → CLI/plugin-admin/build.gradle
... ...
@@ -1,5 +1,5 @@
1 1
 
2  
-description = 'Spring Hadoop Admin CLI'
  2
+description = 'Spring Hadoop Admin CLI admin plugin'
3 3
 apply plugin: 'eclipse'
4 4
 
5 5
 repositories {
@@ -7,6 +7,9 @@ repositories {
7 7
 }
8 8
 
9 9
 dependencies {
  10
+	compile project(':CLI:common')
  11
+	compile project(':CLI:plugin-hdfs')
  12
+	compile project(':CLI:plugin-mapreduce')
10 13
 	compile "org.springframework.shell:spring-shell:$springShellVersion"
11 14
 	compile "org.springframework:spring-web:$springVersion"
12 15
 }
@@ -23,7 +26,7 @@ project.ext.manifestClasspath = "dependency/" + springShellJar.name + " "
23 26
 project.ext.manifestClasspath = project.ext.manifestClasspath + configurations.runtime.collect{ File file -> "dependency/"+file.name}.join(' ')
24 27
 
25 28
 jar {
26  
-	baseName "spring-hadoop-admin-cli"
  29
+	baseName "plugin-admin"
27 30
 	manifest {
28 31
 		attributes 'Main-Class' : 'org.springframework.shell.Bootstrap', "Class-Path" : project.ext.manifestClasspath
29 32
 	}	
@@ -32,7 +35,7 @@ jar {
32 35
 
33 36
 eclipse {
34 37
 	project {
35  
-		name = "spring-hadoop-admin-cli"
  38
+		name = "plugin-admin"
36 39
 	}
37 40
 }
38 41
 
0  CLI/gradle.properties → CLI/plugin-admin/gradle.properties
File renamed without changes
0  ...k/data/hadoop/admin/cli/commands/BaseCommand.java → ...k/data/hadoop/admin/cli/commands/BaseCommand.java
File renamed without changes
1  .../hadoop/admin/cli/commands/ExecutionsCommand.java → .../hadoop/admin/cli/commands/ExecutionsCommand.java
@@ -17,6 +17,7 @@
17 17
 
18 18
 import java.util.Date;
19 19
 
  20
+import org.springframework.data.hadoop.admin.cli.commands.BaseCommand;
20 21
 import org.springframework.roo.shell.CliAvailabilityIndicator;
21 22
 import org.springframework.roo.shell.CliCommand;
22 23
 import org.springframework.roo.shell.CliOption;
0  ...k/data/hadoop/admin/cli/commands/InfoCommand.java → ...k/data/hadoop/admin/cli/commands/InfoCommand.java
File renamed without changes
1  ...k/data/hadoop/admin/cli/commands/JobsCommand.java → ...k/data/hadoop/admin/cli/commands/JobsCommand.java
@@ -15,6 +15,7 @@
15 15
  */
16 16
 package org.springframework.data.hadoop.admin.cli.commands;
17 17
 
  18
+import org.springframework.data.hadoop.admin.cli.commands.BaseCommand;
18 19
 import org.springframework.roo.shell.CliAvailabilityIndicator;
19 20
 import org.springframework.roo.shell.CliCommand;
20 21
 import org.springframework.roo.shell.CliOption;
2  ...ata/hadoop/admin/cli/commands/ProjectCommand.java → ...ata/hadoop/admin/cli/commands/ProjectCommand.java
@@ -25,6 +25,8 @@
25 25
 import java.util.zip.ZipInputStream;
26 26
 
27 27
 import org.codehaus.jackson.map.ObjectMapper;
  28
+import org.springframework.data.hadoop.admin.cli.commands.BaseCommand;
  29
+import org.springframework.data.hadoop.admin.cli.commands.ProjectType;
28 30
 import org.springframework.data.hadoop.admin.cli.util.Log;
29 31
 import org.springframework.roo.shell.CliCommand;
30 32
 import org.springframework.roo.shell.CliOption;
0  ...k/data/hadoop/admin/cli/commands/ProjectType.java → ...k/data/hadoop/admin/cli/commands/ProjectType.java
File renamed without changes
13  ...data/hadoop/admin/cli/commands/TargetCommand.java → ...data/hadoop/admin/cli/commands/TargetCommand.java
@@ -46,17 +46,4 @@ public void target(@CliOption(key = { "url" }, mandatory = true, help = "Spring
46 46
 		}
47 47
 	}
48 48
 	
49  
-	/**
50  
-	 * set HDFS URL
51  
-	 * 
52  
-	 * @param url HDFS url, for example, "hdfs://localhost:9000".
53  
-	 */
54  
-	@CliCommand(value = "hdfs target", help = "set HDFS URL")
55  
-	public void dfsName(@CliOption(key = { "url" }, mandatory = true, help = "HDFS URL") final String url) {
56  
-		try {
57  
-			PropertyUtil.setDfsName(url);
58  
-		} catch (ConfigurationException e) {
59  
-			Log.error("set target url failed. " + e.getMessage());
60  
-		}
61  
-	}
62 49
 }
1  ...ta/hadoop/admin/cli/commands/TemplateCommand.java → ...ta/hadoop/admin/cli/commands/TemplateCommand.java
@@ -19,6 +19,7 @@
19 19
 import java.io.FileFilter;
20 20
 
21 21
 import org.springframework.core.io.FileSystemResource;
  22
+import org.springframework.data.hadoop.admin.cli.commands.BaseCommand;
22 23
 import org.springframework.data.hadoop.admin.cli.util.Log;
23 24
 import org.springframework.roo.shell.CliAvailabilityIndicator;
24 25
 import org.springframework.roo.shell.CliCommand;
1  ...ta/hadoop/admin/cli/commands/WorkflowCommand.java → ...ta/hadoop/admin/cli/commands/WorkflowCommand.java
@@ -19,6 +19,7 @@
19 19
 import java.io.FileFilter;
20 20
 
21 21
 import org.springframework.core.io.FileSystemResource;
  22
+import org.springframework.data.hadoop.admin.cli.commands.BaseCommand;
22 23
 import org.springframework.data.hadoop.admin.cli.util.Log;
23 24
 import org.springframework.roo.shell.CliAvailabilityIndicator;
24 25
 import org.springframework.roo.shell.CliCommand;
2  ...n/cli/plugin/SpringHadoopAdminBannerProvider.java → ...n/cli/plugin/SpringHadoopAdminBannerProvider.java
@@ -30,7 +30,7 @@
30 30
  *
31 31
  */
32 32
 @Component
33  
-@Order(Ordered.HIGHEST_PRECEDENCE)
  33
+@Order(Ordered.LOWEST_PRECEDENCE -2)
34 34
 public class SpringHadoopAdminBannerProvider extends DefaultBannerProvider 
35 35
 				implements CommandMarker {
36 36
 
2  ...gin/SpringHadoopAdminHistoryFileNameProvider.java → ...gin/SpringHadoopAdminHistoryFileNameProvider.java
@@ -28,7 +28,7 @@
28 28
  *
29 29
  */
30 30
 @Component
31  
-@Order(Ordered.HIGHEST_PRECEDENCE)
  31
+@Order(Ordered.LOWEST_PRECEDENCE -2)
32 32
 public class SpringHadoopAdminHistoryFileNameProvider extends DefaultHistoryFileNameProvider{
33 33
 
34 34
 	public String getHistoryFileName() {
2  ...n/cli/plugin/SpringHadoopAdminPromptProvider.java → ...n/cli/plugin/SpringHadoopAdminPromptProvider.java
@@ -27,7 +27,7 @@
27 27
  *
28 28
  */
29 29
 @Component
30  
-@Order(Ordered.HIGHEST_PRECEDENCE)
  30
+@Order(Ordered.LOWEST_PRECEDENCE -2)
31 31
 public class SpringHadoopAdminPromptProvider extends DefaultPromptProvider {
32 32
 
33 33
 	/* (non-Javadoc)
12  CLI/plugin-admin/src/main/resources/META-INF/spring/spring-shell-plugin.xml
... ...
@@ -0,0 +1,12 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<beans xmlns="http://www.springframework.org/schema/beans"
  3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4
+	xmlns:context="http://www.springframework.org/schema/context"
  5
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  6
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
  7
+
  8
+	<context:component-scan base-package="org.springframework.data.hadoop.admin.cli">
  9
+		<context:include-filter type="regex" expression="(commands|plugin)\..*"/>
  10
+	</context:component-scan>
  11
+
  12
+</beans>
23  CLI/plugin-admin/src/main/resources/rest-context.xml
... ...
@@ -0,0 +1,23 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<beans xmlns="http://www.springframework.org/schema/beans"
  3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
  5
+
  6
+	<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
  7
+		<!-- 
  8
+		<property name="messageConverters">
  9
+			<list>
  10
+				<ref bean="stringHttpMessageConverter"/>
  11
+				<ref bean="jsonConverter" />
  12
+			</list>
  13
+		</property>
  14
+		 -->
  15
+	</bean>
  16
+	<bean id="jsonConverter"
  17
+		class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
  18
+		<property name="supportedMediaTypes" value="application/json" />
  19
+	</bean>
  20
+	<bean id="stringHttpMessageConverter"
  21
+		class="org.springframework.http.converter.StringHttpMessageConverter" />
  22
+
  23
+</beans>
3  ...ta/hadoop/admin/cli/commands/BaseCommandTest.java → ...ta/hadoop/admin/cli/commands/BaseCommandTest.java
@@ -19,6 +19,7 @@
19 19
 import org.junit.Assert;
20 20
 import org.junit.Before;
21 21
 import org.junit.Test;
  22
+import org.springframework.data.hadoop.admin.cli.commands.BaseCommand;
22 23
 
23 24
 /**
24 25
  * @author Jarred Li
@@ -45,7 +46,7 @@ public void tearDown() throws Exception {
45 46
 	}
46 47
 
47 48
 	/**
48  
-	 * Test method for {@link org.springframework.data.hadoop.admin.cli.commands.BaseCommand#setCommandURL(java.lang.String)}.
  49
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.mapreduce.commands.BaseCommand#setCommandURL(java.lang.String)}.
49 50
 	 */
50 51
 	@Test
51 52
 	public void testSetCommandURL() {
9  ...ta/hadoop/admin/cli/commands/FileCommandTest.java → ...ta/hadoop/admin/cli/commands/FileCommandTest.java
@@ -18,6 +18,7 @@
18 18
 import org.junit.After;
19 19
 import org.junit.Before;
20 20
 import org.junit.Test;
  21
+import org.springframework.data.hadoop.admin.cli.commands.WorkflowCommand;
21 22
 
22 23
 /**
23 24
  * @author Jarred Li
@@ -44,7 +45,7 @@ public void tearDown() throws Exception {
44 45
 	}
45 46
 
46 47
 	/**
47  
-	 * Test method for {@link org.springframework.data.hadoop.admin.cli.commands.WorkflowCommand#listFiles()}.
  48
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.mapreduce.commands.WorkflowCommand#listFiles()}.
48 49
 	 */
49 50
 	@Test
50 51
 	public void testListFiles() {
@@ -52,7 +53,7 @@ public void testListFiles() {
52 53
 	}
53 54
 
54 55
 	/**
55  
-	 * Test method for {@link org.springframework.data.hadoop.admin.cli.commands.WorkflowCommand#downloadFile(java.lang.String)}.
  56
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.mapreduce.commands.WorkflowCommand#downloadFile(java.lang.String)}.
56 57
 	 */
57 58
 	@Test
58 59
 	public void testDownloadFile() {
@@ -60,7 +61,7 @@ public void testDownloadFile() {
60 61
 	}
61 62
 
62 63
 	/**
63  
-	 * Test method for {@link org.springframework.data.hadoop.admin.cli.commands.WorkflowCommand#uploadFile(java.lang.String, java.lang.String)}.
  64
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.mapreduce.commands.WorkflowCommand#uploadFile(java.lang.String, java.lang.String)}.
64 65
 	 */
65 66
 	@Test
66 67
 	public void testUploadFile() {
@@ -68,7 +69,7 @@ public void testUploadFile() {
68 69
 	}
69 70
 
70 71
 	/**
71  
-	 * Test method for {@link org.springframework.data.hadoop.admin.cli.commands.WorkflowCommand#deleteFile(java.lang.String)}.
  72
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.mapreduce.commands.WorkflowCommand#deleteFile(java.lang.String)}.
72 73
 	 */
73 74
 	@Test
74 75
 	public void testDeleteFile() {
1  ...hadoop/admin/cli/commands/ProjectCommandTest.java → ...hadoop/admin/cli/commands/ProjectCommandTest.java
@@ -23,6 +23,7 @@
23 23
 import org.junit.After;
24 24
 import org.junit.Before;
25 25
 import org.junit.Test;
  26
+import org.springframework.data.hadoop.admin.cli.commands.ProjectCommand;
26 27
 
27 28
 /**
28 29
  * @author Jarred Li
0  ...i/plugin/SpringHadoopAdminBannerProviderTest.java → ...i/plugin/SpringHadoopAdminBannerProviderTest.java
File renamed without changes
0  ...SpringHadoopAdminHistoryFileNameProviderTest.java → ...SpringHadoopAdminHistoryFileNameProviderTest.java
File renamed without changes
0  ...i/plugin/SpringHadoopAdminPromptProviderTest.java → ...i/plugin/SpringHadoopAdminPromptProviderTest.java
File renamed without changes
24  CLI/plugin-hdfs/build.gradle
... ...
@@ -0,0 +1,24 @@
  1
+
  2
+description = 'Spring Hadoop Admin CLI HDFS plugin'
  3
+apply plugin: 'eclipse'
  4
+
  5
+repositories {
  6
+	maven { url "http://spring-roo-repository.springsource.org/release" }
  7
+}
  8
+
  9
+dependencies {
  10
+	compile project(':CLI:common')
  11
+	compile "org.springframework.shell:spring-shell:$springShellVersion"
  12
+	compile "org.apache.hadoop:hadoop-core:$hadoopVersion"
  13
+}
  14
+
  15
+
  16
+
  17
+eclipse {
  18
+	project {
  19
+		name = "plugin-hdfs"
  20
+	}
  21
+}
  22
+
  23
+
  24
+defaultTasks 'clean', 'build'
7  CLI/plugin-hdfs/gradle.properties
... ...
@@ -0,0 +1,7 @@
  1
+springVersion = 3.1.1.RELEASE
  2
+springShellVersion = 1.0.0.BUILD-SNAPSHOT
  3
+hadoopVersion = 1.0.3
  4
+
  5
+
  6
+
  7
+
2  ...ata/hadoop/admin/cli/commands/FsShellCommand.java → ...adoop/admin/cli/hdfs/commands/FsShellCommand.java
@@ -13,7 +13,7 @@
13 13
  * See the License for the specific language governing permissions and
14 14
  * limitations under the License.
15 15
  */
16  
-package org.springframework.data.hadoop.admin.cli.commands;
  16
+package org.springframework.data.hadoop.admin.cli.hdfs.commands;
17 17
 
18 18
 import java.util.ArrayList;
19 19
 import java.util.Arrays;
49  ...plugin-hdfs/src/main/java/org/springframework/data/hadoop/admin/cli/hdfs/commands/HdfsTargetCommand.java
... ...
@@ -0,0 +1,49 @@
  1
+/*
  2
+ * Copyright 2011-2012 the original author or authors.
  3
+ * 
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ * 
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ * 
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+package org.springframework.data.hadoop.admin.cli.hdfs.commands;
  17
+
  18
+import org.apache.commons.configuration.ConfigurationException;
  19
+import org.springframework.data.hadoop.admin.cli.util.Log;
  20
+import org.springframework.data.hadoop.admin.cli.util.PropertyUtil;
  21
+import org.springframework.roo.shell.CliCommand;
  22
+import org.springframework.roo.shell.CliOption;
  23
+import org.springframework.roo.shell.CommandMarker;
  24
+import org.springframework.stereotype.Component;
  25
+
  26
+/**
  27
+ * Target command to set HDFS URL
  28
+ * 
  29
+ * @author Jarred Li
  30
+ *
  31
+ */
  32
+@Component
  33
+public class HdfsTargetCommand implements CommandMarker {
  34
+
  35
+	
  36
+	/**
  37
+	 * set HDFS URL
  38
+	 * 
  39
+	 * @param url HDFS url, for example, "hdfs://localhost:9000".
  40
+	 */
  41
+	@CliCommand(value = "hdfs target", help = "set HDFS URL")
  42
+	public void dfsName(@CliOption(key = { "url" }, mandatory = true, help = "HDFS URL") final String url) {
  43
+		try {
  44
+			PropertyUtil.setDfsName(url);
  45
+		} catch (ConfigurationException e) {
  46
+			Log.error("set target url failed. " + e.getMessage());
  47
+		}
  48
+	}
  49
+}
75  ...n-hdfs/src/main/java/org/springframework/data/hadoop/admin/cli/hdfs/plugin/HDFSPluginBannerProvider.java
... ...
@@ -0,0 +1,75 @@
  1
+/*
  2
+ * Copyright 2011-2012 the original author or authors.
  3
+ * 
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ * 
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ * 
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+package org.springframework.data.hadoop.admin.cli.hdfs.plugin;
  17
+
  18
+import org.springframework.core.Ordered;
  19
+import org.springframework.core.annotation.Order;
  20
+import org.springframework.roo.shell.CliCommand;
  21
+import org.springframework.roo.shell.CommandMarker;
  22
+import org.springframework.roo.support.util.StringUtils;
  23
+import org.springframework.shell.plugin.support.DefaultBannerProvider;
  24
+import org.springframework.stereotype.Component;
  25
+
  26
+/**
  27
+ * Banner Provider to customize Spring Shell Banner
  28
+ * 
  29
+ * @author Jarred Li
  30
+ *
  31
+ */
  32
+@Component
  33
+@Order(Ordered.LOWEST_PRECEDENCE)
  34
+public class HDFSPluginBannerProvider extends DefaultBannerProvider 
  35
+				implements CommandMarker {
  36
+
  37
+	/* (non-Javadoc)
  38
+	 * @see org.springframework.shell.plugin.BannerProvider#getBanner()
  39
+	 */
  40
+	@CliCommand(value = { "version" }, help = "Displays current CLI version")
  41
+	public String getBanner() {
  42
+		StringBuffer buf = new StringBuffer();
  43
+		buf.append("=======================================" + StringUtils.LINE_SEPARATOR);
  44
+		buf.append("*                                      *"+ StringUtils.LINE_SEPARATOR);
  45
+		buf.append("*                                      *"+ StringUtils.LINE_SEPARATOR);
  46
+		buf.append("*      CLI Plugin for HDFS             *" +StringUtils.LINE_SEPARATOR);
  47
+		buf.append("*                                      *"+ StringUtils.LINE_SEPARATOR);
  48
+		buf.append("*                                      *"+ StringUtils.LINE_SEPARATOR);
  49
+		buf.append("=======================================" + StringUtils.LINE_SEPARATOR);
  50
+		buf.append("Verson:" + this.getVersion());
  51
+		return buf.toString();
  52
+
  53
+	}
  54
+
  55
+	/* (non-Javadoc)
  56
+	 * @see org.springframework.shell.plugin.BannerProvider#getVersion()
  57
+	 */
  58
+	public String getVersion() {
  59
+		return "1.0.0";
  60
+	}
  61
+
  62
+	/* (non-Javadoc)
  63
+	 * @see org.springframework.shell.plugin.BannerProvider#getWelcomeMessage()
  64
+	 */
  65
+	public String getWelcomeMessage() {
  66
+		return "Welcome to HDFS CLI";
  67
+	}
  68
+	
  69
+	@Override
  70
+	public String name() {
  71
+		return "hdfs cli banner provider";
  72
+	}
  73
+	
  74
+
  75
+}
43  ...c/main/java/org/springframework/data/hadoop/admin/cli/hdfs/plugin/HDFSPluginHistoryFileNameProvider.java
... ...
@@ -0,0 +1,43 @@
  1
+/*
  2
+ * Copyright 2011-2012 the original author or authors.
  3
+ * 
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ * 
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ * 
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package org.springframework.data.hadoop.admin.cli.hdfs.plugin;
  18
+
  19
+import org.springframework.core.Ordered;
  20
+import org.springframework.core.annotation.Order;
  21
+import org.springframework.shell.plugin.support.DefaultHistoryFileNameProvider;
  22
+import org.springframework.stereotype.Component;
  23
+
  24
+/**
  25
+ * history file name provider to customize Spring Shell's log file 
  26
+ * 
  27
+ * @author Jarred Li
  28
+ *
  29
+ */
  30
+@Component
  31
+@Order(Ordered.LOWEST_PRECEDENCE)
  32
+public class HDFSPluginHistoryFileNameProvider extends DefaultHistoryFileNameProvider{
  33
+
  34
+	public String getHistoryFileName() {
  35
+		return "hdfs-cli.log";
  36
+	}
  37
+
  38
+	@Override
  39
+	public String name() {
  40
+		return "hdfs cli history file name provider";
  41
+	}
  42
+	
  43
+}
45  ...n-hdfs/src/main/java/org/springframework/data/hadoop/admin/cli/hdfs/plugin/HDFSPluginPromptProvider.java
... ...
@@ -0,0 +1,45 @@
  1
+/*
  2
+ * Copyright 2011-2012 the original author or authors.
  3
+ * 
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ * 
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ * 
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+package org.springframework.data.hadoop.admin.cli.hdfs.plugin;
  17
+
  18
+import org.springframework.core.Ordered;
  19
+import org.springframework.core.annotation.Order;
  20
+import org.springframework.shell.plugin.support.DefaultPromptProvider;
  21
+import org.springframework.stereotype.Component;
  22
+
  23
+/**
  24
+ * Propmpt provider to customize Spring Shell's prompt text
  25
+ * 
  26
+ * @author Jarred Li
  27
+ *
  28
+ */
  29
+@Component
  30
+@Order(Ordered.LOWEST_PRECEDENCE)
  31
+public class HDFSPluginPromptProvider extends DefaultPromptProvider {
  32
+
  33
+	/* (non-Javadoc)
  34
+	 * @see org.springframework.shell.plugin.PromptProvider#getPromptText()
  35
+	 */
  36
+	public String getPromptText() {		
  37
+		return "HDFS-CLI>";
  38
+	}
  39
+	
  40
+	@Override
  41
+	public String name() {
  42
+		return "hdfs cli prompt provider";
  43
+	}
  44
+
  45
+}
12  CLI/plugin-hdfs/src/main/resources/META-INF/spring/spring-shell-plugin.xml
... ...
@@ -0,0 +1,12 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<beans xmlns="http://www.springframework.org/schema/beans"
  3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4
+	xmlns:context="http://www.springframework.org/schema/context"
  5
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  6
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
  7
+
  8
+	<context:component-scan base-package="org.springframework.data.hadoop.admin.cli.hdfs">
  9
+		<context:include-filter type="regex" expression="(commands|plugin)\..*"/>
  10
+	</context:component-scan>
  11
+
  12
+</beans>
87  .../src/test/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminBannerProviderTest.java
... ...
@@ -0,0 +1,87 @@
  1
+/*
  2
+ * Copyright 2011-2012 the original author or authors.
  3
+ * 
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ * 
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ * 
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+package org.springframework.data.hadoop.admin.cli.plugin;
  17
+
  18
+import org.junit.After;
  19
+import org.junit.Assert;
  20
+import org.junit.Before;
  21
+import org.junit.Test;
  22
+import org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginBannerProvider;
  23
+
  24
+
  25
+/**
  26
+ * @author Jarred Li
  27
+ *
  28
+ */
  29
+public class SpringHadoopAdminBannerProviderTest{
  30
+
  31
+	private HDFSPluginBannerProvider bannerProvider;
  32
+	
  33
+
  34
+	/**
  35
+	 * @throws java.lang.Exception
  36
+	 */
  37
+	@Before
  38
+	public void setUp() throws Exception {
  39
+		bannerProvider = new HDFSPluginBannerProvider();
  40
+	}
  41
+
  42
+	/**
  43
+	 * @throws java.lang.Exception
  44
+	 */
  45
+	@After
  46
+	public void tearDown() throws Exception {
  47
+		bannerProvider = null;
  48
+	}
  49
+
  50
+
  51
+	/**
  52
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginBannerProvider#getBanner()}.
  53
+	 */
  54
+	@Test
  55
+	public void testGetBanner() {
  56
+		String banner = bannerProvider.getBanner();
  57
+		Assert.assertNotNull(banner);
  58
+	}
  59
+
  60
+	/**
  61
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginBannerProvider#getVersion()}.
  62
+	 */
  63
+	@Test
  64
+	public void testGetVersion() {
  65
+		String version = bannerProvider.getVersion();
  66
+		Assert.assertNotNull(version);
  67
+	}
  68
+
  69
+	/**
  70
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginBannerProvider#getWelcomMessage()}.
  71
+	 */
  72
+	@Test
  73
+	public void testGetWelcomMessage() {
  74
+		String msg = bannerProvider.getWelcomeMessage();
  75
+		Assert.assertNotNull(msg);
  76
+	}
  77
+
  78
+	/**
  79
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginBannerProvider#name()}.
  80
+	 */
  81
+	@Test
  82
+	public void testName() {
  83
+		String name = bannerProvider.name();
  84
+		Assert.assertNotNull(name);
  85
+	}
  86
+
  87
+}
65  .../java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminHistoryFileNameProviderTest.java
... ...
@@ -0,0 +1,65 @@
  1
+/*
  2
+ * Copyright 2011-2012 the original author or authors.
  3
+ * 
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ * 
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ * 
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+package org.springframework.data.hadoop.admin.cli.plugin;
  17
+
  18
+import org.junit.After;
  19
+import org.junit.Assert;
  20
+import org.junit.Before;
  21
+import org.junit.Test;
  22
+import org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginHistoryFileNameProvider;
  23
+
  24
+/**
  25
+ * @author Jarred Li
  26
+ *
  27
+ */
  28
+public class SpringHadoopAdminHistoryFileNameProviderTest {
  29
+
  30
+	private HDFSPluginHistoryFileNameProvider fileNameProvider;
  31
+	/**
  32
+	 * @throws java.lang.Exception
  33
+	 */
  34
+	@Before
  35
+	public void setUp() throws Exception {
  36
+		fileNameProvider = new HDFSPluginHistoryFileNameProvider(); 
  37
+	}
  38
+
  39
+	/**
  40
+	 * @throws java.lang.Exception
  41
+	 */
  42
+	@After
  43
+	public void tearDown() throws Exception {
  44
+		fileNameProvider = null;
  45
+	}
  46
+
  47
+	/**
  48
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginHistoryFileNameProvider#getHistoryFileName()}.
  49
+	 */
  50
+	@Test
  51
+	public void testGetHistoryFileName() {
  52
+		String fileName = fileNameProvider.getHistoryFileName();
  53
+		Assert.assertNotNull(fileName);
  54
+	}
  55
+
  56
+	/**
  57
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginHistoryFileNameProvider#name()}.
  58
+	 */
  59
+	@Test
  60
+	public void testName() {
  61
+		String name = fileNameProvider.name();
  62
+		Assert.assertNotNull(name);
  63
+	}
  64
+
  65
+}
66  .../src/test/java/org/springframework/data/hadoop/admin/cli/plugin/SpringHadoopAdminPromptProviderTest.java
... ...
@@ -0,0 +1,66 @@
  1
+/*
  2
+ * Copyright 2011-2012 the original author or authors.
  3
+ * 
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ * 
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ * 
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+package org.springframework.data.hadoop.admin.cli.plugin;
  17
+
  18
+import org.junit.After;
  19
+import org.junit.Assert;
  20
+import org.junit.Before;
  21
+import org.junit.Test;
  22
+import org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginPromptProvider;
  23
+
  24
+/**
  25
+ * @author Jarred Li
  26
+ *
  27
+ */
  28
+public class SpringHadoopAdminPromptProviderTest {
  29
+
  30
+	private HDFSPluginPromptProvider provider;
  31
+
  32
+	/**
  33
+	 * @throws java.lang.Exception
  34
+	 */
  35
+	@Before
  36
+	public void setUp() throws Exception {
  37
+		provider = new HDFSPluginPromptProvider();
  38
+	}
  39
+
  40
+	/**
  41
+	 * @throws java.lang.Exception
  42
+	 */
  43
+	@After
  44
+	public void tearDown() throws Exception {
  45
+		provider = null;
  46
+	}
  47
+
  48
+	/**
  49
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginPromptProvider#getPromptText()}.
  50
+	 */
  51
+	@Test
  52
+	public void testGetPromptText() {
  53
+		String prompt = provider.getPromptText();
  54
+		Assert.assertNotNull(prompt);
  55
+	}
  56
+
  57
+	/**
  58
+	 * Test method for {@link org.springframework.data.hadoop.admin.cli.hdfs.plugin.HDFSPluginPromptProvider#name()}.
  59
+	 */
  60
+	@Test
  61
+	public void testName() {
  62
+		String name = provider.name();
  63
+		Assert.assertNotNull(name);
  64
+	}
  65
+
  66
+}
23  CLI/plugin-mapreduce/build.gradle
... ...
@@ -0,0 +1,23 @@
  1
+
  2
+description = 'Spring Hadoop Admin CLI MapReduce plugin'
  3
+apply plugin: 'eclipse'
  4
+
  5
+repositories {
  6
+	maven { url "http://spring-roo-repository.springsource.org/release" }
  7
+}
  8
+
  9
+dependencies {
  10
+	compile project(':CLI:common')
  11
+	compile "org.springframework.shell:spring-shell:$springShellVersion"
  12
+	compile "org.apache.hadoop:hadoop-core:$hadoopVersion"
  13
+}
  14
+
  15
+
  16
+eclipse {
  17
+	project {
  18
+		name = "plugin-mapreduce"
  19
+	}
  20
+}
  21
+
  22
+
  23
+defaultTasks 'clean', 'build'
7  CLI/plugin-mapreduce/gradle.properties
... ...
@@ -0,0 +1,7 @@
  1
+springVersion = 3.1.1.RELEASE
  2
+springShellVersion = 1.0.0.BUILD-SNAPSHOT
  3
+hadoopVersion = 1.0.3
  4
+
  5
+
  6
+
  7
+
40  ...n-mapreduce/src/main/java/org/springframework/data/hadoop/admin/cli/mapreduce/commands/MRJobCommand.java
... ...
@@ -0,0 +1,40 @@
  1
+/*
  2
+ * Copyright 2011-2012 the original author or authors.
  3
+ * 
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ * 
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ * 
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+package org.springframework.data.hadoop.admin.cli.mapreduce.commands;
  17
+
  18
+import org.springframework.roo.shell.CliCommand;
  19
+import org.springframework.roo.shell.CommandMarker;
  20
+import org.springframework.stereotype.Component;
  21
+
  22
+/**
  23
+ * Commands to show MR jobs
  24
+ * 
  25
+ * @author Jarred Li
  26
+ *
  27
+ */
  28
+@Component
  29
+public class MRJobCommand implements CommandMarker {
  30
+
  31
+	/**
  32
+	 * show the current service URL
  33
+	 * 
  34
+	 */
  35
+	@CliCommand(value = "mr jobs list", help = "list MapReduce information")
  36
+	public void getMRJobInfo() {
  37
+
  38
+	}
  39
+
  40
+}
75  .../main/java/org/springframework/data/hadoop/admin/cli/mapreduce/plugin/MapReducePluginBannerProvider.java
... ...
@@ -0,0 +1,75 @@
  1
+/*
  2
+ * Copyright 2011-2012 the original author or authors.
  3
+ * 
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at