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


Java Priority類代碼示例

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


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

示例1: getPriority

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
@Override
public Priority getPriority() {
  NMContainerStatusProtoOrBuilder p = viaProto ? proto : builder;
  if (this.priority != null) {
    return this.priority;
  }
  if (!p.hasPriority()) {
    return null;
  }
  this.priority = convertFromProtoFormat(p.getPriority());
  return this.priority;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:13,代碼來源:NMContainerStatusPBImpl.java

示例2: handle

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
@Override
public void handle(ContainerAllocatorEvent event) {
  ContainerId cId =
      ContainerId.newContainerId(getContext().getApplicationAttemptId(),
        containerCount++);
  NodeId nodeId = NodeId.newInstance(NM_HOST, NM_PORT);
  Resource resource = Resource.newInstance(1234, 2, 2);
  ContainerTokenIdentifier containerTokenIdentifier =
      new ContainerTokenIdentifier(cId, nodeId.toString(), "user",
      resource, System.currentTimeMillis() + 10000, 42, 42,
      Priority.newInstance(0), 0);
  Token containerToken = newContainerToken(nodeId, "password".getBytes(),
        containerTokenIdentifier);
  Container container = Container.newInstance(cId, nodeId,
      NM_HOST + ":" + NM_HTTP_PORT, resource, null, containerToken);
  JobID id = TypeConverter.fromYarn(applicationId);
  JobId jobId = TypeConverter.toYarn(id);
  getContext().getEventHandler().handle(new JobHistoryEvent(jobId, 
      new NormalizedResourceEvent(
          org.apache.hadoop.mapreduce.TaskType.REDUCE,
      100)));
  getContext().getEventHandler().handle(new JobHistoryEvent(jobId, 
      new NormalizedResourceEvent(
          org.apache.hadoop.mapreduce.TaskType.MAP,
      100)));
  getContext().getEventHandler().handle(
      new TaskAttemptContainerAssignedEvent(event.getAttemptID(),
          container, null));
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:30,代碼來源:MRApp.java

示例3: newInstance

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
@Public
@Unstable
public static ContainerHistoryData newInstance(ContainerId containerId,
    Resource allocatedResource, NodeId assignedNode, Priority priority,
    long startTime, long finishTime, String diagnosticsInfo,
    int containerExitCode, ContainerState containerState) {
  ContainerHistoryData containerHD = new ContainerHistoryData();
  containerHD.setContainerId(containerId);
  containerHD.setAllocatedResource(allocatedResource);
  containerHD.setAssignedNode(assignedNode);
  containerHD.setPriority(priority);
  containerHD.setStartTime(startTime);
  containerHD.setFinishTime(finishTime);
  containerHD.setDiagnosticsInfo(diagnosticsInfo);
  containerHD.setContainerExitStatus(containerExitCode);
  containerHD.setContainerState(containerState);
  return containerHD;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:ContainerHistoryData.java

示例4: createContainerTokenSecretManager

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
@Override
protected RMContainerTokenSecretManager createContainerTokenSecretManager(
    Configuration conf) {
  return new RMContainerTokenSecretManager(conf) {

    @Override
    public Token createContainerToken(ContainerId containerId,
        NodeId nodeId, String appSubmitter, Resource capability,
        Priority priority, long createTime,
        LogAggregationContext logAggregationContext) {
      numRetries++;
      return super.createContainerToken(containerId, nodeId, appSubmitter,
        capability, priority, createTime, logAggregationContext);
    }
  };
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:TestContainerAllocation.java

示例5: updateDemand

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
@Override
public void updateDemand() {
  demand = Resources.createResource(0);
  // Demand is current consumption plus outstanding requests
  Resources.addTo(demand, getCurrentConsumption());

  // Add up outstanding resource requests
  synchronized (this) {
    for (Priority p : getPriorities()) {
      for (ResourceRequest r : getResourceRequests(p).values()) {
        Resource total = Resources.multiply(r.getCapability(), r.getNumContainers());
        Resources.addTo(demand, total);
      }
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:FSAppAttempt.java

示例6: ContainerRequest

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
/**
 * Instantiates a {@link ContainerRequest} with the given constraints.
 * 
 * @param capability
 *          The {@link Resource} to be requested for each container.
 * @param nodes
 *          Any hosts to request that the containers are placed on.
 * @param racks
 *          Any racks to request that the containers are placed on. The
 *          racks corresponding to any hosts requested will be automatically
 *          added to this list.
 * @param priority
 *          The priority at which to request the containers. Higher
 *          priorities have lower numerical values.
 * @param relaxLocality
 *          If true, containers for this request may be assigned on hosts
 *          and racks other than the ones explicitly requested.
 * @param nodeLabelsExpression
 *          Set node labels to allocate resource, now we only support
 *          asking for only a single node label
 */
public ContainerRequest(Resource capability, String[] nodes,
    String[] racks, Priority priority, boolean relaxLocality,
    String nodeLabelsExpression) {
  // Validate request
  Preconditions.checkArgument(capability != null,
      "The Resource to be requested for each container " +
          "should not be null ");
  Preconditions.checkArgument(priority != null,
      "The priority at which to request containers should not be null ");
  Preconditions.checkArgument(
          !(!relaxLocality && (racks == null || racks.length == 0) 
              && (nodes == null || nodes.length == 0)),
          "Can't turn off locality relaxation on a " + 
          "request with no location constraints");
  this.capability = capability;
  this.nodes = (nodes != null ? ImmutableList.copyOf(nodes) : null);
  this.racks = (racks != null ? ImmutableList.copyOf(racks) : null);
  this.priority = priority;
  this.relaxLocality = relaxLocality;
  this.nodeLabelsExpression = nodeLabelsExpression;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:43,代碼來源:AMRMClient.java

示例7: createResourceReq

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
public ResourceRequest createResourceReq(String resource, int memory, int priority,
    int containers, String labelExpression) throws Exception {
  ResourceRequest req = Records.newRecord(ResourceRequest.class);
  req.setResourceName(resource);
  req.setNumContainers(containers);
  Priority pri = Records.newRecord(Priority.class);
  pri.setPriority(priority);
  req.setPriority(pri);
  Resource capability = Records.newRecord(Resource.class);
  capability.setMemory(memory);
  req.setCapability(capability);
  if (labelExpression != null) {
   req.setNodeLabelExpression(labelExpression); 
  }
  return req;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:MockAM.java

示例8: checkLocalityRelaxationConflict

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
/**
 * ContainerRequests with locality relaxation cannot be made at the same
 * priority as ContainerRequests without locality relaxation.
 */
private void checkLocalityRelaxationConflict(Priority priority,
    Collection<String> locations, boolean relaxLocality) {
  Map<String, TreeMap<Resource, ResourceRequestInfo>> remoteRequests =
      this.remoteRequestsTable.get(priority);
  if (remoteRequests == null) {
    return;
  }
  // Locality relaxation will be set to relaxLocality for all implicitly
  // requested racks. Make sure that existing rack requests match this.
  for (String location : locations) {
      TreeMap<Resource, ResourceRequestInfo> reqs =
          remoteRequests.get(location);
      if (reqs != null && !reqs.isEmpty()) {
        boolean existingRelaxLocality =
            reqs.values().iterator().next().remoteRequest.getRelaxLocality();
        if (relaxLocality != existingRelaxLocality) {
          throw new InvalidContainerRequestException("Cannot submit a "
              + "ContainerRequest asking for location " + location
              + " with locality relaxation " + relaxLocality + " when it has "
              + "already been requested with locality relaxation " + existingRelaxLocality);
        }
      }
    }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:29,代碼來源:AMRMClientImpl.java

示例9: testDifferentLocalityRelaxationSamePriority

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
@Test (expected = InvalidContainerRequestException.class)
public void testDifferentLocalityRelaxationSamePriority() {
  AMRMClientImpl<ContainerRequest> client =
      new AMRMClientImpl<ContainerRequest>();
  Configuration conf = new Configuration();
  conf.setClass(
      CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
      MyResolver.class, DNSToSwitchMapping.class);
  client.init(conf);
  
  Resource capability = Resource.newInstance(1024, 1, 1);
  ContainerRequest request1 =
      new ContainerRequest(capability, new String[] {"host1", "host2"},
          null, Priority.newInstance(1), false);
  client.addContainerRequest(request1);
  ContainerRequest request2 =
      new ContainerRequest(capability, new String[] {"host3"},
          null, Priority.newInstance(1), true);
  client.addContainerRequest(request2);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestAMRMClientContainerRequest.java

示例10: createContainerToken

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
public static Token createContainerToken(ContainerId cId, long rmIdentifier,
    NodeId nodeId, String user,
    NMContainerTokenSecretManager containerTokenSecretManager,
    LogAggregationContext logAggregationContext)
    throws IOException {
  Resource r = BuilderUtils.newResource(1024, 1);
  ContainerTokenIdentifier containerTokenIdentifier =
      new ContainerTokenIdentifier(cId, nodeId.toString(), user, r,
        System.currentTimeMillis() + 100000L, 123, rmIdentifier,
        Priority.newInstance(0), 0, logAggregationContext);
  Token containerToken =
      BuilderUtils
        .newContainerToken(nodeId, containerTokenSecretManager
          .retrievePassword(containerTokenIdentifier),
          containerTokenIdentifier);
  return containerToken;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:TestContainerManager.java

示例11: testFillInRacks

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
@Test
public void testFillInRacks() {
  AMRMClientImpl<ContainerRequest> client =
      new AMRMClientImpl<ContainerRequest>();
  
  Configuration conf = new Configuration();
  conf.setClass(
      CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
      MyResolver.class, DNSToSwitchMapping.class);
  client.init(conf);
 
  Resource capability = Resource.newInstance(1024, 1, 1);
  ContainerRequest request =
      new ContainerRequest(capability, new String[] {"host1", "host2"},
          new String[] {"/rack2"}, Priority.newInstance(1));
  client.addContainerRequest(request);
  verifyResourceRequest(client, request, "host1", true);
  verifyResourceRequest(client, request, "host2", true);
  verifyResourceRequest(client, request, "/rack1", true);
  verifyResourceRequest(client, request, "/rack2", true);
  verifyResourceRequest(client, request, ResourceRequest.ANY, true);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:23,代碼來源:TestAMRMClientContainerRequest.java

示例12: assignNodeLocalContainers

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
private int assignNodeLocalContainers(FiCaSchedulerNode node, 
    FiCaSchedulerApp application, Priority priority) {
  int assignedContainers = 0;
  ResourceRequest request = 
    application.getResourceRequest(priority, node.getNodeName());
  if (request != null) {
    // Don't allocate on this node if we don't need containers on this rack
    ResourceRequest rackRequest =
        application.getResourceRequest(priority, 
            node.getRMNode().getRackName());
    if (rackRequest == null || rackRequest.getNumContainers() <= 0) {
      return 0;
    }
    
    int assignableContainers = 
      Math.min(
          getMaxAllocatableContainers(application, priority, node, 
              NodeType.NODE_LOCAL), 
              request.getNumContainers());
    assignedContainers = 
      assignContainer(node, application, priority, 
          assignableContainers, request, NodeType.NODE_LOCAL);
  }
  return assignedContainers;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:FifoScheduler.java

示例13: assignRackLocalContainers

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
private int assignRackLocalContainers(FiCaSchedulerNode node, 
    FiCaSchedulerApp application, Priority priority) {
  int assignedContainers = 0;
  ResourceRequest request = 
    application.getResourceRequest(priority, node.getRMNode().getRackName());
  if (request != null) {
    // Don't allocate on this rack if the application doens't need containers
    ResourceRequest offSwitchRequest =
        application.getResourceRequest(priority, ResourceRequest.ANY);
    if (offSwitchRequest.getNumContainers() <= 0) {
      return 0;
    }
    
    int assignableContainers = 
      Math.min(
          getMaxAllocatableContainers(application, priority, node, 
              NodeType.RACK_LOCAL), 
              request.getNumContainers());
    assignedContainers = 
      assignContainer(node, application, priority, 
          assignableContainers, request, NodeType.RACK_LOCAL);
  }
  return assignedContainers;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:FifoScheduler.java

示例14: testLocalityRelaxationDifferentLevels

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
@Test (expected = InvalidContainerRequestException.class)
public void testLocalityRelaxationDifferentLevels() {
  AMRMClientImpl<ContainerRequest> client =
      new AMRMClientImpl<ContainerRequest>();
  Configuration conf = new Configuration();
  conf.setClass(
      CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
      MyResolver.class, DNSToSwitchMapping.class);
  client.init(conf);
  
  Resource capability = Resource.newInstance(1024, 1, 1);
  ContainerRequest request1 =
      new ContainerRequest(capability, new String[] {"host1", "host2"},
          null, Priority.newInstance(1), false);
  client.addContainerRequest(request1);
  ContainerRequest request2 =
      new ContainerRequest(capability, null,
          new String[] {"rack1"}, Priority.newInstance(1), true);
  client.addContainerRequest(request2);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestAMRMClientContainerRequest.java

示例15: showRequests

import org.apache.hadoop.yarn.api.records.Priority; //導入依賴的package包/類
public synchronized void showRequests() {
  if (LOG.isDebugEnabled()) {
    for (Priority priority : getPriorities()) {
      Map<String, ResourceRequest> requests = getResourceRequests(priority);
      if (requests != null) {
        LOG.debug("showRequests:" + " application=" + getApplicationId()
            + " headRoom=" + getHeadroom() + " currentConsumption="
            + attemptResourceUsage.getUsed().getMemory());
        for (ResourceRequest request : requests.values()) {
          LOG.debug("showRequests:" + " application=" + getApplicationId()
              + " request=" + request);
        }
      }
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:SchedulerApplicationAttempt.java


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