public bool AssignQueue(OktoQueue queue) { if (Queue != null) { throw new ApplicationException("Attempt to assign queue to matrix entry where queue already assigned."); } Queue = queue; queue.listRap.Add(this); return(true); }
/// <summary> /// Sends messages to network agents instructing them to create flows. /// The messages are sent synchronously in parallel and control is not returned to the /// caller until all network agents have replied. /// </summary> public void InstallFlows() { ValidateState(RateControllerState.Init, "InstallFlows"); ManualResetEvent NetMessagesComplete = NetBeginMessagePairs(netRateController.InstallFlows); MessageTypes replyType = MessageTypes.MessageTypeFlowCreateAck; int typeIndex = (int)replyType; lock (LockPendingReplies[typeIndex]) { foreach (Connection conn in AgentNameToConn.Values) { if (conn.ListQueues.Count == 0) continue; OktoQueue[] arrayQosArg = new OktoQueue[conn.ListQueues.Count]; for (int i = 0; i < conn.ListQueues.Count; i++) arrayQosArg[i] = conn.ListQueues[i]; Console.WriteLine("Installing {0} OktoFs flows on host {1}", arrayQosArg.Length, conn.HostName); MessageFlowCreate mFlowCreate = new MessageFlowCreate(++SeqNo, arrayQosArg); SendParallel(conn, mFlowCreate.Serialize, replyType, mFlowCreate.SeqNo); } WaitForParallelReplies(replyType, Parameters.FLOWC_MESSAGE_TIMEOUT_MS); } // lock replyType = MessageTypes.MessageTypeIoFlowCreateAck; typeIndex = (int)replyType; lock (LockPendingReplies[typeIndex]) { foreach (Connection conn in IoFlowNameToConn.Values) { if (conn.DictIoFlows.Count == 0) continue; Console.WriteLine("Installing {0} IoFlow flows on host {1}", conn.DictIoFlows.Count, conn.HostName); List<Flow> ListIoFlows = conn.DictIoFlows.Values.ToList<Flow>(); MessageIoFlowCreate mIoFlowCreate = new MessageIoFlowCreate(++SeqNo, ListIoFlows); SendParallel(conn, mIoFlowCreate.Serialize, replyType, mIoFlowCreate.SeqNo); } WaitForParallelReplies(replyType, Parameters.FLOWC_MESSAGE_TIMEOUT_MS); } // lock NetMessagesComplete.WaitOne(); // // Optionally enable netRateController alert notification and/or RX stats recording. // UInt64 AlertMask = 0; //AlertMask |= (UInt64)OktoAlertType.AlertRxStats; //AlertMask |= (UInt64)OktoAlertType.AlertNoRap; // Can be very noisy at agents. //AlertMask |= (UInt64)OktoAlertType.AlertNotActive; if (AlertMask != 0) netRateController.SetAlertVec(AlertMask); }
/// <summary> /// Called by client policy module to create a new queue. /// </summary> /// <param name="sourceAgentName">Name of network agent that is source for this queue,</param> /// <param name="bytesPerSecond">Initial rate limit to be associated with the queue.</param> /// <returns>Reference to new queue object if successful, otherwise returns null.</returns> public OktoQueue CreateQueue(string sourceAgentName) { OktoQueue queue = null; Connection conn; ValidateState(RateControllerState.Init, "CreateQueue"); if (AgentNameToConn.TryGetValue(sourceAgentName, out conn)) { queue = new OktoQueue(NextFreeFlowId++, conn); } else { string msg = String.Format("AddQueue({0},{1}) invalid args", sourceAgentName); throw new ArgumentException(msg); } return queue; }
/// <summary> /// Sends messages to network agents instructing them to update queues with /// the values presently stored in the Queue objects. Update messages for /// queues whose rate limit has not changed since the last time this routine /// was called are suppressed. The messages are sent synchronously in parallel /// and control is not returned to the caller until all network agents have replied. /// </summary> public void UpdateRateLimits() { ValidateState(RateControllerState.UpdateCallback, "UpdateRateLimits"); ManualResetEvent NetMessagesComplete = NetBeginMessagePairs(netRateController.UpdateRateLimits); MessageTypes replyType = MessageTypes.MessageTypeFlowUpdateAck; int typeIndex = (int)replyType; lock (LockPendingReplies[typeIndex]) { // // Send update messages only wrt queues whose rate limits have been changed. // foreach (Connection conn in AgentNameToConn.Values) { int countQueues = 0; foreach (OktoQueue queue in conn.ListQueues) if (queue.IsChanged) countQueues++; if (countQueues == 0) continue; OktoQueue[] arrayQosArg = new OktoQueue[countQueues]; int i = 0; foreach (OktoQueue queue in conn.ListQueues) { if (queue.IsChanged) { queue.Update(); arrayQosArg[i++] = queue; } } MessageFlowUpdate mFlowUpdate = new MessageFlowUpdate(++SeqNo, arrayQosArg); SendParallel(conn, mFlowUpdate.Serialize, replyType, mFlowUpdate.SeqNo); } WaitForParallelReplies(replyType, Parameters.DEFAULT_MESSAGE_TIMEOUT_MS); } // lock replyType = MessageTypes.MessageTypeIoFlowUpdateAck; typeIndex = (int)replyType; lock (LockPendingReplies[typeIndex]) { // // Send update messages for IoFlow queues. // Cannot filter unchanged as we don't know how to interpret free-format strings. // foreach (Connection conn in IoFlowNameToConn.Values) { if (conn.DictIoFlows.Count == 0) continue; List<Flow> listFlow = conn.DictIoFlows.Values.ToList<Flow>(); MessageIoFlowUpdate mFlowUpdate = new MessageIoFlowUpdate(++SeqNo, listFlow); SendParallel(conn, mFlowUpdate.Serialize, replyType, mFlowUpdate.SeqNo); } WaitForParallelReplies(replyType, Parameters.DEFAULT_MESSAGE_TIMEOUT_MS); } // lock NetMessagesComplete.WaitOne(); }
public bool AssignQueue(OktoQueue queue) { if (Queue != null) throw new ApplicationException("Attempt to assign queue to matrix entry where queue already assigned."); Queue = queue; queue.listRap.Add(this); return true; }
public MessageFlowUpdate(uint seqNo, OktoQueue[] arrayQosArg) : base(0, seqNo, (byte)MessageTypes.MessageTypeFlowUpdate) { ArrayQosArg = arrayQosArg; int length = (ArrayQosArg.Length * OktoQueue.SIZEOF_QOS_ARG); Debug.Assert(length <= int.MaxValue); Length = (uint)length; }