當前位置: 首頁>>代碼示例>>Java>>正文


Java DeletionAsUserContext類代碼示例

本文整理匯總了Java中org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext的典型用法代碼示例。如果您正苦於以下問題:Java DeletionAsUserContext類的具體用法?Java DeletionAsUserContext怎麽用?Java DeletionAsUserContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DeletionAsUserContext類屬於org.apache.hadoop.yarn.server.nodemanager.executor包,在下文中一共展示了DeletionAsUserContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@Override
public void deleteAsUser(DeletionAsUserContext ctx)
  throws IOException, InterruptedException {
  Path subDir = ctx.getSubDir();
  List<Path> baseDirs = ctx.getBasedirs();

  if (baseDirs == null || baseDirs.size() == 0) {
    LOG.info("Deleting absolute path : " + subDir);
    if (!lfs.delete(subDir, true)) {
      //Maybe retry
      LOG.warn("delete returned false for path: [" + subDir + "]");
    }
    return;
  }
  for (Path baseDir : baseDirs) {
    Path del = subDir == null ? baseDir : new Path(baseDir, subDir);
    LOG.info("Deleting path : " + del);
    if (!lfs.delete(del, true)) {
      LOG.warn("delete returned false for path: [" + del + "]");
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:23,代碼來源:DockerContainerExecutor.java

示例2: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@Override
public void deleteAsUser(DeletionAsUserContext ctx)
    throws IOException, InterruptedException {
  Path subDir = ctx.getSubDir();
  List<Path> baseDirs = ctx.getBasedirs();

  if (baseDirs == null || baseDirs.size() == 0) {
    LOG.info("Deleting absolute path : " + subDir);
    if (!lfs.delete(subDir, true)) {
      //Maybe retry
      LOG.warn("delete returned false for path: [" + subDir + "]");
    }
    return;
  }
  for (Path baseDir : baseDirs) {
    Path del = subDir == null ? baseDir : new Path(baseDir, subDir);
    LOG.info("Deleting path : " + del);
    if (!lfs.delete(del, true)) {
      LOG.warn("delete returned false for path: [" + del + "]");
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:23,代碼來源:DefaultContainerExecutor.java

示例3: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@Override
public void deleteAsUser(DeletionAsUserContext ctx)
    throws IOException, InterruptedException {
  String user = ctx.getUser();
  Path subDir = ctx.getSubDir();
  List<Path> basedirs = ctx.getBasedirs();

  if ((Long.parseLong(subDir.getName()) % 2) == 0) {
    assertNull(user);
  } else {
    assertEquals("dingo", user);
  }

  DeletionAsUserContext.Builder builder = new DeletionAsUserContext
      .Builder()
      .setUser(user)
      .setSubDir(subDir);

  if (basedirs != null) {
    builder.setBasedirs(basedirs.toArray(new Path[basedirs.size()]));
  }

  super.deleteAsUser(builder.build());
  assertFalse(lfs.util().exists(subDir));
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:TestDeletionService.java

示例4: cleanupAppFiles

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
private void cleanupAppFiles(String user) throws Exception {
  cleanupUserAppCache(user);
  cleanupUserFileCache(user);
  cleanupLogDirs(user);

  String[] files =
      { "launch_container.sh", "container_tokens", "touch-file" };
  Path ws = new Path(workSpace.toURI());
  for (String file : files) {
    File f = new File(workSpace, file);
    if (f.exists()) {
      exec.deleteAsUser(new DeletionAsUserContext.Builder()
          .setUser(user)
          .setSubDir(new Path(file))
          .setBasedirs(ws)
          .build());
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:20,代碼來源:TestLinuxContainerExecutor.java

示例5: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@Override
public void deleteAsUser(DeletionAsUserContext ctx)
  throws IOException, InterruptedException {
  Path subDir = ctx.getSubDir();
  List<Path> baseDirs = ctx.getBasedirs();

  if (baseDirs == null || baseDirs.size() == 0) {
    LOG.info("Deleting absolute path : " + subDir);
    if (!lfs.delete(subDir, true)) {
      //Maybe retry
      LOG.warn("delete returned false for path: [" + subDir + "]");
    }
    return;
  }
  for (Path baseDir : baseDirs) {
    Path del = subDir == null ? baseDir : new Path(baseDir, subDir);
    LOG.info("Deleting path : " + del);
    try {
      if (!lfs.delete(del, true)) {
        LOG.warn("delete returned false for path: [" + del + "]");
      }
    } catch (FileNotFoundException e) {
      continue;
    }
  }
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:27,代碼來源:DockerContainerExecutor.java

示例6: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@Override
public void deleteAsUser(DeletionAsUserContext ctx)
    throws IOException, InterruptedException {
  Path subDir = ctx.getSubDir();
  List<Path> baseDirs = ctx.getBasedirs();

  if (baseDirs == null || baseDirs.size() == 0) {
    LOG.info("Deleting absolute path : " + subDir);
    if (!lfs.delete(subDir, true)) {
      //Maybe retry
      LOG.warn("delete returned false for path: [" + subDir + "]");
    }
    return;
  }
  for (Path baseDir : baseDirs) {
    Path del = subDir == null ? baseDir : new Path(baseDir, subDir);
    LOG.info("Deleting path : " + del);
    try {
      if (!lfs.delete(del, true)) {
        LOG.warn("delete returned false for path: [" + del + "]");
      }
    } catch (FileNotFoundException e) {
      continue;
    }
  }
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:27,代碼來源:DefaultContainerExecutor.java

示例7: tearDown

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@After
public void tearDown() throws IOException, InterruptedException {
  if (containerManager != null) {
    containerManager.stop();
  }
  createContainerExecutor().deleteAsUser(new DeletionAsUserContext.Builder()
      .setUser(user)
      .setSubDir(new Path(localDir.getAbsolutePath()))
      .setBasedirs(new Path[] {})
      .build());
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:12,代碼來源:BaseContainerManagerTest.java

示例8: tearDown

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@Override
public void tearDown() throws IOException, InterruptedException {
  super.tearDown();
  createContainerExecutor().deleteAsUser(new DeletionAsUserContext.Builder()
      .setUser(user)
      .setSubDir(new Path(remoteRootLogDir.getAbsolutePath()))
      .setBasedirs(new Path[] {})
      .build());

  dispatcher.await();
  dispatcher.stop();
  dispatcher.close();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:TestLogAggregationService.java

示例9: cleanupUserAppCache

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
private void cleanupUserAppCache(String user) throws Exception {
  List<String> localDirs = dirsHandler.getLocalDirs();
  for (String dir : localDirs) {
    Path usercachedir = new Path(dir, ContainerLocalizer.USERCACHE);
    Path userdir = new Path(usercachedir, user);
    Path appcachedir = new Path(userdir, ContainerLocalizer.APPCACHE);
    exec.deleteAsUser(new DeletionAsUserContext.Builder()
        .setUser(user)
        .setSubDir(appcachedir)
        .build());
    FileContext.getLocalFSFileContext().delete(usercachedir, true);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:TestLinuxContainerExecutor.java

示例10: cleanupUserFileCache

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
private void cleanupUserFileCache(String user) {
  List<String> localDirs = dirsHandler.getLocalDirs();
  for (String dir : localDirs) {
    Path filecache = new Path(dir, ContainerLocalizer.FILECACHE);
    Path filedir = new Path(filecache, user);
    exec.deleteAsUser(new DeletionAsUserContext.Builder()
        .setUser(user)
        .setSubDir(filedir)
        .build());
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:12,代碼來源:TestLinuxContainerExecutor.java

示例11: cleanupLogDirs

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
private void cleanupLogDirs(String user) {
  List<String> logDirs = dirsHandler.getLogDirs();
  for (String dir : logDirs) {
    String appId = "APP_" + id;
    String containerId = "CONTAINER_" + (id - 1);
    Path appdir = new Path(dir, appId);
    Path containerdir = new Path(appdir, containerId);
    exec.deleteAsUser(new DeletionAsUserContext.Builder()
        .setUser(user)
        .setSubDir(containerdir)
        .build());
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:TestLinuxContainerExecutor.java

示例12: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@Override
public void deleteAsUser(DeletionAsUserContext ctx) {
  String user = ctx.getUser();
  Path dir = ctx.getSubDir();
  List<Path> baseDirs = ctx.getBasedirs();

  verifyUsernamePattern(user);

  String runAsUser = getRunAsUser(user);
  String dirString = dir == null ? "" : dir.toUri().getPath();

  PrivilegedOperation deleteAsUserOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.DELETE_AS_USER, (String) null);

  deleteAsUserOp.appendArgs(
      runAsUser,
      user,
      Integer.toString(PrivilegedOperation.
          RunAsUserCommand.DELETE_AS_USER.getValue()),
      dirString);

  List<String> pathsToDelete = new ArrayList<String>();
  if (baseDirs == null || baseDirs.size() == 0) {
    LOG.info("Deleting absolute path : " + dir);
    pathsToDelete.add(dirString);
  } else {
    for (Path baseDir : baseDirs) {
      Path del = dir == null ? baseDir : new Path(baseDir, dir);
      LOG.info("Deleting path : " + del);
      pathsToDelete.add(del.toString());
      deleteAsUserOp.appendArgs(baseDir.toUri().getPath());
    }
  }

  try {
    Configuration conf = super.getConf();
    PrivilegedOperationExecutor privilegedOperationExecutor =
        PrivilegedOperationExecutor.getInstance(conf);

    privilegedOperationExecutor.executePrivilegedOperation(deleteAsUserOp,
        false);
  }   catch (PrivilegedOperationException e) {
    int exitCode = e.getExitCode();
    LOG.error("DeleteAsUser for " + StringUtils.join(" ", pathsToDelete)
        + " returned with exit code: " + exitCode, e);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:48,代碼來源:LinuxContainerExecutor.java

示例13: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@Override
public void deleteAsUser(DeletionAsUserContext ctx)
    throws IOException, InterruptedException {
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:5,代碼來源:TestContainersMonitorResourceChange.java

示例14: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
@Override
public void deleteAsUser(DeletionAsUserContext ctx) {
  String user = ctx.getUser();
  Path dir = ctx.getSubDir();
  List<Path> baseDirs = ctx.getBasedirs();

  verifyUsernamePattern(user);

  String runAsUser = getRunAsUser(user);
  String dirString = dir == null ? "" : dir.toUri().getPath();

  PrivilegedOperation deleteAsUserOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.DELETE_AS_USER, (String) null);

  deleteAsUserOp.appendArgs(
      runAsUser,
      user,
      Integer.toString(PrivilegedOperation.
          RunAsUserCommand.DELETE_AS_USER.getValue()),
      dirString);

  List<String> pathsToDelete = new ArrayList<String>();
  if (baseDirs == null || baseDirs.size() == 0) {
    LOG.info("Deleting absolute path : " + dir);
    pathsToDelete.add(dirString);
  } else {
    for (Path baseDir : baseDirs) {
      Path del = dir == null ? baseDir : new Path(baseDir, dir);
      LOG.info("Deleting path : " + del);
      pathsToDelete.add(del.toString());
      deleteAsUserOp.appendArgs(baseDir.toUri().getPath());
    }
  }

  try {
    Configuration conf = super.getConf();
    PrivilegedOperationExecutor privilegedOperationExecutor =
        getPrivilegedOperationExecutor();

    privilegedOperationExecutor.executePrivilegedOperation(deleteAsUserOp,
        false);
  }   catch (PrivilegedOperationException e) {
    int exitCode = e.getExitCode();
    LOG.error("DeleteAsUser for " + StringUtils.join(" ", pathsToDelete)
        + " returned with exit code: " + exitCode, e);
  }
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:48,代碼來源:LinuxContainerExecutor.java

示例15: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext; //導入依賴的package包/類
/**
 * Delete specified directories as a given user.
 * @param ctx Encapsulates information necessary for deletion.
 * @throws IOException
 * @throws InterruptedException
 */
public abstract void deleteAsUser(DeletionAsUserContext ctx)
    throws IOException, InterruptedException;
 
開發者ID:naver,項目名稱:hadoop,代碼行數:9,代碼來源:ContainerExecutor.java


注:本文中的org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。