Пример #1
0
 private IDistributedStoreKey OpenRegKey(IDistributedStoreKey rootKey, string keyName, bool createIfNotExists, bool ignoreIfNotExits = false)
 {
     if (rootKey == null)
     {
         throw AmExceptionHelper.ConstructClusterApiException(5004, "OpenRegKey()", new object[0]);
     }
     if (!createIfNotExists)
     {
         return(rootKey.OpenKey(keyName, DxStoreKeyAccessMode.Write, ignoreIfNotExits, null));
     }
     return(rootKey.OpenKey(keyName, DxStoreKeyAccessMode.CreateIfNotExist, false, null));
 }
Пример #2
0
 // Token: 0x0600043E RID: 1086 RVA: 0x000168BC File Offset: 0x00014ABC
 protected override void InitializeHandles()
 {
     using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(this.m_cluster.Handle, null, null, DxStoreKeyAccessMode.Write, false))
     {
         using (IDistributedStoreKey distributedStoreKey = clusterKey.OpenKey("ExchangeActiveManager", DxStoreKeyAccessMode.CreateIfNotExist, false, null))
         {
             this.m_regDbHandle      = distributedStoreKey.OpenKey("DbState", DxStoreKeyAccessMode.CreateIfNotExist, false, null);
             this.m_regLastLogHandle = distributedStoreKey.OpenKey("LastLog", DxStoreKeyAccessMode.CreateIfNotExist, false, null);
             this.m_dbgOptionHandle  = distributedStoreKey.OpenKey("DebugOption", DxStoreKeyAccessMode.CreateIfNotExist, false, null);
         }
     }
 }
Пример #3
0
        // Token: 0x06000F53 RID: 3923 RVA: 0x00041F2C File Offset: 0x0004012C
        private void Open()
        {
            AmClusterHandle amClusterHandle = null;
            AmSystemManager instance        = AmSystemManager.Instance;

            if (instance != null)
            {
                AmConfig config = instance.Config;
                if (config != null)
                {
                    AmDagConfig dagConfig = config.DagConfig;
                    if (dagConfig != null)
                    {
                        IAmCluster cluster = dagConfig.Cluster;
                        if (cluster != null)
                        {
                            amClusterHandle = cluster.Handle;
                        }
                    }
                }
            }
            if (amClusterHandle == null || amClusterHandle.IsInvalid)
            {
                throw new AmClusterNotRunningException();
            }
            using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(amClusterHandle, null, null, DxStoreKeyAccessMode.Write, false))
            {
                string keyName = string.Format("{0}\\SafetyNet2\\{1}", "ExchangeActiveManager", this.m_dbGuidStr);
                this.m_dbRegKeyHandle = clusterKey.OpenKey(keyName, DxStoreKeyAccessMode.CreateIfNotExist, false, null);
            }
        }
Пример #4
0
        internal bool IsKeyExist(string keyName, AmCluster cluster = null)
        {
            bool result = false;
            bool flag   = false;

            if (cluster == null)
            {
                cluster = AmCluster.Open();
                flag    = true;
            }
            try
            {
                using (IDistributedStoreKey clusterKey = this.GetClusterKey(cluster.Handle, null, null, DxStoreKeyAccessMode.Read, true))
                {
                    if (clusterKey != null)
                    {
                        using (IDistributedStoreKey distributedStoreKey = clusterKey.OpenKey(keyName, DxStoreKeyAccessMode.Read, true, null))
                        {
                            result = (distributedStoreKey != null);
                        }
                    }
                }
            }
            finally
            {
                if (flag && cluster != null)
                {
                    cluster.Dispose();
                }
            }
            return(result);
        }
Пример #5
0
        // Token: 0x06001BDB RID: 7131 RVA: 0x0007858C File Offset: 0x0007678C
        private void UpdateClusdbInternal(Dictionary <string, string> tmpClusdbUpdates, out string lastAttemptedOperationName)
        {
            lastAttemptedOperationName = "Preparing";
            Dictionary <string, string> clusdbUpdates = this.PrepareUpdates(tmpClusdbUpdates);

            lastAttemptedOperationName = "OpenCluster";
            using (AmCluster amCluster = AmCluster.Open())
            {
                lastAttemptedOperationName = "GetClusterKey";
                using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(amCluster.Handle, null, null, DxStoreKeyAccessMode.Write, false))
                {
                    lastAttemptedOperationName = "OpenAmRootKey";
                    using (IDistributedStoreKey distributedStoreKey = clusterKey.OpenKey("ExchangeActiveManager", DxStoreKeyAccessMode.Write, false, null))
                    {
                        lastAttemptedOperationName = "OpenAmRootKey";
                        using (IDistributedStoreKey distributedStoreKey2 = distributedStoreKey.OpenKey("LastLog", DxStoreKeyAccessMode.CreateIfNotExist, false, null))
                        {
                            lastAttemptedOperationName = "CreateBatch";
                            using (IDistributedStoreBatchRequest distributedStoreBatchRequest = distributedStoreKey2.CreateBatchUpdateRequest())
                            {
                                lastAttemptedOperationName = "PopulateBatch";
                                this.PopulateBatch(distributedStoreKey2, distributedStoreBatchRequest, clusdbUpdates);
                                lastAttemptedOperationName = "ExecuteBatch";
                                distributedStoreBatchRequest.Execute(null);
                            }
                        }
                    }
                }
            }
        }
 // Token: 0x06000449 RID: 1097 RVA: 0x00016D00 File Offset: 0x00014F00
 internal AmPersistentClusdbState(IAmCluster cluster, string keyName)
 {
     using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(cluster.Handle, null, null, DxStoreKeyAccessMode.Write, false))
     {
         string keyName2 = "ExchangeActiveManager\\" + keyName;
         this.m_regHandle = clusterKey.OpenKey(keyName2, DxStoreKeyAccessMode.CreateIfNotExist, false, null);
     }
 }
Пример #7
0
 private void EnqueueShadowAction <T>(DistributedStoreKey key, RequestInfo req, Func <IDistributedStoreKey, bool, StoreKind, T> func)
 {
     if (!this.StoreSettings.IsShadowConfigured)
     {
         return;
     }
     lock (this.shadowLock)
     {
         Queue <Action> queue;
         int            maxAllowedLimit;
         if (req.OperationType == OperationType.Write)
         {
             queue           = this.shadowWriteQueue;
             maxAllowedLimit = RegistryParameters.DistributedStoreShadowMaxAllowedWriteQueueLength;
         }
         else
         {
             maxAllowedLimit = RegistryParameters.DistributedStoreShadowMaxAllowedReadQueueLength;
             if (req.OperationCategory == OperationCategory.OpenKey)
             {
                 queue = this.shadowOpenRequestsQueue;
             }
             else
             {
                 queue = this.shadowReadQueue;
             }
         }
         if (this.EnsureQueueLengthInLimit(queue, maxAllowedLimit, key, req))
         {
             if (!req.IsGetBaseKeyRequest && !req.IsCloseKeyRequest && key.ShadowStoreKey == null)
             {
                 queue.Enqueue(delegate
                 {
                     using (IDistributedStoreKey baseKeyByStoreKind = this.GetBaseKeyByStoreKind(DxStoreKeyAccessMode.Write, key.Context, this.StoreSettings.Shadow))
                     {
                         if (baseKeyByStoreKind != null)
                         {
                             key.ShadowStoreKey = baseKeyByStoreKind.OpenKey(key.FullKeyName, DxStoreKeyAccessMode.Write, false, null);
                         }
                     }
                 });
             }
             queue.Enqueue(delegate
             {
                 this.PerformAction <T>(key, req, false, func);
             });
             if (!this.isShadowActionExecuting)
             {
                 this.isShadowActionExecuting = true;
                 ThreadPool.QueueUserWorkItem(delegate(object o)
                 {
                     this.ExecuteShadowActions();
                 });
             }
         }
     }
 }
        public AmClusterNodeStatusAccessor(IAmCluster cluster, AmServerName nodeName, DxStoreKeyAccessMode mode = DxStoreKeyAccessMode.Read)
        {
            this.ServerName = nodeName;
            string keyName = string.Format("{0}\\{1}", "ExchangeActiveManager\\NodeState", nodeName.NetbiosName);

            using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(cluster.Handle, null, null, mode, false))
            {
                this.distributedStoreKey = clusterKey.OpenKey(keyName, mode, false, null);
            }
        }
Пример #9
0
 public static IEnumerable <string> GetSubkeyNames(this IDistributedStoreKey parentKey, string subkeyName, ReadWriteConstraints constraints)
 {
     using (IDistributedStoreKey distributedStoreKey = parentKey.OpenKey(subkeyName, DxStoreKeyAccessMode.Read, true, constraints))
     {
         if (distributedStoreKey != null)
         {
             return(distributedStoreKey.GetSubkeyNames(constraints));
         }
     }
     return(null);
 }
 // Token: 0x060008A2 RID: 2210 RVA: 0x00029138 File Offset: 0x00027338
 public void Open(string targetServer)
 {
     this.m_hCluster = ClusapiMethods.OpenCluster(targetServer);
     if (this.m_hCluster == null || this.m_hCluster.IsInvalid)
     {
         Marshal.GetLastWin32Error();
         throw new Win32Exception();
     }
     using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(this.ClusterHandle, null, targetServer, DxStoreKeyAccessMode.Write, false))
     {
         this.m_regHandle = clusterKey.OpenKey("Exchange\\DagNetwork", DxStoreKeyAccessMode.CreateIfNotExist, false, null);
     }
 }
        // Token: 0x06000756 RID: 1878 RVA: 0x00023E94 File Offset: 0x00022094
        private void DeleteTimeStampsInternal(AmClusterHandle clusterHandle)
        {
            using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(clusterHandle, null, null, DxStoreKeyAccessMode.Write, false))
            {
                using (IDistributedStoreKey distributedStoreKey = clusterKey.OpenKey("ExchangeActiveManager", DxStoreKeyAccessMode.Write, true, null))
                {
                    if (distributedStoreKey != null)
                    {
                        using (IDistributedStoreKey distributedStoreKey2 = distributedStoreKey.OpenKey("LastLog", DxStoreKeyAccessMode.Write, true, null))
                        {
                            if (distributedStoreKey2 != null)
                            {
                                using (IDistributedStoreBatchRequest distributedStoreBatchRequest = distributedStoreKey2.CreateBatchUpdateRequest())
                                {
                                    foreach (Database database in this.m_databases)
                                    {
                                        string name         = database.Name;
                                        string text         = database.Guid.ToString();
                                        string propertyName = AmDbState.ConstructLastLogTimeStampProperty(text);
                                        string value        = distributedStoreKey2.GetValue(propertyName, null, null);
                                        if (value != null)
                                        {
                                            ClusterBatchLastLogGenDeleter.Tracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "LastLogGeneration time stamp for database [{0} ({1})] found with value '{2}'.", name, text, value);
                                            this.m_logger.AppendLogMessage("Deleting LastLogGeneration time stamp from cluster registry for database [{0} ({1})] with existing value: '{2}'.", new object[]
                                            {
                                                name,
                                                text,
                                                value
                                            });
                                            distributedStoreBatchRequest.DeleteValue(propertyName);
                                        }
                                        else
                                        {
                                            ClusterBatchLastLogGenDeleter.Tracer.TraceDebug <string, string>((long)this.GetHashCode(), "LastLogGeneration time stamp for database [{0} ({1})] does not exist.", name, text);
                                        }
                                    }
                                    distributedStoreBatchRequest.Execute(null);
                                    goto IL_151;
                                }
                            }
                            ClusterBatchLastLogGenDeleter.Tracer.TraceDebug <string, string>((long)this.GetHashCode(), "ActiveManager LastLog key '{0}\\{1}' does not exist in the cluster registry. Skipping deletion.", "ExchangeActiveManager", "LastLog");
IL_151:
                            goto IL_178;
                        }
                    }
                    ClusterBatchLastLogGenDeleter.Tracer.TraceDebug <string>((long)this.GetHashCode(), "ActiveManager root key '{0}' does not exist in the cluster registry. Skipping deletion.", "ExchangeActiveManager");
                    IL_178 :;
                }
            }
        }
Пример #12
0
 public void SetClusterHandle(AmClusterHandle handle)
 {
     if (this.rootKey != null)
     {
         this.rootKey.Dispose();
         this.rootKey = null;
     }
     this.Handle = null;
     using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(handle, null, null, DxStoreKeyAccessMode.Write, false))
     {
         this.rootKey = clusterKey.OpenKey(this.Root, DxStoreKeyAccessMode.CreateIfNotExist, false, null);
         this.Handle  = handle;
     }
 }
Пример #13
0
		private void MonitorEvents()
		{
			AmClusterNotifyHandle amClusterNotifyHandle = null;
			IDistributedStoreKey distributedStoreKey = null;
			IDistributedStoreChangeNotify distributedStoreChangeNotify = null;
			try
			{
				ClusterNotifyFlags networkClusterNotificationMask = RegistryParameters.NetworkClusterNotificationMask;
				NetworkManager.TraceDebug("SettingClusterMask as 0x{0:x}", new object[]
				{
					networkClusterNotificationMask
				});
				amClusterNotifyHandle = ClusapiMethods.CreateClusterNotifyPort(AmClusterNotifyHandle.InvalidHandle, this.ClusterHandle, networkClusterNotificationMask, IntPtr.Zero);
				if (amClusterNotifyHandle == null || amClusterNotifyHandle.IsInvalid)
				{
					int lastWin32Error = Marshal.GetLastWin32Error();
					NetworkManager.TraceError("CreateClusterNotifyPort failed. Error code 0x{0:X8}", new object[]
					{
						lastWin32Error
					});
					throw new ClusCommonTransientException("CreateClusterNotifyPort", new Win32Exception(lastWin32Error));
				}
				using (IDistributedStoreKey clusterKey = DistributedStore.Instance.GetClusterKey(this.ClusterHandle, null, null, DxStoreKeyAccessMode.Write, false))
				{
					distributedStoreKey = clusterKey.OpenKey("Exchange\\DagNetwork", DxStoreKeyAccessMode.CreateIfNotExist, false, null);
				}
				this.RegisterForChangeNotification(distributedStoreKey, amClusterNotifyHandle);
				TimeSpan t = new TimeSpan(0, 0, RegistryParameters.NetworkStatusPollingPeriodInSecs);
				while (this.m_clusterHandlesAreValid && !this.m_shutdown)
				{
					StringBuilder stringBuilder = new StringBuilder(256);
					uint num = Convert.ToUInt32(stringBuilder.Capacity);
					IntPtr zero = IntPtr.Zero;
					ClusterNotifyFlags clusterNotifyFlags;
					int clusterNotify = ClusapiMethods.GetClusterNotify(amClusterNotifyHandle, out zero, out clusterNotifyFlags, stringBuilder, ref num, 3000U);
					if (this.m_shutdown)
					{
						break;
					}
					if (this.m_netMap == null)
					{
						if (!this.TryDriveMapRefresh())
						{
							break;
						}
					}
					else if (clusterNotify == 258)
					{
						if (t < ExDateTime.TimeDiff(ExDateTime.Now, this.m_mapLoadTime) && !this.TryDriveMapRefresh())
						{
							break;
						}
					}
					else if (clusterNotify != 0)
					{
						NetworkManager.TraceDebug("GetClusterNotify() returned unexpected status code 0x{0:X)", new object[]
						{
							clusterNotify
						});
					}
					else
					{
						string text = stringBuilder.ToString();
						NetworkManager.TraceDebug("GetClusterNotify() returned notifyKey={0}, filterType=0x{1:x}, resName={2}", new object[]
						{
							zero,
							clusterNotifyFlags,
							text
						});
						if ((clusterNotifyFlags & ~(ClusterNotifyFlags.CLUSTER_CHANGE_NODE_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_REGISTRY_NAME | ClusterNotifyFlags.CLUSTER_CHANGE_REGISTRY_ATTRIBUTES | ClusterNotifyFlags.CLUSTER_CHANGE_REGISTRY_VALUE | ClusterNotifyFlags.CLUSTER_CHANGE_REGISTRY_SUBTREE | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_DELETED | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_ADDED | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_GROUP_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_GROUP_DELETED | ClusterNotifyFlags.CLUSTER_CHANGE_GROUP_ADDED | ClusterNotifyFlags.CLUSTER_CHANGE_GROUP_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_TYPE_DELETED | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_TYPE_ADDED | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_TYPE_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_CLUSTER_RECONNECT | ClusterNotifyFlags.CLUSTER_CHANGE_QUORUM_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_CLUSTER_PROPERTY)) != ~(ClusterNotifyFlags.CLUSTER_CHANGE_NODE_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_NODE_DELETED | ClusterNotifyFlags.CLUSTER_CHANGE_NODE_ADDED | ClusterNotifyFlags.CLUSTER_CHANGE_NODE_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_REGISTRY_NAME | ClusterNotifyFlags.CLUSTER_CHANGE_REGISTRY_ATTRIBUTES | ClusterNotifyFlags.CLUSTER_CHANGE_REGISTRY_VALUE | ClusterNotifyFlags.CLUSTER_CHANGE_REGISTRY_SUBTREE | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_DELETED | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_ADDED | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_GROUP_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_GROUP_DELETED | ClusterNotifyFlags.CLUSTER_CHANGE_GROUP_ADDED | ClusterNotifyFlags.CLUSTER_CHANGE_GROUP_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_TYPE_DELETED | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_TYPE_ADDED | ClusterNotifyFlags.CLUSTER_CHANGE_RESOURCE_TYPE_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_CLUSTER_RECONNECT | ClusterNotifyFlags.CLUSTER_CHANGE_NETWORK_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_NETWORK_DELETED | ClusterNotifyFlags.CLUSTER_CHANGE_NETWORK_ADDED | ClusterNotifyFlags.CLUSTER_CHANGE_NETWORK_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_NETINTERFACE_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_NETINTERFACE_DELETED | ClusterNotifyFlags.CLUSTER_CHANGE_NETINTERFACE_ADDED | ClusterNotifyFlags.CLUSTER_CHANGE_NETINTERFACE_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_QUORUM_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_CLUSTER_STATE | ClusterNotifyFlags.CLUSTER_CHANGE_CLUSTER_PROPERTY | ClusterNotifyFlags.CLUSTER_CHANGE_HANDLE_CLOSE) && !this.TryDriveMapRefresh())
						{
							break;
						}
					}
				}
			}
			finally
			{
				if (amClusterNotifyHandle != null)
				{
					amClusterNotifyHandle.Dispose();
					amClusterNotifyHandle = null;
				}
				if (distributedStoreChangeNotify != null)
				{
					distributedStoreChangeNotify.Dispose();
				}
				if (distributedStoreKey != null)
				{
					distributedStoreKey.Dispose();
				}
			}
		}
Пример #14
0
 public static IDistributedStoreKey OpenOrCreateKey(this IDistributedStoreKey key, string keyName, bool isIgnoreIfNotExist = false, ReadWriteConstraints constraints = null)
 {
     return(key.OpenKey(keyName, DxStoreKeyAccessMode.CreateIfNotExist, isIgnoreIfNotExist, constraints));
 }