/// <summary>
        /// Sends messages to network agents instructing them to send back traffic
        /// stats. The messages are sent synchronously in parallel and control
        /// is not returned to the caller until all network agents have replied. 
        /// The request can include a delta threshold expressed as a percentage
        /// in which case agents will filter out state for RAPs whose current 
        /// bandwidth falls within the last reported bandwidth plus or minus delta.
        /// </summary>
        /// <param name="deltaThreshold">Stats suppression threshold.</param>
        /// <param name="reset">True iff stats to be set to zero once read.</param>
        public void GetStatsFromServers(double deltaThreshold, bool reset)
        {
            MessageTypes replyType = MessageTypes.MessageTypeStatsReplyDelta;
            int typeIndex = (int)replyType;

            ManualResetEvent NetMessagesComplete =
                NetBeginStatsMessages(netRateController.UpdateTrafficStatsDelta,
                                      deltaThreshold, true, false, reset, true);
            lock (LockPendingReplies[typeIndex])
            {
                foreach (Connection conn in AgentNameToConn.Values)
                {
                    if (conn.ListQueues.Count == 0)
                        continue;
                    uint countRaps = (uint)conn.ListRap.Count;
                    MessageStatsQueryDelta mStatsQuery =
                        new MessageStatsQueryDelta(++SeqNo, countRaps, deltaThreshold, reset);
                    SendParallel(conn, mStatsQuery.Serialize, replyType, mStatsQuery.SeqNo);
                }
                WaitForParallelReplies(replyType, Parameters.DEFAULT_MESSAGE_TIMEOUT_MS);
            } // lock

            replyType = MessageTypes.MessageTypeIoFlowStatsReply;
            typeIndex = (int)replyType;
            lock (LockPendingReplies[typeIndex])
            {
                foreach (Connection conn in IoFlowNameToConn.Values)
                {
                    if (conn.DictIoFlows.Count == 0)
                        continue;
                    MessageIoFlowStatsQuery mIoFlowStatsQuery = new MessageIoFlowStatsQuery(++SeqNo);
                    SendParallel(conn, mIoFlowStatsQuery.Serialize, replyType, mIoFlowStatsQuery.SeqNo);
                }
                WaitForParallelReplies(replyType, Parameters.DEFAULT_MESSAGE_TIMEOUT_MS);
            } // lock

            NetMessagesComplete.WaitOne();
        }
Example #2
0
 public static MessageIoFlowStatsQuery CreateFromNetBytes(byte[] buffer, int offset)
 {
     int oldOffset = offset;
     MessageIoFlowStatsQuery msg = new MessageIoFlowStatsQuery(0);
     msg.Length = (uint)Utils.Int32FromNetBytes(buffer, offset); offset += 4;
     msg.SeqNo = (uint)Utils.Int32FromNetBytes(buffer, offset); offset += 4;
     msg.MessageType = buffer[offset++];
     return msg;
 }