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


Java BuilderUtils类代码示例

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


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

示例1: addResourceRequest

import org.apache.hadoop.yarn.util.BuilderUtils; //导入依赖的package包/类
private void addResourceRequest(Priority priority, String resourceName,
                                Resource capability, int containerCount) {
  Map<String, Map<Resource, ResourceRequest>> remoteRequests =
    this.remoteRequestsTable.get(priority);
  if (remoteRequests == null) {
    remoteRequests = new HashMap<String, Map<Resource, ResourceRequest>>();
    this.remoteRequestsTable.put(priority, remoteRequests);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Added priority=" + priority);
    }
  }
  Map<Resource, ResourceRequest> reqMap = remoteRequests.get(resourceName);
  if (reqMap == null) {
    reqMap = new HashMap<Resource, ResourceRequest>();
    remoteRequests.put(resourceName, reqMap);
  }
  ResourceRequest remoteRequest = reqMap.get(capability);
  if (remoteRequest == null) {
    remoteRequest = BuilderUtils.
      newResourceRequest(priority, resourceName, capability, 0);
    reqMap.put(capability, remoteRequest);
  }

  remoteRequest.setNumContainers(remoteRequest.getNumContainers() + containerCount);

  // Note this down for next interaction with ResourceManager
  addResourceRequestToAsk(remoteRequest);

  if (LOG.isDebugEnabled()) {
    LOG.debug("addResourceRequest:" + " applicationId="
                + appAttemptId + " priority=" + priority.getPriority()
                + " resourceName=" + resourceName + " numContainers="
                + remoteRequest.getNumContainers() + " #asks=" + ask.size());
  }
}
 
开发者ID:apache,项目名称:twill,代码行数:36,代码来源:AMRMClientImpl.java

示例2: allocate

import org.apache.hadoop.yarn.util.BuilderUtils; //导入依赖的package包/类
@Override
public AllocationResponse allocate(float progressIndicator)
  throws YarnRemoteException {
  AllocateResponse allocateResponse = null;
  ArrayList<ResourceRequest> askList = null;
  ArrayList<ContainerId> releaseList = null;
  AllocateRequest allocateRequest = null;

  try {
    synchronized (this) {
      askList = new ArrayList<ResourceRequest>(ask);
      releaseList = new ArrayList<ContainerId>(release);
      // optimistically clear this collection assuming no RPC failure
      ask.clear();
      release.clear();
      allocateRequest = BuilderUtils
        .newAllocateRequest(appAttemptId, lastResponseId, progressIndicator,
                            askList, releaseList);
    }

    allocateResponse = rmClient.allocate(allocateRequest);
    AllocationResponse response = AllocationResponses.create(allocateResponse);

    synchronized (this) {
      // update these on successful RPC
      clusterNodeCount = allocateResponse.getNumClusterNodes();
      lastResponseId = response.getResponseId();
      clusterAvailableResources = response.getAvailableResources();
    }

    return response;
  } finally {
    // TODO how to differentiate remote YARN exception vs error in RPC
    if (allocateResponse == null) {
      // We hit an exception in allocate()
      // Preserve ask and release for next call to allocate()
      synchronized (this) {
        release.addAll(releaseList);
        // Requests could have been added or deleted during call to allocate.
        // If requests were added/removed then there is nothing to do since
        // the ResourceRequest object in ask would have the actual new value.
        // If ask does not have this ResourceRequest then it was unchanged and
        // so we can add the value back safely.
        // This assumes that there will no concurrent calls to allocate() and
        // so we don't have to worry about ask being changed in the
        // synchronized block at the beginning of this method.
        for (ResourceRequest oldAsk : askList) {
          if (!ask.contains(oldAsk)) {
            ask.add(oldAsk);
          }
        }
      }
    }
  }
}
 
开发者ID:apache,项目名称:twill,代码行数:56,代码来源:AMRMClientImpl.java

示例3: createContainerLaunchContext

import org.apache.hadoop.yarn.util.BuilderUtils; //导入依赖的package包/类
public ContainerLaunchContext createContainerLaunchContext(ContainerLaunchContext commonContainerLaunchContext) {
  // Setup environment by cloning from common env.
  Map<String, String> env = commonContainerLaunchContext.getEnvironment();
  Map<String, String> myEnv = new HashMap<String, String>(env.size());
  myEnv.putAll(env);

  // Duplicate the ByteBuffers for access by multiple containers.
  Map<String, ByteBuffer> myServiceData = new HashMap<String, ByteBuffer>();
  for (Map.Entry<String, ByteBuffer> entry : commonContainerLaunchContext.getServiceData().entrySet()) {
    myServiceData.put(entry.getKey(), entry.getValue().duplicate());
  }

  ////////////////////////////////////////////////////////////////////////////
  // Set the local resources
  ////////////////////////////////////////////////////////////////////////////
  // Set the necessary command to execute the application master
  Vector<CharSequence> vargs = new Vector<CharSequence>(30);

  // Set java executable command
  //LOG.info("Setting up app master command");
  vargs.add("${JAVA_HOME}" + "/bin/java");
  // Set Xmx based on am memory size
  vargs.add("-Xmx2000m");
  // Set Remote Debugging
  //if (!context.getQuery().getSubQuery(event.getExecutionBlockId()).isLeafQuery()) {
  //vargs.add("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
  //}
  // Set class name
  //vargs.add(getRunnerClass());
  vargs.add(TajoWorker.class.getCanonicalName());
  vargs.add("tr");     //workerMode
  vargs.add(getId()); // subqueryId
  vargs.add(containerMgrAddress); // nodeId
  vargs.add(containerID.toString()); // containerId
  Vector<CharSequence> taskParams = getTaskParams();
  if(taskParams != null) {
    vargs.addAll(taskParams);
  }

  vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stdout");
  vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stderr");

  // Get final commmand
  StringBuilder command = new StringBuilder();
  for (CharSequence str : vargs) {
    command.append(str).append(" ");
  }

  LOG.info("Completed setting up TaskRunner command " + command.toString());
  List<String> commands = new ArrayList<String>();
  commands.add(command.toString());

  return BuilderUtils.newContainerLaunchContext(containerID, commonContainerLaunchContext.getUser(),
      container.getResource(), commonContainerLaunchContext.getLocalResources(), myEnv, commands,
      myServiceData, null, new HashMap<ApplicationAccessType, String>());
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:57,代码来源:YarnContainerProxy.java

示例4: createApplicationAttemptId

import org.apache.hadoop.yarn.util.BuilderUtils; //导入依赖的package包/类
public static ApplicationAttemptId createApplicationAttemptId(QueryId queryId, int attemptId) {
  return BuilderUtils.newApplicationAttemptId(queryIdToAppId(queryId), attemptId);
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:4,代码来源:ApplicationIdUtils.java

示例5: queryIdToAppId

import org.apache.hadoop.yarn.util.BuilderUtils; //导入依赖的package包/类
public static ApplicationId queryIdToAppId(QueryId queryId) {
  return BuilderUtils.newApplicationId(Long.parseLong(queryId.getId()), queryId.getSeq());
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:4,代码来源:ApplicationIdUtils.java

示例6: createQueryId

import org.apache.hadoop.yarn.util.BuilderUtils; //导入依赖的package包/类
public static QueryId createQueryId(long timestamp, int id) {
  ApplicationId appId = BuilderUtils.newApplicationId(timestamp, id);

  return QueryIdFactory.newQueryId(appId.toString());
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:6,代码来源:TestTajoIds.java


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