Search in sources :

Example 11 with PrivilegedOperationException

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException in project hadoop by apache.

the class TrafficController method initializeState.

private void initializeState() throws ResourceHandlerException {
    LOG.info("Initializing tc state.");
    BatchBuilder builder = new BatchBuilder(PrivilegedOperation.OperationType.TC_MODIFY_STATE).addRootQDisc().addCGroupFilter().addClassToRootQDisc(rootBandwidthMbit).addDefaultClass(defaultClassBandwidthMbit, rootBandwidthMbit).addYARNRootClass(yarnBandwidthMbit, yarnBandwidthMbit);
    PrivilegedOperation op = builder.commitBatchToTempFile();
    try {
        privilegedOperationExecutor.executePrivilegedOperation(op, false);
    } catch (PrivilegedOperationException e) {
        LOG.warn("Failed to bootstrap outbound bandwidth configuration");
        throw new ResourceHandlerException("Failed to bootstrap outbound bandwidth configuration", e);
    }
}
Also used : PrivilegedOperationException(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException) PrivilegedOperation(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation)

Example 12 with PrivilegedOperationException

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException in project hadoop by apache.

the class TrafficController method readStats.

public Map<Integer, Integer> readStats() throws ResourceHandlerException {
    BatchBuilder builder = new BatchBuilder(PrivilegedOperation.OperationType.TC_READ_STATS).readClasses();
    PrivilegedOperation op = builder.commitBatchToTempFile();
    try {
        String output = privilegedOperationExecutor.executePrivilegedOperation(op, true);
        if (LOG.isDebugEnabled()) {
            LOG.debug("TC stats output:" + output);
        }
        Map<Integer, Integer> classIdBytesStats = parseStatsString(output);
        if (LOG.isDebugEnabled()) {
            LOG.debug("classId -> bytes sent %n" + classIdBytesStats);
        }
        return classIdBytesStats;
    } catch (PrivilegedOperationException e) {
        LOG.warn("Failed to get tc stats");
        throw new ResourceHandlerException("Failed to get tc stats", e);
    }
}
Also used : PrivilegedOperationException(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException) PrivilegedOperation(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation)

Example 13 with PrivilegedOperationException

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException in project hadoop by apache.

the class TrafficController method wipeState.

private void wipeState() throws ResourceHandlerException {
    BatchBuilder builder = new BatchBuilder(PrivilegedOperation.OperationType.TC_MODIFY_STATE).wipeState();
    PrivilegedOperation op = builder.commitBatchToTempFile();
    try {
        LOG.info("Wiping tc state.");
        privilegedOperationExecutor.executePrivilegedOperation(op, false);
    } catch (PrivilegedOperationException e) {
        LOG.warn("Failed to wipe tc state. This could happen if the interface" + " is already in its default state. Ignoring.");
    //Ignoring this exception. This could happen if the interface is already
    //in its default state. For this reason we don't throw a
    //ResourceHandlerException here.
    }
}
Also used : PrivilegedOperationException(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException) PrivilegedOperation(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation)

Example 14 with PrivilegedOperationException

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException in project hadoop by apache.

the class TrafficController method readState.

private String readState() throws ResourceHandlerException {
    //Sample state output:
    //    qdisc htb 42: root refcnt 2 r2q 10 default 2 direct_packets_stat 0
    //    filter parent 42: protocol ip pref 10 cgroup handle 0x1
    //
    //    filter parent 42: protocol ip pref 10 cgroup handle 0x1
    //
    //    class htb 42:1 root rate 10000Kbit ceil 10000Kbit burst 1600b cburst 1600b
    //    class htb 42:2 parent 42:1 prio 0 rate 3000Kbit ceil 10000Kbit burst 1599b cburst 1600b
    //    class htb 42:3 parent 42:1 prio 0 rate 7000Kbit ceil 7000Kbit burst 1598b cburst 1598b
    BatchBuilder builder = new BatchBuilder(PrivilegedOperation.OperationType.TC_READ_STATE).readState();
    PrivilegedOperation op = builder.commitBatchToTempFile();
    try {
        String output = privilegedOperationExecutor.executePrivilegedOperation(op, true);
        if (LOG.isDebugEnabled()) {
            LOG.debug("TC state: %n" + output);
        }
        return output;
    } catch (PrivilegedOperationException e) {
        LOG.warn("Failed to bootstrap outbound bandwidth rules");
        throw new ResourceHandlerException("Failed to bootstrap outbound bandwidth rules", e);
    }
}
Also used : PrivilegedOperationException(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException) PrivilegedOperation(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation)

Example 15 with PrivilegedOperationException

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException in project hadoop by apache.

the class DefaultLinuxContainerRuntime method signalContainer.

@Override
public void signalContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException {
    Container container = ctx.getContainer();
    PrivilegedOperation signalOp = new PrivilegedOperation(PrivilegedOperation.OperationType.SIGNAL_CONTAINER);
    signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER), ctx.getExecutionAttribute(USER), Integer.toString(PrivilegedOperation.RunAsUserCommand.SIGNAL_CONTAINER.getValue()), ctx.getExecutionAttribute(PID), Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue()));
    //Some failures here are acceptable. Let the calling executor decide.
    signalOp.disableFailureLogging();
    try {
        PrivilegedOperationExecutor executor = PrivilegedOperationExecutor.getInstance(conf);
        executor.executePrivilegedOperation(null, signalOp, null, container.getLaunchContext().getEnvironment(), false, true);
    } catch (PrivilegedOperationException e) {
        // acceptable. Let the calling executor decide what to do.
        throw new ContainerExecutionException("Signal container failed", e.getExitCode(), e.getOutput(), e.getErrorOutput());
    }
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) PrivilegedOperationExecutor(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationExecutor) ContainerExecutionException(org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerExecutionException) PrivilegedOperationException(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException) PrivilegedOperation(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation)

Aggregations

PrivilegedOperation (org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation)18 PrivilegedOperationException (org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException)18 ContainerExecutionException (org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerExecutionException)7 PrivilegedOperationExecutor (org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationExecutor)6 ArrayList (java.util.ArrayList)5 Container (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)5 IOException (java.io.IOException)4 Configuration (org.apache.hadoop.conf.Configuration)4 Path (org.apache.hadoop.fs.Path)4 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)4 List (java.util.List)3 File (java.io.File)2 ResourceHandlerException (org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerException)2 InetSocketAddress (java.net.InetSocketAddress)1 HashSet (java.util.HashSet)1 AccessControlList (org.apache.hadoop.security.authorize.AccessControlList)1 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)1 ContainerExecutor (org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor)1 ContainerDiagnosticsUpdateEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerDiagnosticsUpdateEvent)1 DefaultLinuxContainerRuntime (org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.DefaultLinuxContainerRuntime)1