Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
ACCUMULO-1166 Adding an example of the Accumulo shell
git-svn-id: https://svn.apache.org/repos/asf/accumulo/contrib/instamo-archetype/trunk@1454779 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
4 changed files
with
232 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters