ctubbsii commented on a change in pull request #274:
URL: https://github.com/apache/accumulo-website/pull/274#discussion_r618629518



##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner

Review comment:
       I'm not a huge fan of either the Author info (for the same reason Apache 
projects don't use the `@author` tag in source code, because it's a 
community-maintained group effort, that all of us are responsible for). 
However, I recognize that blog posts are somewhat different than source code, 
since they are typically authored at a point in time, rather than continuously 
maintained. So, I think it's fine if you want to leave that. Just know that 
it's optional.
   
   I'm also not a fan of the "Reviewers" tag, either, but for additional 
reasons. First, it is intended to reflect reviewers of the blog post itself, 
not the work the blog post is describing. So, right now, it should be blank 
anyway. Second, I don't think it adds any value. The intent of having this 
seems to be to try to give credit for contributors who may have made 
significant contributions as editors in the review process. However, for me 
personally, it feels like I'm being singled out as responsible in some way for 
its content, rather than the entire project being responsible for its content. 
I'm also uncomfortable trying to weigh merit against other individuals like 
this (it raises the question of how much contributing makes you a reviewer, or 
how much contributing would make you a co-author).
   
   So, feel free to retain your Author tag if you want, but please remove the 
Reviewers lines for now, and if you add it back later in response to other 
reviewers, please leave my name off of it, since I'm not comfortable being 
called out on the blog posts by name. I really wish we hadn't started this 
precedent in previous blog posts.
   
   Thanks!

##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner
+---
+
+## Overview
+First introduced in Java 9+, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 
+Java tool that assess user's inputed declarations, statements, and expressions 
and outputs 

Review comment:
       ```suggestion
   Java tool that interprets user's input as Java and outputs 
   ```

##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner
+---
+
+## Overview
+First introduced in Java 9+, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 

Review comment:
       ```suggestion
   First introduced in Java 9, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 
   ```

##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner
+---
+
+## Overview
+First introduced in Java 9+, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 
+Java tool that assess user's inputed declarations, statements, and expressions 
and outputs 
+the results. This tool provides a convenient way to test out and execute quick 
tasks with Accumulo
+in the terminal.
+
+## Major Features
+* During Accumulo build, produces a default JShell script called 
`jshell-init.jsh` 
+containing up-to-date [Accumulo Java APIs][public APIs] and 
[AccumuloClient][client] 
+build implementation

Review comment:
       Instead of mentioning how it is built, which isn't quite relevant to end 
users, it should instead mention that a default `conf/jshell-init.jsh` file is 
provided in our binary distribution tarball, and includes some initial imports 
for interacting with Accumulo's API.
   
   It might be worth mentioning that JShell could be run manually using the 
user's installed `jshell` command from their installation of Java, but that by 
running it with `bin/accumulo jshell`, it will automatically pick up the 
`CLASSPATH` and other environment from the user's `conf/accumulo-env.sh` and 
automatically initialize with the provided `conf/jshell-init.jsh` file, which 
can also be customized by users.
   
   Since all of this is something a user could already do themselves, I think 
the main focus of this blog post should be on the convenience that it offers to 
users, so that they don't have to do it all manually.

##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner
+---
+
+## Overview
+First introduced in Java 9+, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 
+Java tool that assess user's inputed declarations, statements, and expressions 
and outputs 
+the results. This tool provides a convenient way to test out and execute quick 
tasks with Accumulo
+in the terminal.
+
+## Major Features
+* During Accumulo build, produces a default JShell script called 
`jshell-init.jsh` 
+containing up-to-date [Accumulo Java APIs][public APIs] and 
[AccumuloClient][client] 
+build implementation
+
+* Startup JShell with default or custom JShell script 
+
+* Both JShell start up options automatically import all relevant Java APIs 
+
+## Booting Up JShell Accumulo
+After installing and configuring the [latest Accumulo update][accumulo-repo]

Review comment:
       Since this is a 2.1 feature, we could point to the downloads page. If we 
want to publish this blog post before 2.1 is released, then some of the wording 
could be tailored to refer to the "upcoming 2.1 release" for this feature, with 
perhaps a minor mention that they could build pre-release snapshot versions to 
try it out from the git repository if 2.1 isn't released by the time they read 
this.

##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner
+---
+
+## Overview
+First introduced in Java 9+, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 
+Java tool that assess user's inputed declarations, statements, and expressions 
and outputs 
+the results. This tool provides a convenient way to test out and execute quick 
tasks with Accumulo
+in the terminal.
+
+## Major Features
+* During Accumulo build, produces a default JShell script called 
`jshell-init.jsh` 
+containing up-to-date [Accumulo Java APIs][public APIs] and 
[AccumuloClient][client] 
+build implementation
+
+* Startup JShell with default or custom JShell script 
+
+* Both JShell start up options automatically import all relevant Java APIs 
+
+## Booting Up JShell Accumulo
+After installing and configuring the [latest Accumulo update][accumulo-repo]
+follow the steps below to startup JShell:
+
+1) Open up a terminal and navigate to Accumulo's home directory 

Review comment:
       Since "home directory" has a special meaning in Linux environments, it'd 
be better to refer to the Accumulo installation directory, if using the binary 
distribution tarball we provide. If they're using a distribution from a 
commercial vendor or other distributor, their experience may be different.

##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner
+---
+
+## Overview
+First introduced in Java 9+, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 
+Java tool that assess user's inputed declarations, statements, and expressions 
and outputs 
+the results. This tool provides a convenient way to test out and execute quick 
tasks with Accumulo
+in the terminal.
+
+## Major Features
+* During Accumulo build, produces a default JShell script called 
`jshell-init.jsh` 
+containing up-to-date [Accumulo Java APIs][public APIs] and 
[AccumuloClient][client] 
+build implementation
+
+* Startup JShell with default or custom JShell script 
+
+* Both JShell start up options automatically import all relevant Java APIs 

Review comment:
       By default they import classes to interact with the Accumulo API... but 
might not be all relevant Java APIs for the user's intended task. Also, this is 
only by default. The file is customizable by the user in their conf/ directory.

##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner
+---
+
+## Overview
+First introduced in Java 9+, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 
+Java tool that assess user's inputed declarations, statements, and expressions 
and outputs 
+the results. This tool provides a convenient way to test out and execute quick 
tasks with Accumulo
+in the terminal.
+
+## Major Features
+* During Accumulo build, produces a default JShell script called 
`jshell-init.jsh` 
+containing up-to-date [Accumulo Java APIs][public APIs] and 
[AccumuloClient][client] 
+build implementation
+
+* Startup JShell with default or custom JShell script 
+
+* Both JShell start up options automatically import all relevant Java APIs 
+
+## Booting Up JShell Accumulo
+After installing and configuring the [latest Accumulo update][accumulo-repo]
+follow the steps below to startup JShell:
+
+1) Open up a terminal and navigate to Accumulo's home directory 
+
+2) To startup JShell with **default script** use this command:
+
+```bash
+$ bin/accumulo jshell 
+```
+3) To startup JShell with **custom script** use this command:
+
+```bash
+$ bin/accumulo jshell --startup (file/path/to/custom_script.jsh)
+```
+## JShell Accumulo Default Script
+The auto-generated `jshell-init.jsh` is located in Accumulo's `conf/` 
directory. 
+Inside `jshell-init.jsh` contains [Accumulo Java APIs][public APIs] formatted 
as import statements 
+and [AccumuloClient][client] build implementation. On startup the script 
automatically loads in the 
+APIs and attempts to construct a client. Should additional APIs and/or code 
implementations be 
+needed, simply append them to `jshell-init.jsh`. Alternatively you can create 
a separate JShell 
+script and specify the custom script's file path on startup.
+
+The build implementation finds and uses `accumulo-client.properties` in 
Accumulo's 
+classpath to auto-generate an [AccumuloClient][client] called **client**. 
+If `accumulo-client.properties` is found, a similar result will be produced 
below:
+
+``` 
+Preparing JShell for Apache Accumulo 
+
+Building Accumulo client using 
'jar:file:/home/accumulo/lib/accumulo-client.jar!/accumulo-client.properties'
+
+Use 'client' to interact with Accumulo
+
+|  Welcome to JShell -- Version 11.0.10
+|  For an introduction type: /help intro
+
+jshell> 
+```
+If `accumulo-client.properties` is not found, an [AccumuloClient][client] will 
not 
+auto-generate and will produce the following result below:
+
+```
+Preparing JShell for Apache Accumulo 
+
+'accumulo-client.properties' was not found on the classpath
+
+|  Welcome to JShell -- Version 11.0.10
+|  For an introduction type: /help intro
+
+jshell> 
+```
+
+## JShell Accumulo Example
+1) Booting up JShell using default script
+
+```
+Preparing JShell for Apache Accumulo 
+
+Building Accumulo client using 
'file:/home/accumulo/conf/accumulo-client.properties'
+
+Use 'client' to interact with Accumulo
+
+|  Welcome to JShell -- Version 11.0.10
+|  For an introduction type: /help intro
+
+jshell> 
+```
+
+2) Providing JShell with an Accumulo task
+
+```Java
+  // Create a table called "GothamPD".
+  client.tableOperations().create("GothamPD");
+
+  // Create a Mutation object to hold all changes to a row in a table. 
+  // Each row has a unique row ID.
+  Mutation mutation = new Mutation("id0001");
+
+  // Create key/value pairs for Batman. Put them in the "hero" family.
+  mutation.put("hero", "alias", "Batman");
+  mutation.put("hero", "name", "Bruce Wayne");
+  mutation.put("hero", "wearsCape?", "true");
+
+  // Create a BatchWriter to the GothamPD table and add your mutation to it. 
+  // Try w/ resources will close for us.
+  try (BatchWriter writer = client.createBatchWriter("GothamPD")) {
+      writer.addMutation(mutation);
+  }
+
+  // Read and print all rows of the "GothamPD" table. 
+  // Try w/ resources will close for us.
+  try (org.apache.accumulo.core.client.Scanner scan =
+    client.createScanner("GothamPD", Authorizations.EMPTY)) {
+    System.out.println("Gotham Police Department Persons of Interest:");
+    
+    // A Scanner is an extension of java.lang.Iterable so behaves just like 
one.
+    for (Map.Entry<Key,Value> entry : scan) {
+      System.out.printf("Key : %-50s  Value : %s\n", entry.getKey(), 
entry.getValue());
+    }

Review comment:
       As of 2.1, we can use scanner.forEach, which makes this slightly nicer 
example code:
   
   ```suggestion
       scan.forEach((k, v) -> System.out.printf("Key : %-50s  Value : %s\n", k, 
v));
   ```

##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner
+---
+
+## Overview
+First introduced in Java 9+, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 
+Java tool that assess user's inputed declarations, statements, and expressions 
and outputs 
+the results. This tool provides a convenient way to test out and execute quick 
tasks with Accumulo
+in the terminal.
+
+## Major Features
+* During Accumulo build, produces a default JShell script called 
`jshell-init.jsh` 
+containing up-to-date [Accumulo Java APIs][public APIs] and 
[AccumuloClient][client] 
+build implementation
+
+* Startup JShell with default or custom JShell script 
+
+* Both JShell start up options automatically import all relevant Java APIs 
+
+## Booting Up JShell Accumulo
+After installing and configuring the [latest Accumulo update][accumulo-repo]
+follow the steps below to startup JShell:
+
+1) Open up a terminal and navigate to Accumulo's home directory 
+
+2) To startup JShell with **default script** use this command:
+
+```bash
+$ bin/accumulo jshell 
+```
+3) To startup JShell with **custom script** use this command:
+
+```bash
+$ bin/accumulo jshell --startup (file/path/to/custom_script.jsh)
+```
+## JShell Accumulo Default Script
+The auto-generated `jshell-init.jsh` is located in Accumulo's `conf/` 
directory. 
+Inside `jshell-init.jsh` contains [Accumulo Java APIs][public APIs] formatted 
as import statements 
+and [AccumuloClient][client] build implementation. On startup the script 
automatically loads in the 
+APIs and attempts to construct a client. Should additional APIs and/or code 
implementations be 
+needed, simply append them to `jshell-init.jsh`. Alternatively you can create 
a separate JShell 
+script and specify the custom script's file path on startup.

Review comment:
       Might be worth mentioning that you can append any options that you might 
append to the `jshell` command-line if you were running that directly.

##########
File path: _posts/blog/2021-04-21-jshell-accumulo-feature.md
##########
@@ -0,0 +1,141 @@
+---
+Title: JShell Accumulo Feature
+Author: R. Dane Magbuhos
+Reviewers: Christopher Tubbs, Keith Turner
+---
+
+## Overview
+First introduced in Java 9+, [JShell][JShell Doc] is an interactive 
Read-Evaluate-Print-Loop (REPL) 
+Java tool that assess user's inputed declarations, statements, and expressions 
and outputs 
+the results. This tool provides a convenient way to test out and execute quick 
tasks with Accumulo
+in the terminal.
+
+## Major Features
+* During Accumulo build, produces a default JShell script called 
`jshell-init.jsh` 
+containing up-to-date [Accumulo Java APIs][public APIs] and 
[AccumuloClient][client] 
+build implementation
+
+* Startup JShell with default or custom JShell script 
+
+* Both JShell start up options automatically import all relevant Java APIs 
+
+## Booting Up JShell Accumulo
+After installing and configuring the [latest Accumulo update][accumulo-repo]
+follow the steps below to startup JShell:
+
+1) Open up a terminal and navigate to Accumulo's home directory 
+
+2) To startup JShell with **default script** use this command:
+
+```bash
+$ bin/accumulo jshell 
+```
+3) To startup JShell with **custom script** use this command:
+
+```bash
+$ bin/accumulo jshell --startup (file/path/to/custom_script.jsh)
+```
+## JShell Accumulo Default Script
+The auto-generated `jshell-init.jsh` is located in Accumulo's `conf/` 
directory. 
+Inside `jshell-init.jsh` contains [Accumulo Java APIs][public APIs] formatted 
as import statements 
+and [AccumuloClient][client] build implementation. On startup the script 
automatically loads in the 
+APIs and attempts to construct a client. Should additional APIs and/or code 
implementations be 
+needed, simply append them to `jshell-init.jsh`. Alternatively you can create 
a separate JShell 
+script and specify the custom script's file path on startup.
+
+The build implementation finds and uses `accumulo-client.properties` in 
Accumulo's 
+classpath to auto-generate an [AccumuloClient][client] called **client**. 
+If `accumulo-client.properties` is found, a similar result will be produced 
below:
+
+``` 
+Preparing JShell for Apache Accumulo 
+
+Building Accumulo client using 
'jar:file:/home/accumulo/lib/accumulo-client.jar!/accumulo-client.properties'
+
+Use 'client' to interact with Accumulo
+
+|  Welcome to JShell -- Version 11.0.10
+|  For an introduction type: /help intro
+
+jshell> 
+```
+If `accumulo-client.properties` is not found, an [AccumuloClient][client] will 
not 
+auto-generate and will produce the following result below:
+
+```
+Preparing JShell for Apache Accumulo 
+
+'accumulo-client.properties' was not found on the classpath
+
+|  Welcome to JShell -- Version 11.0.10
+|  For an introduction type: /help intro
+
+jshell> 
+```
+
+## JShell Accumulo Example
+1) Booting up JShell using default script
+
+```
+Preparing JShell for Apache Accumulo 
+
+Building Accumulo client using 
'file:/home/accumulo/conf/accumulo-client.properties'
+
+Use 'client' to interact with Accumulo
+
+|  Welcome to JShell -- Version 11.0.10
+|  For an introduction type: /help intro
+
+jshell> 
+```
+
+2) Providing JShell with an Accumulo task
+
+```Java
+  // Create a table called "GothamPD".
+  client.tableOperations().create("GothamPD");
+
+  // Create a Mutation object to hold all changes to a row in a table. 
+  // Each row has a unique row ID.
+  Mutation mutation = new Mutation("id0001");
+
+  // Create key/value pairs for Batman. Put them in the "hero" family.
+  mutation.put("hero", "alias", "Batman");
+  mutation.put("hero", "name", "Bruce Wayne");
+  mutation.put("hero", "wearsCape?", "true");
+
+  // Create a BatchWriter to the GothamPD table and add your mutation to it. 
+  // Try w/ resources will close for us.
+  try (BatchWriter writer = client.createBatchWriter("GothamPD")) {
+      writer.addMutation(mutation);
+  }
+
+  // Read and print all rows of the "GothamPD" table. 
+  // Try w/ resources will close for us.
+  try (org.apache.accumulo.core.client.Scanner scan =
+    client.createScanner("GothamPD", Authorizations.EMPTY)) {

Review comment:
       Might be worth a mention that the fully-qualified class name for Scanner 
needs to be used because of a conflict with Java's built-in 
`java.util.Scanner`, but that if they want to use a shortname, they can assign 
it to the `ScannerBase` type instead.
   
   ```suggestion
     // Read and print all rows of the "GothamPD" table. 
     // Try w/ resources will close for us.
     try (ScannerBase scan = client.createScanner("GothamPD", 
Authorizations.EMPTY)) {
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to