You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2021/02/04 17:59:27 UTC

[GitHub] [accumulo] slackwinner opened a new pull request #1910: Adding JShell Accumulo Feature

slackwinner opened a new pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910


   In response to apache/accumulo#1870, this commit includes basic functionality to boot up JShell with Accumulo's API imported.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583734216



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       For the DEFAULT script, I originally left that as a start up parameter to ensure the user can see the default import library and the Accumulo API when they first boot up JShell. I believe having two start-up statements should do the trick. Also I believe I found a work around regarding the Scanner. Whenever a Scanner is defined, we need to explicitly specify which Scanner are we referring to. For example: 
   
   **Referencing Accumulo Scanner:**
   org.apache.accumulo.core.client.Scanner scan = client.createScanner("GothamPD", Authorizations.EMPTY);
   
   **Referencing Java Scanner:**
    java.util.Scanner myObj = new java.util.Scanner(System.in);
   
   I created a Java test code where there one function uses the Accumulo Scanner and another function uses the Java Scanner. I then executed the code in JShell with Accumulo and both functions where able to execute with no issues. 
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-786013267


   > As part of https://issues.apache.org/jira/browse/ACCUMULO-1399 I added the ability for users to write scripts in a supported JSR-223 engine and run them in the shell. How does adding jshell to the shell compare to this? Is it duplicative, should the script command be deprecated?
   
   @dlmarion Rhino, the default scripting engine that feature used is already removed from Java, and replaced with Nashorn, which is now also deprecated and scheduled for removal in JDK 15. So, that feature won't work anymore anyway. So, yes, that script command should be deprecated.
   
   I don't know all the use cases for the shell script command, but I suspect that they can all be replaced with the use of JShell. JShell is even better, actually, because it can be used interactively.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner edited a comment on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner edited a comment on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773505326


   @ctubbsii This is still in a work in progress but I wanted to share what I have done so far. Essentially, I added a "jshell entry" in bin/accumulo so that the user can easily activate jshell with the classpath imported. In addition, there is a jshell-init.jsh file that allows the user to load in the default Accumulo public APIs. Also the user can customize jshell-init by adding or removing public APIs. Currently jshell-init has hard coded public APIs as I am  still figuring out how to import the classes automatically as well as making sure the classes are always up to date during a build. Feel free to comment if you have any suggestions/ideas on how to automate the import process or improve the jshell feature as a whole. Below are simple examples on how to boot up Jshell with Accumulo. 
   
   Update as of 02/18: I've included a bash script that auto generates jshell-init-.jsh and is invoked by maven. Once the Accumulo package is built, the JShell Accumulo Feature is ready for usage.
   
   **Starting JShell with Accumulo (Updated as of 02/18):**
   _$ bin/accumulo jshell_
   - This cmd will pass the $CLASSPATH to Jshell and import the default java libraries and Accumulo public APIs from the .jsh file.
   
   _$ bin/accumulo jshell --startup (Path to user's custom file(s))_
   - This cmd will pass the $CLASSPATH to Jshell and import the default Java libraries first before importing the user's custom file(s)
   
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773505326


   This is still in a work in progress but I wanted to share what I have done so far. Essentially, I added a "jshell entry" in bin/accumulo so that the user can easily activate jshell with the classpath imported. In addition, there is a jshell-init.jsh file allows the user to load in the default Accumulo public APIs. Also the user can customize the jshell-init by adding or removing public APIs. Currently jshell-init has hard coded public APIs as I am  still figuring out how to import the classes automatically as well as making sure the classes are always up to date during a build. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773505326


   This is still in a work in progress but I wanted to share what I have done so far. Essentially, I added a "jshell entry" in bin/accumulo so that the user can easily activate jshell with the classpath imported. In addition, there is a jshell-init.jsh file allows the user to load in the default Accumulo public APIs. Also the user can customize the jshell-init by adding or removing public APIs. Currently jshell-init has hard coded public APIs as I am  still figuring out how to import the classes automatically as well as making sure the classes are always up to date during a build. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r585926149



##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,77 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI() {
+  local srcDir="$1" api apiPath
+  # Validate each source directory before populating JShell-Init file
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    exit 1
+  fi
+
+  # Extract API info from provided source directory
+  mapfile -t api < <(find "$srcDir" -type f -name '*.java' -print0 | xargs -0 -n1 dirname | sort -u)
+
+  # Load in API and format source directory into Java import statements
+  for apiPath in "${api[@]}"; do
+    echo "import ${apiPath##*/java/}.*;" | tr / .
+  done
+  echo
+}
+
+function main() {
+  local SOURCE bin scriptPath mainBase corePath
+  # Establish Accumulo's main base directory
+  SOURCE="${BASH_SOURCE[0]}"
+  while [[ -h "${SOURCE}" ]]; do
+    bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+    SOURCE="$(readlink "${SOURCE}")"
+    [[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}"
+  done
+
+  # Establish file and folder paths for JShell config
+  scriptPath="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+  mainBase="$( cd -P "${scriptPath}"/../../../.. && pwd )"
+  corePath="$mainBase/core/src/main/java/org/apache/accumulo/core"
+
+  # Create new jshell-init file
+  mkdir -p "$mainBase/assemble/target"
+  echo 'Generating JShell-Init file'
+  {
+    echo '// Accumulo Client API'
+    addAccumuloAPI "$corePath/client"
+    echo '// Accumulo Data API'
+    addAccumuloAPI "$corePath/data"
+    echo '// Accumulo Security API'
+    addAccumuloAPI "$corePath/security"
+    echo '// Accumulo MiniCluster API'
+    addAccumuloAPI "$mainBase/minicluster/src/main/java/org/apache/accumulo/minicluster"
+    echo '// Accumulo Hadoop API'
+    addAccumuloAPI "$mainBase/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce"
+    echo '// Essential Hadoop API

Review comment:
       Oops. I broke this with the missing quote
   ```suggestion
       echo '// Essential Hadoop API'
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583748528



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       Would you like me to modify the create-jshell.sh script to import all the classes from java.util.* into the jshell-init.jsh file or just go with the alternative solution?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner edited a comment on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner edited a comment on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773505326






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583055100



##########
File path: assemble/conf/create-jshell.sh
##########
@@ -0,0 +1,134 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addLicenseHeader(){
+  export header="$1"
+  export jPath="$2"
+  
+  # Does an auto-generated JShell config file exists?
+  if [[ -e "$jPath" ]]; then
+    printf "%s\n" "/*" >> "$jPath"
+    
+    # Load in license header
+    while IFS= read -r line; do
+      echo "$line" >> "$jPath"
+    done < "$header"
+    
+    printf "%s\n" "*/" >> "$jPath" 
+    echo " " >> "$jPath"
+  else
+    echo "Cannot add license header in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi

Review comment:
       @ctubbsii Thank you for reviewing my code submission. I'll make the proposed updates and test out the code before pushing a revised copy later.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner edited a comment on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner edited a comment on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773505326


   @ctubbsii This is still in a work in progress but I wanted to share what I have done so far. Essentially, I added a "jshell entry" in bin/accumulo so that the user can easily activate jshell with the classpath imported. In addition, there is a jshell-init.jsh file that allows the user to load in the default Accumulo public APIs. Also the user can customize jshell-init by adding or removing public APIs. Currently jshell-init has hard coded public APIs as I am  still figuring out how to import the classes automatically as well as making sure the classes are always up to date during a build. Feel free to comment if you have any suggestions/ideas on how to automate the import process or improve the jshell feature as a whole. Below are simple examples on how to boot up Jshell with Accumulo. 
   
   Update as of 02/18: I've included a bash script that auto generates jshell-init-.jsh and is invoked by maven. Once the Accumulo package is built, the JShell Accumulo Feature is ready for usage.
   
   **Starting JShell with Accumulo (Updated as of 02/18):**
   _$ bin/accumulo jshell_
   - This cmd will pass the $CLASSPATH to Jshell and import the default java libraries and Accumulo public APIs from the .jsh file.
   
   _$ bin/accumulo jshell --startup (Path to Jshell-init.jsh file)_
   - This cmd will pass the $CLASSPATH to Jshell and import the default Java libraries first before importing the user's custom file(s)
   
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583734216



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       For the DEFAULT script, I originally left that as a start up parameter to ensure the user can see the default import library and the Accumulo API when they first boot up JShell. I believe having two start-up statements should do the trick. Also I believe I found a work around regarding the Scanner. Whenever a Scanner is defined, we need to explicitly specify which Scanner we are referring to. For example: 
   
   **Referencing Accumulo Scanner:**
   org.apache.accumulo.core.client.Scanner scan = client.createScanner("GothamPD", Authorizations.EMPTY);
   
   **Referencing Java Scanner:**
    java.util.Scanner myObj = new java.util.Scanner(System.in);
   
   I created a Java test code where one function uses the Accumulo Scanner and another function uses the Java Scanner. I then executed the code in JShell with Accumulo and both functions where able to execute with no issues. 
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r584643716



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  

Review comment:
       @ctubbsii Thank you for the helpful improvements/suggestions. This code review is helping me understand bash scripting in general. I'll apply these improvements and push a revised copy soon. 




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner edited a comment on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner edited a comment on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773505326


   @ctubbsii This is still in a work in progress but I wanted to share what I have done so far. Essentially, I added a "jshell entry" in bin/accumulo so that the user can easily activate jshell with the classpath imported. In addition, there is a jshell-init.jsh file that allows the user to load in the default Accumulo public APIs. Also the user can customize jshell-init by adding or removing public APIs. Currently jshell-init has hard coded public APIs as I am  still figuring out how to import the classes automatically as well as making sure the classes are always up to date during a build. Feel free to comment if you have any suggestions/ideas on how to automate the import process or improve the jshell feature as a whole. Below are simple examples on how to boot up Jshell with Accumulo. 
   
   Update as of 02/18: I've included a bash script that auto generates jshell-init-.jsh and is invoked by maven. Once the Accumulo package is built, the JShell Accumulo Feature is ready for usage.
   
   **Starting JShell with Accumulo (Updated as of 02/18):**
   _$ bin/accumulo jshell_
   - This cmd will pass the $CLASSPATH to Jshell and import the default java libraries and Accumulo public APIs from the .jsh file.
   
   _$ bin/accumulo jshell --startup (Path to user's custom file(s)_
   - This cmd will pass the $CLASSPATH to Jshell and import the default Java libraries first before importing the user's custom file(s)
   
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] dlmarion commented on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
dlmarion commented on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-786020529


   Nashorn might be planned for removal, but the ability to plug in a JSR-223 compatible script library is not. Users can still plug in their own library, like https://github.com/eclipsesource/J2V8.
   
   I'm fine with deprecation, we just need to make sure it makes it into the release notes so that users have time to migrate their javascript / python / whatever files to java.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner edited a comment on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner edited a comment on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773505326


   @ctubbsii This is still in a work in progress but I wanted to share what I have done so far. Essentially, I added a "jshell entry" in bin/accumulo so that the user can easily activate jshell with the classpath imported. In addition, there is a jshell-init.jsh file that allows the user to load in the default Accumulo public APIs. Also the user can customize jshell-init by adding or removing public APIs. Currently jshell-init has hard coded public APIs as I am  still figuring out how to import the classes automatically as well as making sure the classes are always up to date during a build. Feel free to comment if you have any suggestions/ideas on how to automate the import process or improve the jshell feature as a whole. Below are simple examples on how to boot up Jshell with Accumulo. 
   
   Update as of 02/18: I've included a bash script that auto generates jshell-init-.jsh and is invoked by maven. Once the Accumulo package is built, the JShell Accumulo Feature is ready for usage.
   
   **Starting JShell with Accumulo (Updated as of 02/18):**
   _$ bin/accumulo jshell
   - This cmd will pass the $CLASSPATH to Jshell and import the default java libraries and Accumulo public APIs from the .jsh file.
   
   _$ bin/accumulo jshell --startup (Path to Jshell-init.jsh file)_
   - This cmd will pass the $CLASSPATH to Jshell and import the default Java libraries first before importing the user's custom file(s)
   
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r582920014



##########
File path: assemble/conf/create-jshell.sh
##########
@@ -0,0 +1,134 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addLicenseHeader(){
+  export header="$1"
+  export jPath="$2"
+  
+  # Does an auto-generated JShell config file exists?
+  if [[ -e "$jPath" ]]; then
+    printf "%s\n" "/*" >> "$jPath"
+    
+    # Load in license header
+    while IFS= read -r line; do
+      echo "$line" >> "$jPath"
+    done < "$header"
+    
+    printf "%s\n" "*/" >> "$jPath" 
+    echo " " >> "$jPath"
+  else
+    echo "Cannot add license header in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi

Review comment:
       The generated file doesn't hold any meaningful/copyrightable content. It's just generated import statements, so it's not strictly necessary to add the license header. The rat check error from the missing license header can be avoided by generating the file in the build tree, rather than the source tree. For maven, that means generating it in `assemble/target/` directory rather than `assemble/conf/`
   
   That should simplify things a bit.

##########
File path: assemble/pom.xml
##########
@@ -520,6 +520,16 @@
               </arguments>
             </configuration>
           </execution>
+          <execution>
+            <id>create-jshell</id>
+            <goals>
+              <goal>exec</goal>
+            </goals>
+            <phase>compile</phase>
+            <configuration>
+              <executable>${basedir}/conf/create-jshell.sh</executable>

Review comment:
       Since this file should not be included as part of the distribution tarball, but is instead part of the build tools, this `create-jshell.sh` file should live in `assemble/src/main/scripts/`
   
   ```suggestion
                 <executable>src/main/scripts/create-jshell.sh</executable>
   ```

##########
File path: assemble/conf/create-jshell.sh
##########
@@ -0,0 +1,134 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addLicenseHeader(){
+  export header="$1"
+  export jPath="$2"
+  
+  # Does an auto-generated JShell config file exists?
+  if [[ -e "$jPath" ]]; then
+    printf "%s\n" "/*" >> "$jPath"
+    
+    # Load in license header
+    while IFS= read -r line; do
+      echo "$line" >> "$jPath"
+    done < "$header"
+    
+    printf "%s\n" "*/" >> "$jPath" 
+    echo " " >> "$jPath"
+  else
+    echo "Cannot add license header in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+}
+
+function addAccumuloAPI(){
+  export srcDir="$1"
+  export jPath="$2"
+  export client="accumulo/core/client"
+  export data="accumulo/core/data"
+  export security="accumulo/core/security"
+  export mini="accumulo/minicluster"
+  export hadoop="accumulo/hadoop"
+    
+  # Does an auto-generated JShell config file exists?
+  if [[ ! -e "$jPath" ]]; then
+    echo "Cannot add APIs in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+  
+  # Is the source directory valid?
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    rm "$jPath"
+    exit 1
+  fi
+  
+  # Does a valid JShell path and source directory exists?
+  if [[ -e "$jPath" ]] && [[ -d "$srcDir" ]]; then
+    # Add API category designator in jshell-init.jsh 
+    case "$srcDir" in
+        *"$client"*) echo "// Accumulo Client API" >> "$jPath";;
+        *"$data"*) echo "// Accumulo Data API" >> "$jPath";;
+        *"$security"*) echo "// Accumulo Security API" >> "$jPath";;
+        *"$mini"*) echo "// Accumulo Minicluster API" >> "$jPath";;
+        *"$hadoop"*) echo "// Accumulo Hadoop API" >> "$jPath";;

Review comment:
       I like how you added section headers to the generated file!

##########
File path: assemble/conf/create-jshell.sh
##########
@@ -0,0 +1,134 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addLicenseHeader(){
+  export header="$1"
+  export jPath="$2"
+  
+  # Does an auto-generated JShell config file exists?
+  if [[ -e "$jPath" ]]; then
+    printf "%s\n" "/*" >> "$jPath"
+    
+    # Load in license header
+    while IFS= read -r line; do
+      echo "$line" >> "$jPath"
+    done < "$header"
+    
+    printf "%s\n" "*/" >> "$jPath" 
+    echo " " >> "$jPath"
+  else
+    echo "Cannot add license header in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+}
+
+function addAccumuloAPI(){
+  export srcDir="$1"
+  export jPath="$2"
+  export client="accumulo/core/client"
+  export data="accumulo/core/data"
+  export security="accumulo/core/security"
+  export mini="accumulo/minicluster"
+  export hadoop="accumulo/hadoop"
+    
+  # Does an auto-generated JShell config file exists?
+  if [[ ! -e "$jPath" ]]; then
+    echo "Cannot add APIs in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+  
+  # Is the source directory valid?
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    rm "$jPath"
+    exit 1
+  fi
+  
+  # Does a valid JShell path and source directory exists?
+  if [[ -e "$jPath" ]] && [[ -d "$srcDir" ]]; then
+    # Add API category designator in jshell-init.jsh 
+    case "$srcDir" in
+        *"$client"*) echo "// Accumulo Client API" >> "$jPath";;
+        *"$data"*) echo "// Accumulo Data API" >> "$jPath";;
+        *"$security"*) echo "// Accumulo Security API" >> "$jPath";;
+        *"$mini"*) echo "// Accumulo Minicluster API" >> "$jPath";;
+        *"$hadoop"*) echo "// Accumulo Hadoop API" >> "$jPath";;
+        *) echo "// Other API" >> "$jPath";;
+    esac
+   
+    # Extract API info from provided source directory
+    mapfile -t api < <(find "$srcDir" -type f -name '*.java'| 
+                       xargs -n1 dirname| sort -u)
+   
+    # Load in API and format source directory into Java import statements
+    for apiPath in "${api[@]}"; do
+       printf "%s\n" "import ${apiPath##*/java/}.*" >> "$jPath"
+    done
+    sed -i '/^ *import / s#/#.#g' "$jPath"
+    echo " " >> "$jPath"
+  fi
+}
+
+function main(){
+  # Establish Accumulo's main base directory
+  SOURCE="${BASH_SOURCE[0]}"
+  while [[ -h "${SOURCE}" ]]; do
+    bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+    SOURCE="$(readlink "${SOURCE}")"
+    [[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}"
+  done
+    
+  # Establish file and folder paths for JShell config
+  export conf="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"; 
+  export jPath="$conf/jshell-init.jsh"

Review comment:
       You should generate this in the `assemble/target` directory during the build, and then update the `assemble/src/main/assemblies/component.xml` file to ensure it is copied to the appropriate `conf/` directory by the `maven-assembly-plugin` for the distribution tarball.

##########
File path: assemble/bin/accumulo
##########
@@ -58,7 +58,30 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+ 
+  # Verify what file(s) is loaded into JShell
+  if [[ $cmd == "jshell" ]] && [[ "$#" -eq 1 ]]; then
+    # Load in default Accumulo APIs into JShell
+    CLASSPATH="$CLASSPATH" "$@" "$jShellPath" 
+    exit 0
 
+  elif [[ $cmd == "jshell" ]] && [[ "$#" -ne 1 ]]; then
+    cmdArr=( "$@" )
+    # Traverse through user bash command and verify -startup argument exists
+    for arg in "${!cmdArr[@]}"; do
+       if [[ "${cmdArr[arg]}" =~ "-startup" ]]; then
+         # Insert "DEFAULT" JShell script after -startup argument
+         cmdArr=( "${cmdArr[@]:0:arg}" "DEFAULT" "${cmdArr[@]:arg+1}" )
+       fi
+    done
+    # Load in default java libraries first followed by custom file(s)
+    CLASSPATH="$CLASSPATH" "${cmdArr[@]}"
+    exit 0
+  fi

Review comment:
       CLASSPATH is probably already exported, so you might not need that part. If you do, then `export CLASSPATH` on the preceding line before the exec might be more clear.
   
   Also, you can probably inject the startup file (if it exists) before the user's own arguments, as in:
   
   ```suggestion
     jShellPath="$conf/jshell-init.jsh"
     if [[ $cmd == "jshell" ]]; then
       shift
       if [[ -f "$jShellPath" ]]; then
         exec "$cmd" --startup "$jShellPath" "$@"
       else
         exec "$cmd" "$@"
       fi
     fi
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii merged pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii merged pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] keith-turner commented on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
keith-turner commented on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-810358584


   > Is there an example of how to use this?
   
   I used this recently to quickly create some data for testing compactions.  Below is a bit of bash I wrote to use this new feature.
   
   ```bash
   bin/accumulo jshell -<<EOF
   var client=Accumulo.newClient().from("conf/accumulo-client.properties").build();
   var writer=client.createBatchWriter("testTable");
   String prev = "";
   for(int i = 0; i < 2000000; i++){ var uuid = UUID.randomUUID().toString(); Mutation m = new Mutation(uuid); m.put("","",prev); writer.addMutation(m); prev = uuid;}
   writer.close()
   /exit
   EOF
   ```


-- 
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773563654


   @slackwinner Since you're still working on this, I converted it to a Draft pull request.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773563654


   @slackwinner Since you're still working on this, I converted it to a Draft pull request.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583734216



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       For the DEFAULT script, I originally left that as a start up parameter to ensure the user can see the default import library and the Accumulo API when they first boot up JShell. I believe having two start-up statements should do the trick. Also I believe I found a work around regarding the Scanner. Whenever a Scanner is defined, we need to explicitly specify which Scanner are we referring to. For example: 
   
   **Referencing Accumulo Scanner:**
   org.apache.accumulo.core.client.Scanner scan = client.createScanner("GothamPD", Authorizations.EMPTY);
   
   **Referencing Java Scanner:**
    java.util.Scanner myObj = new java.util.Scanner(System.in);
   
   I created a Java test code where one function uses the Accumulo Scanner and another function uses the Java Scanner. I then executed the code in JShell with Accumulo and both functions where able to execute with no issues. 
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] dlmarion commented on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
dlmarion commented on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-810200838


   Is there an example of how to use this?


-- 
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:
users@infra.apache.org



[GitHub] [accumulo] dlmarion commented on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
dlmarion commented on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-786003423


   As part of https://issues.apache.org/jira/browse/ACCUMULO-1399 I added the ability for users to write scripts in a supported JSR-223 engine and run them in the shell. How does adding jshell to the shell compare to this? Is it duplicative, should the script command be deprecated?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583745312



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       I was aware of the workaround, but it's still annoying to specify the fully-qualified class name. Since the java.util.Scanner is very unlikely to be used by Accumulo devs using this, I was thinking we could try to exclude it by replacing `java.util.*` from the defaults with a narrower set of useful imports from `java.util`, but I'm not sure what that set would look like. It would probably include a bunch of Collection classes, but I'm not sure what else.
   
   The alternative is that we just settle for the workaround for now, and consider a new name for Scanner in Accumulo's public API in the future to make it easier to coexist with java.util.Scanner.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583755717



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       Cool. I just pushed a commit to apply your double-startup option idea into the accumulo script file. 




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583864338



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  

Review comment:
       Remove trailing whitespace on empty lines. Also, I don't think this variable needs to be exported, since it's only ever used within this same script, and not used by any subcommands. However, it is used inside a function (called 'main'), so you can make it a local variable, so its assignment doesn't leak outside the function. Annoyingly, the default in bash is that assignments create global variables.
   
   ```suggestion
   
     # Set up path variable for default import config file
     local jShellPath="$conf/jshell-init.jsh"
   
   ```

##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,110 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI(){
+  export srcDir="$1"
+  export jPath="$2"
+  export client="accumulo/core/client"
+  export data="accumulo/core/data"
+  export security="accumulo/core/security"
+  export mini="accumulo/minicluster"
+  export hadoop="accumulo/hadoop"
+    
+  # Does an auto-generated JShell config file exists?
+  if [[ ! -e "$jPath" ]]; then
+    echo "Cannot add APIs in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+  
+  # Is the source directory valid?
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    rm "$jPath"
+    exit 1
+  fi
+  
+  # Does a valid JShell path and source directory exists?
+  if [[ -e "$jPath" ]] && [[ -d "$srcDir" ]]; then
+    # Add API category designator in jshell-init.jsh 
+    case "$srcDir" in
+        *"$client"*) echo "// Accumulo Client API" >> "$jPath";;
+        *"$data"*) echo "// Accumulo Data API" >> "$jPath";;
+        *"$security"*) echo "// Accumulo Security API" >> "$jPath";;
+        *"$mini"*) echo "// Accumulo Minicluster API" >> "$jPath";;
+        *"$hadoop"*) echo "// Accumulo Hadoop API" >> "$jPath";;
+        *) echo "// Other API" >> "$jPath";;
+    esac
+   
+    # Extract API info from provided source directory
+    mapfile -t api < <(find "$srcDir" -type f -name '*.java'| 
+                       xargs -n1 dirname| sort -u)

Review comment:
       When I ran shellcheck on this script, it warned of files containing special characters that might propose a problem. Making the output of `find` a null `\0` character and the input of `xargs` look split on null characters, the risk goes away:
   
   ```suggestion
       # Extract API info from provided source directory
       mapfile -t api < <(find "$srcDir" -type f -name '*.java' -print0 | 
                          xargs -0 -n1 dirname| sort -u)
   ```

##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,110 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI(){
+  export srcDir="$1"
+  export jPath="$2"
+  export client="accumulo/core/client"
+  export data="accumulo/core/data"
+  export security="accumulo/core/security"
+  export mini="accumulo/minicluster"
+  export hadoop="accumulo/hadoop"
+    
+  # Does an auto-generated JShell config file exists?
+  if [[ ! -e "$jPath" ]]; then
+    echo "Cannot add APIs in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+  
+  # Is the source directory valid?
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    rm "$jPath"
+    exit 1
+  fi
+  
+  # Does a valid JShell path and source directory exists?
+  if [[ -e "$jPath" ]] && [[ -d "$srcDir" ]]; then
+    # Add API category designator in jshell-init.jsh 
+    case "$srcDir" in
+        *"$client"*) echo "// Accumulo Client API" >> "$jPath";;
+        *"$data"*) echo "// Accumulo Data API" >> "$jPath";;
+        *"$security"*) echo "// Accumulo Security API" >> "$jPath";;
+        *"$mini"*) echo "// Accumulo Minicluster API" >> "$jPath";;
+        *"$hadoop"*) echo "// Accumulo Hadoop API" >> "$jPath";;
+        *) echo "// Other API" >> "$jPath";;
+    esac
+   
+    # Extract API info from provided source directory
+    mapfile -t api < <(find "$srcDir" -type f -name '*.java'| 
+                       xargs -n1 dirname| sort -u)
+   
+    # Load in API and format source directory into Java import statements
+    for apiPath in "${api[@]}"; do
+       printf "%s\n" "import ${apiPath##*/java/}.*" >> "$jPath"
+    done
+    sed -i '/^ *import / s#/#.#g' "$jPath"
+    echo " " >> "$jPath"
+  fi
+}
+
+function main(){
+  # Establish Accumulo's main base directory
+  SOURCE="${BASH_SOURCE[0]}"
+  while [[ -h "${SOURCE}" ]]; do
+    bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+    SOURCE="$(readlink "${SOURCE}")"
+    [[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}"
+  done
+    
+  # Establish file and folder paths for JShell config
+  export scriptPath="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"; 
+  export mainBase=$( cd -P "${scriptPath}"/../../../.. && pwd );
+  export jPath="$mainBase/assemble/target/jshell-init.jsh"
+  export corePath="core/src/main/java/org/apache/accumulo/core"
+  export miniPath="minicluster/src/main/java/org/apache/accumulo"
+  export hadoopPath="hadoop-mapreduce/src/main/java/org/apache/accumulo"
+    
+  # Create path to Accumulo Public API Source Directories
+  export CLIENT="$mainBase/$corePath/client"
+  export DATA="$mainBase/$corePath/data"
+  export SECURITY="$mainBase/$corePath/security"
+  export MINI="$mainBase/$miniPath/minicluster"
+  export HADOOP="$mainBase/$hadoopPath/hadoop/mapreduce" 

Review comment:
       shellcheck warns of return code suppression when assigning and exporting at the same time. It would also warn after these are converted to local variables, which can also be done, since these don't need to be exported. This only applies when assigning a variable to the result of a command, but not to simple assignments.
   
   I strongly recommend running shellcheck to catch any potential errors on any scripts you write.
   
   ```suggestion
     local scriptPath; scriptPath="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"; 
     local mainBase; mainBase=$( cd -P "${scriptPath}"/../../../.. && pwd );
     local jPath="$mainBase/assemble/target/jshell-init.jsh"
     local corePath="core/src/main/java/org/apache/accumulo/core"
     local miniPath="minicluster/src/main/java/org/apache/accumulo"
     local hadoopPath="hadoop-mapreduce/src/main/java/org/apache/accumulo"
       
     # Create path to Accumulo Public API Source Directories
     local CLIENT="$mainBase/$corePath/client"
     local DATA="$mainBase/$corePath/data"
     local SECURITY="$mainBase/$corePath/security"
     local MINI="$mainBase/$miniPath/minicluster"
     local HADOOP="$mainBase/$hadoopPath/hadoop/mapreduce" 
   ```

##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,110 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI(){
+  export srcDir="$1"
+  export jPath="$2"
+  export client="accumulo/core/client"
+  export data="accumulo/core/data"
+  export security="accumulo/core/security"
+  export mini="accumulo/minicluster"
+  export hadoop="accumulo/hadoop"
+    
+  # Does an auto-generated JShell config file exists?
+  if [[ ! -e "$jPath" ]]; then
+    echo "Cannot add APIs in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+  
+  # Is the source directory valid?
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    rm "$jPath"
+    exit 1
+  fi
+  
+  # Does a valid JShell path and source directory exists?
+  if [[ -e "$jPath" ]] && [[ -d "$srcDir" ]]; then
+    # Add API category designator in jshell-init.jsh 
+    case "$srcDir" in
+        *"$client"*) echo "// Accumulo Client API" >> "$jPath";;
+        *"$data"*) echo "// Accumulo Data API" >> "$jPath";;
+        *"$security"*) echo "// Accumulo Security API" >> "$jPath";;
+        *"$mini"*) echo "// Accumulo Minicluster API" >> "$jPath";;
+        *"$hadoop"*) echo "// Accumulo Hadoop API" >> "$jPath";;
+        *) echo "// Other API" >> "$jPath";;
+    esac
+   
+    # Extract API info from provided source directory
+    mapfile -t api < <(find "$srcDir" -type f -name '*.java'| 
+                       xargs -n1 dirname| sort -u)
+   
+    # Load in API and format source directory into Java import statements
+    for apiPath in "${api[@]}"; do
+       printf "%s\n" "import ${apiPath##*/java/}.*" >> "$jPath"
+    done
+    sed -i '/^ *import / s#/#.#g' "$jPath"
+    echo " " >> "$jPath"
+  fi
+}
+
+function main(){
+  # Establish Accumulo's main base directory
+  SOURCE="${BASH_SOURCE[0]}"
+  while [[ -h "${SOURCE}" ]]; do
+    bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+    SOURCE="$(readlink "${SOURCE}")"
+    [[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}"
+  done
+    
+  # Establish file and folder paths for JShell config
+  export scriptPath="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"; 
+  export mainBase=$( cd -P "${scriptPath}"/../../../.. && pwd );
+  export jPath="$mainBase/assemble/target/jshell-init.jsh"
+  export corePath="core/src/main/java/org/apache/accumulo/core"
+  export miniPath="minicluster/src/main/java/org/apache/accumulo"
+  export hadoopPath="hadoop-mapreduce/src/main/java/org/apache/accumulo"
+    
+  # Create path to Accumulo Public API Source Directories
+  export CLIENT="$mainBase/$corePath/client"
+  export DATA="$mainBase/$corePath/data"
+  export SECURITY="$mainBase/$corePath/security"
+  export MINI="$mainBase/$miniPath/minicluster"
+  export HADOOP="$mainBase/$hadoopPath/hadoop/mapreduce" 
+   
+  # Does an auto-generated JShell config file exists?
+  if [[ -e "$jPath" ]]; then
+     rm "$jPath"
+  fi
+    
+  # Create new jshell-init file and load in license header   
+  touch "$jPath"

Review comment:
       This file can be erased and created at the same time. Also, you can make sure its directory is created also, in case the script runs before other parts of Maven that normally create the target directory:
   
   ```suggestion
     # Create new jshell-init file
     mkdir -p "$mainBase/assemble/target"
     :> "$jPath"
   ```
   

##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,110 @@
+#! /usr/bin/env bash

Review comment:
       This file has a lot of lines that have trailing whitespace. It'd be good to remove any trailing spaces on all lines in the file. If you're using VIM, you can do this with the command:
   ```
   :1,$ s/  *$//c
   ```
   This goes through lines 1, through $ (marker for last line in file), and replaces any single space followed by an optional sequence of multiple spaces at the end of each line with an empty string, and the `c` at the end is to confirm each one, so you can make sure it's working correctly. Drop the `c` if you just want to run without checking.

##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,110 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI(){
+  export srcDir="$1"
+  export jPath="$2"
+  export client="accumulo/core/client"
+  export data="accumulo/core/data"
+  export security="accumulo/core/security"
+  export mini="accumulo/minicluster"
+  export hadoop="accumulo/hadoop"

Review comment:
       I don't think any of the variables in this entire script need to be exported, but they can all be declared as local variables. A few other variables don't have any exports, but can also be declared as local variables if they are inside a function.

##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,110 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI(){
+  export srcDir="$1"
+  export jPath="$2"
+  export client="accumulo/core/client"
+  export data="accumulo/core/data"
+  export security="accumulo/core/security"
+  export mini="accumulo/minicluster"
+  export hadoop="accumulo/hadoop"
+    
+  # Does an auto-generated JShell config file exists?
+  if [[ ! -e "$jPath" ]]; then
+    echo "Cannot add APIs in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+  
+  # Is the source directory valid?
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    rm "$jPath"
+    exit 1
+  fi
+  
+  # Does a valid JShell path and source directory exists?
+  if [[ -e "$jPath" ]] && [[ -d "$srcDir" ]]; then
+    # Add API category designator in jshell-init.jsh 
+    case "$srcDir" in
+        *"$client"*) echo "// Accumulo Client API" >> "$jPath";;
+        *"$data"*) echo "// Accumulo Data API" >> "$jPath";;
+        *"$security"*) echo "// Accumulo Security API" >> "$jPath";;
+        *"$mini"*) echo "// Accumulo Minicluster API" >> "$jPath";;
+        *"$hadoop"*) echo "// Accumulo Hadoop API" >> "$jPath";;
+        *) echo "// Other API" >> "$jPath";;
+    esac
+   
+    # Extract API info from provided source directory
+    mapfile -t api < <(find "$srcDir" -type f -name '*.java'| 
+                       xargs -n1 dirname| sort -u)
+   
+    # Load in API and format source directory into Java import statements
+    for apiPath in "${api[@]}"; do
+       printf "%s\n" "import ${apiPath##*/java/}.*" >> "$jPath"
+    done
+    sed -i '/^ *import / s#/#.#g' "$jPath"
+    echo " " >> "$jPath"

Review comment:
       You could just use echo here instead of printf, since the only thing printf is doing is adding the newline, which echo would do by default. `tr` is probably also faster than `sed`, and the extra blank line doesn't need a space:
   
   ```suggestion
          echo "import ${apiPath##*/java/}.*" | tr / . >> "$jPath"
       done
       echo >> "$jPath"
   ```

##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,110 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI(){
+  export srcDir="$1"
+  export jPath="$2"
+  export client="accumulo/core/client"
+  export data="accumulo/core/data"
+  export security="accumulo/core/security"
+  export mini="accumulo/minicluster"
+  export hadoop="accumulo/hadoop"
+    
+  # Does an auto-generated JShell config file exists?
+  if [[ ! -e "$jPath" ]]; then
+    echo "Cannot add APIs in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+  
+  # Is the source directory valid?
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    rm "$jPath"
+    exit 1
+  fi
+  
+  # Does a valid JShell path and source directory exists?
+  if [[ -e "$jPath" ]] && [[ -d "$srcDir" ]]; then
+    # Add API category designator in jshell-init.jsh 
+    case "$srcDir" in
+        *"$client"*) echo "// Accumulo Client API" >> "$jPath";;
+        *"$data"*) echo "// Accumulo Data API" >> "$jPath";;
+        *"$security"*) echo "// Accumulo Security API" >> "$jPath";;
+        *"$mini"*) echo "// Accumulo Minicluster API" >> "$jPath";;
+        *"$hadoop"*) echo "// Accumulo Hadoop API" >> "$jPath";;
+        *) echo "// Other API" >> "$jPath";;
+    esac
+   
+    # Extract API info from provided source directory
+    mapfile -t api < <(find "$srcDir" -type f -name '*.java'| 
+                       xargs -n1 dirname| sort -u)
+   
+    # Load in API and format source directory into Java import statements
+    for apiPath in "${api[@]}"; do
+       printf "%s\n" "import ${apiPath##*/java/}.*" >> "$jPath"
+    done
+    sed -i '/^ *import / s#/#.#g' "$jPath"
+    echo " " >> "$jPath"
+  fi
+}
+
+function main(){
+  # Establish Accumulo's main base directory
+  SOURCE="${BASH_SOURCE[0]}"
+  while [[ -h "${SOURCE}" ]]; do
+    bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+    SOURCE="$(readlink "${SOURCE}")"
+    [[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}"
+  done
+    
+  # Establish file and folder paths for JShell config
+  export scriptPath="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"; 
+  export mainBase=$( cd -P "${scriptPath}"/../../../.. && pwd );
+  export jPath="$mainBase/assemble/target/jshell-init.jsh"
+  export corePath="core/src/main/java/org/apache/accumulo/core"
+  export miniPath="minicluster/src/main/java/org/apache/accumulo"
+  export hadoopPath="hadoop-mapreduce/src/main/java/org/apache/accumulo"
+    
+  # Create path to Accumulo Public API Source Directories
+  export CLIENT="$mainBase/$corePath/client"
+  export DATA="$mainBase/$corePath/data"
+  export SECURITY="$mainBase/$corePath/security"
+  export MINI="$mainBase/$miniPath/minicluster"
+  export HADOOP="$mainBase/$hadoopPath/hadoop/mapreduce" 
+   
+  # Does an auto-generated JShell config file exists?
+  if [[ -e "$jPath" ]]; then
+     rm "$jPath"
+  fi
+    
+  # Create new jshell-init file and load in license header   
+  touch "$jPath"
+ 
+  # Create and add Accumulo APIs into API storage 
+  apiStorage=("$CLIENT" "$DATA" "$SECURITY" "$MINI" "$HADOOP")
+   
+  # Traverse through each source directory and load in Accumulo APIs
+  for srcDir in "${apiStorage[@]}"; do

Review comment:
       These local variables, like arrays and loop variables are easy to overlook and accidentally create global variables. Global variables aren't necessarily a problem in a small single-threaded script, but it's good practice to keep variables as local as possible.
   
   ```suggestion
     local apiStorage=("$CLIENT" "$DATA" "$SECURITY" "$MINI" "$HADOOP")
      
     # Traverse through each source directory and load in Accumulo APIs
     local srcDir
     for srcDir in "${apiStorage[@]}"; do
   ```

##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,110 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI(){
+  export srcDir="$1"
+  export jPath="$2"
+  export client="accumulo/core/client"
+  export data="accumulo/core/data"
+  export security="accumulo/core/security"
+  export mini="accumulo/minicluster"
+  export hadoop="accumulo/hadoop"
+    
+  # Does an auto-generated JShell config file exists?
+  if [[ ! -e "$jPath" ]]; then
+    echo "Cannot add APIs in $jPath"
+    echo "Please ensure jshell-init.jsh exists"
+    exit 1
+  fi
+  
+  # Is the source directory valid?
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    rm "$jPath"
+    exit 1
+  fi
+  
+  # Does a valid JShell path and source directory exists?
+  if [[ -e "$jPath" ]] && [[ -d "$srcDir" ]]; then
+    # Add API category designator in jshell-init.jsh 
+    case "$srcDir" in
+        *"$client"*) echo "// Accumulo Client API" >> "$jPath";;
+        *"$data"*) echo "// Accumulo Data API" >> "$jPath";;
+        *"$security"*) echo "// Accumulo Security API" >> "$jPath";;
+        *"$mini"*) echo "// Accumulo Minicluster API" >> "$jPath";;
+        *"$hadoop"*) echo "// Accumulo Hadoop API" >> "$jPath";;
+        *) echo "// Other API" >> "$jPath";;
+    esac
+   
+    # Extract API info from provided source directory
+    mapfile -t api < <(find "$srcDir" -type f -name '*.java'| 
+                       xargs -n1 dirname| sort -u)
+   
+    # Load in API and format source directory into Java import statements
+    for apiPath in "${api[@]}"; do
+       printf "%s\n" "import ${apiPath##*/java/}.*" >> "$jPath"
+    done
+    sed -i '/^ *import / s#/#.#g' "$jPath"
+    echo " " >> "$jPath"
+  fi
+}
+
+function main(){
+  # Establish Accumulo's main base directory
+  SOURCE="${BASH_SOURCE[0]}"
+  while [[ -h "${SOURCE}" ]]; do
+    bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+    SOURCE="$(readlink "${SOURCE}")"
+    [[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}"
+  done
+    
+  # Establish file and folder paths for JShell config
+  export scriptPath="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"; 
+  export mainBase=$( cd -P "${scriptPath}"/../../../.. && pwd );
+  export jPath="$mainBase/assemble/target/jshell-init.jsh"
+  export corePath="core/src/main/java/org/apache/accumulo/core"
+  export miniPath="minicluster/src/main/java/org/apache/accumulo"
+  export hadoopPath="hadoop-mapreduce/src/main/java/org/apache/accumulo"
+    
+  # Create path to Accumulo Public API Source Directories
+  export CLIENT="$mainBase/$corePath/client"
+  export DATA="$mainBase/$corePath/data"
+  export SECURITY="$mainBase/$corePath/security"
+  export MINI="$mainBase/$miniPath/minicluster"
+  export HADOOP="$mainBase/$hadoopPath/hadoop/mapreduce" 
+   
+  # Does an auto-generated JShell config file exists?
+  if [[ -e "$jPath" ]]; then
+     rm "$jPath"
+  fi
+    
+  # Create new jshell-init file and load in license header   
+  touch "$jPath"
+ 
+  # Create and add Accumulo APIs into API storage 
+  apiStorage=("$CLIENT" "$DATA" "$SECURITY" "$MINI" "$HADOOP")
+   
+  # Traverse through each source directory and load in Accumulo APIs
+  for srcDir in "${apiStorage[@]}"; do
+    addAccumuloAPI "$srcDir" "$jPath"
+  done
+  exit 0

Review comment:
       Normally at the end of a function, you'd want to let the return code of the last command propagate outside of the function. If this loop terminates abnormally, we shouldn't mask its return code with our own using `exit 0`, which forces it to terminate successfully, even if there was an error.
   
   Also, I was thinking, you don't need to pass in the filename to the function or create it ahead of time. Instead, you can just create the file right here at the output of the whole for loop. That would simplify the implementation of the addAccumuloAPI command a lot.
   
   ```suggestion
       addAccumuloAPI "$srcDir"
     done > "$jPath"
   ```
   One other suggestion I had was that you could move the printing of the section headers to outside that method, that way you don't need to create so many variables in that method to do the section header checks. You could either move the if statements to here, inside this for loop, before calling `addAccumuloAPI`, or you remove the loop, and do something like the following. You wouldn't even need all the extra variables this way, because you could just inline them:
   
   ```bash
     {
       echo "// section header here for client"
       addAccumuloAPI "$CLIENT"
       echo "// section header here for data"
       addAccumuloAPI "$DATA"
       # etc...
     } > "$jPath"
   ```
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r585866749



##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,92 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI(){
+  local srcDir="$1"
+  # Extract API info from provided source directory
+  mapfile -t api < <(find "$srcDir" -type f -name '*.java' -print0|
+                     xargs -0 -n1 dirname| sort -u)
+
+  # Load in API and format source directory into Java import statements
+  for apiPath in "${api[@]}"; do
+     echo "import ${apiPath##*/java/}.*" | tr / .
+  done
+  echo
+}
+
+function main(){
+  # Establish Accumulo's main base directory
+  SOURCE="${BASH_SOURCE[0]}"
+  while [[ -h "${SOURCE}" ]]; do
+    bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+    SOURCE="$(readlink "${SOURCE}")"
+    [[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}"
+  done
+
+  # Establish file and folder paths for JShell config
+  local scriptPath
+  scriptPath="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+  local mainBase
+  mainBase="$( cd -P "${scriptPath}"/../../../.. && pwd )"
+  local jPath="$mainBase/assemble/target/jshell-init.jsh"
+  local corePath="core/src/main/java/org/apache/accumulo/core"
+  local miniPath="minicluster/src/main/java/org/apache/accumulo"
+  local hadoopPath="hadoop-mapreduce/src/main/java/org/apache/accumulo"
+
+  # Create path to Accumulo Public API Source Directories
+  local CLIENT="$mainBase/$corePath/client"
+  local DATA="$mainBase/$corePath/data"
+  local SECURITY="$mainBase/$corePath/security"
+  local MINI="$mainBase/$miniPath/minicluster"
+  local HADOOP="$mainBase/$hadoopPath/hadoop/mapreduce"
+
+  # Create new jshell-init file
+  mkdir -p "$mainBase/assemble/target"
+  :> "$jPath"
+
+  # Create and add Accumulo APIs into API storage
+  local apiStorage=("$CLIENT" "$DATA" "$SECURITY" "$MINI" "$HADOOP")
+  local srcDir
+
+  # Validate each source directory before populating JShell-Init file
+  for srcDir in "${apiStorage[@]}"; do
+    if [[ ! -d "$srcDir" ]]; then
+      echo "Could not auto-generate jshell-init.jsh"
+      echo "$srcDir is not a valid directory. Please make sure it exists."
+      rm "$jPath"
+      exit 1
+    fi
+  done
+  echo "Generating JShell-Init file"
+  {
+    echo "System.out.println(\"Preparing JShell for Apache Accumulo\")"
+    echo "// Accumulo Client API"
+    addAccumuloAPI "${apiStorage[0]}"
+    echo "// Accumulo Data API"
+    addAccumuloAPI "${apiStorage[1]}"
+    echo "// Accumulo Security API"
+    addAccumuloAPI "${apiStorage[2]}"
+    echo "// Accumulo MiniCluster API"
+    addAccumuloAPI "${apiStorage[3]}"
+    echo "// Accumulo Hadoop API"
+    addAccumuloAPI "${apiStorage[4]}"
+  } > "$jPath"
+}
+main "$@"

Review comment:
       I had a few other minor tips for this script, but probably not worth going back and forth over them, so here they are as one lump suggestion:
   
   * Minor style improvements (indentation using 2 spaces instead of 3,
     space before opening brace in function declaration and around pipes
   * Declare additional variables as local (SOURCE, bin) and place in
     single line at top of each function
   * Do validation of srcDirs in called method, rather than in a separate
     loop, to avoid needing to use an array for the srcDirs
   * Reduce number of variables needed by inlining several
   * Remove redundant clearing of destination file
   * Use single quote for strings that don't have embedded variables
   * Move System.out.println to after the imports
   
   ```suggestion
   function addAccumuloAPI() {
     local srcDir="$1" api apiPath
     # Validate each source directory before populating JShell-Init file
     if [[ ! -d "$srcDir" ]]; then
       echo "$srcDir is not a valid directory. Please make sure it exists."
       exit 1
     fi
   
     # Extract API info from provided source directory
     mapfile -t api < <(find "$srcDir" -type f -name '*.java' -print0 | xargs -0 -n1 dirname | sort -u)
   
     # Load in API and format source directory into Java import statements
     for apiPath in "${api[@]}"; do
       echo "import ${apiPath##*/java/}.*" | tr / .
     done
     echo
   }
   
   function main() {
     local SOURCE bin scriptPath mainBase corePath
     # Establish Accumulo's main base directory
     SOURCE="${BASH_SOURCE[0]}"
     while [[ -h "${SOURCE}" ]]; do
       bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
       SOURCE="$(readlink "${SOURCE}")"
       [[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}"
     done
   
     # Establish file and folder paths for JShell config
     scriptPath="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
     mainBase="$( cd -P "${scriptPath}"/../../../.. && pwd )"
     corePath="$mainBase/core/src/main/java/org/apache/accumulo/core"
   
     # Create new jshell-init file
     mkdir -p "$mainBase/assemble/target"
     echo 'Generating JShell-Init file'
     {
       echo '// Accumulo Client API'
       addAccumuloAPI "$corePath/client"
       echo '// Accumulo Data API'
       addAccumuloAPI "$corePath/data"
       echo '// Accumulo Security API'
       addAccumuloAPI "$corePath/security"
       echo '// Accumulo MiniCluster API'
       addAccumuloAPI "$mainBase/minicluster/src/main/java/org/apache/accumulo/minicluster"
       echo '// Accumulo Hadoop API'
       addAccumuloAPI "$mainBase/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce"
       echo
       echo 'System.out.println("Preparing JShell for Apache Accumulo")'
       echo
     } > "$mainBase/assemble/target/jshell-init.jsh"
   }
   
   main "$@"
   
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r585920009



##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,74 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI() {
+  local srcDir="$1" api apiPath
+  # Validate each source directory before populating JShell-Init file
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    exit 1
+  fi
+
+  # Extract API info from provided source directory
+  mapfile -t api < <(find "$srcDir" -type f -name '*.java' -print0 | xargs -0 -n1 dirname | sort -u)
+
+  # Load in API and format source directory into Java import statements
+  for apiPath in "${api[@]}"; do
+    echo "import ${apiPath##*/java/}.*" | tr / .

Review comment:
       Trailing semicolon isn't strictly necessary for JShell, but it's nice to have.
   
   ```suggestion
       echo "import ${apiPath##*/java/}.*;" | tr / .
   ```

##########
File path: assemble/src/main/scripts/create-jshell.sh
##########
@@ -0,0 +1,74 @@
+#! /usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+function addAccumuloAPI() {
+  local srcDir="$1" api apiPath
+  # Validate each source directory before populating JShell-Init file
+  if [[ ! -d "$srcDir" ]]; then
+    echo "$srcDir is not a valid directory. Please make sure it exists."
+    exit 1
+  fi
+
+  # Extract API info from provided source directory
+  mapfile -t api < <(find "$srcDir" -type f -name '*.java' -print0 | xargs -0 -n1 dirname | sort -u)
+
+  # Load in API and format source directory into Java import statements
+  for apiPath in "${api[@]}"; do
+    echo "import ${apiPath##*/java/}.*" | tr / .
+  done
+  echo
+}
+
+function main() {
+  local SOURCE bin scriptPath mainBase corePath
+  # Establish Accumulo's main base directory
+  SOURCE="${BASH_SOURCE[0]}"
+  while [[ -h "${SOURCE}" ]]; do
+    bin="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+    SOURCE="$(readlink "${SOURCE}")"
+    [[ "${SOURCE}" != /* ]] && SOURCE="${bin}/${SOURCE}"
+  done
+
+  # Establish file and folder paths for JShell config
+  scriptPath="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
+  mainBase="$( cd -P "${scriptPath}"/../../../.. && pwd )"
+  corePath="$mainBase/core/src/main/java/org/apache/accumulo/core"
+
+  # Create new jshell-init file
+  mkdir -p "$mainBase/assemble/target"
+  echo 'Generating JShell-Init file'
+  {
+    echo '// Accumulo Client API'
+    addAccumuloAPI "$corePath/client"
+    echo '// Accumulo Data API'
+    addAccumuloAPI "$corePath/data"
+    echo '// Accumulo Security API'
+    addAccumuloAPI "$corePath/security"
+    echo '// Accumulo MiniCluster API'
+    addAccumuloAPI "$mainBase/minicluster/src/main/java/org/apache/accumulo/minicluster"
+    echo '// Accumulo Hadoop API'
+    addAccumuloAPI "$mainBase/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce"
+    echo
+    echo 'System.out.println("Preparing JShell for Apache Accumulo")'

Review comment:
       While playing with these changes, I noticed that `Text` from Hadoop would be nice to have by default, as it is frequently used in our own APIs.
   
   ```suggestion
       echo '// Essential Hadoop API
       echo 'import org.apache.hadoop.io.Text;'
       echo
       echo '// Initialization code'
       echo 'System.out.println("Preparing JShell for Apache Accumulo");'
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583717807



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       I just learned that we can actually specify more than one `--startup` option, so if we don't want to customize the `java.*` imports for now, and just want the defaults, we can do:
   
   ```suggestion
         exec "$cmd" --startup DEFAULT --startup "$jShellPath" "$@"
   ```
   
   This preserves proper `/reset` and `/reload` behavior without mixing and matching `[options]` and `[load-files]` parameter, but saves us the work of generating `java.*` imports ourselves. However, it does leave the Scanner conflict in place, which is probably acceptable for now.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583681393



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       I think `--startup DEFAULT` is a redundant option, since it is the default behavior.
   
   I was thinking `--startup "$jShellPath"` could be used instead of `--startup DEFAULT`, as its replacement. So, the choice we have is to use the default startup or to replace it.
   
   This really comes down to [the difference between an 'option' and a 'parameter'](https://stackoverflow.com/a/36495940/196405), and the fact that the man page says `jshell [options] [load-files]`, implying options should precede file parameters, as is typical for command-line programs.
   
   To explain why this matters, consider the following. In my explanation, I replace the `--startup DEFAULT` option with the `--no-startup` option, to show the differences between options and file parameters, while ignoring the behavioral differences between including the `DEFAULT` startup or not.
   
   Functionally, the following are the same:
   ```
   jshell --startup    conf/jshell-init.jsh <-- replaces the DEFAULT startup with this file
   jshell --no-startup conf/jshell-init.jsh <-- skips the DEFAULT startup and only executes this file
   ```
   
   However, if we're also passing in user options in `$@`, this becomes a problem. To see why, imagine the user executes `bin/accumulo jshell -v userFile.jsh`, then the resulting commands look like:
   ```
   jshell --startup    conf/jshell-init.jsh -v userFile.jsh <-- replaces the DEFAULT startup, also sets the verbose feedback mode, and then executes the user file
   jshell --no-startup conf/jshell-init.jsh -v userFile.jsh <-- may work, but mixes [options] with [load-files]
   ```
   
   I actually tried these both, and jshell did work for me, even though it is not correct according to the manual. It seems jshell is a bit forgiving, at least in the version I have installed. However, we shouldn't count on it working.
   
   And, there is still a difference. If you run `/list -all`, you can see that anything executed as a startup script is listed with the letter `s` followed by a number, and anything executed after, including all commands from `[load-files]` parameters, just gets a number. This matters for user experience, because if you want to reset the state of the jshell using `/reset`, all the startup scripts will re-execute, but any `[load-files]` ones will not (`/reload` would be used instead of `/reset` if you want to re-run the other commands after resetting).
   
   So, this is all to say that I think that we should make sure that when we execute `jshell-init.jsh`, we should ensure that it is done as a `--startup` option, and not as a `[load-files]` parameter. That way, `/reset` and `/reload` behave as expected, and we don't mix and match `[options]` and `[load-files]` arguments when users specify additional options to the command, which may not work in future.
   
   The only downside to this is that if we want any `java.*` imports automatically loaded, we need to include them in the generated file. However, this isn't really a downside, as much as it is an opportunity to tailor our initial imports to avoid any potential conflicts (such as that between `java.util.Scanner` and `org.apache.accumulo.core.client.Scanner`).
   
   ```suggestion
         exec "$cmd" --startup "$jShellPath" "$@"
   ```

##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       I just learned that we can actually specify more than one `--startup` option, so if we don't want to customize the `java.*` imports for now, and just want the defaults, we can do:
   
   ```suggestion
         exec "$cmd" --startup DEFAULT --startup "$jShellPath" "$@"
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner edited a comment on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner edited a comment on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773505326


   @ctubbsii This is still in a work in progress but I wanted to share what I have done so far. Essentially, I added a "jshell entry" in bin/accumulo so that the user can easily activate jshell with the classpath imported. In addition, there is a jshell-init.jsh file that allows the user to load in the default Accumulo public APIs. Also the user can customize jshell-init by adding or removing public APIs. Currently jshell-init has hard coded public APIs as I am  still figuring out how to import the classes automatically as well as making sure the classes are always up to date during a build. Feel free to comment if you have any suggestions/ideas on how to automate the import process or improve the jshell feature as a whole. Below are simple examples on how to boot up Jshell with Accumulo. 
   
   **Starting JShell with Accumulo Example:**
   _$ bin/accumulo jshell (Path to Jshell-init.jsh file)_
   - This cmd will pass the $CLASSPATH to Jshell and import both the Accumulo public APIs  from the .jsh file and the default java libraries.
   
   _$bin/accumulo jshell --startup (Path to Jshell-init.jsh file)_
   - This cmd will pass the $CLASSPATH to Jshell and only import both the Accumulo public APIs from the .jsh file.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583748528



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       Would you like me to manually import all the classes from java.util.* into the jshell-init.jsh file or just go with the alternative solution?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583734216



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       For the DEFAULT script, I originally left that as a start up parameter to ensure the user can see the default import library and the Accumulo API when they first boot up JShell. I believe having two start-up statements should do the trick and I do see the results you are getting from my end. Also I believe I found a work around regarding the Scanner. Whenever a Scanner is defined, we need to explicitly specify which Scanner we are referring to. For example: 
   
   **Referencing Accumulo Scanner:**
   org.apache.accumulo.core.client.Scanner scan = client.createScanner("GothamPD", Authorizations.EMPTY);
   
   **Referencing Java Scanner:**
    java.util.Scanner myObj = new java.util.Scanner(System.in);
   
   I created a Java test code where one function uses the Accumulo Scanner and another function uses the Java Scanner. I then executed the code in JShell with Accumulo and both functions where able to execute with no issues. 
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583734216



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       Yeah for the DEFAULT script, I originally left that as a start up parameter to ensure the user can see the default import library and the Accumulo API when they first boot up JShell. I believe having two start-up statements should do the trick. Also I believe I found a work around regarding the Scanner. Whenever a Scanner is defined, we need to explicitly specify which Scanner are we referring to. For example: 
   
   **Referencing Accumulo Scanner:**
   (org.apache.accumulo.core.client.Scanner scan = client.createScanner("GothamPD", Authorizations.EMPTY);
   
   **Referencing Java Scanner:**
    java.util.Scanner myObj = new java.util.Scanner(System.in);
   
   I created a Java test code where there one function uses the Accumulo Scanner and another function uses the Java Scanner. I then executed the code in JShell with Accumulo and both functions where able to execute with no issues. 
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583734216



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       @ctubbsii For the DEFAULT script, I originally left that as a start up parameter to ensure the user can see the default import library and the Accumulo API when they first boot up JShell. I believe having two start-up statements should do the trick and I do see the results you are getting from my end. Also I believe I found a work around regarding the Scanner. Whenever a Scanner is defined, we need to explicitly specify which Scanner we are referring to. For example: 
   
   **Referencing Accumulo Scanner:**
   org.apache.accumulo.core.client.Scanner scan = client.createScanner("GothamPD", Authorizations.EMPTY);
   
   **Referencing Java Scanner:**
    java.util.Scanner myObj = new java.util.Scanner(System.in);
   
   I created a Java test code where one function uses the Accumulo Scanner and another function uses the Java Scanner. I then executed the code in JShell with Accumulo and both functions where able to execute with no issues. 
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583755717



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       Cool. I just pushed a commit to apply your double-startup option idea into the accumulo script file. Thanks for explaining the reasoning behind the --startup option. I did not consider the /reset case up until now. 




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner closed pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner closed pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583734216



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       For the DEFAULT script, I originally left that as a start up parameter to ensure the user can see the default import library and the Accumulo API when they first boot up JShell. I believe having two start-up statements should do the trick. Also I believe I found a work around regarding the Scanner. Whenever a Scanner is defined, we need to explicitly specify which Scanner are we referring to. For example: 
   
   **Referencing Accumulo Scanner:**
   (org.apache.accumulo.core.client.Scanner scan = client.createScanner("GothamPD", Authorizations.EMPTY);
   
   **Referencing Java Scanner:**
    java.util.Scanner myObj = new java.util.Scanner(System.in);
   
   I created a Java test code where there one function uses the Accumulo Scanner and another function uses the Java Scanner. I then executed the code in JShell with Accumulo and both functions where able to execute with no issues. 
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#discussion_r583753872



##########
File path: assemble/bin/accumulo
##########
@@ -58,6 +58,18 @@ function main() {
     echo "$CLASSPATH"
     exit 0
   fi
+  
+  # Set up path variable for default import config file
+  export jShellPath="$conf/jshell-init.jsh"
+  
+  if [[ $cmd == "jshell" ]]; then
+    shift
+    if [[ -f "$jShellPath" ]]; then
+      exec "$cmd" --startup DEFAULT "$jShellPath" "$@"

Review comment:
       Let's just go with the double-startup option for now. `--startup DEFAULT --startup "$jShellPath"`




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [accumulo] slackwinner edited a comment on pull request #1910: Adding JShell Accumulo Feature

Posted by GitBox <gi...@apache.org>.
slackwinner edited a comment on pull request #1910:
URL: https://github.com/apache/accumulo/pull/1910#issuecomment-773505326


   @ctubbsii This is still in a work in progress but I wanted to share what I have done so far. Essentially, I added a "jshell entry" in bin/accumulo so that the user can easily activate jshell with the classpath imported. In addition, there is a jshell-init.jsh file that allows the user to load in the default Accumulo public APIs. Also the user can customize jshell-init by adding or removing public APIs. Currently jshell-init has hard coded public APIs as I am  still figuring out how to import the classes automatically as well as making sure the classes are always up to date during a build. Feel free to comment if you have any suggestions/ideas on how to automate the import process or improve the jshell feature as a whole. Below are simple examples on how to boot up Jshell with Accumulo. 
   
   **Starting JShell with Accumulo Example:**
   _$ bin/accumulo jshell (Path to Jshell-init.jsh file)_
   - This cmd will pass the $CLASSPATH to Jshell and import both the Accumulo public APIs  from the .jsh file and the default java libraries.
   
   _$ bin/accumulo jshell --startup (Path to Jshell-init.jsh file)_
   - This cmd will pass the $CLASSPATH to Jshell and only import both the Accumulo public APIs from the .jsh file.
   


----------------------------------------------------------------
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:
users@infra.apache.org