|
@@ -24,23 +24,12 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.io.IOUtils;
|
|
import org.apache.hadoop.io.IOUtils;
|
|
import org.apache.hadoop.mapreduce.MRConfig;
|
|
import org.apache.hadoop.mapreduce.MRConfig;
|
|
-import org.apache.hadoop.mapreduce.QueueState;
|
|
|
|
-import org.apache.hadoop.security.UserGroupInformation;
|
|
|
|
-import org.apache.hadoop.security.authorize.AccessControlList;
|
|
|
|
-import org.apache.hadoop.util.StringUtils;
|
|
|
|
-import org.codehaus.jackson.JsonFactory;
|
|
|
|
-import org.codehaus.jackson.JsonGenerationException;
|
|
|
|
-import org.codehaus.jackson.JsonGenerator;
|
|
|
|
|
|
|
|
import java.io.BufferedInputStream;
|
|
import java.io.BufferedInputStream;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.io.Writer;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
-import java.util.Set;
|
|
|
|
-import java.util.List;
|
|
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
|
|
@@ -206,113 +195,8 @@ public class QueueManager {
|
|
LOG.info("AllQueues : " + allQueues + "; LeafQueues : " + leafQueues);
|
|
LOG.info("AllQueues : " + allQueues + "; LeafQueues : " + leafQueues);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Return the set of leaf level queues configured in the system to
|
|
|
|
- * which jobs are submitted.
|
|
|
|
- * <p/>
|
|
|
|
- * The number of queues configured should be dependent on the Scheduler
|
|
|
|
- * configured. Note that some schedulers work with only one queue, whereas
|
|
|
|
- * others can support multiple queues.
|
|
|
|
- *
|
|
|
|
- * @return Set of queue names.
|
|
|
|
- */
|
|
|
|
- public synchronized Set<String> getLeafQueueNames() {
|
|
|
|
- return leafQueues.keySet();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Return true if the given user is part of the ACL for the given
|
|
|
|
- * {@link QueueACL} name for the given queue.
|
|
|
|
- * <p/>
|
|
|
|
- * An operation is allowed if all users are provided access for this
|
|
|
|
- * operation, or if either the user or any of the groups specified is
|
|
|
|
- * provided access.
|
|
|
|
- *
|
|
|
|
- * @param queueName Queue on which the operation needs to be performed.
|
|
|
|
- * @param qACL The queue ACL name to be checked
|
|
|
|
- * @param ugi The user and groups who wish to perform the operation.
|
|
|
|
- * @return true if the operation is allowed, false otherwise.
|
|
|
|
- */
|
|
|
|
- public synchronized boolean hasAccess(
|
|
|
|
- String queueName, QueueACL qACL, UserGroupInformation ugi) {
|
|
|
|
-
|
|
|
|
- Queue q = leafQueues.get(queueName);
|
|
|
|
-
|
|
|
|
- if (q == null) {
|
|
|
|
- LOG.info("Queue " + queueName + " is not present");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if(q.getChildren() != null && !q.getChildren().isEmpty()) {
|
|
|
|
- LOG.info("Cannot submit job to parent queue " + q.getName());
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!areAclsEnabled()) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (LOG.isDebugEnabled()) {
|
|
|
|
- LOG.debug("Checking access for the acl " + toFullPropertyName(queueName,
|
|
|
|
- qACL.getAclName()) + " for user " + ugi.getShortUserName());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- AccessControlList acl = q.getAcls().get(
|
|
|
|
- toFullPropertyName(queueName, qACL.getAclName()));
|
|
|
|
- if (acl == null) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Check if user is part of the ACL
|
|
|
|
- return acl.isUserAllowed(ugi);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Checks whether the given queue is running or not.
|
|
|
|
- *
|
|
|
|
- * @param queueName name of the queue
|
|
|
|
- * @return true, if the queue is running.
|
|
|
|
- */
|
|
|
|
- synchronized boolean isRunning(String queueName) {
|
|
|
|
- Queue q = leafQueues.get(queueName);
|
|
|
|
- if (q != null) {
|
|
|
|
- return q.getState().equals(QueueState.RUNNING);
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Set a generic Object that represents scheduling information relevant
|
|
|
|
- * to a queue.
|
|
|
|
- * <p/>
|
|
|
|
- * A string representation of this Object will be used by the framework
|
|
|
|
- * to display in user facing applications like the JobTracker web UI and
|
|
|
|
- * the hadoop CLI.
|
|
|
|
- *
|
|
|
|
- * @param queueName queue for which the scheduling information is to be set.
|
|
|
|
- * @param queueInfo scheduling information for this queue.
|
|
|
|
- */
|
|
|
|
- public synchronized void setSchedulerInfo(
|
|
|
|
- String queueName,
|
|
|
|
- Object queueInfo) {
|
|
|
|
- if (allQueues.get(queueName) != null) {
|
|
|
|
- allQueues.get(queueName).setSchedulingInfo(queueInfo);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Return the scheduler information configured for this queue.
|
|
|
|
- *
|
|
|
|
- * @param queueName queue for which the scheduling information is required.
|
|
|
|
- * @return The scheduling information for this queue.
|
|
|
|
- */
|
|
|
|
- public synchronized Object getSchedulerInfo(String queueName) {
|
|
|
|
- if (allQueues.get(queueName) != null) {
|
|
|
|
- return allQueues.get(queueName).getSchedulingInfo();
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
static final String MSG_REFRESH_FAILURE_WITH_CHANGE_OF_HIERARCHY =
|
|
static final String MSG_REFRESH_FAILURE_WITH_CHANGE_OF_HIERARCHY =
|
|
"Unable to refresh queues because queue-hierarchy changed. "
|
|
"Unable to refresh queues because queue-hierarchy changed. "
|
|
+ "Retaining existing configuration. ";
|
|
+ "Retaining existing configuration. ";
|
|
@@ -322,73 +206,7 @@ public class QueueManager {
|
|
+ " configuration properties. "
|
|
+ " configuration properties. "
|
|
+ "Retaining existing configuration throughout the system.";
|
|
+ "Retaining existing configuration throughout the system.";
|
|
|
|
|
|
- /**
|
|
|
|
- * Refresh acls, state and scheduler properties for the configured queues.
|
|
|
|
- * <p/>
|
|
|
|
- * This method reloads configuration related to queues, but does not
|
|
|
|
- * support changes to the list of queues or hierarchy. The expected usage
|
|
|
|
- * is that an administrator can modify the queue configuration file and
|
|
|
|
- * fire an admin command to reload queue configuration. If there is a
|
|
|
|
- * problem in reloading configuration, then this method guarantees that
|
|
|
|
- * existing queue configuration is untouched and in a consistent state.
|
|
|
|
- *
|
|
|
|
- * @param schedulerRefresher
|
|
|
|
- * @throws IOException when queue configuration file is invalid.
|
|
|
|
- */
|
|
|
|
- synchronized void refreshQueues(Configuration conf,
|
|
|
|
- QueueRefresher schedulerRefresher)
|
|
|
|
- throws IOException {
|
|
|
|
-
|
|
|
|
- // Create a new configuration parser using the passed conf object.
|
|
|
|
- QueueConfigurationParser cp =
|
|
|
|
- getQueueConfigurationParser(conf, true, areAclsEnabled);
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * (1) Validate the refresh of properties owned by QueueManager. As of now,
|
|
|
|
- * while refreshing queue properties, we only check that the hierarchy is
|
|
|
|
- * the same w.r.t queue names, ACLs and state for each queue and don't
|
|
|
|
- * support adding new queues or removing old queues
|
|
|
|
- */
|
|
|
|
- if (!root.isHierarchySameAs(cp.getRoot())) {
|
|
|
|
- LOG.warn(MSG_REFRESH_FAILURE_WITH_CHANGE_OF_HIERARCHY);
|
|
|
|
- throw new IOException(MSG_REFRESH_FAILURE_WITH_CHANGE_OF_HIERARCHY);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * (2) QueueManager owned properties are validated. Now validate and
|
|
|
|
- * refresh the properties of scheduler in a single step.
|
|
|
|
- */
|
|
|
|
- if (schedulerRefresher != null) {
|
|
|
|
- try {
|
|
|
|
- schedulerRefresher.refreshQueues(cp.getRoot().getJobQueueInfo().getChildren());
|
|
|
|
- } catch (Throwable e) {
|
|
|
|
- StringBuilder msg =
|
|
|
|
- new StringBuilder(
|
|
|
|
- "Scheduler's refresh-queues failed with the exception : "
|
|
|
|
- + StringUtils.stringifyException(e));
|
|
|
|
- msg.append("\n");
|
|
|
|
- msg.append(MSG_REFRESH_FAILURE_WITH_SCHEDULER_FAILURE);
|
|
|
|
- LOG.error(msg.toString());
|
|
|
|
- throw new IOException(msg.toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * (3) Scheduler has validated and refreshed its queues successfully, now
|
|
|
|
- * refresh the properties owned by QueueManager
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
- // First copy the scheduling information recursively into the new
|
|
|
|
- // queue-hierarchy. This is done to retain old scheduling information. This
|
|
|
|
- // is done after scheduler refresh and not before it because during refresh,
|
|
|
|
- // schedulers may wish to change their scheduling info objects too.
|
|
|
|
- cp.getRoot().copySchedulingInfo(this.root);
|
|
|
|
-
|
|
|
|
- // Now switch roots.
|
|
|
|
- initialize(cp);
|
|
|
|
-
|
|
|
|
- LOG.info("Queue configuration is refreshed successfully.");
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
|
|
// this method is for internal use only
|
|
// this method is for internal use only
|
|
public static final String toFullPropertyName(
|
|
public static final String toFullPropertyName(
|
|
@@ -397,172 +215,10 @@ public class QueueManager {
|
|
return QUEUE_CONF_PROPERTY_NAME_PREFIX + queue + "." + property;
|
|
return QUEUE_CONF_PROPERTY_NAME_PREFIX + queue + "." + property;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Return an array of {@link JobQueueInfo} objects for all the
|
|
|
|
- * queues configurated in the system.
|
|
|
|
- *
|
|
|
|
- * @return array of JobQueueInfo objects.
|
|
|
|
- */
|
|
|
|
- synchronized JobQueueInfo[] getJobQueueInfos() {
|
|
|
|
- ArrayList<JobQueueInfo> queueInfoList = new ArrayList<JobQueueInfo>();
|
|
|
|
- for (String queue : allQueues.keySet()) {
|
|
|
|
- JobQueueInfo queueInfo = getJobQueueInfo(queue);
|
|
|
|
- if (queueInfo != null) {
|
|
|
|
- queueInfoList.add(queueInfo);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return queueInfoList.toArray(
|
|
|
|
- new JobQueueInfo[queueInfoList.size()]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Return {@link JobQueueInfo} for a given queue.
|
|
|
|
- *
|
|
|
|
- * @param queue name of the queue
|
|
|
|
- * @return JobQueueInfo for the queue, null if the queue is not found.
|
|
|
|
- */
|
|
|
|
- synchronized JobQueueInfo getJobQueueInfo(String queue) {
|
|
|
|
- if (allQueues.containsKey(queue)) {
|
|
|
|
- return allQueues.get(queue).getJobQueueInfo();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * JobQueueInfo for all the queues.
|
|
|
|
- * <p/>
|
|
|
|
- * Contribs can use this data structure to either create a hierarchy or for
|
|
|
|
- * traversing.
|
|
|
|
- * They can also use this to refresh properties in case of refreshQueues
|
|
|
|
- *
|
|
|
|
- * @return a map for easy navigation.
|
|
|
|
- */
|
|
|
|
- synchronized Map<String, JobQueueInfo> getJobQueueInfoMapping() {
|
|
|
|
- Map<String, JobQueueInfo> m = new HashMap<String, JobQueueInfo>();
|
|
|
|
-
|
|
|
|
- for (String key : allQueues.keySet()) {
|
|
|
|
- m.put(key, allQueues.get(key).getJobQueueInfo());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return m;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Generates the array of QueueAclsInfo object.
|
|
|
|
- * <p/>
|
|
|
|
- * The array consists of only those queues for which user has acls.
|
|
|
|
- *
|
|
|
|
- * @return QueueAclsInfo[]
|
|
|
|
- * @throws java.io.IOException
|
|
|
|
- */
|
|
|
|
- synchronized QueueAclsInfo[] getQueueAcls(UserGroupInformation ugi)
|
|
|
|
- throws IOException {
|
|
|
|
- //List of all QueueAclsInfo objects , this list is returned
|
|
|
|
- ArrayList<QueueAclsInfo> queueAclsInfolist =
|
|
|
|
- new ArrayList<QueueAclsInfo>();
|
|
|
|
- QueueACL[] qAcls = QueueACL.values();
|
|
|
|
- for (String queueName : leafQueues.keySet()) {
|
|
|
|
- QueueAclsInfo queueAclsInfo = null;
|
|
|
|
- ArrayList<String> operationsAllowed = null;
|
|
|
|
- for (QueueACL qAcl : qAcls) {
|
|
|
|
- if (hasAccess(queueName, qAcl, ugi)) {
|
|
|
|
- if (operationsAllowed == null) {
|
|
|
|
- operationsAllowed = new ArrayList<String>();
|
|
|
|
- }
|
|
|
|
- operationsAllowed.add(qAcl.getAclName());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (operationsAllowed != null) {
|
|
|
|
- //There is atleast 1 operation supported for queue <queueName>
|
|
|
|
- //, hence initialize queueAclsInfo
|
|
|
|
- queueAclsInfo = new QueueAclsInfo(
|
|
|
|
- queueName, operationsAllowed.toArray
|
|
|
|
- (new String[operationsAllowed.size()]));
|
|
|
|
- queueAclsInfolist.add(queueAclsInfo);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return queueAclsInfolist.toArray(
|
|
|
|
- new QueueAclsInfo[queueAclsInfolist.size()]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * ONLY FOR TESTING - Do not use in production code.
|
|
|
|
- * This method is used for setting up of leafQueues only.
|
|
|
|
- * We are not setting the hierarchy here.
|
|
|
|
- *
|
|
|
|
- * @param queues
|
|
|
|
- */
|
|
|
|
- synchronized void setQueues(Queue[] queues) {
|
|
|
|
- root.getChildren().clear();
|
|
|
|
- leafQueues.clear();
|
|
|
|
- allQueues.clear();
|
|
|
|
-
|
|
|
|
- for (Queue queue : queues) {
|
|
|
|
- root.addChild(queue);
|
|
|
|
- }
|
|
|
|
- //At this point we have root populated
|
|
|
|
- //update data structures leafNodes.
|
|
|
|
- leafQueues = getRoot().getLeafQueues();
|
|
|
|
- allQueues.putAll(getRoot().getInnerQueues());
|
|
|
|
- allQueues.putAll(leafQueues);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Return an array of {@link JobQueueInfo} objects for the root
|
|
|
|
- * queues configured in the system.
|
|
|
|
- * <p/>
|
|
|
|
- * Root queues are queues that are at the top-most level in the
|
|
|
|
- * hierarchy of queues in mapred-queues.xml, or they are the queues
|
|
|
|
- * configured in the mapred.queue.names key in mapred-site.xml.
|
|
|
|
- *
|
|
|
|
- * @return array of JobQueueInfo objects for root level queues.
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
- JobQueueInfo[] getRootQueues() {
|
|
|
|
- List<JobQueueInfo> list = getRoot().getJobQueueInfo().getChildren();
|
|
|
|
- return list.toArray(new JobQueueInfo[list.size()]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Get the complete hierarchy of children for queue
|
|
|
|
- * queueName
|
|
|
|
- *
|
|
|
|
- * @param queueName
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- JobQueueInfo[] getChildQueues(String queueName) {
|
|
|
|
- List<JobQueueInfo> list =
|
|
|
|
- allQueues.get(queueName).getJobQueueInfo().getChildren();
|
|
|
|
- if (list != null) {
|
|
|
|
- return list.toArray(new JobQueueInfo[list.size()]);
|
|
|
|
- } else {
|
|
|
|
- return new JobQueueInfo[0];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Used only for testing purposes .
|
|
|
|
- * This method is unstable as refreshQueues would leave this
|
|
|
|
- * data structure in unstable state.
|
|
|
|
- *
|
|
|
|
- * @param queueName
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- Queue getQueue(String queueName) {
|
|
|
|
- return this.allQueues.get(queueName);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Return if ACLs are enabled for the Map/Reduce system
|
|
|
|
- *
|
|
|
|
- * @return true if ACLs are enabled.
|
|
|
|
- */
|
|
|
|
- boolean areAclsEnabled() {
|
|
|
|
- return areAclsEnabled;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* Used only for test.
|
|
* Used only for test.
|
|
@@ -573,131 +229,6 @@ public class QueueManager {
|
|
return root;
|
|
return root;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Returns the specific queue ACL for the given queue.
|
|
|
|
- * Returns null if the given queue does not exist or the acl is not
|
|
|
|
- * configured for that queue.
|
|
|
|
- * If acls are disabled(mapreduce.cluster.acls.enabled set to false), returns
|
|
|
|
- * ACL with all users.
|
|
|
|
- */
|
|
|
|
- synchronized AccessControlList getQueueACL(String queueName,
|
|
|
|
- QueueACL qACL) {
|
|
|
|
- if (areAclsEnabled) {
|
|
|
|
- Queue q = leafQueues.get(queueName);
|
|
|
|
- if (q != null) {
|
|
|
|
- return q.getAcls().get(toFullPropertyName(
|
|
|
|
- queueName, qACL.getAclName()));
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- LOG.warn("Queue " + queueName + " is not present.");
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return new AccessControlList("*");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Dumps the configuration of hierarchy of queues
|
|
|
|
- * @param out the writer object to which dump is written
|
|
|
|
- * @throws IOException
|
|
|
|
- */
|
|
|
|
- static void dumpConfiguration(Writer out,Configuration conf) throws IOException {
|
|
|
|
- dumpConfiguration(out, null,conf);
|
|
|
|
- }
|
|
|
|
|
|
|
|
- /***
|
|
|
|
- * Dumps the configuration of hierarchy of queues with
|
|
|
|
- * the xml file path given. It is to be used directly ONLY FOR TESTING.
|
|
|
|
- * @param out the writer object to which dump is written to.
|
|
|
|
- * @param configFile the filename of xml file
|
|
|
|
- * @throws IOException
|
|
|
|
- */
|
|
|
|
- static void dumpConfiguration(Writer out, String configFile,
|
|
|
|
- Configuration conf) throws IOException {
|
|
|
|
- if (conf != null && conf.get(DeprecatedQueueConfigurationParser.
|
|
|
|
- MAPRED_QUEUE_NAMES_KEY) != null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- JsonFactory dumpFactory = new JsonFactory();
|
|
|
|
- JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
|
|
|
|
- QueueConfigurationParser parser;
|
|
|
|
- boolean aclsEnabled = false;
|
|
|
|
- if (conf != null) {
|
|
|
|
- aclsEnabled = conf.getBoolean(MRConfig.MR_ACLS_ENABLED, false);
|
|
|
|
- }
|
|
|
|
- if (configFile != null && !"".equals(configFile)) {
|
|
|
|
- parser = new QueueConfigurationParser(configFile, aclsEnabled);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- parser = getQueueConfigurationParser(null, false, aclsEnabled);
|
|
|
|
- }
|
|
|
|
- dumpGenerator.writeStartObject();
|
|
|
|
- dumpGenerator.writeFieldName("queues");
|
|
|
|
- dumpGenerator.writeStartArray();
|
|
|
|
- dumpConfiguration(dumpGenerator,parser.getRoot().getChildren());
|
|
|
|
- dumpGenerator.writeEndArray();
|
|
|
|
- dumpGenerator.writeEndObject();
|
|
|
|
- dumpGenerator.flush();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * method to perform depth-first search and write the parameters of every
|
|
|
|
- * queue in JSON format.
|
|
|
|
- * @param dumpGenerator JsonGenerator object which takes the dump and flushes
|
|
|
|
- * to a writer object
|
|
|
|
- * @param rootQueues the top-level queues
|
|
|
|
- * @throws JsonGenerationException
|
|
|
|
- * @throws IOException
|
|
|
|
- */
|
|
|
|
- private static void dumpConfiguration(JsonGenerator dumpGenerator,
|
|
|
|
- Set<Queue> rootQueues) throws JsonGenerationException, IOException {
|
|
|
|
- for (Queue queue : rootQueues) {
|
|
|
|
- dumpGenerator.writeStartObject();
|
|
|
|
- dumpGenerator.writeStringField("name", queue.getName());
|
|
|
|
- dumpGenerator.writeStringField("state", queue.getState().toString());
|
|
|
|
- AccessControlList submitJobList = null;
|
|
|
|
- AccessControlList administerJobsList = null;
|
|
|
|
- if (queue.getAcls() != null) {
|
|
|
|
- submitJobList =
|
|
|
|
- queue.getAcls().get(toFullPropertyName(queue.getName(),
|
|
|
|
- QueueACL.SUBMIT_JOB.getAclName()));
|
|
|
|
- administerJobsList =
|
|
|
|
- queue.getAcls().get(toFullPropertyName(queue.getName(),
|
|
|
|
- QueueACL.ADMINISTER_JOBS.getAclName()));
|
|
|
|
- }
|
|
|
|
- String aclsSubmitJobValue = " ";
|
|
|
|
- if (submitJobList != null ) {
|
|
|
|
- aclsSubmitJobValue = submitJobList.getAclString();
|
|
|
|
- }
|
|
|
|
- dumpGenerator.writeStringField("acl_submit_job", aclsSubmitJobValue);
|
|
|
|
- String aclsAdministerValue = " ";
|
|
|
|
- if (administerJobsList != null) {
|
|
|
|
- aclsAdministerValue = administerJobsList.getAclString();
|
|
|
|
- }
|
|
|
|
- dumpGenerator.writeStringField("acl_administer_jobs",
|
|
|
|
- aclsAdministerValue);
|
|
|
|
- dumpGenerator.writeFieldName("properties");
|
|
|
|
- dumpGenerator.writeStartArray();
|
|
|
|
- if (queue.getProperties() != null) {
|
|
|
|
- for (Map.Entry<Object, Object>property :
|
|
|
|
- queue.getProperties().entrySet()) {
|
|
|
|
- dumpGenerator.writeStartObject();
|
|
|
|
- dumpGenerator.writeStringField("key", (String)property.getKey());
|
|
|
|
- dumpGenerator.writeStringField("value", (String)property.getValue());
|
|
|
|
- dumpGenerator.writeEndObject();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- dumpGenerator.writeEndArray();
|
|
|
|
- Set<Queue> childQueues = queue.getChildren();
|
|
|
|
- dumpGenerator.writeFieldName("children");
|
|
|
|
- dumpGenerator.writeStartArray();
|
|
|
|
- if (childQueues != null && childQueues.size() > 0) {
|
|
|
|
- dumpConfiguration(dumpGenerator, childQueues);
|
|
|
|
- }
|
|
|
|
- dumpGenerator.writeEndArray();
|
|
|
|
- dumpGenerator.writeEndObject();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
}
|
|
}
|