Пример #1
0
        internal AmNetworkState GetState(bool isThrowIfUnknown)
        {
            AmNetworkState clusterNetworkState = ClusapiMethods.GetClusterNetworkState(this.Handle);

            if (clusterNetworkState == AmNetworkState.Unavailable)
            {
                int       lastWin32Error = Marshal.GetLastWin32Error();
                Exception ex             = new Win32Exception(lastWin32Error);
                AmTrace.Debug("GetClusterNetworkState() returned error (rc={0}, message={1})", new object[]
                {
                    lastWin32Error,
                    ex
                });
                if (isThrowIfUnknown)
                {
                    throw AmExceptionHelper.ConstructClusterApiException(lastWin32Error, "GetClusterNetworkState()", new object[0]);
                }
            }
            return(clusterNetworkState);
        }
Пример #2
0
        public void MoveGroup(TimeSpan timeout, AmServerName destinationNode)
        {
            DateTime     t   = DateTime.UtcNow.Add(timeout);
            uint         num = 0U;
            AmGroupState amGroupState;
            AmServerName amServerName;

            this.GetStateAndOwningNode(out amGroupState, out amServerName);
            using (IAmClusterNode amClusterNode = this.OwningCluster.OpenNode(destinationNode))
            {
                num = ClusapiMethods.MoveClusterGroup(this.Handle, amClusterNode.Handle);
                goto IL_87;
            }
IL_4B:
            AmGroupState amGroupState2;
            AmServerName amServerName2;

            this.GetStateAndOwningNode(out amGroupState2, out amServerName2);
            if (amGroupState == amGroupState2)
            {
                num = 0U;
                goto IL_9C;
            }
            ExTraceGlobals.ClusterTracer.TraceDebug <string, AmGroupState, AmGroupState>((long)this.GetHashCode(), "MoveGroup: {0} is in progress (initial={1}, current={2}), waiting and polling again.", this.Name, amGroupState, amGroupState2);
            Thread.Sleep(1000);
IL_87:
            if (num == 997U && DateTime.UtcNow < t)
            {
                goto IL_4B;
            }
IL_9C:
            if (num != 0U)
            {
                throw AmExceptionHelper.ConstructClusterApiException((int)num, "MoveClusterGroup( name={0}, dest={1})", new object[]
                {
                    this.Name,
                    destinationNode.NetbiosName
                });
            }
        }
Пример #3
0
        // Token: 0x06000245 RID: 581 RVA: 0x0000AAC8 File Offset: 0x00008CC8
        private AmClusterRawData GetResourceControlData(AmClusterResourceControlCode code)
        {
            uint             num = 1024U;
            AmClusterRawData amClusterRawData = AmClusterRawData.Allocate(num);
            int num2 = ClusapiMethods.ClusterResourceControl(this.Handle, IntPtr.Zero, code, IntPtr.Zero, 0U, amClusterRawData.Buffer, num, out num);

            if (num2 == 234)
            {
                amClusterRawData.Dispose();
                amClusterRawData = AmClusterRawData.Allocate(num);
                num2             = ClusapiMethods.ClusterResourceControl(this.Handle, IntPtr.Zero, code, IntPtr.Zero, 0U, amClusterRawData.Buffer, num, out num);
            }
            if (num2 != 0)
            {
                amClusterRawData.Dispose();
                throw AmExceptionHelper.ConstructClusterApiException(num2, "ClusterResourceControl(controlcode={0})", new object[]
                {
                    code
                });
            }
            return(amClusterRawData);
        }
Пример #4
0
        // Token: 0x0600023B RID: 571 RVA: 0x0000A5C4 File Offset: 0x000087C4
        public void RemoveDependency(AmClusterResource childDependency)
        {
            string name = this.Name;
            uint   num  = ClusapiMethods.RemoveClusterResourceDependency(this.Handle, childDependency.Handle);

            if (num == 0U)
            {
                return;
            }
            int num2 = (int)num;

            if (num == 5002U)
            {
                AmClusterResource.Tracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "RemoveClusterResourceDependency( parent={0}, child={1}) returned a non-fatal error 0x{2:x}", this.Name, childDependency.Name, num2);
                return;
            }
            throw AmExceptionHelper.ConstructClusterApiException(num2, "RemoveClusterResourceDependency( parent={0}, child={1})", new object[]
            {
                this.Name,
                childDependency.Name
            });
        }
Пример #5
0
        internal bool WaitForEvent(out AmClusterEventInfo eventInfo, TimeSpan timeout)
        {
            ClusterNotifyFlags eventCode     = ~(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);
            StringBuilder      stringBuilder = new StringBuilder(1024);
            uint   num  = Convert.ToUInt32(stringBuilder.Capacity);
            IntPtr zero = IntPtr.Zero;
            int    num2 = 0;

            try
            {
                num2 = ClusapiMethods.GetClusterNotify(this.m_hChange, out zero, out eventCode, stringBuilder, ref num, Convert.ToUInt32(timeout.TotalMilliseconds));
            }
            catch (AccessViolationException innerException)
            {
                throw new ClusterApiException("GetClusterNotify", innerException);
            }
            if (num2 == 258)
            {
                eventInfo = null;
                return(false);
            }
            if (num2 == 0)
            {
                eventInfo = new AmClusterEventInfo(stringBuilder.ToString(), eventCode, zero);
                ExTraceGlobals.ClusterEventsTracer.TraceDebug <AmClusterEventInfo>((long)this.GetHashCode(), "WaitForEvent returns: {0}", eventInfo);
                return(true);
            }
            AmTrace.Error("GetClusterNotify returned error 0x{0:X8}", new object[]
            {
                num2
            });
            if (this.m_isClosed && num2 == 6)
            {
                AmTrace.Error("Cluster notification port handle is closed", new object[0]);
                eventInfo = null;
                return(false);
            }
            throw AmExceptionHelper.ConstructClusterApiException(num2, "GetClusterNotify()", new object[0]);
        }
Пример #6
0
        // Token: 0x06000216 RID: 534 RVA: 0x00009964 File Offset: 0x00007B64
        public string[] ParseMultipleStringsFromPropList(string propName)
        {
            List <string>     list = new List <string>(10);
            SafeHGlobalHandle safeHGlobalHandle;
            uint num2;
            uint num = ClusapiMethods.ResUtilFindMultiSzProperty(this.RawBuffer, this.BufferSize, propName, out safeHGlobalHandle, out num2);

            if (num != 2U)
            {
                if (num != 0U)
                {
                    throw AmExceptionHelper.ConstructClusterApiException((int)num, "ResUtilFindMultiSzProperty()", new object[0]);
                }
                IntPtr left = safeHGlobalHandle.DangerousGetHandle();
                int    num3 = 0;
                while ((long)num3 < (long)((ulong)num2))
                {
                    string text = Marshal.PtrToStringUni(AmClusterPropList.IntPtrAdd(left, num3));
                    list.Add(text);
                    num3 += (text.Length + 1) * 2;
                }
            }
            return(list.ToArray());
        }
Пример #7
0
        // Token: 0x06000241 RID: 577 RVA: 0x0000A6B4 File Offset: 0x000088B4
        public void SetAllPossibleOwnerNodes()
        {
            IEnumerable <IAmClusterNode> enumerable = null;
            ClusterApiException          ex         = null;

            try
            {
                enumerable = this.OwningCluster.EnumerateNodes();
                foreach (IAmClusterNode amClusterNode in enumerable)
                {
                    uint num = ClusapiMethods.AddClusterResourceNode(this.Handle, amClusterNode.Handle);
                    if (num != 0U && num != 5010U)
                    {
                        ex = AmExceptionHelper.ConstructClusterApiException((int)num, "AddClusterResourceNode( resource={0}, node={1} )", new object[]
                        {
                            this.Name,
                            amClusterNode.Name
                        });
                    }
                }
            }
            finally
            {
                if (enumerable != null)
                {
                    foreach (IAmClusterNode amClusterNode2 in enumerable)
                    {
                        amClusterNode2.Dispose();
                    }
                }
                if (ex != null)
                {
                    throw ex;
                }
            }
        }
        // Token: 0x0600026B RID: 619 RVA: 0x0000C614 File Offset: 0x0000A814
        internal static uint Win32ErrorCodeFromComException(COMException comException)
        {
            uint errorCode = (uint)comException.ErrorCode;

            return(AmExceptionHelper.Win32ErrorCodeFromHresult(errorCode));
        }
        // Token: 0x06000266 RID: 614 RVA: 0x0000C534 File Offset: 0x0000A734
        public static string GetExceptionGenericStringOrNoneString(Exception ex, Func <Exception, string> stringExtractor)
        {
            string message = (ex != null) ? stringExtractor(ex) : Strings.NoErrorSpecified;

            return(AmExceptionHelper.GetMessageOrNoneString(message));
        }
 // Token: 0x06000265 RID: 613 RVA: 0x0000C50E File Offset: 0x0000A70E
 public static string GetExceptionToStringOrNoneString(Exception ex)
 {
     return(AmExceptionHelper.GetExceptionGenericStringOrNoneString(ex, (Exception exception) => exception.ToString()));
 }
 // Token: 0x06000264 RID: 612 RVA: 0x0000C4E1 File Offset: 0x0000A6E1
 public static string GetExceptionMessageOrNoneString(Exception ex)
 {
     return(AmExceptionHelper.GetExceptionGenericStringOrNoneString(ex, (Exception exception) => exception.Message));
 }
 // Token: 0x06000273 RID: 627 RVA: 0x0000C794 File Offset: 0x0000A994
 internal static void HandleRetryExceptions(Exception e, ref int count, bool dbAccess, IAmCluster cluster)
 {
     AmExceptionHelper.HandleRetryExceptions(e, ref count, dbAccess, cluster, null);
 }
 // Token: 0x06000272 RID: 626 RVA: 0x0000C774 File Offset: 0x0000A974
 internal static void HandleRetryExceptions(Exception e, ref int count, IAmCluster cluster)
 {
     AmExceptionHelper.HandleRetryExceptions(e, ref count, false, cluster, null);
 }
        // Token: 0x0600026F RID: 623 RVA: 0x0000C6FC File Offset: 0x0000A8FC
        internal static ClusterApiException ConstructClusterApiExceptionNoErr(string methodName, params object[] methodParameters)
        {
            int lastWin32Error = Marshal.GetLastWin32Error();

            return(AmExceptionHelper.ConstructClusterApiException(lastWin32Error, methodName, methodParameters));
        }
        // Token: 0x0600021F RID: 543 RVA: 0x00009B74 File Offset: 0x00007D74
        internal static void Set <T>(string key, T oValue, AmClusterRegkeyHandle handle)
        {
            IntPtr intPtr  = IntPtr.Zero;
            IntPtr intPtr2 = IntPtr.Zero;

            try
            {
                int num;
                if (oValue is string)
                {
                    string text = oValue as string;
                    intPtr = Marshal.StringToHGlobalUni(text);
                    num    = ClusapiMethods.ClusterRegSetValue(handle, key, RegistryValueKind.String, intPtr, (text.Length + 1) * 2);
                }
                else if (oValue is string[])
                {
                    string[] array   = oValue as string[];
                    int      num2    = 0;
                    IntPtr   intPtr3 = IntPtr.Zero;
                    foreach (string text2 in array)
                    {
                        num2 += text2.Length + 1;
                    }
                    num2   *= 2;
                    intPtr2 = Marshal.AllocHGlobal(num2);
                    intPtr3 = intPtr2;
                    foreach (string text3 in array)
                    {
                        Marshal.Copy(text3.ToCharArray(), 0, intPtr3, text3.Length);
                        intPtr3 = new IntPtr(intPtr3.ToInt64() + (long)(text3.Length * 2));
                        Marshal.WriteInt16(intPtr3, '\0');
                        intPtr3 = new IntPtr(intPtr3.ToInt64() + 2L);
                    }
                    num = ClusapiMethods.ClusterRegSetValue(handle, key, RegistryValueKind.MultiString, intPtr2, num2);
                }
                else if (oValue is byte[])
                {
                    byte[] array4 = oValue as byte[];
                    intPtr2 = Marshal.AllocHGlobal(array4.Length);
                    Marshal.Copy(array4, 0, intPtr2, array4.Length);
                    num = ClusapiMethods.ClusterRegSetValue(handle, key, RegistryValueKind.Binary, intPtr2, array4.Length);
                }
                else if (oValue is int)
                {
                    intPtr2 = Marshal.AllocHGlobal(4);
                    Marshal.WriteInt32(intPtr2, Convert.ToInt32(oValue));
                    num = ClusapiMethods.ClusterRegSetValue(handle, key, RegistryValueKind.DWord, intPtr2, 4);
                }
                else if (oValue is uint)
                {
                    intPtr2 = Marshal.AllocHGlobal(4);
                    Marshal.WriteInt32(intPtr2, (int)Convert.ToUInt32(oValue));
                    num = ClusapiMethods.ClusterRegSetValue(handle, key, RegistryValueKind.DWord, intPtr2, 4);
                }
                else if (oValue is long)
                {
                    intPtr2 = Marshal.AllocHGlobal(8);
                    Marshal.WriteInt64(intPtr2, Convert.ToInt64(oValue));
                    num = ClusapiMethods.ClusterRegSetValue(handle, key, RegistryValueKind.QWord, intPtr2, 8);
                }
                else
                {
                    if (!(oValue is ulong))
                    {
                        throw new ClusterUnsupportedRegistryTypeException(typeof(T).ToString());
                    }
                    intPtr2 = Marshal.AllocHGlobal(8);
                    Marshal.WriteInt64(intPtr2, (long)Convert.ToUInt64(oValue));
                    num = ClusapiMethods.ClusterRegSetValue(handle, key, RegistryValueKind.QWord, intPtr2, 8);
                }
                if (num != 0)
                {
                    throw AmExceptionHelper.ConstructClusterApiException(num, "ClusterRegSetValue()", new object[0]);
                }
            }
            finally
            {
                if (intPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(intPtr);
                }
                if (intPtr2 != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(intPtr2);
                }
            }
        }