/// <summary>
        ///
        /// </summary>
        /// <param name="signature"></param>
        /// <param name="routingPolicy"></param>
        /// <remarks>Parameter routingPolicy can be NULL. In that case, we will first check
        /// if there is an config in the config file and use it. If setting is not found,
        /// we will always treat an error that matches the signature as a fatal error.</remarks>
        public void RegisterError(
            ErrorSignatureBase signature,
            ErrorRoutingPolicy routingPolicy)
        {
            Debug.Assert(null != signature, "null == signature");
            if (null == signature)
            {
                throw new ArgumentNullException("signature");
            }

            if (!m_signatures.Contains(signature, signature as IEqualityComparer <ErrorSignatureBase>))
            {
                // new signature
                m_signatures.Add(signature);
                m_routers.Add(new ErrorRouter(signature, routingPolicy));
            }
            else
            {
                // The error signature is registered already.
                // We *always* replace the existing policy with the new one.
                // The caller (sync orchestrator) makes sure the policies in the configuration file
                // overwrites those registered by adapter in the code
                foreach (ErrorRouter router in m_routers)
                {
                    if (router.Signature.CompareTo(signature) == 0)
                    {
                        router.RoutingPolicy = routingPolicy;
                    }
                }
            }

            // sort the signatures to make the
            m_signatures.Sort(new ErrorSignatureComparer());
        }
        /// <summary>
        /// Register the error routers that are configured in the configuration file
        /// </summary>
        /// <remarks>
        /// Calling this method may overwrite the "hard-coded policy" registered by the adapter. This method
        /// should be called after all the adapters are given a chance to register their "hard-coded policy"
        /// </remarks>
        internal void RegisterErrorsInConfigurationFile()
        {
            if (null != m_customRouterSettings)
            {
                foreach (BM.ErrorRouter routerConfig in m_customRouterSettings.ErrorRouter)
                {
                    ErrorSignatureBase signature = ErrorSignatureFactory.CreateErrorSignaure(routerConfig.Signature);
                    if (null != signature)
                    {
                        ErrorRoutingPolicy policy = ErrorRoutingPolicyFactory.CreateRoutingPolicy(routerConfig.Policy);
                        this.RegisterError(signature, policy);
                    }
                }
            }

            // last step, call register wild card error routing policy
            DefaultErrorRoutingPolicies.RegisterImplicitDefaultErrors(this);
        }
 /// <summary>
 /// Register an error signature with a custom routing policy
 /// </summary>
 /// <param name="signature"></param>
 /// <param name="routineRule"></param>
 public void RegisterError(
     ErrorSignatureBase signature,
     ErrorRoutingPolicy routineRule)
 {
     m_errRegService.RegisterError(signature, routineRule);
 }
Пример #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="signature">The signature of the error</param>
 /// <param name="routingPolicy">The routing policy for this class of errors; if NULL, default policy
 /// will be used, i.e. always report the error as critical and push to channels that are defined by
 /// the global configuration</param>
 public ErrorRouter(ErrorSignatureBase signature, ErrorRoutingPolicy routingPolicy)
 {
     Signature     = signature;
     RoutingPolicy = routingPolicy;
 }