Exemplo n.º 1
0
        /// <summary>
        /// Creates and returns the policy module version 2.
        /// </summary>
        /// <returns>
        /// The Policy module V2.
        /// </returns>
        public IPolicyModule GetPolicyModule()
        {
            if (policyModule == null)
            {
                policyModule = new PolicyModule.PolicyModule(_configuration, _hostingEnvironment, _loggerFactory);

                Type policyLogicType = CreateTypeFromConfiguration("PolicyModule", "PolicyRenewalLogic", "OpenImis.ModulesV3.PolicyModule.Logic.PolicyRenewalLogic");
                policyModule.SetPolicyLogic((IPolicyRenewalLogic)ActivatorUtilities.CreateInstance(_serviceProvider, policyLogicType));
            }
            return(policyModule);
        }
        TrafficMatrixEntry[,] TrafficMatrix; // Traffic matrix ordered by (loc,rem) addr pairs.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// The primary class of the Rate Controller implementation. Provides the 
        /// runtime environment for a Policy Module implementing a control algorithm.
        /// </summary>
        /// <param name="client">Reference to client policy module.</param>
        /// <param name="tenantId">Unique TenantId.</param>
        /// <param name="agentPort">Port on which network agents are listening.</param>
        public OktofsRateController(IPolicyModule client, uint tenantId, int agentPort)
        {
            //
            // Initialize state for Oktofs rate controller.
            //
            iPolicyModule = client;
            AgentPort = agentPort;
            TenantId = tenantId;
            AgentNameToConn = new Dictionary<string, Connection>(StringComparer.OrdinalIgnoreCase);
            IoFlowNameToConn = new Dictionary<string, Connection>(StringComparer.OrdinalIgnoreCase);
            LockPendingReplies = new object[(int)MessageTypes.EndOfList];
            for (int i = 0; i < LockPendingReplies.Length; i++)
                LockPendingReplies[i] = new object();
            CountPendingReplies = new int[(int)MessageTypes.EndOfList];
            DictPendingReplies = new Dictionary<uint, MessageTypes>();
            DictVmNameToSid = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            DictDevice = new Dictionary<string, Device>();
            const int TIMER_QUEUE_LENGTH = 16;
            softTimer = new SoftTimer(TIMER_QUEUE_LENGTH, this);
            qpc = new Qpc();

            //
            // Initialize a Oktopus network rate controller as an embedded object.
            //
            netRateController = new RateController(this, tenantId, Parameters.NETAGENT_TCP_PORT_NUMBER);

            //
            // Callbacks into Policy Module are performed sequentially on a single work queue thread.
            // Work items on this queue are generated by Timeouts and by Alerts from network agents.
            //
            const int WORK_QUEUE_LENGTH = 128;
            const int WORK_QUEUE_MAX_READERS = 1;
            RcWorkQueue = new WorkQueue<RcWorkItem>(this.RunRcWorkQueueItem, WORK_QUEUE_MAX_READERS, WORK_QUEUE_LENGTH);
        }