Example usage for org.apache.hadoop.yarn.api.records Container getVersion

List of usage examples for org.apache.hadoop.yarn.api.records Container getVersion

Introduction

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

Prototype

@Private
@Unstable
public int getVersion() 

Source Link

Document

Get the version of this container.

Usage

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

License:Apache License

public static void removeContainersToDecrease(
        final Collection<org.apache.hadoop.yarn.api.records.Container> containers) throws IOException {
    long start = System.currentTimeMillis();
    AsyncLightWeightRequestHandler removeContainerToDecrease = new AsyncLightWeightRequestHandler(
            YARNOperationType.TEST) {/*from   www.ja v  a2s. co  m*/
        @Override
        public Object performTask() throws StorageException {
            connector.beginTransaction();
            connector.writeLock();
            ContainerToDecreaseDataAccess ctsDA = (ContainerToDecreaseDataAccess) RMStorageFactory
                    .getDataAccess(ContainerToDecreaseDataAccess.class);
            List<io.hops.metadata.yarn.entity.Container> containersToDecrease = new ArrayList<io.hops.metadata.yarn.entity.Container>();
            for (org.apache.hadoop.yarn.api.records.Container container : containers) {
                containersToDecrease.add(new io.hops.metadata.yarn.entity.Container(
                        container.getId().toString(), container.getNodeId().toString(),
                        container.getNodeHttpAddress(), container.getPriority().getPriority(),
                        container.getResource().getMemorySize(), container.getResource().getVirtualCores(),
                        container.getResource().getGPUs(), container.getVersion()));
            }
            ctsDA.removeAll(containersToDecrease);
            connector.commit();
            return null;
        }
    };

    removeContainerToDecrease.handle();
    long duration = System.currentTimeMillis() - start;
    if (duration > 10) {
        LOG.error("too long " + duration);
    }
}

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

License:Apache License

public static void addContainersToDecrease(final List<org.apache.hadoop.yarn.api.records.Container> containers)
        throws IOException {
    long start = System.currentTimeMillis();
    AsyncLightWeightRequestHandler addContainerToDecrease = new AsyncLightWeightRequestHandler(
            YARNOperationType.TEST) {//  w  w  w .ja  v  a2 s  .co m
        @Override
        public Object performTask() throws StorageException {
            connector.beginTransaction();
            connector.writeLock();
            ContainerToDecreaseDataAccess ctsDA = (ContainerToDecreaseDataAccess) RMStorageFactory
                    .getDataAccess(ContainerToDecreaseDataAccess.class);
            List<io.hops.metadata.yarn.entity.Container> containersToDecrease = new ArrayList<io.hops.metadata.yarn.entity.Container>();
            for (org.apache.hadoop.yarn.api.records.Container container : containers) {
                containersToDecrease.add(new io.hops.metadata.yarn.entity.Container(
                        container.getId().toString(), container.getNodeId().toString(),
                        container.getNodeHttpAddress(), container.getPriority().getPriority(),
                        container.getResource().getMemorySize(), container.getResource().getVirtualCores(),
                        container.getResource().getGPUs(), container.getVersion()));
            }
            ctsDA.addAll(containersToDecrease);
            connector.commit();
            return null;
        }
    };

    addContainerToDecrease.handle();
    long duration = System.currentTimeMillis() - start;
    if (duration > 10) {
        LOG.error("too long " + duration);
    }
}