Skip to content

Instantly share code, notes, and snippets.

@wjsl
Last active January 14, 2016 15:04
Show Gist options
  • Save wjsl/3372a404a20e54c4da19 to your computer and use it in GitHub Desktop.
Save wjsl/3372a404a20e54c4da19 to your computer and use it in GitHub Desktop.
Quick way to get a shell to a MiniAccumulo Instance
def main(args: Array[String]): Unit = {
Logger.getLogger("org.apache.zookeeper").setLevel(Level.OFF)
val log = LoggerFactory.getLogger(getClass)
val work_dir = Files.createTempDir()
log.info("Working dir: {}", work_dir)
val password = "secret"
val accumulo = new MiniAccumuloCluster(new MiniAccumuloConfig(Files.createTempDir(), password))
var returnCode: Option[Int] = None
try {
accumulo.start()
val shell = new Shell();
val shell_args = s"-u root -p $password -zi ${accumulo.getInstanceName} -zh ${accumulo.getZooKeepers}".split(" ")
try {
if (!shell.config(shell_args:_*)) {
returnCode = Option(shell.getExitCode)
} else {
returnCode = Option(shell.start())
}
} finally {
shell.shutdown
}
} finally {
accumulo.stop()
work_dir.deleteOnExit()
}
System.exit(returnCode.get)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment