예제 #1
0
 public abstract void CallbackAlert(MessageAlert messageAlert, RateControllerState state);
예제 #2
0
        public override void CallbackAlert(MessageAlert messageAlert, RateControllerState state)
        {
            ulong[] Args = messageAlert.Args;
            //switch (messageAlert.AlertType)
            //{
            //    case OktoAlertType.AlertDemoGui:
            //        switch ((AlertDemoGui)Args[0])
            //        {
            //            case AlertDemoGui.ChangeLimitTokenSec:
            //                throw new NotImplementedException();
            //                break;
            //            case AlertDemoGui.ChangePolicy:
            //                throw new NotImplementedException();
            //                break;
            //            case AlertDemoGui.SetCapacity:
            //                throw new NotImplementedException();
            //                break;
            //            case AlertDemoGui.SetIsAlgorithmEnabled:
            //                throw new NotImplementedException();
            //                break;
            //            case AlertDemoGui.ChangePriority:
            //                throw new NotImplementedException();
            //                break;
            //            case AlertDemoGui.SetControlInterval:
            //                throw new NotImplementedException();
            //                break;
            //            case AlertDemoGui.SetVecIdx:
            //                throw new NotImplementedException();
            //                break;
            //            default:
            //                throw new ArgumentOutOfRangeException("AlertDemoGui unhandled " + Args[0].ToString());
            //        }
            //        break;

            //    default:
            //        throw new NotImplementedException();
            //        break;
            //}
            string logmsg = string.Format("CallbackAlert {0} received alert type {1} args:", DateTime.Now, messageAlert.AlertType.ToString());
            for (int i = 0; i < Args.Length; i++)
                logmsg += Args[i].ToString() + ",";
            rateController.Log(logmsg);
        }
예제 #3
0
 public static MessageAlert CreateFromNetBytes(byte[] buffer, int offset)
 {
     MessageAlert msg = new MessageAlert();
     msg.Length = (uint)Utils.Int32FromNetBytes(buffer, offset); offset += 4;
     msg.SeqNo = (uint)Utils.Int32FromNetBytes(buffer, offset); offset += 4;
     msg.MessageType = buffer[offset++];
     // Message body is <AlertVec,argsLen,UInt64[argsLen]>.
     msg.alertType = (OktoAlertType)Utils.Int64FromNetBytes(buffer, offset); offset += 8;
     int argsLen = Utils.Int32FromNetBytes(buffer, offset); offset += 4;
     msg.args = new ulong[argsLen];
     for (int i = 0; i < argsLen; i++)
     {
         msg.args[i] = (ulong)Utils.Int64FromNetBytes(buffer, offset);
         offset += 8;
     }
     return msg;
 }
 public void PostAlert(OktoAlertType alertType, ulong[] args)
 {
     // Push message to the sequential work queue for upcall into Policy Module.
     MessageAlert mAlert = new MessageAlert(alertType,args);
     RcWorkItem rcWorkItem = new RcWorkItem(RcWorkItemType.Alert, mAlert, 0, null);
     RcWorkQueue.Enqueue(rcWorkItem);
 }
예제 #5
0
 public static MessageAlert CreateFromNetAlert(MessageNetAlert netAlert)
 {
     MessageAlert msg = new MessageAlert();
     msg.Length = netAlert.Length;
     msg.SeqNo = netAlert.SeqNo;
     msg.MessageType = netAlert.MessageType;
     msg.netAlertVec= netAlert.AlertVec;
     msg.args = new ulong[8];
     msg.args[0] = netAlert.EthSrcAddr;
     msg.args[1] = netAlert.EthDestAddr;
     msg.args[2] = netAlert.IPv4SrcAddr;
     msg.args[3] = netAlert.IPv4DestAddr;
     msg.args[4] = netAlert.TenantId;
     msg.args[5] = netAlert.FlowId;
     msg.args[6] = netAlert.i_index;
     msg.args[7] = netAlert.j_index;
     return msg;
 }