This is an automated email from the ASF dual-hosted git repository. ctubbsii pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new f9bc914 Auto Generate Accumulo Client in JShell (#1995) f9bc914 is described below commit f9bc91405ea4fb166d50d28a26d438265af5b554 Author: slackwinner <50567198+slackwin...@users.noreply.github.com> AuthorDate: Wed Apr 21 17:05:47 2021 -0400 Auto Generate Accumulo Client in JShell (#1995) Auto-generate an Accumulo client on JShell startup, if a client properties file is found on the class path. --- assemble/src/main/scripts/create-jshell.sh | 31 ++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/assemble/src/main/scripts/create-jshell.sh b/assemble/src/main/scripts/create-jshell.sh index 6d58fee..2cc2702 100755 --- a/assemble/src/main/scripts/create-jshell.sh +++ b/assemble/src/main/scripts/create-jshell.sh @@ -36,6 +36,31 @@ function addAccumuloAPI() { echo } +function addClientBuild() { +cat <<EOF + URL clientPropUrl = + AccumuloClient.class.getClassLoader().getResource("accumulo-client.properties"); + AccumuloClient client = null; + String name; String zk; String principal; String token; + + // Does Accumulo properties exists? + if (clientPropUrl != null) { + var prop = new Properties(); + + // Load in Accumulo properties + System.out.println("Building Accumulo client using '" + clientPropUrl + "'\n"); + try (var in = clientPropUrl.openStream()) { + prop.load(in); + } + // Build Accumulo Client after try-with-resources is closed + client = Accumulo.newClient().from(prop).build(); + System.out.println("Use 'client' to interact with Accumulo\n"); + + } else + System.out.println("'accumulo-client.properties' was not found on the classpath\n"); +EOF +} + function main() { local SOURCE bin scriptPath mainBase corePath # Establish Accumulo's main base directory @@ -68,9 +93,11 @@ function main() { echo '// Essential Hadoop API' echo 'import org.apache.hadoop.io.Text;' echo - echo '// Initialization code' - echo 'System.out.println("Preparing JShell for Apache Accumulo");' + echo '// Initialization Code' + echo 'System.out.println("Preparing JShell for Apache Accumulo\n");' echo + echo '// Accumulo Client Build' + addClientBuild } > "$mainBase/assemble/target/jshell-init.jsh" }