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 2019/05/23 21:10:23 UTC

[GitHub] [accumulo] ctubbsii commented on a change in pull request #1112: Fixes #1052 - Review DistributedCache usage - Changed how token files and property files get cached

ctubbsii commented on a change in pull request #1112: Fixes #1052 - Review DistributedCache usage - Changed how token files and property files get cached
URL: https://github.com/apache/accumulo/pull/1112#discussion_r287134136
 
 

 ##########
 File path: test/src/main/java/org/apache/accumulo/test/mapreduce/TokenFileIT.java
 ##########
 @@ -84,6 +89,40 @@ protected void cleanup(Context context) throws IOException, InterruptedException
         m.put("", "", Integer.toString(count));
         context.write(new Text(), m);
       }
+
+      @Override
+      protected void setup(Context context) throws IOException, InterruptedException {
+        if (context.getCacheFiles() != null && context.getCacheFiles().length > 0) {
+          // At this point in the MapReduce Job you can get the cached files in HDFS if you want
+          URI[] cachedFiles = context.getCacheFiles();
+          // On the line below we access the file by the pseudonym created during caching in
+          // ConfiguratorBase
+          String fileByPsuedonym = getFileContents(ConfiguratorBase.tokenFileName);
+          assertTrue(!fileByPsuedonym.isEmpty());
+          assertTrue(cachedFiles.length > 0);
+        }
+        super.setup(context);
+      }
+
+      private String getFileContents(String filename) throws FileNotFoundException, IOException {
+
+        StringBuilder sb = new StringBuilder();
+        BufferedReader br = new BufferedReader(new FileReader(filename));
 
 Review comment:
   I think you could read the file contents with many fewer lines of code, especially in Java 8.
   
   Something like:
   ```java
       return Files.lines(filename).collect(Collectors.joining(System.lineSeparator()));
   ```

----------------------------------------------------------------
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


With regards,
Apache Git Services