Ejemplo n.º 1
0
        internal static IAmCluster CreateDagCluster(string clusterName, AmServerName firstNodeName, string[] ipAddresses, uint[] netmasks, out string verboseLog)
        {
            IAmCluster result = null;
            HaTaskStringBuilderOutputHelper haTaskStringBuilderOutputHelper = new HaTaskStringBuilderOutputHelper("m.e.cluster.replay.dll!CreateDagCluster");
            GCHandle  value = GCHandle.Alloc(haTaskStringBuilderOutputHelper);
            Exception ex    = null;

            try
            {
                haTaskStringBuilderOutputHelper.WriteProgressSimple(ReplayStrings.DagTaskFormingClusterProgress(clusterName, firstNodeName.NetbiosName));
                haTaskStringBuilderOutputHelper.LastException = null;
                haTaskStringBuilderOutputHelper.MaxPercentageDuringCallback = 0;
                result = ClusterFactory.Instance.CreateExchangeCluster(clusterName, firstNodeName, ipAddresses, netmasks, haTaskStringBuilderOutputHelper, GCHandle.ToIntPtr(value), out ex, true);
                if (ex != null)
                {
                    haTaskStringBuilderOutputHelper.WriteErrorSimple(ex);
                }
            }
            catch (LocalizedException exception)
            {
                DagHelper.ThrowDagTaskOperationWrapper(exception);
            }
            finally
            {
                verboseLog = haTaskStringBuilderOutputHelper.ToString();
                value.Free();
            }
            return(result);
        }
Ejemplo n.º 2
0
        // Token: 0x060008B7 RID: 2231 RVA: 0x00029DD4 File Offset: 0x00027FD4
        internal static void AddDagClusterNode(AmServerName mailboxServerName, out string verboseLog)
        {
            string tmpVerboseLog = string.Empty;
            HaTaskStringBuilderOutputHelper output = new HaTaskStringBuilderOutputHelper("m.e.cluster.replay.dll!AddDagClusterNode");

            DagHelper.nodeActionTracker.PerformNodeAction(output, mailboxServerName, NodeAction.Add, delegate
            {
                DagHelper.AddDagClusterNodeInternal(output, mailboxServerName, out tmpVerboseLog);
            });
            verboseLog = tmpVerboseLog;
        }
Ejemplo n.º 3
0
        // Token: 0x060008B9 RID: 2233 RVA: 0x00029F54 File Offset: 0x00028154
        internal static bool EvictDagClusterNode(AmServerName convictedNode, out string verboseLog)
        {
            string tmpVerboseLog = string.Empty;
            bool   isSuccess     = false;
            HaTaskStringBuilderOutputHelper output = new HaTaskStringBuilderOutputHelper("m.e.cluster.replay.dll!EvictDagClusterNode");

            DagHelper.nodeActionTracker.PerformNodeAction(output, convictedNode, NodeAction.Evict, delegate
            {
                isSuccess = DagHelper.EvictDagClusterNodeInternal(output, convictedNode, out tmpVerboseLog);
            });
            verboseLog = tmpVerboseLog;
            return(isSuccess);
        }
Ejemplo n.º 4
0
 // Token: 0x060008B8 RID: 2232 RVA: 0x00029E34 File Offset: 0x00028034
 private static void AddDagClusterNodeInternal(HaTaskStringBuilderOutputHelper output, AmServerName mailboxServerName, out string verboseLog)
 {
     try
     {
         Exception ex = null;
         output.AppendLogMessage("Opening a local AmCluster handle.", new object[0]);
         using (IAmCluster amCluster = ClusterFactory.Instance.Open())
         {
             output.WriteProgressSimple(ReplayStrings.DagTaskAddingServerToDag(mailboxServerName.NetbiosName, amCluster.Name));
             GCHandle value = GCHandle.Alloc(output);
             try
             {
                 output.LastException = null;
                 output.MaxPercentageDuringCallback = 0;
                 amCluster.AddNodeToCluster(mailboxServerName, output, GCHandle.ToIntPtr(value), out ex, true);
             }
             finally
             {
                 value.Free();
             }
         }
         if (output.LastException != null)
         {
             output.WriteErrorSimple(output.LastException);
         }
         if (ex != null)
         {
             output.WriteErrorSimple(ex);
         }
         output.WriteProgressSimple(ReplayStrings.DagTaskJoinedNodeToCluster(mailboxServerName.NetbiosName));
     }
     catch (LocalizedException exception)
     {
         DagHelper.ThrowDagTaskOperationWrapper(exception);
     }
     finally
     {
         verboseLog = output.ToString();
     }
 }
Ejemplo n.º 5
0
 // Token: 0x06001BD4 RID: 7124 RVA: 0x00077F58 File Offset: 0x00076158
 private void WriterProc(object o)
 {
     ExTraceGlobals.ClusterTracer.TraceDebug((long)this.GetHashCode(), "ClusterBatchWriter.WriterProc entered.");
     try
     {
         if (!DagHelper.IsLocalNodeClustered())
         {
             ClusterBatchWriter.Tracer.Information(0L, "The local machine is not clustered. Skipping cluster batch writer proc.");
             return;
         }
     }
     catch (ExClusTransientException arg)
     {
         ClusterBatchWriter.Tracer.Information <ExClusTransientException>(0L, "ClusterBatchWriter.WriterProc failed to determine clustering: {0}", arg);
         return;
     }
     lock (this.s_lock)
     {
         if (this.m_fRunning)
         {
             ExTraceGlobals.ClusterTracer.TraceDebug((long)this.GetHashCode(), "ClusterBatchWriter WriterProc bailing as another thread is running.");
             return;
         }
         this.m_fRunning = true;
     }
     try
     {
         Dictionary <string, string> clusdbUpdates;
         lock (this.s_lock)
         {
             ExTraceGlobals.ClusterTracer.TraceDebug <int>((long)this.GetHashCode(), "ClusterBatchWriter m_clusdbUpdates.Count={0}.", this.m_clusdbUpdates.Count);
             clusdbUpdates        = this.m_clusdbUpdates;
             this.m_clusdbUpdates = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
         }
         bool flag3 = this.SendUpdatesAndCheckIfLocalUpdateRequired(clusdbUpdates);
         if (flag3)
         {
             ActiveManagerServerPerfmon.LastLogLocalClusterBatchUpdatesAttempted.Increment();
             if (!this.UpdateClusdb(clusdbUpdates))
             {
                 ActiveManagerServerPerfmon.LastLogLocalClusterBatchUpdatesFailed.Increment();
                 lock (this.s_lock)
                 {
                     foreach (string key in clusdbUpdates.Keys)
                     {
                         if (!this.m_clusdbUpdates.ContainsKey(key))
                         {
                             this.m_clusdbUpdates[key] = clusdbUpdates[key];
                         }
                     }
                     ExTraceGlobals.ClusterTracer.TraceDebug <int>((long)this.GetHashCode(), "ClusterBatchWriter UpdateClusdb failed. m_clusdbUpdates.Count={0}.", this.m_clusdbUpdates.Count);
                 }
             }
         }
     }
     finally
     {
         lock (this.s_lock)
         {
             this.m_fRunning = false;
         }
     }
     ExTraceGlobals.ClusterTracer.TraceDebug((long)this.GetHashCode(), "ClusterBatchWriter.WriterProc completed.");
 }
Ejemplo n.º 6
0
 public static bool IsLocalNodeClustered()
 {
     return(DagHelper.IsLocalNodeClustered());
 }
        // Token: 0x06002412 RID: 9234 RVA: 0x000A881C File Offset: 0x000A6A1C
        private void Init()
        {
            bool flag = false;

            try
            {
                object serviceLock;
                Monitor.Enter(serviceLock = this.m_serviceLock, ref flag);
                if (!this.m_fShutdown)
                {
                    IADDatabaseAvailabilityGroup dag = null;
                    Exception exception     = null;
                    TimeSpan  invokeTimeout = TimeSpan.FromSeconds((double)RegistryParameters.MonitoringADGetConfigTimeoutInSec);
                    try
                    {
                        InvokeWithTimeout.Invoke(delegate()
                        {
                            dag = DagHelper.GetLocalServerDatabaseAvailabilityGroup(null, out exception);
                        }, invokeTimeout);
                    }
                    catch (TimeoutException exception)
                    {
                        TimeoutException exception2;
                        exception = exception2;
                    }
                    if (exception != null)
                    {
                        ExTraceGlobals.ThirdPartyManagerTracer.TraceError <Exception>(0L, "TPR Init fails due to AD problems: {0}", exception);
                        this.m_initFailMsg = exception.Message;
                        ReplayEventLogConstants.Tuple_TPRManagerInitFailure.LogEvent(this.Name, new object[]
                        {
                            this.m_initFailMsg
                        });
                    }
                    else
                    {
                        if (dag == null)
                        {
                            ExTraceGlobals.ThirdPartyManagerTracer.TraceDebug(0L, "TPR not enabled because we are not in a DAG");
                        }
                        else
                        {
                            if (dag.ThirdPartyReplication == ThirdPartyReplicationMode.Enabled)
                            {
                                this.m_tprEnabled = true;
                            }
                            ExTraceGlobals.ThirdPartyManagerTracer.TraceDebug <string>(0L, "TPR is {0}enabled", this.m_tprEnabled ? string.Empty : "not ");
                        }
                        this.m_initialized = true;
                    }
                }
            }
            finally
            {
                if (flag)
                {
                    object serviceLock;
                    Monitor.Exit(serviceLock);
                }
            }
        }
Ejemplo n.º 8
0
        // Token: 0x060008BC RID: 2236 RVA: 0x0002A100 File Offset: 0x00028300
        internal static void ForceCleanupNode(out string verboseLog)
        {
            ExTraceGlobals.ClusterTracer.TraceDebug(0L, "ForceCleanupNode called");
            HaTaskStringBuilderOutputHelper haTaskStringBuilderOutputHelper = new HaTaskStringBuilderOutputHelper("m.e.cluster.replay.dll!ForceCleanupNode");

            try
            {
                ManagementScope managementScope = new ManagementScope("\\\\.\\root\\MSCluster");
                managementScope.Connect();
                string path = "MSCluster_Cluster";
                using (ManagementClass managementClass = new ManagementClass(managementScope, new ManagementPath(path), null))
                {
                    managementClass.Get();
                    using (ManagementObjectCollection instances = managementClass.GetInstances())
                    {
                        if (instances == null)
                        {
                            throw new ManagementApiException("mgmtClass.GetInstances()");
                        }
                        foreach (ManagementBaseObject managementBaseObject in instances)
                        {
                            ManagementObject managementObject = (ManagementObject)managementBaseObject;
                            using (managementObject)
                            {
                                using (ManagementBaseObject methodParameters = managementObject.GetMethodParameters("ForceCleanup"))
                                {
                                    if (methodParameters == null)
                                    {
                                        throw new ManagementApiException("clus.GetMethodParameters(\"ForceCleanup\")");
                                    }
                                    methodParameters.SetPropertyValue("Timeout", 10000);
                                    methodParameters.SetPropertyValue("NodeName", Environment.MachineName);
                                    try
                                    {
                                        using (managementObject.InvokeMethod("ForceCleanup", methodParameters, null))
                                        {
                                        }
                                    }
                                    catch (ManagementException ex)
                                    {
                                        ExTraceGlobals.ClusterTracer.TraceDebug <string>(0L, "ForceCleanup throws {0}", ex.Message);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (COMException exception)
            {
                DagHelper.ThrowDagTaskOperationWrapper(exception);
            }
            catch (ManagementApiException exception2)
            {
                DagHelper.ThrowDagTaskOperationWrapper(exception2);
            }
            catch (ManagementException exception3)
            {
                DagHelper.ThrowDagTaskOperationWrapper(exception3);
            }
            finally
            {
                verboseLog = haTaskStringBuilderOutputHelper.ToString();
            }
        }
Ejemplo n.º 9
0
 // Token: 0x060008B0 RID: 2224 RVA: 0x000299A0 File Offset: 0x00027BA0
 public static bool IsLocalNodeClustered()
 {
     return(DagHelper.IsNodeClustered(AmServerName.LocalComputerName));
 }
Ejemplo n.º 10
0
        // Token: 0x060008AC RID: 2220 RVA: 0x00029304 File Offset: 0x00027504
        internal static void CreateFileShareWitnessQuorum(ITaskOutputHelper output, IAmCluster cluster, string fswShare)
        {
            output = (output ?? NullTaskOutputHelper.GetNullLogger());
            IAmClusterGroup amClusterGroup = cluster.FindCoreClusterGroup();

            if (amClusterGroup == null)
            {
                Thread.Sleep(10000);
                amClusterGroup = cluster.FindCoreClusterGroup();
                if (amClusterGroup == null)
                {
                    throw new FailedToGetClusterCoreGroupException();
                }
            }
            using (amClusterGroup)
            {
                IEnumerable <AmClusterResource> source = amClusterGroup.EnumerateResourcesOfType("File Share Witness");
                IAmClusterResource amClusterResource   = source.ElementAtOrDefault(0);
                try
                {
                    bool flag = false;
                    if (amClusterResource == null)
                    {
                        output.AppendLogMessage("CreateFileShareWitnessQuorum: Could not find an existing FSW resource. A new one will be created.", new object[0]);
                        flag = true;
                    }
                    else if (amClusterResource.GetState() == AmResourceState.Failed)
                    {
                        output.AppendLogMessage("CreateFileShareWitnessQuorum: The existing FSW resource is in a Failed state. It should be deleted and recreated.", new object[0]);
                        flag = true;
                    }
                    else
                    {
                        string privateProperty = amClusterResource.GetPrivateProperty <string>("SharePath");
                        if (!SharedHelper.StringIEquals(privateProperty, fswShare))
                        {
                            output.AppendLogMessage("CreateFileShareWitnessQuorum: There is already a FSW, but the current share path ({0}) is not what's desired ({1}). Will try to fix it.", new object[]
                            {
                                privateProperty,
                                fswShare
                            });
                            List <string> list = new List <string>(4);
                            foreach (IAmClusterNode amClusterNode in cluster.EnumerateNodes())
                            {
                                using (amClusterNode)
                                {
                                    if (!AmClusterNode.IsNodeUp(amClusterNode.State))
                                    {
                                        list.Add(amClusterNode.Name.NetbiosName);
                                    }
                                }
                            }
                            if (list.Count > 0)
                            {
                                output.WriteErrorSimple(new DagTaskSetDagNeedsAllNodesUpToChangeQuorumException(string.Join(",", list.ToArray())));
                            }
                            DagHelper.SetFswSharePath(output, cluster, amClusterResource, fswShare);
                        }
                    }
                    AmResourceState state;
                    if (!flag && amClusterResource != null)
                    {
                        try
                        {
                            state = amClusterResource.GetState();
                            if (state != AmResourceState.Online)
                            {
                                output.AppendLogMessage("The FSW is not online (it is {0}). Attempting to bring online.", new object[]
                                {
                                    state
                                });
                                amClusterResource.OnlineResource();
                            }
                            state = amClusterResource.GetState();
                            output.AppendLogMessage("The fsw resource is now in state {0}.", new object[]
                            {
                                state
                            });
                            if (state != AmResourceState.Online)
                            {
                                flag = true;
                            }
                        }
                        catch (ClusterException ex)
                        {
                            output.AppendLogMessage("Bringing the FSW resource online failed, so it will be deleted and recreated. For the record, the error was {0}", new object[]
                            {
                                ex
                            });
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        if (amClusterResource != null)
                        {
                            amClusterResource.Dispose();
                            amClusterResource = null;
                        }
                        output.AppendLogMessage("CreateFileShareWitnessQuorum: Calling RevertToMnsQuorum to clean everything up first.", new object[0]);
                        DagHelper.RevertToMnsQuorum(output, cluster);
                        string text = string.Format("File Share Witness ({0})", fswShare);
                        output.AppendLogMessage("Creating a new file share witness resource named '{0}'.", new object[]
                        {
                            text
                        });
                        amClusterResource = amClusterGroup.CreateResource(text, "File Share Witness");
                        DagHelper.SetFswSharePath(output, cluster, amClusterResource, fswShare);
                    }
                    output.AppendLogMessage("The FSW resource is now in state {0}.", new object[]
                    {
                        amClusterResource.GetState()
                    });
                    string text2;
                    uint   maxLogSize;
                    string quorumResourceInformation = cluster.GetQuorumResourceInformation(out text2, out maxLogSize);
                    output.AppendLogMessage("The current quorum resource is '{0}'. About to set it to the FSW.", new object[]
                    {
                        quorumResourceInformation
                    });
                    state = amClusterResource.GetState();
                    if (state != AmResourceState.Online)
                    {
                        output.WriteErrorSimple(new DagTaskFileShareWitnessResourceIsStillNotOnlineException(fswShare, state.ToString()));
                    }
                    cluster.SetQuorumResource(amClusterResource, null, maxLogSize);
                    quorumResourceInformation = cluster.GetQuorumResourceInformation(out text2, out maxLogSize);
                    output.AppendLogMessage("The quorum resource is now '{0}'.", new object[]
                    {
                        quorumResourceInformation
                    });
                    output.AppendLogMessage("Bringing the quorum resource online...", new object[0]);
                    amClusterResource.OnlineResource();
                }
                finally
                {
                    if (amClusterResource != null)
                    {
                        amClusterResource.Dispose();
                        amClusterResource = null;
                    }
                }
            }
        }