当前位置: 首页>>代码示例>>Java>>正文


Java ConverterUtils类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.util.ConverterUtils的典型用法代码示例。如果您正苦于以下问题:Java ConverterUtils类的具体用法?Java ConverterUtils怎么用?Java ConverterUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConverterUtils类属于org.apache.hadoop.yarn.util包,在下文中一共展示了ConverterUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newResourceLocalizationSpec

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
public static ResourceLocalizationSpec newResourceLocalizationSpec(
    LocalResource rsrc, Path path) {
  URL local = ConverterUtils.getYarnUrlFromPath(path);
  ResourceLocalizationSpec resourceLocalizationSpec =
      Records.newRecord(ResourceLocalizationSpec.class);
  resourceLocalizationSpec.setDestinationDirectory(local);
  resourceLocalizationSpec.setResource(rsrc);
  return resourceLocalizationSpec;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:NodeManagerBuilderUtils.java

示例2: createCommitterEventHandler

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
private static CommitterEventHandler createCommitterEventHandler(
    Dispatcher dispatcher, OutputCommitter committer) {
  final SystemClock clock = new SystemClock();
  AppContext appContext = mock(AppContext.class);
  when(appContext.getEventHandler()).thenReturn(
      dispatcher.getEventHandler());
  when(appContext.getClock()).thenReturn(clock);
  RMHeartbeatHandler heartbeatHandler = new RMHeartbeatHandler() {
    @Override
    public long getLastHeartbeatTime() {
      return clock.getTime();
    }
    @Override
    public void runOnNextHeartbeat(Runnable callback) {
      callback.run();
    }
  };
  ApplicationAttemptId id = 
    ConverterUtils.toApplicationAttemptId("appattempt_1234567890000_0001_0");
  when(appContext.getApplicationID()).thenReturn(id.getApplicationId());
  when(appContext.getApplicationAttemptId()).thenReturn(id);
  CommitterEventHandler handler =
      new CommitterEventHandler(appContext, committer, heartbeatHandler);
  dispatcher.register(CommitterEventType.class, handler);
  return handler;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestJobImpl.java

示例3: listApplicationAttempts

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
/**
 * Lists the application attempts matching the given applicationid
 * 
 * @param applicationId
 * @throws YarnException
 * @throws IOException
 */
private void listApplicationAttempts(String applicationId) throws YarnException,
    IOException {
  PrintWriter writer = new PrintWriter(
      new OutputStreamWriter(sysout, Charset.forName("UTF-8")));

  List<ApplicationAttemptReport> appAttemptsReport = client
      .getApplicationAttempts(ConverterUtils.toApplicationId(applicationId));
  writer.println("Total number of application attempts " + ":"
      + appAttemptsReport.size());
  writer.printf(APPLICATION_ATTEMPTS_PATTERN, "ApplicationAttempt-Id",
      "State", "AM-Container-Id", "Tracking-URL");
  for (ApplicationAttemptReport appAttemptReport : appAttemptsReport) {
    writer.printf(APPLICATION_ATTEMPTS_PATTERN, appAttemptReport
        .getApplicationAttemptId(), appAttemptReport
        .getYarnApplicationAttemptState(), appAttemptReport
        .getAMContainerId().toString(), appAttemptReport.getTrackingUrl());
  }
  writer.flush();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:ApplicationCLI.java

示例4: getAllContainers

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
public List<ContainerId> getAllContainers(String applicationId,
    Configuration conf) {
  List<ContainerId> containers = new ArrayList<ContainerId>();
  String[] logDirs = HPCConfiguration.getHPCLogDirs(conf);
  for (String logDir : logDirs) {
    File appDir = new File(logDir, applicationId);
    if (appDir.exists()) {
      String[] containerDirs = appDir.list();
      if (containerDirs != null) {
        for (String containerDir : containerDirs) {
          try {
            ContainerId containerId = ConverterUtils
                .toContainerId(containerDir);
            containers.add(containerId);
          } catch (Exception e) {
            // Skip the non container dir's
            LOG.debug("Skipping non container dir : " + containerDir, e);
          }
        }
      }
    }
  }
  return containers;
}
 
开发者ID:intel-hpdd,项目名称:scheduling-connector-for-hadoop,代码行数:25,代码来源:HPCLogAggregateHandler.java

示例5: killApplication

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
public static void killApplication(String applicationId) throws Exception {
  try {
    YarnClient yarnClient = YarnClient.createYarnClient();
    yarnClient.init(conf);
    yarnClient.start();
    LOGGER.logInfo("[yarn application -kill %s]", applicationId);
    yarnClient.killApplication(ConverterUtils.toApplicationId(applicationId));
    yarnClient.stop();
  } catch (ApplicationNotFoundException ignored) {
  } catch (Exception e) {
    if (e.getMessage().toLowerCase().contains("invalid applicationid")) {
      // ignored
    } else {
      throw e;
    }
  }
}
 
开发者ID:Microsoft,项目名称:pai,代码行数:18,代码来源:HadoopUtils.java

示例6: sendErrorMessage

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
private void sendErrorMessage() throws InterruptedException {
  List<TaskState> stateList = Arrays.asList(
      TaskState.CONTAINER_ALLOCATED, TaskState.CONTAINER_LAUNCHED, TaskState.CONTAINER_RUNNING);
  List<TaskStatus> list = statusManager.getTaskStatus(new HashSet<>(stateList));
  while (list.size() < taskNum) {
    Thread.sleep(2000);
    list = statusManager.getTaskStatus(new HashSet<>(stateList));
  }

  String containerIdStr = list.get(0).getContainerId();
  ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);

  ContainerStatus status = Records.newRecord(ContainerStatus.class);
  status.setContainerId(containerId);
  status.setState(ContainerState.COMPLETE);
  status.setExitStatus(ExitStatusKey.SUCCEEDED.toInt());
  onContainersCompleted(Collections.singletonList(status));
}
 
开发者ID:Microsoft,项目名称:pai,代码行数:19,代码来源:KillAllOnAnyCompletedTest.java

示例7: verifyAndGetContainerId

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
private ContainerId verifyAndGetContainerId(Block html) {
  String containerIdStr = $(CONTAINER_ID);
  if (containerIdStr == null || containerIdStr.isEmpty()) {
    html.h1()._("Cannot get container logs without a ContainerId")._();
    return null;
  }
  ContainerId containerId = null;
  try {
    containerId = ConverterUtils.toContainerId(containerIdStr);
  } catch (IllegalArgumentException e) {
    html.h1()
        ._("Cannot get container logs for invalid containerId: "
            + containerIdStr)._();
    return null;
  }
  return containerId;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:AggregatedLogsBlock.java

示例8: render

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
@Override
protected void render(Block html) {
  ApplicationId applicationID =
      ConverterUtils.toApplicationId(this.recordFactory,
          $(APPLICATION_ID));
  Application app = this.nmContext.getApplications().get(applicationID);
  AppInfo info = new AppInfo(app);
  info("Application's information")
        ._("ApplicationId", info.getId())
        ._("ApplicationState", info.getState())
        ._("User", info.getUser());
  TABLE<Hamlet> containersListBody = html._(InfoBlock.class)
      .table("#containers");
  for (String containerIdStr : info.getContainers()) {
    containersListBody
           .tr().td()
             .a(url("container", containerIdStr), containerIdStr)
             ._()._();
  }
  containersListBody._();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:ApplicationPage.java

示例9: getMRClientProtocol

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
private MRClientProtocol getMRClientProtocol(Token token,
    final InetSocketAddress hsAddress, String user, final Configuration conf) {
  UserGroupInformation ugi = UserGroupInformation.createRemoteUser(user);
  ugi.addToken(ConverterUtils.convertFromYarn(token, hsAddress));

  final YarnRPC rpc = YarnRPC.create(conf);
  MRClientProtocol hsWithDT = ugi
      .doAs(new PrivilegedAction<MRClientProtocol>() {

        @Override
        public MRClientProtocol run() {
          return (MRClientProtocol) rpc.getProxy(HSClientProtocol.class,
              hsAddress, conf);
        }
      });
  return hsWithDT;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestJHSSecurity.java

示例10: newProxy

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
@Private
@VisibleForTesting
protected ContainerManagementProtocol newProxy(final YarnRPC rpc,
    String containerManagerBindAddr, ContainerId containerId, Token token)
    throws InvalidToken {

  if (token == null) {
    throw new InvalidToken("No NMToken sent for "
        + containerManagerBindAddr);
  }
  
  final InetSocketAddress cmAddr =
      NetUtils.createSocketAddr(containerManagerBindAddr);
  LOG.info("Opening proxy : " + containerManagerBindAddr);
  // the user in createRemoteUser in this context has to be ContainerID
  UserGroupInformation user =
      UserGroupInformation.createRemoteUser(containerId
          .getApplicationAttemptId().toString());

  org.apache.hadoop.security.token.Token<NMTokenIdentifier> nmToken =
      ConverterUtils.convertFromYarn(token, cmAddr);
  user.addToken(nmToken);

  return NMProxy.createNMProxy(conf, ContainerManagementProtocol.class,
    user, rpc, cmAddr);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:ContainerManagementProtocolProxy.java

示例11: getNodeApp

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
@GET
@Path("/apps/{appid}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public AppInfo getNodeApp(@PathParam("appid") String appId) {
  init();
  ApplicationId id = ConverterUtils.toApplicationId(recordFactory, appId);
  if (id == null) {
    throw new NotFoundException("app with id " + appId + " not found");
  }
  Application app = this.nmContext.getApplications().get(id);
  if (app == null) {
    throw new NotFoundException("app with id " + appId + " not found");
  }
  return new AppInfo(app);

}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:NMWebServices.java

示例12: getNodeContainer

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
@GET
@Path("/containers/{containerid}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ContainerInfo getNodeContainer(@PathParam("containerid") String id) {
  ContainerId containerId = null;
  init();
  try {
    containerId = ConverterUtils.toContainerId(id);
  } catch (Exception e) {
    throw new BadRequestException("invalid container id, " + id);
  }

  Container container = nmContext.getContainers().get(containerId);
  if (container == null) {
    throw new NotFoundException("container with id, " + id + ", not found");
  }
  return new ContainerInfo(this.nmContext, container, uriInfo.getBaseUri()
      .toString(), webapp.name());

}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:NMWebServices.java

示例13: handleInitApplicationResources

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
/**
 * Handle event received the first time any container is scheduled
 * by a given application.
 */
@SuppressWarnings("unchecked")
private void handleInitApplicationResources(Application app) {
  // 0) Create application tracking structs
  String userName = app.getUser();
  privateRsrc.putIfAbsent(userName, new LocalResourcesTrackerImpl(userName,
      null, dispatcher, true, super.getConfig(), stateStore));
  String appIdStr = ConverterUtils.toString(app.getAppId());
  appRsrc.putIfAbsent(appIdStr, new LocalResourcesTrackerImpl(app.getUser(),
      app.getAppId(), dispatcher, false, super.getConfig(), stateStore));
  // 1) Signal container init
  //
  // This is handled by the ApplicationImpl state machine and allows
  // containers to proceed with launching.
  dispatcher.getEventHandler().handle(new ApplicationInitedEvent(
        app.getAppId()));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:ResourceLocalizationService.java

示例14: createAppDir

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
private Path createAppDir(String user, String applicationId,
    UserGroupInformation userUgi, Configuration conf,
    Path remoteNodeTmpLogFileForApp) throws IOException {
  FileSystem remoteFS = FileSystem.get(conf);

  // Only creating directories if they are missing to avoid
  // unnecessary load on the filesystem from all of the nodes
  String remoteRootLogDirSuffix = conf.get(
      YarnConfiguration.NM_REMOTE_APP_LOG_DIR_SUFFIX,
      YarnConfiguration.DEFAULT_NM_REMOTE_APP_LOG_DIR_SUFFIX);
  Path appDir = LogAggregationUtils.getRemoteAppLogDir(
      remoteNodeTmpLogFileForApp,
      ConverterUtils.toApplicationId(applicationId), user,
      remoteRootLogDirSuffix);
  appDir = appDir.makeQualified(remoteFS.getUri(),
      remoteFS.getWorkingDirectory());

  if (!checkExists(remoteFS, appDir, APP_DIR_PERMISSIONS)) {
    Path suffixDir = LogAggregationUtils.getRemoteLogSuffixedDir(
        remoteNodeTmpLogFileForApp, user, remoteRootLogDirSuffix);
    suffixDir = suffixDir.makeQualified(remoteFS.getUri(),
        remoteFS.getWorkingDirectory());

    if (!checkExists(remoteFS, suffixDir, APP_DIR_PERMISSIONS)) {
      Path userDir = LogAggregationUtils.getRemoteLogUserDir(
          remoteNodeTmpLogFileForApp, user);
      userDir = userDir.makeQualified(remoteFS.getUri(),
          remoteFS.getWorkingDirectory());

      if (!checkExists(remoteFS, userDir, APP_DIR_PERMISSIONS)) {
        createDir(remoteFS, userDir, APP_DIR_PERMISSIONS);
      }

      createDir(remoteFS, suffixDir, APP_DIR_PERMISSIONS);
    }

    createDir(remoteFS, appDir, APP_DIR_PERMISSIONS);
  }
  return appDir;
}
 
开发者ID:intel-hpdd,项目名称:scheduling-connector-for-hadoop,代码行数:41,代码来源:HPCLogAggregateHandler.java

示例15: testNodeSingleContainersHelper

import org.apache.hadoop.yarn.util.ConverterUtils; //导入依赖的package包/类
public void testNodeSingleContainersHelper(String media)
    throws JSONException, Exception {
  WebResource r = resource();
  Application app = new MockApp(1);
  nmContext.getApplications().put(app.getAppId(), app);
  HashMap<String, String> hash = addAppContainers(app);
  Application app2 = new MockApp(2);
  nmContext.getApplications().put(app2.getAppId(), app2);
  addAppContainers(app2);

  for (String id : hash.keySet()) {
    ClientResponse response = r.path("ws").path("v1").path("node")
        .path("containers").path(id).accept(media).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    verifyNodeContainerInfo(json.getJSONObject("container"), nmContext
        .getContainers().get(ConverterUtils.toContainerId(id)));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestNMWebServicesContainers.java


注:本文中的org.apache.hadoop.yarn.util.ConverterUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。