Example usage for org.apache.hadoop.yarn.server.resourcemanager.rmnode UpdatedContainerInfo getNewlyLaunchedContainers

List of usage examples for org.apache.hadoop.yarn.server.resourcemanager.rmnode UpdatedContainerInfo getNewlyLaunchedContainers

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.resourcemanager.rmnode UpdatedContainerInfo getNewlyLaunchedContainers.

Prototype

public List<ContainerStatus> getNewlyLaunchedContainers() 

Source Link

Usage

From source file:io.hops.util.DBUtility.java

License:Apache License

public static void removeUCI(List<UpdatedContainerInfo> ContainerInfoList, String nodeId) throws IOException {
    long start = System.currentTimeMillis();
    final List<io.hops.metadata.yarn.entity.UpdatedContainerInfo> uciToRemove = new ArrayList<io.hops.metadata.yarn.entity.UpdatedContainerInfo>();
    final List<ContainerStatus> containerStatusToRemove = new ArrayList<ContainerStatus>();
    for (UpdatedContainerInfo uci : ContainerInfoList) {
        if (uci.getNewlyLaunchedContainers() != null && !uci.getNewlyLaunchedContainers().isEmpty()) {
            for (org.apache.hadoop.yarn.api.records.ContainerStatus containerStatus : uci
                    .getNewlyLaunchedContainers()) {
                io.hops.metadata.yarn.entity.UpdatedContainerInfo hopUCI = new io.hops.metadata.yarn.entity.UpdatedContainerInfo(
                        nodeId, containerStatus.getContainerId().toString(), uci.getUciId());
                uciToRemove.add(hopUCI);

                ContainerStatus hopConStatus = new ContainerStatus(containerStatus.getContainerId().toString(),
                        nodeId, uci.getUciId());
                containerStatusToRemove.add(hopConStatus);
            }/*from   ww  w  .j  a v  a 2 s .c o  m*/
        }
        if (uci.getCompletedContainers() != null && !uci.getCompletedContainers().isEmpty()) {
            for (org.apache.hadoop.yarn.api.records.ContainerStatus containerStatus : uci
                    .getCompletedContainers()) {
                io.hops.metadata.yarn.entity.UpdatedContainerInfo hopUCI = new io.hops.metadata.yarn.entity.UpdatedContainerInfo(
                        nodeId, containerStatus.getContainerId().toString(), uci.getUciId());
                uciToRemove.add(hopUCI);
                ContainerStatus hopConStatus = new ContainerStatus(containerStatus.getContainerId().toString(),
                        nodeId, uci.getUciId());
                containerStatusToRemove.add(hopConStatus);
            }
        }
    }

    AsyncLightWeightRequestHandler removeUCIHandler = new AsyncLightWeightRequestHandler(
            YARNOperationType.TEST) {
        @Override
        public Object performTask() throws StorageException {
            connector.beginTransaction();
            connector.writeLock();
            UpdatedContainerInfoDataAccess uciDA = (UpdatedContainerInfoDataAccess) RMStorageFactory
                    .getDataAccess(UpdatedContainerInfoDataAccess.class);
            uciDA.removeAll(uciToRemove);

            ContainerStatusDataAccess csDA = (ContainerStatusDataAccess) RMStorageFactory
                    .getDataAccess(ContainerStatusDataAccess.class);
            csDA.removeAll(containerStatusToRemove);
            connector.commit();
            return null;
        }
    };
    removeUCIHandler.handle();
    long duration = System.currentTimeMillis() - start;
    if (duration > 10) {
        LOG.error("too long " + duration);
    }
}

From source file:io.hops.util.ToCommitHB.java

License:Apache License

public void addNodeUpdateQueue(UpdatedContainerInfo uci) {
    this.uciID = uci.getUciId();
    if (uci.getNewlyLaunchedContainers() != null && !uci.getNewlyLaunchedContainers().isEmpty()) {
        for (org.apache.hadoop.yarn.api.records.ContainerStatus containerStatus : uci
                .getNewlyLaunchedContainers()) {
            io.hops.metadata.yarn.entity.UpdatedContainerInfo hopUCI = new io.hops.metadata.yarn.entity.UpdatedContainerInfo(
                    nodeId, containerStatus.getContainerId().toString(), uciID, pendingEventId);
            uciToAdd.add(hopUCI);//  w ww . j a  v  a 2 s.  com
            this.pendingEventContains++;

            ContainerStatus hopConStatus = new ContainerStatus(containerStatus.getContainerId().toString(),
                    containerStatus.getState().toString(), containerStatus.getDiagnostics(),
                    containerStatus.getExitStatus(), nodeId, pendingEventId, uciID);
            containerStatusToAdd.add(hopConStatus);
            this.pendingEventContains++;
        }
    }
    if (uci.getCompletedContainers() != null && !uci.getCompletedContainers().isEmpty()) {
        for (org.apache.hadoop.yarn.api.records.ContainerStatus containerStatus : uci
                .getCompletedContainers()) {
            io.hops.metadata.yarn.entity.UpdatedContainerInfo hopUCI = new io.hops.metadata.yarn.entity.UpdatedContainerInfo(
                    nodeId, containerStatus.getContainerId().toString(), uciID, pendingEventId);
            uciToAdd.add(hopUCI);
            this.pendingEventContains++;
            ContainerStatus hopConStatus = new ContainerStatus(containerStatus.getContainerId().toString(),
                    containerStatus.getState().toString(), containerStatus.getDiagnostics(),
                    containerStatus.getExitStatus(), nodeId, pendingEventId, uciID);
            containerStatusToAdd.add(hopConStatus);
            this.pendingEventContains++;
        }
    }
}