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


Java ContainerLaunchContext类代码示例

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


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

示例1: testContainerKill

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
@Test
public void testContainerKill() throws IOException {
  String appSubmitter = "nobody";
  String cmd = String.valueOf(
      PrivilegedOperation.RunAsUserCommand.SIGNAL_CONTAINER.getValue());
  ContainerExecutor.Signal signal = ContainerExecutor.Signal.QUIT;
  String sigVal = String.valueOf(signal.getValue());

  Container container = mock(Container.class);
  ContainerId cId = mock(ContainerId.class);
  ContainerLaunchContext context = mock(ContainerLaunchContext.class);

  when(container.getContainerId()).thenReturn(cId);
  when(container.getLaunchContext()).thenReturn(context);

  mockExec.signalContainer(new ContainerSignalContext.Builder()
      .setContainer(container)
      .setUser(appSubmitter)
      .setPid("1000")
      .setSignal(signal)
      .build());
  assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
      appSubmitter, cmd, "1000", sigVal),
      readMockParams());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestLinuxContainerExecutorWithMocks.java

示例2: run

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
public boolean run() throws Exception {
  YarnClientApplication app = createApplication();
  ApplicationId appId = app.getNewApplicationResponse().getApplicationId();

  // Copy the application jar to the filesystem
  FileSystem fs = FileSystem.get(conf);
  String appIdStr = appId.toString();
  Path dstJarPath = Utils.copyLocalFileToDfs(fs, appIdStr, new Path(tfJar), Constants.TF_JAR_NAME);
  Path dstLibPath = Utils.copyLocalFileToDfs(fs, appIdStr, new Path(tfLib),
      Constants.TF_LIB_NAME);
  Map<String, Path> files = new HashMap<>();
  files.put(Constants.TF_JAR_NAME, dstJarPath);
  Map<String, LocalResource> localResources = Utils.makeLocalResources(fs, files);
  Map<String, String> javaEnv = Utils.setJavaEnv(conf);
  String command = makeAppMasterCommand(dstLibPath.toString(), dstJarPath.toString());
  LOG.info("Make ApplicationMaster command: " + command);
  ContainerLaunchContext launchContext = ContainerLaunchContext.newInstance(
      localResources, javaEnv, Lists.newArrayList(command), null, null, null);
  Resource resource = Resource.newInstance(amMemory, amVCores);
  submitApplication(app, appName, launchContext, resource, amQueue);
  return awaitApplication(appId);
}
 
开发者ID:Intel-bigdata,项目名称:TensorFlowOnYARN,代码行数:23,代码来源:LaunchCluster.java

示例3: newApplicationSubmissionContext

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
public static ApplicationSubmissionContext newApplicationSubmissionContext(
    ApplicationId applicationId, String applicationName, String queue,
    Priority priority, ContainerLaunchContext amContainer,
    boolean isUnmanagedAM, boolean cancelTokensWhenComplete,
    int maxAppAttempts, Resource resource, String applicationType) {
  ApplicationSubmissionContext context =
      recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
  context.setApplicationId(applicationId);
  context.setApplicationName(applicationName);
  context.setQueue(queue);
  context.setPriority(priority);
  context.setAMContainerSpec(amContainer);
  context.setUnmanagedAM(isUnmanagedAM);
  context.setCancelTokensWhenComplete(cancelTokensWhenComplete);
  context.setMaxAppAttempts(maxAppAttempts);
  context.setResource(resource);
  context.setApplicationType(applicationType);
  return context;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:BuilderUtils.java

示例4: startContainer

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
private void startContainer(final YarnRPC rpc,
    org.apache.hadoop.yarn.api.records.Token nmToken,
    org.apache.hadoop.yarn.api.records.Token containerToken,
    NodeId nodeId, String user) throws Exception {

  ContainerLaunchContext context =
      Records.newRecord(ContainerLaunchContext.class);
  StartContainerRequest scRequest =
      StartContainerRequest.newInstance(context,containerToken);
  List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
  list.add(scRequest);
  StartContainersRequest allRequests =
      StartContainersRequest.newInstance(list);
  ContainerManagementProtocol proxy = null;
  try {
    proxy = getContainerManagementProtocolProxy(rpc, nmToken, nodeId, user);
    StartContainersResponse response = proxy.startContainers(allRequests);
    for(SerializedException ex : response.getFailedRequests().values()){
      parseAndThrowException(ex.deSerialize());
    }
  } finally {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestContainerManagerSecurity.java

示例5: parseCredentials

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
private Credentials parseCredentials(ContainerLaunchContext launchContext)
    throws IOException {
  Credentials credentials = new Credentials();
  // //////////// Parse credentials
  ByteBuffer tokens = launchContext.getTokens();

  if (tokens != null) {
    DataInputByteBuffer buf = new DataInputByteBuffer();
    tokens.rewind();
    buf.reset(tokens);
    credentials.readTokenStorageStream(buf);
    if (LOG.isDebugEnabled()) {
      for (Token<? extends TokenIdentifier> tk : credentials.getAllTokens()) {
        LOG.debug(tk.getService() + " = " + tk.toString());
      }
    }
  }
  // //////////// End of parsing credentials
  return credentials;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:ContainerManagerImpl.java

示例6: ContainerImpl

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
public ContainerImpl(Configuration conf, Dispatcher dispatcher,
    NMStateStoreService stateStore, ContainerLaunchContext launchContext,
    Credentials creds, NodeManagerMetrics metrics,
    ContainerTokenIdentifier containerTokenIdentifier) {
  this.daemonConf = conf;
  this.dispatcher = dispatcher;
  this.stateStore = stateStore;
  this.launchContext = launchContext;
  this.containerTokenIdentifier = containerTokenIdentifier;
  this.containerId = containerTokenIdentifier.getContainerID();
  this.resource = containerTokenIdentifier.getResource();
  this.diagnostics = new StringBuilder();
  this.credentials = creds;
  this.metrics = metrics;
  user = containerTokenIdentifier.getApplicationSubmitter();
  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  this.readLock = readWriteLock.readLock();
  this.writeLock = readWriteLock.writeLock();

  stateMachine = stateMachineFactory.make(this);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:ContainerImpl.java

示例7: MockContainer

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
public MockContainer(ApplicationAttemptId appAttemptId,
    Dispatcher dispatcher, Configuration conf, String user,
    ApplicationId appId, int uniqId) throws IOException{

  this.user = user;
  this.recordFactory = RecordFactoryProvider.getRecordFactory(conf);
  this.id = BuilderUtils.newContainerId(recordFactory, appId, appAttemptId,
      uniqId);
  this.launchContext = recordFactory
      .newRecordInstance(ContainerLaunchContext.class);
  long currentTime = System.currentTimeMillis();
  this.containerTokenIdentifier =
      BuilderUtils.newContainerTokenIdentifier(BuilderUtils
        .newContainerToken(id, "127.0.0.1", 1234, user,
          BuilderUtils.newResource(1024, 1), currentTime + 10000, 123,
          "password".getBytes(), currentTime));
  this.state = ContainerState.NEW;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:MockContainer.java

示例8: testCallFailureWithNullLocalizedResources

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test (timeout = 10000)
public void testCallFailureWithNullLocalizedResources() {
  Container container = mock(Container.class);
  when(container.getContainerId()).thenReturn(ContainerId.newContainerId(
      ApplicationAttemptId.newInstance(ApplicationId.newInstance(
          System.currentTimeMillis(), 1), 1), 1));
  ContainerLaunchContext clc = mock(ContainerLaunchContext.class);
  when(clc.getCommands()).thenReturn(Collections.<String>emptyList());
  when(container.getLaunchContext()).thenReturn(clc);
  when(container.getLocalizedResources()).thenReturn(null);
  Dispatcher dispatcher = mock(Dispatcher.class);
  EventHandler eventHandler = new EventHandler() {
    public void handle(Event event) {
      Assert.assertTrue(event instanceof ContainerExitEvent);
      ContainerExitEvent exitEvent = (ContainerExitEvent) event;
      Assert.assertEquals(ContainerEventType.CONTAINER_EXITED_WITH_FAILURE,
          exitEvent.getType());
    }
  };
  when(dispatcher.getEventHandler()).thenReturn(eventHandler);
  ContainerLaunch launch = new ContainerLaunch(context, new Configuration(),
      dispatcher, exec, null, container, dirsHandler, containerManager);
  launch.call();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestContainerLaunch.java

示例9: startContainer

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
private StartContainersResponse startContainer(Context context,
    final ContainerManagerImpl cm, ContainerId cid,
    ContainerLaunchContext clc, LogAggregationContext logAggregationContext)
        throws Exception {
  UserGroupInformation user = UserGroupInformation.createRemoteUser(
      cid.getApplicationAttemptId().toString());
  StartContainerRequest scReq = StartContainerRequest.newInstance(
      clc, TestContainerManager.createContainerToken(cid, 0,
          context.getNodeId(), user.getShortUserName(),
          context.getContainerTokenSecretManager(), logAggregationContext));
  final List<StartContainerRequest> scReqList =
      new ArrayList<StartContainerRequest>();
  scReqList.add(scReq);
  NMTokenIdentifier nmToken = new NMTokenIdentifier(
      cid.getApplicationAttemptId(), context.getNodeId(),
      user.getShortUserName(),
      context.getNMTokenSecretManager().getCurrentKey().getKeyId());
  user.addTokenIdentifier(nmToken);
  return user.doAs(new PrivilegedExceptionAction<StartContainersResponse>() {
    @Override
    public StartContainersResponse run() throws Exception {
      return cm.startContainers(
          StartContainersRequest.newInstance(scReqList));
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestContainerManagerRecovery.java

示例10: createAMContainerLaunchContext

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
private ContainerLaunchContext createAMContainerLaunchContext(
    ApplicationSubmissionContext applicationMasterContext,
    ContainerId containerID) throws IOException {

  // Construct the actual Container
  ContainerLaunchContext container = 
      applicationMasterContext.getAMContainerSpec();
  LOG.info("Command to launch container "
      + containerID
      + " : "
      + StringUtils.arrayToString(container.getCommands().toArray(
          new String[0])));
  
  // Finalize the container
  setupTokens(container, containerID);
  
  return container;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:AMLauncher.java

示例11: testAppRecoverPath

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
@Test (timeout = 30000)
public void testAppRecoverPath() throws IOException {
  LOG.info("--- START: testAppRecoverPath ---");
  ApplicationSubmissionContext sub =
      Records.newRecord(ApplicationSubmissionContext.class);
  ContainerLaunchContext clc =
      Records.newRecord(ContainerLaunchContext.class);
  Credentials credentials = new Credentials();
  DataOutputBuffer dob = new DataOutputBuffer();
  credentials.writeTokenStorageToStream(dob);
  ByteBuffer securityTokens =
      ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
  clc.setTokens(securityTokens);
  sub.setAMContainerSpec(clc);
  testCreateAppSubmittedRecovery(sub);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestRMAppTransitions.java

示例12: mockSubmitAppRequest

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private SubmitApplicationRequest mockSubmitAppRequest(ApplicationId appId,
      String name, String queue, Set<String> tags, boolean unmanaged) {

  ContainerLaunchContext amContainerSpec = mock(ContainerLaunchContext.class);

  Resource resource = Resources.createResource(
      YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB);

  ApplicationSubmissionContext submissionContext =
      recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
  submissionContext.setAMContainerSpec(amContainerSpec);
  submissionContext.setApplicationName(name);
  submissionContext.setQueue(queue);
  submissionContext.setApplicationId(appId);
  submissionContext.setResource(resource);
  submissionContext.setApplicationType(appType);
  submissionContext.setApplicationTags(tags);
  submissionContext.setUnmanagedAM(unmanaged);

  SubmitApplicationRequest submitRequest =
      recordFactory.newRecordInstance(SubmitApplicationRequest.class);
  submitRequest.setApplicationSubmissionContext(submissionContext);
  return submitRequest;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestClientRMService.java

示例13: startContainerAsync

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
public void startContainerAsync(
    Container container, ContainerLaunchContext containerLaunchContext) {
  if (containers.putIfAbsent(container.getId(),
      new StatefulContainer(this, container.getId())) != null) {
    callbackHandler.onStartContainerError(container.getId(),
        RPCUtil.getRemoteException("Container " + container.getId() +
            " is already started or scheduled to start"));
  }
  try {
    events.put(new StartContainerEvent(container, containerLaunchContext));
  } catch (InterruptedException e) {
    LOG.warn("Exception when scheduling the event of starting Container " +
        container.getId());
    callbackHandler.onStartContainerError(container.getId(), e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:NMClientAsyncImpl.java

示例14: testSubmitApplicationOnHA

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
@Test(timeout = 15000)
public void testSubmitApplicationOnHA() throws Exception {
  ApplicationSubmissionContext appContext =
      Records.newRecord(ApplicationSubmissionContext.class);
  appContext.setApplicationId(cluster.createFakeAppId());
  ContainerLaunchContext amContainer =
      Records.newRecord(ContainerLaunchContext.class);
  appContext.setAMContainerSpec(amContainer);
  Resource capability = Records.newRecord(Resource.class);
  capability.setMemory(10);
  capability.setVirtualCores(1);
  capability.setGpuCores(1);
  appContext.setResource(capability);
  ApplicationId appId = client.submitApplication(appContext);
  Assert.assertTrue(getActiveRM().getRMContext().getRMApps()
      .containsKey(appId));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestApplicationClientProtocolOnHA.java

示例15: createContainerLauncher

import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; //导入依赖的package包/类
@Override
protected ContainerLauncher createContainerLauncher(AppContext context) {
  return new MockContainerLauncher() {
    @Override
    public void handle(ContainerLauncherEvent event) {
      if (event.getType() == EventType.CONTAINER_REMOTE_LAUNCH) {
        ContainerRemoteLaunchEvent launchEvent = (ContainerRemoteLaunchEvent) event;
        ContainerLaunchContext launchContext =
            launchEvent.getContainerLaunchContext();
        String cmdString = launchContext.getCommands().toString();
        LOG.info("launchContext " + cmdString);
        myCommandLine = cmdString;
        cmdEnvironment = launchContext.getEnvironment();
      }
      super.handle(event);
    }
  };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestMapReduceChildJVM.java


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