/// <summary>
        /// Sends messages to network agents instructing them to set traffic stats
        /// to zero. The messages are sent synchronously in parallel and control
        /// is not returned to the caller until all network agents have replied.
        /// </summary>
        public void ResetStats()
        {
            const MessageTypes replyType = MessageTypes.MessageTypeStatsZeroAck;
            const int typeIndex = (int)replyType;

            ValidateState(RateControllerState.SettleCallback, "ResetStats");
            ManualResetEvent NetMessagesComplete = NetBeginMessagePairs(netRateController.ResetStats);
            lock (LockPendingReplies[typeIndex])
            {
                foreach (Connection conn in AgentNameToConn.Values)
                {
                    if (conn.ListQueues.Count == 0)
                        continue;
                    MessageStatsZero mStatsZero = new MessageStatsZero(++SeqNo);
                    SendParallel(conn, mStatsZero.Serialize, replyType, mStatsZero.SeqNo);
                }
                foreach (Connection conn in IoFlowNameToConn.Values)
                {
                    if (conn.DictIoFlows.Count == 0)
                        continue;
                    MessageStatsZero mStatsZero = new MessageStatsZero(++SeqNo);
                    SendParallel(conn, mStatsZero.Serialize, replyType, mStatsZero.SeqNo);
                }
                WaitForParallelReplies(replyType, Parameters.DEFAULT_MESSAGE_TIMEOUT_MS);
            } // lock
            NetMessagesComplete.WaitOne();
        }
Exemple #2
0
 public static MessageStatsZero CreateFromNetBytes(byte[] buffer, int offset)
 {
     int oldOffset = offset;
     MessageStatsZero msg = new MessageStatsZero(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;
 }