Example #1
0
        public bool MoveGroupToReplayEnabledNode(IsReplayRunning isReplayRunning, string resourceType, TimeSpan timeout, out string finalDestinationNode)
        {
            finalDestinationNode = null;
            if (resourceType == string.Empty)
            {
                return(this.MoveGroupToReplayEnabledNode(isReplayRunning, timeout, out finalDestinationNode));
            }
            IEnumerable <AmClusterResource> enumerable = this.EnumerateResourcesOfType(resourceType);
            AmClusterResource amClusterResource        = enumerable.ElementAtOrDefault(0);

            if (amClusterResource != null)
            {
                try
                {
                    AmServerName ownerNode = this.OwnerNode;
                    foreach (string text in amClusterResource.EnumeratePossibleOwnerNames())
                    {
                        AmServerName amServerName = new AmServerName(text);
                        if (!ownerNode.Equals(amServerName) && isReplayRunning(amServerName.Fqdn))
                        {
                            try
                            {
                                AmClusterGroup.MoveClusterGroupWithTimeout(ownerNode, amServerName, timeout);
                                if (this.OwnerNode.Equals(amServerName))
                                {
                                    finalDestinationNode = amServerName.Fqdn;
                                    return(true);
                                }
                            }
                            catch (ClusterException arg)
                            {
                                ExTraceGlobals.ClusterTracer.TraceError <string, string, ClusterException>((long)this.GetHashCode(), "MoveGroupToReplayEnabledNode: MoveGroup ({0}) to node {1} failed with exception: {2}.", this.Name, text, arg);
                            }
                        }
                    }
                    return(false);
                }
                finally
                {
                    foreach (AmClusterResource amClusterResource2 in enumerable)
                    {
                        amClusterResource2.Dispose();
                    }
                }
            }
            return(this.MoveGroupToReplayEnabledNode(isReplayRunning, timeout, out finalDestinationNode));
        }
Example #2
0
        private bool MoveGroupToReplayEnabledNode(IsReplayRunning isReplayRunning, TimeSpan timeout, out string finalDestinationNode)
        {
            DateTime     dateTime  = DateTime.UtcNow.Add(timeout);
            AmServerName ownerNode = this.OwnerNode;

            finalDestinationNode = ownerNode.NetbiosName;
            foreach (IAmClusterNode amClusterNode in this.OwningCluster.EnumerateNodes())
            {
                try
                {
                    if (!amClusterNode.Name.Equals(this.OwnerNode))
                    {
                        TimeSpan t = dateTime.Subtract(DateTime.UtcNow);
                        if (t > TimeSpan.Zero && amClusterNode.State == AmNodeState.Up && isReplayRunning(amClusterNode.Name.Fqdn))
                        {
                            try
                            {
                                AmServerName name = amClusterNode.Name;
                                AmClusterGroup.MoveClusterGroupWithTimeout(ownerNode, name, timeout);
                                if (this.OwnerNode.Equals(name))
                                {
                                    finalDestinationNode = name.Fqdn;
                                    return(true);
                                }
                            }
                            catch (ClusterException arg)
                            {
                                ExTraceGlobals.ClusterTracer.TraceError <string, AmServerName, ClusterException>((long)this.GetHashCode(), "MoveGroupToReplayEnabledNode: MoveGroup ({0}) to node {1} failed with exception: {2}.", this.Name, amClusterNode.Name, arg);
                            }
                        }
                    }
                }
                finally
                {
                    amClusterNode.Dispose();
                }
            }
            return(false);
        }