ctubbsii commented on a change in pull request #1060: Closes #1053 add 
multi-volume support to import table command.
URL: https://github.com/apache/accumulo/pull/1060#discussion_r400406722
 
 

 ##########
 File path: 
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
 ##########
 @@ -1477,6 +1479,47 @@ public Text getMaxRow(String tableName, Authorizations 
auths, Text startRow,
     return finalUsages;
   }
 
+  /**
+   * Search multiple directories for exportMetadata.zip, the control file used 
for the importable
+   * command.
+   *
+   * @param context
+   *          used to obtain filesystem based on configuration
+   * @param importDirs
+   *          the list of directories to search.
+   * @return the Path representing the location of the file.
+   * @throws AccumuloException
+   *           if zero or more than one copy of the exportMetadata.zip file 
are found in the
+   *           directories provided.
+   */
+  public static Path findExportFile(ClientContext context, String[] importDirs)
+      throws AccumuloException {
+    LinkedHashSet<Path> exportFiles = new LinkedHashSet<>();
+    for (String importDir : importDirs) {
+      Path exportFilePath = null;
+      try {
+        FileSystem fs = new 
Path(importDir).getFileSystem(context.getHadoopConf());
+        exportFilePath = new Path(importDir, Constants.EXPORT_FILE);
+        if (fs.exists(exportFilePath)) {
+          exportFiles.add(exportFilePath);
+        }
+      } catch (IOException ioe) {
+        log.warn("Non-Fatal IOException reading export file: {}", 
exportFilePath, ioe);
+      }
+    }
+
+    if (exportFiles.size() > 1) {
+      String fileList = Arrays.toString(exportFiles.toArray());
+      log.warn("Found multiple export metadata files: " + fileList);
+      throw new AccumuloException("Found multiple export metadata files: " + 
fileList);
+    } else if (exportFiles.isEmpty()) {
+      log.warn("Unable to locate export metadata");
+      throw new AccumuloException("Unable to locate export metadata");
 
 Review comment:
   Should log or throw, but not both.

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