예제 #1
0
 public static void RemoveDatabaseRequestedSchemaVersion(IClusterDB iClusterDB, Guid databaseGuid)
 {
     using (IClusterDBWriteBatch clusterDBWriteBatch = iClusterDB.CreateWriteBatch("Exchange\\Databases"))
     {
         clusterDBWriteBatch.DeleteKey(databaseGuid.ToString());
         clusterDBWriteBatch.Execute();
     }
 }
예제 #2
0
 public static void RemoveServerSchemaVersionRange(IClusterDB iClusterDB, Guid serverGuid)
 {
     using (IClusterDBWriteBatch clusterDBWriteBatch = iClusterDB.CreateWriteBatch("Exchange\\Servers"))
     {
         clusterDBWriteBatch.DeleteKey(serverGuid.ToString());
         clusterDBWriteBatch.Execute();
     }
 }
예제 #3
0
        public static void WriteRequestedDatabaseSchemaVersion(IClusterDB iClusterDB, Guid databaseGuid, int requestedVersion)
        {
            string registryKey = string.Format("Exchange\\Databases\\{0}\\Schema", databaseGuid);

            using (IClusterDBWriteBatch clusterDBWriteBatch = iClusterDB.CreateWriteBatch(registryKey))
            {
                clusterDBWriteBatch.SetValue("Requested Version", requestedVersion);
                clusterDBWriteBatch.Execute();
            }
        }
예제 #4
0
        public static void WriteServerDatabaseSchemaVersionRange(IClusterDB iClusterDB, Guid serverGuid, int minVersion, int maxVersion)
        {
            string registryKey = string.Format("Exchange\\Servers\\{0}\\Schema", serverGuid);

            using (IClusterDBWriteBatch clusterDBWriteBatch = iClusterDB.CreateWriteBatch(registryKey))
            {
                clusterDBWriteBatch.SetValue("Minimum Version", minVersion);
                clusterDBWriteBatch.SetValue("Maximum Version", maxVersion);
                clusterDBWriteBatch.Execute();
            }
        }
예제 #5
0
        // Token: 0x060000B3 RID: 179 RVA: 0x000052F4 File Offset: 0x000034F4
        private void PopulateBatch(IClusterDBWriteBatch writeBatch, Dictionary <AmServerName, AmCachedLastLogUpdater.ServerRequestInfo> requestInfoMap)
        {
            Dictionary <Guid, AmDbStateInfo> dbStateInfoMap = new Dictionary <Guid, AmDbStateInfo>();
            AmConfig config = AmSystemManager.Instance.Config;

            if (!config.IsPAM)
            {
                throw new AmInvalidConfiguration(string.Format("Role = {0}", config.Role));
            }
            AmDbStateInfo[] array = config.DbState.ReadAll();
            if (array != null)
            {
                dbStateInfoMap = array.ToDictionary((AmDbStateInfo s) => s.DatabaseGuid);
            }
            foreach (AmCachedLastLogUpdater.ServerRequestInfo serverRequestInfo in requestInfoMap.Values)
            {
                AmServerName            serverName        = serverRequestInfo.ServerName;
                Dictionary <Guid, long> databaseLogGenMap = serverRequestInfo.DatabaseLogGenMap;
                HashSet <Guid>          databasesByServer = this.GetDatabasesByServer(serverName);
                string value = serverRequestInfo.MostRecentRequestReceivedUtc.ToString("s");
                foreach (KeyValuePair <Guid, long> keyValuePair in databaseLogGenMap)
                {
                    Guid   key       = keyValuePair.Key;
                    long   value2    = keyValuePair.Value;
                    string text      = key.ToString();
                    string valueName = AmDbState.ConstructLastLogTimeStampProperty(text);
                    if (this.IsDatabaseActiveOnServer(dbStateInfoMap, key, serverName))
                    {
                        writeBatch.SetValue(text, value2.ToString());
                        writeBatch.SetValue(valueName, value);
                    }
                    databasesByServer.Remove(key);
                }
                foreach (Guid databaseGuid in databasesByServer)
                {
                    string valueName2 = AmDbState.ConstructLastLogTimeStampProperty(databaseGuid.ToString());
                    if (this.IsDatabaseActiveOnServer(dbStateInfoMap, databaseGuid, serverName))
                    {
                        writeBatch.SetValue(valueName2, value);
                    }
                }
                writeBatch.SetValue(serverName.NetbiosName, value);
            }
        }
        private int RemoveItemsFromClusdb(string objectName, IClusterDB clusdb, string keyName, bool isDeleteKey, IEnumerable <Guid> collection, Func <string, string> nameGenerator = null, int batchSize = 200)
        {
            if (!DistributedStore.Instance.IsKeyExist(keyName, null))
            {
                return(0);
            }
            int num  = 0;
            int num2 = 0;
            HashSet <string> hashSet = new HashSet <string>(collection.Select(delegate(Guid id)
            {
                string text2 = id.ToString();
                if (nameGenerator != null)
                {
                    return(nameGenerator(text2));
                }
                return(text2);
            }));

            num2 = hashSet.Count;
            try
            {
                if (isDeleteKey)
                {
                    IEnumerable <string> subKeyNames = clusdb.GetSubKeyNames(keyName);
                    hashSet.IntersectWith(subKeyNames);
                }
                else
                {
                    IEnumerable <string> other = from vi in clusdb.GetValueInfos(keyName)
                                                 select vi.Item1;
                    hashSet.IntersectWith(other);
                }
            }
            catch (Exception ex)
            {
                ReplayCrimsonEvents.ClusdbPeriodicCleanupFailed.Log <string, string>(objectName, ex.ToString());
                return(0);
            }
            if (hashSet.Count == 0)
            {
                return(0);
            }
            int       num3      = 0;
            int       num4      = 0;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            foreach (IEnumerable <string> enumerable in hashSet.Batch(batchSize))
            {
                num++;
                int num5 = 0;
                try
                {
                    using (IClusterDBWriteBatch clusterDBWriteBatch = clusdb.CreateWriteBatch(keyName))
                    {
                        foreach (string text in enumerable)
                        {
                            num5++;
                            if (isDeleteKey)
                            {
                                clusterDBWriteBatch.DeleteKey(text);
                            }
                            else
                            {
                                clusterDBWriteBatch.DeleteValue(text);
                            }
                        }
                        clusterDBWriteBatch.Execute();
                        num3 += num5;
                    }
                }
                catch (Exception ex2)
                {
                    num4++;
                    ReplayCrimsonEvents.ClusdbCleanupBatchOperationFailed.Log <string, string, string, bool, int, int, int, int>(objectName, ex2.Message, keyName, isDeleteKey, num, num5, num2, hashSet.Count);
                }
            }
            long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;

            ReplayCrimsonEvents.ClusdbPeriodicCleanupCompleted.Log <string, string, int, string, int, int, long>(objectName, keyName, num3, isDeleteKey ? "Key" : "Property", num, num4, elapsedMilliseconds);
            return(num3);
        }
예제 #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);
             }
         }
     }
 }