Package org.apache.hadoop.yarn.api

Examples of org.apache.hadoop.yarn.api.ContainerManager


      // the user in createRemoteUser in this context has to be ContainerID
      user = UserGroupInformation.createRemoteUser(containerID.toString());
      user.addToken(token);
    }

    ContainerManager proxy = user
        .doAs(new PrivilegedAction<ContainerManager>() {
          @Override
          public ContainerManager run() {
            return (ContainerManager) rpc.getProxy(ContainerManager.class,
                cmAddr, getConfig());
View Full Code Here


        sendContainerLaunchFailedMsg(taskAttemptID,
            "Container was killed before it was launched");
        return;
      }
     
      ContainerManager proxy = null;
      try {

        proxy = getCMProxy(containerID, containerMgrAddress,
            containerToken);

        // Construct the actual Container
        ContainerLaunchContext containerLaunchContext =
          event.getContainer();

        // Now launch the actual container
        StartContainerRequest startRequest = Records
          .newRecord(StartContainerRequest.class);
        startRequest.setContainerLaunchContext(containerLaunchContext);
        StartContainerResponse response = proxy.startContainer(startRequest);

        ByteBuffer portInfo = response
          .getServiceResponse(ShuffleHandler.MAPREDUCE_SHUFFLE_SERVICEID);
        int port = -1;
        if(portInfo != null) {
View Full Code Here

      if(this.state == ContainerState.PREP) {
        this.state = ContainerState.KILLED_BEFORE_LAUNCH;
      } else if (!isCompletelyDone()) {
        LOG.info("KILLING " + taskAttemptID);

        ContainerManager proxy = null;
        try {
          proxy = getCMProxy(this.containerID, this.containerMgrAddress,
              this.containerToken);

            // kill the remote container if already launched
            StopContainerRequest stopRequest = Records
              .newRecord(StopContainerRequest.class);
            stopRequest.setContainerId(this.containerID);
            proxy.stopContainer(stopRequest);

        } catch (Throwable t) {

          // ignore the cleanup failure
          String message = "cleanup failed for container "
View Full Code Here

        @Override
        protected ContainerManager getCMProxy(ContainerId containerID,
            String containerManagerBindAddr, ContainerToken containerToken)
            throws IOException {
          // make proxy connect to our local containerManager server
          ContainerManager proxy = (ContainerManager) rpc.getProxy(
              ContainerManager.class,
              NetUtils.getConnectAddress(server), conf);
          return proxy;
        }
      };
View Full Code Here

    context.setResource(container.getResource());

    StartContainerRequest startRequest = Records.newRecord(StartContainerRequest.class);
    startRequest.setContainerLaunchContext(context);

    ContainerManager manager = connectContainerManager(container);
    try {
      manager.startContainer(startRequest);
      return new ContainerTerminator(container, manager);
    } catch (YarnRemoteException e) {
      LOG.error("Error in launching process", e);
      throw Throwables.propagate(e);
    }
View Full Code Here

        try {
          timer.schedule(new CommandTimer(Thread.currentThread(), event),
              nmTimeOut);

          ContainerManager proxy = getCMProxy(containerID,
              containerManagerBindAddr, containerToken);

          // Interruped during getProxy, but that didn't throw exception
          if (Thread.currentThread().isInterrupted()) {
            // The timer cancelled the command in the mean while.
            String message = "Start-container for " + event.getContainerID()
                + " got interrupted. Returning.";
            sendContainerLaunchFailedMsg(taskAttemptID, message);
            return;
          }

          // Construct the actual Container
          ContainerLaunchContext containerLaunchContext =
              launchEvent.getContainer();

          // Now launch the actual container
          StartContainerRequest startRequest = recordFactory
              .newRecordInstance(StartContainerRequest.class);
          startRequest.setContainerLaunchContext(containerLaunchContext);
          StartContainerResponse response = proxy.startContainer(startRequest);

          // container started properly. Stop the timer
          timer.cancel();
          if (Thread.currentThread().isInterrupted()) {
            // The timer cancelled the command in the mean while, but
            // startContainer didn't throw exception
            String message = "Start-container for " + event.getContainerID()
                + " got interrupted. Returning.";
            sendContainerLaunchFailedMsg(taskAttemptID, message);
            return;
          }

          ByteBuffer portInfo = response
              .getServiceResponse(ShuffleHandler.MAPREDUCE_SHUFFLE_SERVICEID);
          int port = -1;
          if(portInfo != null) {
            port = ShuffleHandler.deserializeMetaData(portInfo);
          }
          LOG.info("Shuffle port returned by ContainerManager for "
              + taskAttemptID + " : " + port);
         
          if(port < 0) {
            throw new IllegalStateException("Invalid shuffle port number "
                + port + " returned for " + taskAttemptID);
          }

          // after launching, send launched event to task attempt to move
          // it from ASSIGNED to RUNNING state
          context.getEventHandler().handle(
              new TaskAttemptContainerLaunchedEvent(taskAttemptID, port));
        } catch (Throwable t) {
          String message = "Container launch failed for " + containerID
              + " : " + StringUtils.stringifyException(t);
          sendContainerLaunchFailedMsg(taskAttemptID, message);
        } finally {
          timer.cancel();
        }

        break;

      case CONTAINER_REMOTE_CLEANUP:
        // We will have to remove the launch (meant "cleanup"? FIXME) event if it is still in eventQueue
        // and not yet processed
        if (eventQueue.contains(event)) {
          eventQueue.remove(event); // TODO: Any synchro needed?
          //deallocate the container
          context.getEventHandler().handle(
              new ContainerAllocatorEvent(taskAttemptID,
                  ContainerAllocator.EventType.CONTAINER_DEALLOCATE));
        } else {

          try {
            timer.schedule(new CommandTimer(Thread.currentThread(), event),
                nmTimeOut);

            ContainerManager proxy = getCMProxy(containerID,
                containerManagerBindAddr, containerToken);

            if (Thread.currentThread().isInterrupted()) {
              // The timer cancelled the command in the mean while. No need to
              // return, send cleanedup event anyways.
              LOG.info("Stop-container for " + event.getContainerID()
                  + " got interrupted.");
            } else {

              // TODO:check whether container is launched

              // kill the remote container if already launched
              StopContainerRequest stopRequest = recordFactory
                  .newRecordInstance(StopContainerRequest.class);
              stopRequest.setContainerId(event.getContainerID());
              proxy.stopContainer(stopRequest);
            }
          } catch (Throwable t) {
            // ignore the cleanup failure
            String message = "cleanup failed for container "
                + event.getContainerID() + " : "
View Full Code Here

        // the user in createRemoteUser in this context has to be ContainerID
        user = UserGroupInformation.createRemoteUser(containerID.toString());
        user.addToken(token);
      }

      ContainerManager proxy = user
          .doAs(new PrivilegedAction<ContainerManager>() {
            @Override
            public ContainerManager run() {
              YarnRPC rpc = YarnRPC.create(getConfig());
              return (ContainerManager) rpc.getProxy(ContainerManager.class,
View Full Code Here

            containerToken.getService()));
    authenticatedUser.addToken(token);
    authenticatedUser.doAs(new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        ContainerManager client = (ContainerManager) yarnRPC.getProxy(
            ContainerManager.class, NetUtils
                .createSocketAddr(allocatedContainer.getNodeId().toString()),
            conf);
        LOG.info("Going to make a legal stopContainer() request");
        StopContainerRequest request = recordFactory
            .newRecordInstance(StopContainerRequest.class);
        request.setContainerId(containerID);
        client.stopContainer(request);
        return null;
      }
    });

    KillApplicationRequest request = Records
View Full Code Here

            .getService()));
    maliceUser.addToken(modifiedToken);
    maliceUser.doAs(new PrivilegedAction<Void>() {
      @Override
      public Void run() {
        ContainerManager client = (ContainerManager) yarnRPC.getProxy(
            ContainerManager.class, NetUtils
                .createSocketAddr(allocatedContainer.getNodeId().toString()),
            conf);

        LOG.info("Going to contact NM:  ilLegal request");
        GetContainerStatusRequest request = recordFactory
            .newRecordInstance(GetContainerStatusRequest.class);
        request.setContainerId(containerID);
        try {
          client.getContainerStatus(request);
          fail("Connection initiation with illegally modified "
              + "tokens is expected to fail.");
        } catch (YarnRemoteException e) {
          LOG.error("Got exception", e);
          fail("Cannot get a YARN remote exception as "
View Full Code Here

    unauthorizedUser.addToken(token);
    unauthorizedUser.doAs(new PrivilegedAction<Void>() {
      @Override
      public Void run() {
        ContainerManager client = (ContainerManager) yarnRPC.getProxy(
            ContainerManager.class, NetUtils
                .createSocketAddr(allocatedContainer.getNodeId().toString()),
            conf);

        LOG.info("Going to contact NM:  unauthorized request");
View Full Code Here

TOP

Related Classes of org.apache.hadoop.yarn.api.ContainerManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.