// 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: 0x06000536 RID: 1334 RVA: 0x0001393C File Offset: 0x00011B3C private IDistributedStoreKey OpenKeyInternal(string subKeyName, DxStoreKeyAccessMode mode, bool isIgnoreIfNotExist) { AmClusterRegkeyHandle amClusterRegkeyHandle = null; AmClusterRegkeyHandle keyHandle = this.KeyHandle; RegSAM regSam = ClusterDbKey.GetRegSam(mode); int num = ClusapiMethods.ClusterRegOpenKey(keyHandle, subKeyName, regSam, out amClusterRegkeyHandle); if (mode == DxStoreKeyAccessMode.CreateIfNotExist && (num == 2 || num == 3)) { uint num2; num = ClusapiMethods.ClusterRegCreateKey(keyHandle, subKeyName, 0U, regSam, IntPtr.Zero, out amClusterRegkeyHandle, out num2); } if (num == 0) { return(new ClusterDbKey(amClusterRegkeyHandle, this.ClusterHandle)); } if (amClusterRegkeyHandle != null && !amClusterRegkeyHandle.IsInvalid) { amClusterRegkeyHandle.Dispose(); } amClusterRegkeyHandle = null; if (!isIgnoreIfNotExist) { throw new ClusterApiException("ClusterRegOpenKey", new Win32Exception(num)); } return(null); }
// Token: 0x0600052C RID: 1324 RVA: 0x000135F4 File Offset: 0x000117F4 public IEnumerable <string> GetSubkeyNames(ReadWriteConstraints constraints) { List <string> list = new List <string>(); int num = 128; int num2 = 0; int num4; for (;;) { StringBuilder stringBuilder = new StringBuilder(num); int num3 = num; num4 = ClusapiMethods.ClusterRegEnumKey(this.KeyHandle, num2, stringBuilder, ref num3, IntPtr.Zero); if (234 == num4) { num = num3 + 1; stringBuilder = new StringBuilder(num); num4 = ClusapiMethods.ClusterRegEnumKey(this.KeyHandle, num2, stringBuilder, ref num3, IntPtr.Zero); } if (num4 != 0) { break; } list.Add(stringBuilder.ToString()); num2++; } if (259 != num4) { throw AmExceptionHelper.ConstructClusterApiException(num4, "ClusterRegEnumKey()", new object[0]); } return(list.ToArray()); }
// Token: 0x06000755 RID: 1877 RVA: 0x00023DE4 File Offset: 0x00021FE4 public void DeleteTimeStamps() { if (this.m_databases == null || this.m_databases.Count == 0) { ClusterBatchLastLogGenDeleter.Tracer.TraceDebug((long)this.GetHashCode(), "No databases specified, so skipping cluster batch timestamp deletion."); return; } AmClusterHandle amClusterHandle; if (this.m_cluster == null) { amClusterHandle = ClusapiMethods.OpenCluster(null); } else { amClusterHandle = this.m_cluster.Handle; } if (amClusterHandle.IsInvalid) { Exception ex = new ClusterApiException("OpenCluster", new Win32Exception()); ClusterBatchLastLogGenDeleter.Tracer.TraceError <Exception>((long)this.GetHashCode(), "The cluster handle is invalid! Exception: {0}", ex); throw ex; } try { this.DeleteTimeStampsInternal(amClusterHandle); } finally { if (this.m_cluster == null) { amClusterHandle.Close(); } } }
// Token: 0x06000528 RID: 1320 RVA: 0x00013480 File Offset: 0x00011680 public bool SetValue(string propertyName, object propertyValue, RegistryValueKind valueKind, bool isBestEffort, ReadWriteConstraints constraints) { bool result = false; using (ClusdbMarshalledProperty clusdbMarshalledProperty = ClusdbMarshalledProperty.Create(propertyName, propertyValue, valueKind)) { if (clusdbMarshalledProperty != null) { int num = ClusapiMethods.ClusterRegSetValue(this.KeyHandle, clusdbMarshalledProperty.PropertyName, clusdbMarshalledProperty.ValueKind, clusdbMarshalledProperty.PropertyValueIntPtr, clusdbMarshalledProperty.PropertyValueSize); if (num != 0) { if (!isBestEffort) { throw AmExceptionHelper.ConstructClusterApiException(num, "ClusterRegSetValue()", new object[0]); } } else { result = true; } } else if (!isBestEffort) { string typeName = (propertyValue != null) ? propertyValue.GetType().Name : "<null>"; throw new ClusterApiException("ClusterRegSetValue(unsupported registry type)", new ClusterUnsupportedRegistryTypeException(typeName)); } } return(result); }
// Token: 0x060008B1 RID: 2225 RVA: 0x000299D0 File Offset: 0x00027BD0 public static bool IsNodeClustered(AmServerName serverName) { string nodeName = serverName.Fqdn; if (serverName.IsLocalComputerName) { nodeName = null; } AmNodeClusterState dwClusStatus = AmNodeClusterState.NotInstalled; int dwError = -1; try { Action invokableAction = delegate() { dwError = ClusapiMethods.GetNodeClusterState(nodeName, ref dwClusStatus); }; InvokeWithTimeout.Invoke(invokableAction, TimeSpan.FromSeconds((double)RegistryParameters.RemoteClusterCallTimeoutInSec)); } catch (TimeoutException) { dwError = 1460; } if (dwError != 0) { throw new ExClusTransientException("IsNodeClustered", new Win32Exception(dwError)); } return(dwClusStatus == AmNodeClusterState.Running || dwClusStatus == AmNodeClusterState.NotRunning); }
public DistributedStore.Context ConstructContext(string nodeName) { return(new DistributedStore.Context { ChannelFactory = null, ClusterHandle = ClusapiMethods.OpenCluster(nodeName), NodeName = nodeName }); }
// Token: 0x060004FC RID: 1276 RVA: 0x00012FB4 File Offset: 0x000111B4 public void DeleteValue(string propertyName) { int num = ClusapiMethods.ClusterRegBatchAddCommand(this.batchHandle, CLUSTER_REG_COMMAND.CLUSREG_DELETE_VALUE, propertyName, RegistryValueKind.Unknown, IntPtr.Zero, 0); if (num != 0) { throw AmExceptionHelper.ConstructClusterApiException(num, "ClusterRegBatchAddCommand(CLUSREG_DELETE_VALUE)", new object[0]); } Interlocked.Increment(ref this.totalCommands); }
// Token: 0x06000533 RID: 1331 RVA: 0x000138B8 File Offset: 0x00011AB8 internal static IDistributedStoreKey GetBaseKey(AmClusterHandle clusterHandle, DxStoreKeyAccessMode mode) { RegSAM regSam = ClusterDbKey.GetRegSam(mode); AmClusterRegkeyHandle clusterKey = ClusapiMethods.GetClusterKey(clusterHandle, regSam); if (clusterKey == null || clusterKey.IsInvalid) { throw AmExceptionHelper.ConstructClusterApiExceptionNoErr("GetClusterKey", new object[0]); } return(new ClusterDbKey(clusterKey, clusterHandle)); }
// Token: 0x060004F6 RID: 1270 RVA: 0x00012E40 File Offset: 0x00011040 public ClusdbBatchRequest(ClusterDbKey containerKey) { AmClusterBatchHandle amClusterBatchHandle = null; int num = ClusapiMethods.ClusterRegCreateBatch(containerKey.KeyHandle, out amClusterBatchHandle); if (num != 0 || amClusterBatchHandle.IsInvalid) { throw AmExceptionHelper.ConstructClusterApiException(num, "ClusterRegCreateBatch()", new object[0]); } this.batchHandle = amClusterBatchHandle; this.ContainerKey = containerKey; }
// 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: 0x0600052B RID: 1323 RVA: 0x000135B4 File Offset: 0x000117B4 public bool DeleteValue(string propertyName, bool isIgnoreIfNotExist, ReadWriteConstraints constraints) { if (isIgnoreIfNotExist && !this.IsPropertyExists(propertyName, constraints)) { return(false); } int num = ClusapiMethods.ClusterRegDeleteValue(this.KeyHandle, propertyName); if (num != 0) { throw AmExceptionHelper.ConstructClusterApiException(num, "ClusterRegDeleteValue()", new object[0]); } return(true); }
// Token: 0x06000537 RID: 1335 RVA: 0x000139C4 File Offset: 0x00011BC4 private bool DeleteKeyInternal(string keyName, ReadWriteConstraints constraints) { IEnumerable <string> subkeyNames = this.GetSubkeyNames(keyName, constraints); foreach (string path in subkeyNames) { this.DeleteKeyInternal(Path.Combine(keyName, path), constraints); } int num = ClusapiMethods.ClusterRegDeleteKey(this.KeyHandle, keyName); if (num != 2 && num != 0) { throw new ClusterApiException("ClusterRegDeleteKey", new Win32Exception(num)); } return(true); }
// Token: 0x060004FB RID: 1275 RVA: 0x00012F34 File Offset: 0x00011134 public void SetValue(string propertyName, object propertyValue, RegistryValueKind valueKind) { ClusdbMarshalledProperty clusdbMarshalledProperty = ClusdbMarshalledProperty.Create(propertyName, propertyValue, valueKind); if (clusdbMarshalledProperty == null) { throw new ClusterApiException("WfcDataStoreBatch.SetValue - property value is null", new ClusterUnsupportedRegistryTypeException("null")); } this.properties.Add(clusdbMarshalledProperty); int num = ClusapiMethods.ClusterRegBatchAddCommand(this.batchHandle, CLUSTER_REG_COMMAND.CLUSREG_SET_VALUE, clusdbMarshalledProperty.PropertyName, clusdbMarshalledProperty.ValueKind, clusdbMarshalledProperty.PropertyValueIntPtr, clusdbMarshalledProperty.PropertyValueSize); if (num != 0) { throw AmExceptionHelper.ConstructClusterApiException(num, "ClusterRegBatchAddCommand(CLUSREG_SET_VALUE)", new object[0]); } Interlocked.Increment(ref this.totalCommands); }
private void RegisterForChangeNotification(IDistributedStoreKey dsKey, AmClusterNotifyHandle hChange) { AmClusterRegkeyHandle clusdbKeyHandle = this.GetClusdbKeyHandle(dsKey); if (clusdbKeyHandle != null && !clusdbKeyHandle.IsInvalid) { ClusterNotifyFlags dwFilter = ClusterNotifyFlags.CLUSTER_CHANGE_REGISTRY_VALUE; IntPtr dwNotifyKey = (IntPtr)1; int num = ClusapiMethods.RegisterClusterNotify(hChange, dwFilter, clusdbKeyHandle, dwNotifyKey); if (num != 0) { NetworkManager.TraceError("RegisterClusterNotify for reg notification 0x{0:X8}", new object[] { num }); throw AmExceptionHelper.ConstructClusterApiException(num, "RegisterClusterNotify(Network Registry)", new object[0]); } } }
// Token: 0x06000538 RID: 1336 RVA: 0x00013A44 File Offset: 0x00011C44 private object GetRaw(AmClusterRegkeyHandle hKey, string valueName, out bool doesValueExist, out RegistryValueKind valueKind) { IntPtr intPtr = IntPtr.Zero; int num = 1024; object result; try { intPtr = Marshal.AllocHGlobal(num); int num2 = ClusapiMethods.ClusterRegQueryValue(hKey, valueName, out valueKind, intPtr, ref num); if (num2 == 234) { int num3 = 0; do { Marshal.FreeHGlobal(intPtr); intPtr = Marshal.AllocHGlobal(num); num2 = ClusapiMethods.ClusterRegQueryValue(hKey, valueName, out valueKind, intPtr, ref num); }while (num2 == 234 && num3++ < 3); } if (num2 == 2 || num2 == 1018) { doesValueExist = false; result = null; } else { if (num2 != 0) { throw new ClusterApiException("GetRaw()", new Win32Exception(num2)); } doesValueExist = true; result = this.ParseRegistryValue(valueKind, intPtr, num); } } finally { if (intPtr != IntPtr.Zero) { Marshal.FreeHGlobal(intPtr); } } return(result); }
// Token: 0x0600052D RID: 1325 RVA: 0x00013694 File Offset: 0x00011894 public IEnumerable <Tuple <string, RegistryValueKind> > GetValueInfos(ReadWriteConstraints constraints) { List <Tuple <string, RegistryValueKind> > list = new List <Tuple <string, RegistryValueKind> >(); int num = 128; int num2 = 0; int item = 0; int num5; for (;;) { StringBuilder stringBuilder = new StringBuilder(num); int num3 = num; int num4 = 0; num5 = ClusapiMethods.ClusterRegEnumValue(this.KeyHandle, num2, stringBuilder, ref num3, ref item, IntPtr.Zero, ref num4); if (259 == num5) { return(list); } if (234 != num5 && num5 != 0) { break; } if (num3 > num) { num = num3 + 1; num4 = 0; stringBuilder = new StringBuilder(num); num5 = ClusapiMethods.ClusterRegEnumValue(this.KeyHandle, num2, stringBuilder, ref num3, ref item, IntPtr.Zero, ref num4); } if (234 != num5 && num5 != 0) { goto Block_6; } list.Add(new Tuple <string, RegistryValueKind>(stringBuilder.ToString(), (RegistryValueKind)item)); num2++; } throw AmExceptionHelper.ConstructClusterApiException(num5, "ClusterRegEnumValue(first)", new object[0]); Block_6: throw AmExceptionHelper.ConstructClusterApiException(num5, "ClusterRegEnumValue(second)", new object[0]); }
private bool RefreshClusterHandles() { this.CloseClusterHandles(); Exception ex = null; try { this.m_hCluster = ClusapiMethods.OpenCluster(null); if (this.m_hCluster == null || this.m_hCluster.IsInvalid) { int lastWin32Error = Marshal.GetLastWin32Error(); NetworkManager.TraceError("OpenCluster() failed with error {0}.", new object[] { lastWin32Error }); return false; } this.m_clusterHandlesAreValid = true; return true; } catch (ClusterException ex2) { ex = ex2; } catch (TransientException ex3) { ex = ex3; } if (ex != null) { NetworkManager.TraceError("RefreshClusterHandles() failed with error {0}.", new object[] { ex }); } return false; }
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(); } } }