/// <summary>Refresh acls, state and scheduler properties for the configured queues.</summary> /// <remarks> /// 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. /// </remarks> /// <param name="schedulerRefresher"/> /// <exception cref="System.IO.IOException">when queue configuration file is invalid. /// </exception> internal virtual void RefreshQueues(Configuration conf, QueueRefresher schedulerRefresher ) { lock (this) { // 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(MsgRefreshFailureWithChangeOfHierarchy); throw new IOException(MsgRefreshFailureWithChangeOfHierarchy); } /* * (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 (Exception e) { StringBuilder msg = new StringBuilder("Scheduler's refresh-queues failed with the exception : " + StringUtils.StringifyException(e)); msg.Append("\n"); msg.Append(MsgRefreshFailureWithSchedulerFailure); 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."); } }
/// <summary> /// Initialize the queue-manager with the queue hierarchy specified by the /// given /// <see cref="QueueConfigurationParser"/> /// . /// </summary> /// <param name="cp"/> private void Initialize(QueueConfigurationParser cp) { this.root = cp.GetRoot(); leafQueues.Clear(); allQueues.Clear(); //At this point we have root populated //update data structures leafNodes. leafQueues = GetRoot().GetLeafQueues(); allQueues.PutAll(GetRoot().GetInnerQueues()); allQueues.PutAll(leafQueues); Log.Info("AllQueues : " + allQueues + "; LeafQueues : " + leafQueues); }