private String copyJarsToDfs()

in modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java [376:422]


  private String copyJarsToDfs(String jars, String destDir) {
    String dfsAppRoot = config.getDfsRoot() + "/" + config.getApplicationName();
    String dfsDestDir = dfsAppRoot + "/" + destDir;

    FileSystem fs = null;
    try {
      fs = FileSystem.get(new URI(config.getDfsRoot()), new Configuration());
      fs.mkdirs(new Path(dfsDestDir));
    } catch (Exception e) {
      logger.error("Failed to create DFS directory {}", dfsDestDir);
      if (fs != null) {
        try {
          fs.close();
        } catch (IOException ioe) {
          throw new IllegalStateException(ioe);
        }
      }
      throw new IllegalStateException(e);
    }

    StringBuilder classpath = new StringBuilder();
    for (String jarPath : jars.split(",")) {
      String jarName = requireNonNull(java.nio.file.Path.of(jarPath).getFileName()).toString();
      try {
        fs.copyFromLocalFile(new Path(jarPath), new Path(dfsDestDir));
      } catch (IOException e) {
        logger.error("Failed to copy file {} to DFS directory {}", jarPath, dfsDestDir);
        try {
          fs.close();
        } catch (IOException ioe) {
          throw new IllegalStateException(ioe);
        }
        throw new IllegalStateException(e);
      }
      if (classpath.length() != 0) {
        classpath.append(",");
      }
      classpath.append(dfsDestDir).append("/").append(jarName);
    }

    try {
      fs.close();
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
    return classpath.toString();
  }