public void SetValue <T>(string keyName, string propertyName, T propetyValue) { using (IDistributedStoreKey distributedStoreKey = this.OpenRegKey(keyName, true, false)) { distributedStoreKey.SetValue(propertyName, propetyValue, false, null); } }
// Token: 0x06001BDD RID: 7133 RVA: 0x000787A8 File Offset: 0x000769A8 private void PopulateBatch(IDistributedStoreKey stateHandle, IDistributedStoreBatchRequest batchHandle, Dictionary <string, string> clusdbUpdates) { string propertyValue = ExDateTime.UtcNow.ToString("s"); foreach (string text in clusdbUpdates.Keys) { bool flag = false; long num = 0L; long num2 = 0L; bool flag2 = false; string text2 = clusdbUpdates[text]; string value = stateHandle.GetValue(text, null, out flag, null); if (flag) { flag2 = true; } if (text2 != null && (!flag || !long.TryParse(text2, out num) || !long.TryParse(value, out num2) || num > num2)) { ClusterBatchWriter.Tracer.TraceError <string, long, long>(0L, "ClusterBatchWriter prepping update for db {0} from {1} to {2}", text, num2, num); batchHandle.SetValue(text, text2, RegistryValueKind.Unknown); flag2 = true; } if (flag2) { string propertyName = AmDbState.ConstructLastLogTimeStampProperty(text); batchHandle.SetValue(propertyName, propertyValue, RegistryValueKind.Unknown); } } batchHandle.SetValue(AmServerName.LocalComputerName.NetbiosName, propertyValue, RegistryValueKind.Unknown); }
// 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); } } } } } }
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); }
internal void SetDxStorePrivateProperty <T>(string propertyName, T propertyValue) { using (IDistributedStoreKey baseKey = DistributedStore.Instance.DxStoreKeyFactoryInstance.GetBaseKey(DxStoreKeyAccessMode.Write, null, null, true)) { baseKey.SetValue(propertyName, propertyValue, false, null); } }
internal IDistributedStoreKey GetClusterKey(AmClusterHandle clusterHandle, CachedChannelFactory <IDxStoreAccess> channelFactory = null, string nodeName = null, DxStoreKeyAccessMode mode = DxStoreKeyAccessMode.Read, bool isBestEffort = false) { IDistributedStoreKey result = null; try { if (this.StoreSettings.IsCompositeModeEnabled || RegistryParameters.DistributedStoreIsLogPerformanceForSingleStore) { result = this.GetClusterCompositeKey(clusterHandle, channelFactory, nodeName, mode); } else { DistributedStore.Context context = new DistributedStore.Context { ClusterHandle = clusterHandle, ChannelFactory = channelFactory, NodeName = nodeName }; result = this.GetBaseKeyByStoreKind(mode, context, this.StoreSettings.Primary); } } catch (ClusterException) { if (!isBestEffort) { throw; } } return(result); }
// Token: 0x060005BB RID: 1467 RVA: 0x000158A4 File Offset: 0x00013AA4 public IDistributedStoreKey OpenKey(string subkeyName, DxStoreKeyAccessMode mode, bool isIgnoreIfNotExist, ReadWriteConstraints constraints) { return(this.BaseParameters.KeyFactory.RunOperationAndTranslateException <IDistributedStoreKey>(OperationCategory.OpenKey, Path.Combine(this.FullKeyName, subkeyName), delegate() { ReadOptions readOptions = this.GetReadOptions(constraints); WriteOptions writeOptions = this.GetWriteOptions(constraints); DxStoreAccessRequest.CheckKey checkKey = this.CreateRequest <DxStoreAccessRequest.CheckKey>(); checkKey.IsCreateIfNotExist = (mode == DxStoreKeyAccessMode.CreateIfNotExist); checkKey.SubkeyName = subkeyName; checkKey.ReadOptions = readOptions; checkKey.WriteOptions = writeOptions; DxStoreAccessReply.CheckKey checkKey2 = this.BaseParameters.Client.CheckKey(checkKey, null); this.SetReadResult(constraints, checkKey2.ReadResult); this.SetWriteResult(constraints, checkKey2.WriteResult); IDistributedStoreKey result = null; if (!checkKey2.IsExist) { if (!isIgnoreIfNotExist) { throw new DxStoreKeyNotFoundException(subkeyName); } } else { result = new DxStoreKey(Path.Combine(this.FullKeyName, subkeyName), mode, this.BaseParameters); } return result; }, false)); }
// Token: 0x060005A3 RID: 1443 RVA: 0x00014FD8 File Offset: 0x000131D8 private void ThrowIfKeyIsInvalid(IDistributedStoreKey key) { if (key == null) { throw new DxStoreKeyInvalidKeyException(this.FullKeyName); } }
private T PerformAction <T>(DistributedStoreKey key, RequestInfo req, bool isPrimary, Func <IDistributedStoreKey, bool, StoreKind, T> func) { IDistributedStoreKey arg = isPrimary ? key.PrimaryStoreKey : key.ShadowStoreKey; StoreKind storeKind = isPrimary ? this.StoreSettings.Primary : this.StoreSettings.Shadow; this.PerfTracker.UpdateStart(key, storeKind, isPrimary); Exception exception = null; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); T result; try { result = func(arg, isPrimary, storeKind); } catch (Exception ex) { exception = ex; throw; } finally { this.PerfTracker.UpdateFinish(key, storeKind, isPrimary, req, stopwatch.ElapsedMilliseconds, exception, false); } return(result); }
// Token: 0x06000542 RID: 1346 RVA: 0x00013C98 File Offset: 0x00011E98 public XElement GetXElementSnapshot(string keyName = null) { bool flag = false; if (this.clusterHandle == null || this.clusterHandle.IsInvalid) { this.clusterHandle = ClusapiMethods.OpenCluster(null); flag = true; } XElement xelementSnapshotInternal; try { using (IDistributedStoreKey distributedStoreKey = ClusterDbKey.GetBaseKey(this.clusterHandle, DxStoreKeyAccessMode.Read)) { this.baseKey = distributedStoreKey; xelementSnapshotInternal = this.GetXElementSnapshotInternal(keyName); } } finally { if (flag && this.clusterHandle != null && !this.clusterHandle.IsInvalid) { this.clusterHandle.Close(); this.clusterHandle = null; } } return(xelementSnapshotInternal); }
// Token: 0x06000447 RID: 1095 RVA: 0x00016BD0 File Offset: 0x00014DD0 protected override T GetDebugOptionInternal <T>(string serverName, string propertyName, T defaultValue, out bool doesValueExist) { doesValueExist = false; T result = defaultValue; try { if (serverName == null) { result = this.m_dbgOptionHandle.GetValue(propertyName, defaultValue, null); } else { using (IDistributedStoreKey distributedStoreKey = this.m_dbgOptionHandle.OpenKey(serverName, DxStoreKeyAccessMode.Read, true, null)) { if (distributedStoreKey != null) { result = distributedStoreKey.GetValue(propertyName, defaultValue, null); } } } } catch (ClusterException ex) { AmTrace.Debug("Ignoring cluster exception while trying to get debug option (serverName={0}, propertyName={1}, exception={2})", new object[] { serverName, propertyName, ex }); } return(result); }
// Token: 0x06000448 RID: 1096 RVA: 0x00016C60 File Offset: 0x00014E60 protected override bool SetDebugOptionInternal <T>(string serverName, string propertyName, T propertyValue) { try { if (serverName == null) { this.m_dbgOptionHandle.SetValue(propertyName, propertyValue, false, null); } else { using (IDistributedStoreKey distributedStoreKey = this.m_dbgOptionHandle.OpenKey(serverName, DxStoreKeyAccessMode.CreateIfNotExist, false, null)) { distributedStoreKey.SetValue(propertyName, propertyValue, false, null); } } return(true); } catch (ClusterException ex) { AmTrace.Debug("Ignoring cluster exception while trying to set debug option (serverName={0}, propertyName={1}, propertyValue={2}, exception={3})", new object[] { serverName, propertyName, propertyValue.ToString(), ex }); } return(false); }
public void DeleteValue(string keyName, string propertyName) { using (IDistributedStoreKey distributedStoreKey = this.OpenRegKey(keyName, false, true)) { distributedStoreKey.DeleteValue(propertyName, true, null); } }
// 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); } }
// 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); } }
public void SetKeyByRole(DistributedStoreKey compositeKey, bool isPrimary, IDistributedStoreKey key) { if (isPrimary) { compositeKey.PrimaryStoreKey = key; return; } compositeKey.ShadowStoreKey = key; }
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 IEnumerable <Tuple <string, RegistryValueKind> > GetValueInfos(string registryKey) { IEnumerable <Tuple <string, RegistryValueKind> > valueInfos; using (IDistributedStoreKey distributedStoreKey = this.OpenRegKey(registryKey, false, false)) { valueInfos = distributedStoreKey.GetValueInfos(null); } return(valueInfos); }
internal T GetDxStorePrivateProperty <T>(string propertyName, T defaultValue) { T value; using (IDistributedStoreKey baseKey = DistributedStore.Instance.DxStoreKeyFactoryInstance.GetBaseKey(DxStoreKeyAccessMode.Read, null, null, true)) { value = baseKey.GetValue(propertyName, defaultValue, null); } return(value); }
public IEnumerable <string> GetSubKeyNames(string registryKey) { IEnumerable <string> subkeyNames; using (IDistributedStoreKey distributedStoreKey = this.OpenRegKey(registryKey, false, false)) { subkeyNames = distributedStoreKey.GetSubkeyNames(null); } return(subkeyNames); }
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); } }
public static T GetValue <T>(this IDistributedStoreKey key, string propertyName, T defaultValue, out bool isValueExist, ReadWriteConstraints constriants = null) { RegistryValueKind registryValueKind; object value = key.GetValue(propertyName, out isValueExist, out registryValueKind, constriants); if (isValueExist) { return((T)((object)value)); } return(defaultValue); }
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: 0x0600053A RID: 1338 RVA: 0x00013B98 File Offset: 0x00011D98 private bool IsKeyExists(string subKeyName, ReadWriteConstraints constraints) { using (IDistributedStoreKey distributedStoreKey = this.OpenKey(subKeyName, DxStoreKeyAccessMode.Read, true, constraints)) { if (distributedStoreKey != null) { return(true); } } return(false); }
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)); }
// 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); } } }
// Token: 0x060005A4 RID: 1444 RVA: 0x00014FEC File Offset: 0x000131EC private IDistributedStoreKey OpenKeyInternal(string subKeyName, DxStoreKeyAccessMode mode, bool isIgnoreIfNotExist, ReadWriteConstraints constraints) { if (mode == DxStoreKeyAccessMode.CreateIfNotExist) { IDistributedStoreKey distributedStoreKey = this.OpenKeyFinal(subKeyName, DxStoreKeyAccessMode.Write, true, constraints); if (distributedStoreKey != null) { return(distributedStoreKey); } } return(this.OpenKeyFinal(subKeyName, mode, isIgnoreIfNotExist, constraints)); }
// 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); } }
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; } }
// 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 :; } } }