protected override void TimerCallbackInternal()
 {
     try
     {
         if (AmSystemManager.Instance.Config.IsPAM)
         {
             using (IClusterDB clusterDB = ClusterDB.Open())
             {
                 this.CleanupStaleEntries(clusterDB);
             }
         }
     }
     catch (Exception ex)
     {
         ReplayCrimsonEvents.ClusdbPeriodicCleanupFailed.Log <string, string>("Common", ex.ToString());
     }
     finally
     {
         if (this.staleDatabases.Count > 0 || this.staleServers.Count > 0)
         {
             ReplayCrimsonEvents.ClusdbPeriodicCleanupFoundStale.Log <int, int>(this.staleDatabases.Count, this.staleServers.Count);
         }
         else
         {
             ReplayCrimsonEvents.ClusdbPeriodicCleanupNoStale.Log();
         }
     }
 }
Exemple #2
0
        internal static void RemoveEntryFromClusdb(string serverName, string actionName)
        {
            using (IClusterDB clusterDB = ClusterDB.Open())
            {
                string keyName = AmThrottledActionTracker <TData> .ConstructRegKeyName(serverName);

                clusterDB.DeleteValue(keyName, actionName);
            }
        }
Exemple #3
0
        public static IClusterDB OpenClusterDatabase(ITopologyConfigurationSession taskSession, Task.TaskVerboseLoggingDelegate writeLog, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskErrorLoggingDelegate writeError, Database database, bool allowNoOwningServer, out DatabaseAvailabilityGroup dag)
        {
            string machineName = database.Server.ToString();

            try
            {
                ADObjectId server     = database.Server;
                MiniServer miniServer = taskSession.ReadMiniServer(server, DatabaseTasksHelper.MiniserverProperties);
                if (miniServer == null)
                {
                    writeWarning(Strings.ErrorDBOwningServerNotFound(database.Identity.ToString()));
                    if (allowNoOwningServer)
                    {
                        dag = null;
                        return(null);
                    }
                    writeError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(database.Name)), ErrorCategory.InvalidOperation, database);
                }
                machineName = miniServer.Fqdn;
                ADObjectId databaseAvailabilityGroup = miniServer.DatabaseAvailabilityGroup;
                if (databaseAvailabilityGroup != null)
                {
                    dag = DagTaskHelper.ReadDag(databaseAvailabilityGroup, taskSession);
                    if (dag != null)
                    {
                        AmServerName amServerName = new AmServerName(miniServer);
                        writeLog(Strings.OpeningClusterDatabase(amServerName.ToString()));
                        return(ClusterDB.Open(amServerName));
                    }
                }
            }
            catch (ClusterException ex)
            {
                writeWarning(Strings.CouldNotConnectToClusterError(machineName, ex.Message));
            }
            catch (DataSourceTransientException)
            {
                writeWarning(Strings.CouldNotConnectToCluster(machineName));
            }
            catch (DataSourceOperationException)
            {
                writeWarning(Strings.CouldNotConnectToCluster(machineName));
            }
            dag = null;
            return(null);
        }
Exemple #4
0
        // Token: 0x06001BD8 RID: 7128 RVA: 0x00078450 File Offset: 0x00076650
        internal static ExDateTime GetLastServerUpdateTimeFromClusdb()
        {
            ExDateTime exDateTimeMinValueUtc = SharedHelper.ExDateTimeMinValueUtc;

            try
            {
                using (IClusterDB clusterDB = ClusterDB.Open())
                {
                    string value = clusterDB.GetValue <string>("ExchangeActiveManager\\LastLog", AmServerName.LocalComputerName.NetbiosName, string.Empty);
                    if (!string.IsNullOrEmpty(value) && !ExDateTime.TryParse(value, out exDateTimeMinValueUtc))
                    {
                        exDateTimeMinValueUtc = SharedHelper.ExDateTimeMinValueUtc;
                    }
                }
            }
            catch (ClusterException ex)
            {
                ClusterBatchWriter.Tracer.TraceError <string>(0L, "GetLastServerUpdateTimeFromClusdb() failed with {0}", ex.Message);
            }
            return(exDateTimeMinValueUtc);
        }
Exemple #5
0
        private void InitializeFromClusdbInternal()
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsPAM)
            {
                AmDagConfig dagConfig = config.DagConfig;
                using (IClusterDB clusterDB = ClusterDB.Open())
                {
                    foreach (AmServerName amServerName in dagConfig.MemberServers)
                    {
                        string keyName = AmThrottledActionTracker <TData> .ConstructRegKeyName(amServerName.NetbiosName);

                        string[] value = clusterDB.GetValue <string[]>(keyName, this.ActionName, null);
                        if (value != null && value.Length > 0)
                        {
                            LinkedList <TData> linkedList = new LinkedList <TData>();
                            foreach (string text in value)
                            {
                                int num = text.IndexOf('=');
                                if (num != -1)
                                {
                                    string s       = text.Substring(0, num);
                                    string dataStr = null;
                                    if (num < text.Length - 1)
                                    {
                                        dataStr = text.Substring(num + 1);
                                    }
                                    ExDateTime actionTime = ExDateTime.Parse(s);
                                    TData      value2     = Activator.CreateInstance <TData>();
                                    value2.Initialize(actionTime, dataStr);
                                    linkedList.AddFirst(value2);
                                }
                            }
                            this.actionHistory[amServerName] = linkedList;
                        }
                    }
                }
            }
        }
Exemple #6
0
        private void Persist(AmServerName node)
        {
            LinkedList <TData> linkedList;

            if (this.actionHistory.TryGetValue(node, out linkedList) && linkedList != null && linkedList.Count > 0)
            {
                using (IClusterDB clusterDB = ClusterDB.Open())
                {
                    List <string> list = new List <string>();
                    foreach (TData tdata in linkedList)
                    {
                        string arg     = tdata.Time.UniversalTime.ToString("o");
                        string dataStr = tdata.DataStr;
                        string item    = string.Format("{0}{1}{2}", arg, '=', dataStr);
                        list.Add(item);
                    }
                    string[] propetyValue = list.ToArray();
                    string   keyName      = AmThrottledActionTracker <TData> .ConstructRegKeyName(node.NetbiosName);

                    clusterDB.SetValue <string[]>(keyName, this.ActionName, propetyValue);
                }
            }
        }
Exemple #7
0
 // Token: 0x060000B2 RID: 178 RVA: 0x00005148 File Offset: 0x00003348
 internal void Flush()
 {
     if (AmSystemManager.Instance.Config.IsPAM)
     {
         Dictionary <AmServerName, AmCachedLastLogUpdater.ServerRequestInfo> dictionary = this.Cleanup();
         if (dictionary.Count > 0)
         {
             Exception ex = null;
             try
             {
                 using (IClusterDB clusterDB = ClusterDB.Open())
                 {
                     if (clusterDB.IsInitialized)
                     {
                         using (IClusterDBWriteBatch clusterDBWriteBatch = clusterDB.CreateWriteBatch("ExchangeActiveManager\\LastLog"))
                         {
                             this.PopulateBatch(clusterDBWriteBatch, dictionary);
                             clusterDBWriteBatch.Execute();
                             ExDateTime now = ExDateTime.Now;
                             foreach (AmServerName key in dictionary.Keys)
                             {
                                 this.serverUpdateTimeMap[key] = now;
                             }
                             goto IL_BA;
                         }
                     }
                     ExTraceGlobals.ClusterTracer.TraceError((long)this.GetHashCode(), "Flush(): clusdb is not initialized");
                     IL_BA :;
                 }
             }
             catch (ADExternalException ex2)
             {
                 ex = ex2;
             }
             catch (ADOperationException ex3)
             {
                 ex = ex3;
             }
             catch (ADTransientException ex4)
             {
                 ex = ex4;
             }
             catch (ClusterException ex5)
             {
                 ex = ex5;
             }
             catch (AmServerException ex6)
             {
                 ex = ex6;
             }
             catch (AmServerTransientException ex7)
             {
                 ex = ex7;
             }
             if (ex != null)
             {
                 ReplayCrimsonEvents.CachedLastLogUpdateFailed.LogPeriodic <int, string>(AmServerName.LocalComputerName.NetbiosName, TimeSpan.FromMinutes(5.0), dictionary.Count, ex.Message);
             }
         }
     }
 }