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);
}
}
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);
}
}
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.
}
}
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);
}
}
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());
}
}
Aggregations