public static Exception Write(IAmCluster cluster, AmServerName srvName, AmClusterNodeNetworkStatus status)
        {
            Exception ex = null;

            try
            {
                using (AmClusterNodeStatusAccessor amClusterNodeStatusAccessor = new AmClusterNodeStatusAccessor(cluster, srvName, DxStoreKeyAccessMode.CreateIfNotExist))
                {
                    amClusterNodeStatusAccessor.Write(status);
                }
            }
            catch (SerializationException ex2)
            {
                ex = ex2;
            }
            catch (ClusterException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                AmClusterNodeStatusAccessor.Tracer.TraceError <AmServerName, AmClusterNodeNetworkStatus, Exception>(0L, "AmClusterNodeNetworkStatus.Write({0},{1}) failed: {2}", srvName, status, ex);
            }
            return(ex);
        }
        public static AmClusterNodeNetworkStatus Read(IAmCluster cluster, AmServerName srvName, out Exception ex)
        {
            ex = null;
            AmClusterNodeNetworkStatus amClusterNodeNetworkStatus = null;

            try
            {
                using (AmClusterNodeStatusAccessor amClusterNodeStatusAccessor = new AmClusterNodeStatusAccessor(cluster, srvName, DxStoreKeyAccessMode.Read))
                {
                    amClusterNodeNetworkStatus = amClusterNodeStatusAccessor.Read();
                }
            }
            catch (SerializationException ex2)
            {
                ex = ex2;
            }
            catch (ClusterException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                AmClusterNodeStatusAccessor.Tracer.TraceError <AmServerName, Exception>(0L, "AmClusterNodeNetworkStatus.Read({0}) failed: {1}", srvName, ex);
            }
            else if (amClusterNodeNetworkStatus == null)
            {
                AmClusterNodeStatusAccessor.Tracer.TraceError <AmServerName>(0L, "AmClusterNodeNetworkStatus.Read({0}) No status has yet been published", srvName);
            }
            return(amClusterNodeNetworkStatus);
        }
        public void Write(AmClusterNodeNetworkStatus state)
        {
            state.LastUpdate = DateTime.UtcNow;
            string propertyValue = state.Serialize();

            this.distributedStoreKey.SetValue("NetworkStatus", propertyValue, false, null);
            AmClusterNodeStatusAccessor.Tracer.TraceDebug <AmServerName, AmClusterNodeNetworkStatus>(0L, "AmClusterNodeNetworkStatus.Write({0}):{1}", this.ServerName, state);
        }
        public AmClusterNodeNetworkStatus Read()
        {
            string value = this.distributedStoreKey.GetValue("NetworkStatus", null, null);

            if (!string.IsNullOrEmpty(value))
            {
                return(AmClusterNodeNetworkStatus.Deserialize(value));
            }
            return(null);
        }
예제 #5
0
        private void ProcessNicEvent(AmClusterEventInfo cei)
        {
            Dictionary <string, AmNetworkMonitor.Nic> nicTable = this.m_nicTable;
            IAmCluster cluster = this.GetCluster();

            if (nicTable == null || cluster == null)
            {
                AmNetworkMonitor.Tracer.TraceError(0L, "Not yet initialized. Ignoring event");
                return;
            }
            AmNetworkMonitor.Nic nic;
            if (!nicTable.TryGetValue(cei.ObjectName, out nic))
            {
                this.TriggerClusterRefresh("nic not found");
                return;
            }
            AmNetInterfaceState nicState = this.GetNicState(cei.ObjectName);

            switch (nicState)
            {
            case AmNetInterfaceState.Unavailable:
                AmNetworkMonitor.Tracer.TraceError <string, AmNetInterfaceState>(0L, "MAPI NIC '{0}' is {1}.", cei.ObjectName, nicState);
                return;

            case AmNetInterfaceState.Failed:
            case AmNetInterfaceState.Unreachable:
            {
                AmNetworkMonitor.Tracer.TraceError <string, AmNetInterfaceState>(0L, "MAPI NIC '{0}' is {1}.", cei.ObjectName, nicState);
                AmEvtMapiNetworkFailure amEvtMapiNetworkFailure = new AmEvtMapiNetworkFailure(nic.Node.Name);
                amEvtMapiNetworkFailure.Notify(true);
                return;
            }

            case AmNetInterfaceState.Up:
                AmNetworkMonitor.Tracer.TraceDebug <string>(0L, "MAPI NIC '{0}' is Up.", cei.ObjectName);
                if (nic.Node.Name.IsLocalComputerName)
                {
                    AmClusterNodeNetworkStatus amClusterNodeNetworkStatus = new AmClusterNodeNetworkStatus();
                    Exception ex = AmClusterNodeStatusAccessor.Write(cluster, nic.Node.Name, amClusterNodeNetworkStatus);
                    if (ex != null)
                    {
                        ReplayCrimsonEvents.AmNodeStatusUpdateFailed.Log <string, string>(amClusterNodeNetworkStatus.ToString(), ex.Message);
                        return;
                    }
                }
                break;

            default:
                AmNetworkMonitor.Tracer.TraceError <AmNetInterfaceState, string>(0L, "Unexpected NIC state {0} for {1}", nicState, cei.ObjectName);
                break;
            }
        }
예제 #6
0
        private bool IsNodePubliclyUp(AmNetworkMonitor.Node node)
        {
            IAmCluster cluster = this.GetCluster();

            if (cluster == null)
            {
                AmNetworkMonitor.Tracer.TraceError <AmServerName>(0L, "If cluster object is not valid, then assume node {0} is up", node.Name);
                return(true);
            }
            Exception   ex;
            AmNodeState nodeState = cluster.GetNodeState(node.Name, out ex);

            if (ex != null)
            {
                return(false);
            }
            if (!AmClusterNode.IsNodeUp(nodeState))
            {
                return(false);
            }
            AmClusterNodeNetworkStatus amClusterNodeNetworkStatus = AmClusterNodeStatusAccessor.Read(cluster, node.Name, out ex);

            return(amClusterNodeNetworkStatus == null || amClusterNodeNetworkStatus.HasADAccess);
        }
 public bool IsEqual(AmClusterNodeNetworkStatus other)
 {
     return(this.IsHealthy == other.IsHealthy && this.HasADAccess == other.HasADAccess && this.ClusterErrorOverride == other.ClusterErrorOverride);
 }
예제 #8
0
        // Token: 0x060000E2 RID: 226 RVA: 0x00006554 File Offset: 0x00004754
        public void ReportHasADAccess(bool hasAccess)
        {
            bool flag = false;
            AmClusterNodeNetworkStatus amClusterNodeNetworkStatus = new AmClusterNodeNetworkStatus();

            amClusterNodeNetworkStatus.HasADAccess = hasAccess;
            if (this.Cluster == null || this.m_cem == null)
            {
                AmClusterMonitor.Tracer.TraceError(0L, "ReportHasADAccess fails because we aren't initialized or running in a DAG");
                return;
            }
            try
            {
                using (AmClusterNodeStatusAccessor amClusterNodeStatusAccessor = new AmClusterNodeStatusAccessor(this.Cluster, AmServerName.LocalComputerName, DxStoreKeyAccessMode.CreateIfNotExist))
                {
                    AmClusterNodeNetworkStatus amClusterNodeNetworkStatus2 = amClusterNodeStatusAccessor.Read();
                    if (amClusterNodeNetworkStatus2 != null)
                    {
                        if (amClusterNodeNetworkStatus2.ClusterErrorOverride && amClusterNodeNetworkStatus.HasADAccess && !AmSystemManager.Instance.NetworkMonitor.AreAnyMapiNicsUp(AmServerName.LocalComputerName))
                        {
                            amClusterNodeNetworkStatus.ClusterErrorOverride = true;
                        }
                        if (!amClusterNodeNetworkStatus.IsEqual(amClusterNodeNetworkStatus2))
                        {
                            flag = true;
                        }
                    }
                    else
                    {
                        flag = true;
                    }
                    if (flag)
                    {
                        amClusterNodeStatusAccessor.Write(amClusterNodeNetworkStatus);
                    }
                }
                if (flag)
                {
                    if (amClusterNodeNetworkStatus.IsHealthy)
                    {
                        if (amClusterNodeNetworkStatus.ClusterErrorOverride)
                        {
                            ReplayCrimsonEvents.AmMapiAccessExpectedByAD.Log();
                        }
                        else
                        {
                            ReplayCrimsonEvents.AmADStatusRecordedAsAccessible.Log();
                        }
                    }
                    else
                    {
                        ReplayCrimsonEvents.AmADStatusRecordedAsFailed.Log();
                    }
                }
            }
            catch (ClusterException ex)
            {
                AmClusterMonitor.Tracer.TraceError <ClusterException>(0L, "ReportNodeState failed: {0}", ex);
                ReplayCrimsonEvents.AmNodeStatusUpdateFailed.Log <AmClusterNodeNetworkStatus, string>(amClusterNodeNetworkStatus, ex.Message);
            }
            catch (SerializationException ex2)
            {
                AmClusterMonitor.Tracer.TraceError <SerializationException>(0L, "ReportNodeState failed: {0}", ex2);
                ReplayCrimsonEvents.AmNodeStatusUpdateFailed.Log <AmClusterNodeNetworkStatus, string>(amClusterNodeNetworkStatus, ex2.ToString());
            }
        }