src/main/java/org/apache/mesos/hdfs/executor/AbstractNodeExecutor.java
/**
   * Create Symbolic Link for the HDFS binary.
   **/
Create Symbolic Link for the HDFS binary.
Create Symbolic Link for the HDFS binary .
private void createSymbolicLink() {
    log.info("Creating a symbolic link for HDFS binary");
    try {
      File sandboxHdfsBinary = new File(System.getProperty("user.dir"));
      Path sandboxHdfsBinaryPath = Paths.get(sandboxHdfsBinary.getAbsolutePath());
      File frameworkMountDir = new File(schedulerConf.getFrameworkMountPath());
      if (!frameworkMountDir.exists()) {
        frameworkMountDir.mkdirs();
      }
      String hdfsBinaryPath = schedulerConf.getFrameworkMountPath()
          + "/" + HDFSConstants.HDFS_BINARY_DIR;
      File hdfsBinaryDir = new File(hdfsBinaryPath);
      try {
        ProcessBuilder processBuilder = new ProcessBuilder("unlink", hdfsBinaryPath);
        Process process = processBuilder.start();
        redirectProcess(process);
        int exitCode = process.waitFor();
        if (exitCode != 0) {
          log.info("Unable to unlink old sym link. Link may not exist. Exit code: " + exitCode);
        }
      } catch (IOException e) {
        log.fatal("Could not unlink " + hdfsBinaryPath + ": " + e);
        System.exit(1);
      }
      if (hdfsBinaryDir.exists()) {
        deleteFile(hdfsBinaryDir);
      }
      Path hdfsLinkDirPath = Paths.get(hdfsBinaryPath);
      Files.createSymbolicLink(hdfsLinkDirPath, sandboxHdfsBinaryPath);
      log.info("The linked HDFS binary path is: " + sandboxHdfsBinaryPath);
      log.info("The symbolic link path is: " + hdfsLinkDirPath);
      addBinaryToPath(hdfsBinaryPath);
    } catch (Exception e) {
      log.fatal("Error creating the symbolic link to hdfs binary: " + e);
      System.exit(1);
    }
  }
private void createSymbolicLink ( ) { log . info ( "Creating a symbolic link for HDFS binary" ) ; try { File sandboxHdfsBinary = new File ( System . getProperty ( "user.dir" ) ) ; Path sandboxHdfsBinaryPath = Paths . get ( sandboxHdfsBinary . getAbsolutePath ( ) ) ; File frameworkMountDir = new File ( schedulerConf . getFrameworkMountPath ( ) ) ; if ( ! frameworkMountDir . exists ( ) ) { frameworkMountDir . mkdirs ( ) ; } String hdfsBinaryPath = schedulerConf . getFrameworkMountPath ( ) + "/" + HDFSConstants . HDFS_BINARY_DIR ; File hdfsBinaryDir = new File ( hdfsBinaryPath ) ; try { ProcessBuilder processBuilder = new ProcessBuilder ( "unlink" , hdfsBinaryPath ) ; Process process = processBuilder . start ( ) ; redirectProcess ( process ) ; int exitCode = process . waitFor ( ) ; if ( exitCode != 0 ) { log . info ( "Unable to unlink old sym link. Link may not exist. Exit code: " + exitCode ) ; } } catch ( IOException e ) { log . fatal ( "Could not unlink " + hdfsBinaryPath + ": " + e ) ; System . exit ( 1 ) ; } if ( hdfsBinaryDir . exists ( ) ) { deleteFile ( hdfsBinaryDir ) ; } Path hdfsLinkDirPath = Paths . get ( hdfsBinaryPath ) ; Files . createSymbolicLink ( hdfsLinkDirPath , sandboxHdfsBinaryPath ) ; log . info ( "The linked HDFS binary path is: " + sandboxHdfsBinaryPath ) ; log . info ( "The symbolic link path is: " + hdfsLinkDirPath ) ; addBinaryToPath ( hdfsBinaryPath ) ; } catch ( Exception e ) { log . fatal ( "Error creating the symbolic link to hdfs binary: " + e ) ; System . exit ( 1 ) ; } }
Create Symbolic Link for the HDFS binary.
Create Symbolic Link for the HDFS binary .
// Find Hdfs binary in sandbox // Create mesosphere opt dir (parent dir of the symbolic link) if it does not exist // Delete and recreate directory for symbolic link every time // Try to delete the symbolic link in case a dangling link is present // Delete the file if it exists // Create symbolic link // Adding binary to the PATH environment variable