/// <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);
        }
Esempio n. 2
0
 public static MessageIoFlowCreate CreateFromNetBytes(byte[] buffer, int offset)
 {
     int oldOffset = offset;
     MessageIoFlowCreate msg = new MessageIoFlowCreate();
     msg.Length = (uint)Utils.Int32FromNetBytes(buffer, offset); offset += 4;
     msg.SeqNo = (uint)Utils.Int32FromNetBytes(buffer, offset); offset += 4;
     msg.MessageType = buffer[offset++];
     msg.ListParams = new List<IoFlowMessageParams>();
     int countParams = Utils.Int32FromNetBytes(buffer, offset); offset += 4;
     for (int i = 0; i < countParams; i++)
     {
         IoFlowMessageParams ioFlowParams = IoFlowMessageParams.CreateFromNetBytes(buffer, offset);
         msg.ListParams.Add(ioFlowParams);
         offset += ioFlowParams.NetByteCount;
     }
     return msg;
 }