Skip to content
Permalink
Browse files
ACCUMULO-1166 Adding an example of the Accumulo shell
  • Loading branch information
joshelser committed Mar 10, 2013
1 parent b0a085c commit 72861761605bac477ec76b29684cec340dfb76de
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 120 deletions.
@@ -14,14 +14,26 @@ vim src/main/java/${package}/AccumuloApp.java
mvn package
```

After packing the code, you can run one of the below applications.

Map Reduce
----------

Its possible to run local map reduce jobs against the MiniAccumuloCluster
It's possible to run local map reduce jobs against the MiniAccumuloCluster
instance. There is an example of this in the src directory The following
command will run the map reduce example.

```
mvn exec:exec
mvn exec:exec -P mapreduce
```

Accumulo Shell
-----------

The Accumulo shell is a simple application that, among other features, provides
interactive access to tables in Accumulo. The following command will launch the
shell against a local Accumulo instance.

```
mvn exec:exec -P shell
```
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?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
@@ -14,119 +14,156 @@
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>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<packaging>jar</packaging>
<version>${version}</version>
<name>Instamo Example</name>
<url>http://accumulo.apache.org</url>
<properties>
<accumulo.version>1.5.0-SNAPSHOT</accumulo.version>
<hadoop-one.version>1.0.4</hadoop-one.version>
<hadoop-two.version>2.0.2-alpha</hadoop-two.version>
<maclass>${package}.MapReduceExample</maclass>
</properties>
<profiles>
--><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>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<packaging>jar</packaging>
<version>${version}</version>
<name>Instamo Example</name>
<url>http://accumulo.apache.org</url>

<properties>
<accumulo.version>1.5.0-SNAPSHOT</accumulo.version>
<hadoop-one.version>1.0.4</hadoop-one.version>
<hadoop-two.version>2.0.2-alpha</hadoop-two.version>
<maclass>${package}.MapReduceExample</maclass>
</properties>

<profiles>
<!-- profile for building against Hadoop 1.0.x
Activate by not specifying hadoop.profile -->
<profile>
<id>hadoop-1.0</id>
<activation>
<property>
<name>!hadoop.profile</name>
</property>
</activation>
<properties>
<hadoop.version>${hadoop-one.version}</hadoop.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>
</profile>
Activate by not specifying hadoop.profile -->
<profile>
<id>hadoop-1.0</id>
<activation>
<property>
<name>!hadoop.profile</name>
</property>
</activation>
<properties>
<hadoop.version>${hadoop-one.version}</hadoop.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>
</profile>
<!-- profile for building against Hadoop 2.0.x
Activate using: mvn -Dhadoop.profile=2.0 -->
<profile>
<id>hadoop-2.0</id>
<activation>
<property>
<name>hadoop.profile</name>
<value>2.0</value>
</property>
</activation>
<properties>
<hadoop.version>${hadoop-two.version}</hadoop.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-core</artifactId>
<version>${accumulo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-server</artifactId>
<version>${accumulo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.3.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-test</artifactId>
<version>${accumulo.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>${maclass}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
Activate using: mvn -Dhadoop.profile=2.0 -->
<profile>
<id>hadoop-2.0</id>
<activation>
<property>
<name>hadoop.profile</name>
<value>2.0</value>
</property>
</activation>
<properties>
<hadoop.version>${hadoop-two.version}</hadoop.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>shell</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>instamo.example.ShellExample</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>mapreduce</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>${maclass}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-core</artifactId>
<version>${accumulo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-server</artifactId>
<version>${accumulo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-test</artifactId>
<version>${accumulo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.3.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
@@ -0,0 +1,63 @@
package instamo.example;

import com.google.common.io.Files;

import java.io.File;
import java.io.IOException;
import java.lang.InterruptedException;
import java.lang.Runnable;
import java.util.Arrays;

import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.test.MiniAccumuloCluster;

public class ShellExample implements Runnable {

@Override
public void run() {
File tempDir = null;
MiniAccumuloCluster mac = null;

try {
tempDir = Files.createTempDir();
tempDir.deleteOnExit();

final String PASSWORD = "pass1234";

mac = new MiniAccumuloCluster(tempDir, PASSWORD);

mac.start();

String[] args = new String[] {"-u", "root", "-p", PASSWORD, "-z",
mac.getInstanceName(), mac.getZooKeepers()};

Shell.main(args);

} catch (InterruptedException e) {
System.err.println("Error starting MiniAccumuloCluster: " + e.getMessage());
} catch (IOException e) {
System.err.println("Error starting MiniAccumuloCluster: " + e.getMessage());
} finally {
if (null != tempDir) {
tempDir.delete();
}

if (null != mac) {
try {
mac.stop();
} catch (InterruptedException e) {
System.err.println("Error stopping MiniAccumuloCluster: " + e.getMessage());
} catch (IOException e) {
System.err.println("Error stopping MiniAccumuloCluster: " + e.getMessage());
}
}
}
}

public static void main(String[] args) {
System.out.println("\n ---- Initializing Accumulo Shell\n");

ShellExample shell = new ShellExample();
shell.run();
}
}
@@ -7,6 +7,6 @@ log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=[%t] %-5p %c %x - %m%n

log4j.logger.org.apache.zookeeper=ERROR,CA
log4j.logger.org.apache.accumulo.core.client.impl.ServerClient=ERROR
log4j.logger.org.apache.accumulo.server.security.Auditor=off

log4j.logger.org.apache.accumulo.core.client.impl.ServerClient=ERROR,CA
log4j.logger.org.apache.accumulo.core.util.shell.Shell.audit=WARN,CA
log4j.logger.org.apache.commons.vfs2.impl.DefaultFileSystemManager=WARN,CA

0 comments on commit 7286176

Please sign in to comment.