Example usage for org.apache.hadoop.yarn.api.records ContainerId toString

List of usage examples for org.apache.hadoop.yarn.api.records ContainerId toString

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.records ContainerId toString.

Prototype

@Override
public String toString() 

Source Link

Usage

From source file:org.apache.hoya.api.ClusterNode.java

License:Apache License

/**
 * server-side ctor takes the container ID and builds the name from it
 * @param containerId container ID/*  ww  w  . j  a va2  s  . com*/
 */
public ClusterNode(ContainerId containerId) {
    this.containerId = containerId;
    this.name = containerId.toString();
}

From source file:org.apache.hoya.yarn.appmaster.state.AppState.java

License:Apache License

/**
 * Note that a container has been submitted for release; update internal state
 * and mark the associated ContainerInfo released field to indicate that
 * while it is still in the active list, it has been queued for release.
 *
 * @param container container//from ww w .  ja  v  a  2s  . c  o m
 * @throws HoyaInternalStateException if there is no container of that ID
 * on the active list
 */
public synchronized void containerReleaseSubmitted(Container container) throws HoyaInternalStateException {
    ContainerId id = container.getId();
    //look up the container
    RoleInstance info = getActiveContainer(id);
    if (info == null) {
        throw new HoyaInternalStateException("No active container with ID " + id.toString());
    }
    //verify that it isn't already released
    if (containersBeingReleased.containsKey(id)) {
        throw new HoyaInternalStateException("Container %s already queued for release", id);
    }
    info.released = true;
    containersBeingReleased.put(id, info.container);
    RoleStatus role = lookupRoleStatus(info.roleId);
    role.incReleasing();
    roleHistory.onContainerReleaseSubmitted(container);
}

From source file:org.apache.hoya.yarn.appmaster.state.AppState.java

License:Apache License

/**
 * handle completed node in the CD -move something from the live
 * server list to the completed server list
 * @param amConf YarnConfiguration//  www  .  j ava 2 s  .  c  om
 * @param status the node that has just completed
 * @return NodeCompletionResult
 */
public synchronized NodeCompletionResult onCompletedNode(YarnConfiguration amConf, ContainerStatus status) {
    ContainerId containerId = status.getContainerId();
    NodeCompletionResult result = new NodeCompletionResult();
    RoleInstance roleInstance;

    if (containersBeingReleased.containsKey(containerId)) {
        log.info("Container was queued for release");
        Container container = containersBeingReleased.remove(containerId);
        RoleStatus roleStatus = lookupRoleStatus(container);
        log.info("decrementing role count for role {}", roleStatus.getName());
        roleStatus.decReleasing();
        roleStatus.decActual();
        roleStatus.incCompleted();
        roleHistory.onReleaseCompleted(container);

    } else if (surplusNodes.remove(containerId)) {
        //its a surplus one being purged
        result.surplusNode = true;
    } else {
        //a container has failed 
        result.containerFailed = true;
        roleInstance = activeContainers.remove(containerId);
        if (roleInstance != null) {
            //it was active, move it to failed 
            incFailedCountainerCount();
            failedNodes.put(containerId, roleInstance);
        } else {
            // the container may have been noted as failed already, so look
            // it up
            roleInstance = failedNodes.get(containerId);
        }
        if (roleInstance != null) {
            int roleId = roleInstance.roleId;
            log.info("Failed container in role {}", roleId);
            try {
                RoleStatus roleStatus = lookupRoleStatus(roleId);
                roleStatus.decActual();
                boolean shortLived = isShortLived(roleInstance);
                String message;
                if (roleInstance.container != null) {
                    String user = null;
                    try {
                        user = HoyaUtils.getCurrentUser().getShortUserName();
                    } catch (IOException ioe) {
                    }
                    String completedLogsUrl = null;
                    Container c = roleInstance.container;
                    String url = null;
                    if (amConf != null) {
                        url = amConf.get(YarnConfiguration.YARN_LOG_SERVER_URL);
                    }
                    if (user != null && url != null) {
                        completedLogsUrl = url + "/" + c.getNodeId() + "/" + roleInstance.getContainerId()
                                + "/ctx/" + user;
                    }
                    message = String.format(
                            "Failure %s on host %s" + (completedLogsUrl != null ? ", see %s" : ""),
                            roleInstance.getContainerId(), c.getNodeId().getHost(), completedLogsUrl);
                } else {
                    message = String.format("Failure %s", containerId.toString());
                }
                roleStatus.noteFailed(message);
                //have a look to see if it short lived
                if (shortLived) {
                    roleStatus.incStartFailed();
                }

                if (roleInstance.container != null) {
                    roleHistory.onFailedContainer(roleInstance.container, shortLived);
                }

            } catch (YarnRuntimeException e1) {
                log.error("Failed container of unknown role {}", roleId);
            }
        } else {
            //this isn't a known container.

            log.error("Notified of completed container {} that is not in the list"
                    + " of active or failed containers", containerId);
            completionOfUnknownContainerEvent.incrementAndGet();
        }
    }

    if (result.surplusNode) {
        //a surplus node
        return result;
    }

    //record the complete node's details; this pulls it from the livenode set 
    //remove the node
    ContainerId id = status.getContainerId();
    RoleInstance node = getLiveNodes().remove(id);
    if (node == null) {
        log.warn("Received notification of completion of unknown node {}", id);
        completionOfNodeNotInLiveListEvent.incrementAndGet();

    } else {
        node.state = ClusterDescription.STATE_DESTROYED;
        node.exitCode = status.getExitStatus();
        node.diagnostics = status.getDiagnostics();
        getCompletedNodes().put(id, node);
        result.roleInstance = node;
    }
    return result;
}

From source file:org.apache.myriad.executor.MyriadExecutorAuxService.java

License:Apache License

@Override
public void initializeContainer(ContainerInitializationContext initContainerContext) {
    ContainerId containerId = initContainerContext.getContainerId();
    synchronized (containerIds) {
        containerIds.add(containerId.toString());
    }/*from   w  ww.j  a  v  a 2  s . c  om*/
    sendStatus(containerId, TaskState.TASK_RUNNING);
}

From source file:org.apache.myriad.executor.MyriadExecutorAuxService.java

License:Apache License

@Override
public void stopContainer(ContainerTerminationContext stopContainerContext) {
    ContainerId containerId = stopContainerContext.getContainerId();
    synchronized (containerIds) {
        containerIds.remove(containerId.toString());
    }//w  w  w.j  a  va 2 s.  c o  m
    sendStatus(stopContainerContext.getContainerId(), TaskState.TASK_FINISHED);
}

From source file:org.apache.myriad.executor.MyriadExecutorAuxService.java

License:Apache License

private void sendStatus(ContainerId containerId, TaskState taskState) {
    Protos.TaskID taskId = Protos.TaskID.newBuilder()
            .setValue(YARN_CONTAINER_TASK_ID_PREFIX + containerId.toString()).build();

    TaskStatus status = TaskStatus.newBuilder().setTaskId(taskId).setState(taskState).build();
    driver.sendStatusUpdate(status);/*from  ww w .  j a v a  2  s  .  c  o m*/
    LOGGER.debug("Sent status " + taskState + " for taskId " + taskId);
}

From source file:org.apache.reef.runtime.yarn.driver.YarnContainerManager.java

License:Apache License

@Override
public final void onContainerStarted(final ContainerId containerId,
        final Map<String, ByteBuffer> stringByteBufferMap) {
    final Optional<Container> container = this.containers.getOptional(containerId.toString());
    if (container.isPresent()) {
        this.nodeManager.getContainerStatusAsync(containerId, container.get().getNodeId());
    }/*from   w ww .j  a va2s  .c  om*/
}

From source file:org.apache.reef.runtime.yarn.driver.YarnContainerManager.java

License:Apache License

@Override
public final void onContainerStopped(final ContainerId containerId) {
    final boolean hasContainer = this.containers.hasContainer(containerId.toString());
    if (hasContainer) {
        final ResourceStatusProto.Builder resourceStatusBuilder = ResourceStatusProto.newBuilder()
                .setIdentifier(containerId.toString());
        resourceStatusBuilder.setState(ReefServiceProtos.State.DONE);
        this.reefEventHandlers.onResourceStatus(resourceStatusBuilder.build());
    }//from  w  ww.ja v  a  2  s . c  o m
}

From source file:org.apache.reef.runtime.yarn.driver.YarnContainerManager.java

License:Apache License

private void handleContainerError(final ContainerId containerId, final Throwable throwable) {

    final ResourceStatusProto.Builder resourceStatusBuilder = ResourceStatusProto.newBuilder()
            .setIdentifier(containerId.toString());

    resourceStatusBuilder.setState(ReefServiceProtos.State.FAILED);
    resourceStatusBuilder.setExitCode(1);
    resourceStatusBuilder.setDiagnostics(throwable.getMessage());
    this.reefEventHandlers.onResourceStatus(resourceStatusBuilder.build());
}

From source file:org.apache.samza.job.yarn.YarnClusterResourceManager.java

License:Apache License

@Override
public void onContainerStarted(ContainerId containerId, Map<String, ByteBuffer> allServiceResponse) {
    String processorId = getPendingProcessorId(containerId);
    if (processorId != null) {
        log.info("Got start notification for Container ID: {} for Processor ID: {}", containerId, processorId);
        // 1. Move the processor from pending to running state
        final YarnContainer container = state.pendingProcessors.remove(processorId);

        state.runningProcessors.put(processorId, container);

        // 2. Invoke the success callback.
        SamzaResource resource = new SamzaResource(container.resource().getVirtualCores(),
                container.resource().getMemory(), container.nodeId().getHost(), containerId.toString());
        clusterManagerCallback.onStreamProcessorLaunchSuccess(resource);
    } else {//  w  ww . ja va  2s. c om
        log.warn("Did not find the Processor ID for the start notification for Container ID: {}. "
                + "Ignoring notification.", containerId);
    }
}