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


Java Priority.setPriority方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.api.records.Priority.setPriority方法的典型用法代码示例。如果您正苦于以下问题:Java Priority.setPriority方法的具体用法?Java Priority.setPriority怎么用?Java Priority.setPriority使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.api.records.Priority的用法示例。


在下文中一共展示了Priority.setPriority方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: submitTasks

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
/**
 * submit tasks to request containers for the tasks
 *
 * @param tasks
 *            a collection of tasks we want to ask container for
 */
private synchronized void submitTasks(Collection<TaskRecord> tasks) {
    for (TaskRecord r : tasks) {
        Resource resource = Records.newRecord(Resource.class);
        if (r.taskRole == "server") {
          resource.setMemory(serverMemoryMB);
          resource.setVirtualCores(serverCores);
        } else {
          resource.setMemory(workerMemoryMB);
          resource.setVirtualCores(workerCores);
        }
        Priority priority = Records.newRecord(Priority.class);
        priority.setPriority(this.appPriority);
        r.containerRequest = new ContainerRequest(resource, null, null,
                priority);
        rmClient.addContainerRequest(r.containerRequest);
        pendingTasks.add(r);
    }
}
 
开发者ID:Intel-bigdata,项目名称:MXNetOnYARN,代码行数:25,代码来源:ApplicationMaster.java

示例3: createResourceRequest

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
private ResourceRequest createResourceRequest(int memory, String host,
    int priority, int numContainers) {
  ResourceRequest request = recordFactory
      .newRecordInstance(ResourceRequest.class);
  request.setCapability(Resources.createResource(memory));
  request.setResourceName(host);
  request.setNumContainers(numContainers);
  Priority prio = recordFactory.newRecordInstance(Priority.class);
  prio.setPriority(priority);
  request.setPriority(prio);
  return request;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestFifoScheduler.java

示例4: createResourceRequest

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
protected ResourceRequest createResourceRequest(
    int memory, int vcores, int gcores, String host, int priority, int numContainers,
    boolean relaxLocality) {
  ResourceRequest request = recordFactory.newRecordInstance(ResourceRequest.class);
  request.setCapability(BuilderUtils.newResource(memory, vcores, gcores));
  request.setResourceName(host);
  request.setNumContainers(numContainers);
  Priority prio = recordFactory.newRecordInstance(Priority.class);
  prio.setPriority(priority);
  request.setPriority(prio);
  request.setRelaxLocality(relaxLocality);
  request.setNodeLabelExpression(RMNodeLabelsManager.NO_LABEL);
  return request;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:FairSchedulerTestBase.java

示例5: createMockPriority

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
public static Priority createMockPriority( int priority) {
//    Priority p = mock(Priority.class);
//    when(p.getPriority()).thenReturn(priority);
    Priority p = recordFactory.newRecordInstance(Priority.class);
    p.setPriority(priority);
    return p;
  }
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:TestUtils.java

示例6: createApp

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
private ApplicationId createApp(YarnClient rmClient, boolean unmanaged) 
  throws Exception {
  YarnClientApplication newApp = rmClient.createApplication();

  ApplicationId appId = newApp.getNewApplicationResponse().getApplicationId();

  // Create launch context for app master
  ApplicationSubmissionContext appContext
    = Records.newRecord(ApplicationSubmissionContext.class);

  // set the application id
  appContext.setApplicationId(appId);

  // set the application name
  appContext.setApplicationName("test");

  // Set the priority for the application master
  Priority pri = Records.newRecord(Priority.class);
  pri.setPriority(1);
  appContext.setPriority(pri);

  // Set the queue to which this application is to be submitted in the RM
  appContext.setQueue("default");

  // Set up the container launch context for the application master
  ContainerLaunchContext amContainer
    = Records.newRecord(ContainerLaunchContext.class);
  appContext.setAMContainerSpec(amContainer);
  appContext.setResource(Resource.newInstance(1024, 1));
  appContext.setUnmanagedAM(unmanaged);

  // Submit the application to the applications manager
  rmClient.submitApplication(appContext);

  return appId;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TestYarnClient.java

示例7: createResourceRequest

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
protected ResourceRequest createResourceRequest(
        Resource resource, String host, int priority, int numContainers) {
  ResourceRequest request = recordFactory
      .newRecordInstance(ResourceRequest.class);
  request.setCapability(resource);
  request.setResourceName(host);
  request.setNumContainers(numContainers);
  Priority prio = recordFactory.newRecordInstance(Priority.class);
  prio.setPriority(priority);
  request.setPriority(prio);
  return request;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:AMSimulator.java

示例8: newPriority

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
public static Priority newPriority(int p) {
  Priority priority = recordFactory.newRecordInstance(Priority.class);
  priority.setPriority(p);
  return priority;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:BuilderUtils.java

示例9: getPriority

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
@Override
public Priority getPriority() {
  Priority p = recordFactory.newRecordInstance(Priority.class);
  p.setPriority(1);
  return p;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:FSQueue.java

示例10: startApp

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
@Before
public void startApp() throws Exception {
  // submit new app
  ApplicationSubmissionContext appContext = 
      yarnClient.createApplication().getApplicationSubmissionContext();
  ApplicationId appId = appContext.getApplicationId();
  // set the application name
  appContext.setApplicationName("Test");
  // Set the priority for the application master
  Priority pri = Records.newRecord(Priority.class);
  pri.setPriority(0);
  appContext.setPriority(pri);
  // Set the queue to which this application is to be submitted in the RM
  appContext.setQueue("default");
  // Set up the container launch context for the application master
  ContainerLaunchContext amContainer =
      BuilderUtils.newContainerLaunchContext(
        Collections.<String, LocalResource> emptyMap(),
        new HashMap<String, String>(), Arrays.asList("sleep", "100"),
        new HashMap<String, ByteBuffer>(), null,
        new HashMap<ApplicationAccessType, String>());
  appContext.setAMContainerSpec(amContainer);
  appContext.setResource(Resource.newInstance(1024, 1, 1));
  // Create the request to send to the applications manager
  SubmitApplicationRequest appRequest = Records
      .newRecord(SubmitApplicationRequest.class);
  appRequest.setApplicationSubmissionContext(appContext);
  // Submit the application to the applications manager
  yarnClient.submitApplication(appContext);

  // wait for app to start
  RMAppAttempt appAttempt = null;
  while (true) {
    ApplicationReport appReport = yarnClient.getApplicationReport(appId);
    if (appReport.getYarnApplicationState() == YarnApplicationState.ACCEPTED) {
      attemptId = appReport.getCurrentApplicationAttemptId();
      appAttempt =
          yarnCluster.getResourceManager().getRMContext().getRMApps()
            .get(attemptId.getApplicationId()).getCurrentAppAttempt();
      while (true) {
        if (appAttempt.getAppAttemptState() == RMAppAttemptState.LAUNCHED) {
          break;
        }
      }
      break;
    }
  }
  // Just dig into the ResourceManager and get the AMRMToken just for the sake
  // of testing.
  UserGroupInformation.setLoginUser(UserGroupInformation
    .createRemoteUser(UserGroupInformation.getCurrentUser().getUserName()));

  // emulate RM setup of AMRM token in credentials by adding the token
  // *before* setting the token service
  UserGroupInformation.getCurrentUser().addToken(appAttempt.getAMRMToken());
  appAttempt.getAMRMToken().setService(ClientRMProxy.getAMRMTokenService(conf));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:58,代码来源:TestAMRMClient.java

示例11: run

import org.apache.hadoop.yarn.api.records.Priority; //导入方法依赖的package包/类
public boolean run() throws IOException, YarnException {
  LOG.info("Starting Client");
  
  // Connect to ResourceManager
  rmClient.start();
  try {  
    // Create launch context for app master
    LOG.info("Setting up application submission context for ASM");
    ApplicationSubmissionContext appContext = rmClient.createApplication()
        .getApplicationSubmissionContext();
    ApplicationId appId = appContext.getApplicationId();

    // set the application name
    appContext.setApplicationName(appName);

    // Set the priority for the application master
    Priority pri = Records.newRecord(Priority.class);
    pri.setPriority(amPriority);
    appContext.setPriority(pri);

    // Set the queue to which this application is to be submitted in the RM
    appContext.setQueue(amQueue);

    // Set up the container launch context for the application master
    ContainerLaunchContext amContainer = Records
        .newRecord(ContainerLaunchContext.class);
    appContext.setAMContainerSpec(amContainer);

    // unmanaged AM
    appContext.setUnmanagedAM(true);
    LOG.info("Setting unmanaged AM");

    // Submit the application to the applications manager
    LOG.info("Submitting application to ASM");
    rmClient.submitApplication(appContext);

    ApplicationReport appReport =
        monitorApplication(appId, EnumSet.of(YarnApplicationState.ACCEPTED,
          YarnApplicationState.KILLED, YarnApplicationState.FAILED,
          YarnApplicationState.FINISHED));

    if (appReport.getYarnApplicationState() == YarnApplicationState.ACCEPTED) {
      // Monitor the application attempt to wait for launch state
      ApplicationAttemptReport attemptReport =
          monitorCurrentAppAttempt(appId,
            YarnApplicationAttemptState.LAUNCHED);
      ApplicationAttemptId attemptId =
          attemptReport.getApplicationAttemptId();
      LOG.info("Launching AM with application attempt id " + attemptId);
      // launch AM
      launchAM(attemptId);
      // Monitor the application for end state
      appReport =
          monitorApplication(appId, EnumSet.of(YarnApplicationState.KILLED,
            YarnApplicationState.FAILED, YarnApplicationState.FINISHED));
    }

    YarnApplicationState appState = appReport.getYarnApplicationState();
    FinalApplicationStatus appStatus = appReport.getFinalApplicationStatus();

    LOG.info("App ended with state: " + appReport.getYarnApplicationState()
        + " and status: " + appStatus);
    
    boolean success;
    if (YarnApplicationState.FINISHED == appState
        && FinalApplicationStatus.SUCCEEDED == appStatus) {
      LOG.info("Application has completed successfully.");
      success = true;
    } else {
      LOG.info("Application did finished unsuccessfully." + " YarnState="
          + appState.toString() + ", FinalStatus=" + appStatus.toString());
      success = false;
    }
    
    return success;
  } finally {
    rmClient.stop();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:80,代码来源:UnmanagedAMLauncher.java


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