accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Marion (JIRA)" <>
Subject [jira] [Commented] (ACCUMULO-1399) Pluggable commands for the shell
Date Sun, 19 May 2013 00:23:15 GMT


Dave Marion commented on ACCUMULO-1399:

2nd patch includes a script command. See the comment above for the extensions command. The
script command allows you to run scripts using JSR-223 engines. A list of JSR-223 engines
can be found in this thread:
Documentation for the scripting feature can be found at

Here are some examples:

echo "println(arg1)" > /tmp/hello.rhino

./accumulo shell --fake

list JSR-223 engines on the classpath
script -l

execute an inline script
script -e rhino -s "println('Hello')"

execute an inline script with 1 arg
script -e rhino -s "println(arg1)" -a arg1=Hello

execute an inline script with 2 args
script -e rhino -s "println(arg1+', '+arg2)" -a arg1=Hello -a arg2=World

execute a script in a file
script -e rhino -f /tmp/hello.rhino -a arg1=Hello

invoke a function in a script
script -e rhino -s "function hello(arg1) { println('Hello, ' + arg1); }" -fx hello -a arg1=Dave

invoke a method on a function
script -e js -s "var obj = new Object(); obj.hello = function(arg1) { println('Hello, ' +
arg1); }" -obj obj:hello -a arg1=Dave

 I was trying to do something more complicated. The script below compiles and runs without
error, but no data is in the table afterwards. Any idea what I am missing?
function testInsert(tableName, numRows) {
  if (!connection.tableOperations().exists(tableName)) {
    println("Table does not exist");
  var bwConfig = new org.apache.accumulo.core.client.BatchWriterConfig();
  var bw = connection.createBatchWriter(tableName, bwConfig);
  for (var x = 0; x < numRows; x++) {
    var mut = new;
    println("Adding " + x);

  var scanner = connection.createScanner(tableName, new;
  var scanIterator = scanner.iterator();
  while (scanIterator.hasNext()) {
    var entry =;
    println(entry.getKey().toString()+"  ->  "+entry.getValue());

run the test function
script -e rhino -f /tmp/insert.js  -a tableName=foo -a numRows=10 -fx testInsert

> Pluggable commands for the shell
> --------------------------------
>                 Key: ACCUMULO-1399
>                 URL:
>             Project: Accumulo
>          Issue Type: New Feature
>          Components: shell
>            Reporter: Dave Marion
>            Assignee: Dave Marion
>            Priority: Minor
>             Fix For: 1.6.0
>         Attachments: ACCUMULO-1399-1.patch, ACCUMULO-1399-2.patch
> Proposing modification to the Shell to allow applications to create their own set of
commands. This might be accomplished using java.util.ServiceLoader or something like it. Specifically,
I'm thinking of a case where I have a create table command that is different than the one
provided by the Shell. In my case, my create table command may create one or more tables and
setup iterators on them.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message