risdenk commented on a change in pull request #231: KNOX-2128 - Custom 
DataSource and SQL Commands for KnoxShell and KnoxShellTable
URL: https://github.com/apache/knox/pull/231#discussion_r363336267
 
 

 ##########
 File path: 
gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
 ##########
 @@ -570,6 +580,89 @@ public String toString() {
     return String.format(Locale.ROOT, "KnoxSession{base='%s'}", base);
   }
 
+  /**
+   * Persist provided Map to a file within the {user.home}/.knoxshell directory
+   * @param <T>
+   * @param fileName of persisted file
+   * @param map to persist
+   */
+  public static <T> void persistToKnoxShell(String fileName, Map<String, 
List<T>> map) {
+    String s = JsonUtils.renderAsJsonString(map);
+    String home = System.getProperty("user.home");
+    try {
+      FileUtils.write(new File(
+          home + File.separator +
+          ".knoxshell" + File.separator + fileName),
+          s, StandardCharsets.UTF_8);
+    } catch (IOException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+  }
 
 Review comment:
   So these read/write methods for histories scare me a bit. Could there be 
multiple knoxshells reading/writing at once? Can we lock the file via the Java 
NIO methods? Should these methods be synchronized to prevent multiple usage at 
once from the same JVM. 
   
   Is the directory ".knoxshell" assumed to exist already?
   
   This applies to reading as well. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to