/**
   * write text to a remote file system
   *
   * @param hdfsPath !null remote path
   * @param content !null test content
   */
  @Override
  public void writeToFileSystem(final String hdfsPath, final String content) {
    if (isRunningAsUser()) {
      super.writeToFileSystem(hdfsPath, content);
      return;
    }
    UserGroupInformation uig = getCurrentUserGroup();
    try {
      //          if(true)    throw new UnsupportedOperationException("Uncomment when using version
      // 1.0.*");
      uig.doAs(
          new PrivilegedExceptionAction<Void>() {

            public Void run() throws Exception {
              FileSystem fs = getDFS();
              Path src = new Path(hdfsPath);
              Path parent = src.getParent();
              guaranteeDirectory(parent);
              OutputStream os = FileSystem.create(fs, src, FULL_FILE_ACCESS);
              FileUtilities.writeFile(os, content);
              return null;
            }
          });
    } catch (Exception e) {
      throw new RuntimeException(
          "Failed to writeToFileSystem because "
              + e.getMessage()
              + " exception of class "
              + e.getClass(),
          e);
    }
  }
  @Override
  public void writeToFileSystem(final String hdfsPath, final File localPath) {
    if (isRunningAsUser()) {
      super.writeToFileSystem(hdfsPath, localPath);
      return;
    }
    UserGroupInformation uig = getCurrentUserGroup();
    try {
      //           if(true)    throw new UnsupportedOperationException("Uncomment when using version
      // 1.0.*");
      uig.doAs(
          new PrivilegedExceptionAction<Void>() {

            public Void run() throws Exception {
              FileSystem fileSystem = getDFS();

              Path dst = new Path(hdfsPath);

              Path src = new Path(localPath.getAbsolutePath());

              fileSystem.copyFromLocalFile(src, dst);
              fileSystem.setPermission(dst, FULL_FILE_ACCESS);
              return null;
            }
          });
    } catch (Exception e) {
      throw new RuntimeException(
          "Failed to writeToFileSystem because "
              + e.getMessage()
              + " exception of class "
              + e.getClass(),
          e);
    }
  }
 @Override
 protected void setDFS(FileSystem DFS) {
   if (DFS instanceof LocalFileSystem)
     throw new IllegalArgumentException(
         "This class must talk to a remote file system"); // ToDo change
   super.setDFS(DFS);
 }
  /**
   * guarantee the existance of a directory on the remote system
   *
   * @param hdfsPath !null path - on the remote system
   */
  @Override
  public void guaranteeDirectory(String hdfsPath) {
    if (isRunningAsUser()) {
      super.guaranteeDirectory(hdfsPath);
      return;
    }
    Path src = new Path(hdfsPath);

    guaranteeDirectory(src);
  }
  /**
   * guarantee the existance of a file on the remote system
   *
   * @param hdfsPath !null path - on the remote system
   * @param file !null exitsing file
   */
  @Override
  public void guaranteeFile(String hdfsPath, File file) {
    if (isRunningAsUser()) {
      super.guaranteeFile(hdfsPath, file);
      return;
    }
    final FileSystem fs = getDFS();
    Path src = new Path(hdfsPath);

    try {
      if (fs.exists(src)) return;
      this.writeToFileSystem(hdfsPath, file);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }