private void PerformTargetServerValidation()
        {
            DatabaseTasksHelper.CheckServerObjectForCopyTask(this.ActivateOnServer, new Task.TaskErrorLoggingDelegate(base.WriteError), this.m_targetServer);
            if (this.CommandType == MoveActiveMailboxDatabase.CommandTypes.MoveSingleDatabase)
            {
                DatabaseCopy   databaseCopy;
                DatabaseCopy[] array;
                DatabaseTasksHelper.CheckDatabaseCopyForCopyTask(this.m_database, new Task.TaskErrorLoggingDelegate(this.m_output.WriteError), this.m_targetServer, out databaseCopy, out array);
            }
            if (this.m_dag == null)
            {
                this.m_dag = ((IConfigurationSession)base.DataSession).Read <DatabaseAvailabilityGroup>(this.m_targetServer.DatabaseAvailabilityGroup);
            }
            IADDatabaseAvailabilityGroup dag = ADObjectWrapperFactory.CreateWrapper(this.m_dag);

            if (AmBestCopySelectionHelper.IsServerInDacAndStopped(dag, new AmServerName(this.m_targetServer.Name)))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorServerDacedAndNotStarted(this.m_dag.Name, this.m_targetServer.Name)), ErrorCategory.InvalidOperation, null);
            }
            DatabaseTasksHelper.CheckReplayServiceRunningOnNode(this.m_targetAmServer, new Task.TaskErrorLoggingDelegate(base.WriteError));
            DagTaskHelper.CheckStoreIsRunning(new Task.TaskErrorLoggingDelegate(base.WriteError), this.m_targetAmServer);
            if (this.MountDialOverride != DatabaseMountDialOverride.Lossless)
            {
                base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, this.m_targetServer, true, new DataAccessTask <Database> .ADObjectOutOfScopeString(Strings.ErrorServerOutOfScope));
            }
        }
Beispiel #2
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     this.LogCommandLineParameters();
     this.m_removeNode     = false;
     this.m_destroyCluster = false;
     this.ResolveParameters();
     DagTaskHelper.VerifyDagAndServersAreWithinScopes <DatabaseAvailabilityGroup>(this, this.m_dag, true);
     this.m_output.WriteProgress(Strings.ProgressStatusInProgress, Strings.DagTaskRemoveDagServerRunningChecks(this.m_mailboxServerName, this.m_dagName), 0);
     this.CheckDatabasesAreNotReplicated();
     if (!this.m_configurationOnly)
     {
         DagTaskHelper.CheckServerDoesNotBelongToDifferentDag(new Task.TaskErrorLoggingDelegate(this.m_output.WriteError), base.DataSession, this.m_mailboxServer, this.m_dagName);
         this.CheckFswSettings();
         this.CheckClusterStateForDagServerRemoval();
         if (!this.m_configurationOnly)
         {
             using (IAmClusterGroup amClusterGroup = this.m_clusDag.FindCoreClusterGroup())
             {
                 AmServerName ownerNode = amClusterGroup.OwnerNode;
                 this.m_output.AppendLogMessage("Checking if msexchangerepl is running on {0}.", new object[]
                 {
                     ownerNode.NetbiosName
                 });
                 DatabaseTasksHelper.CheckReplayServiceRunningOnNode(ownerNode, new Task.TaskErrorLoggingDelegate(base.WriteError));
                 if (this.m_clusDag.CnoName != string.Empty)
                 {
                     using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("Network Name"))
                     {
                         DagTaskHelper.LogCnoState(this.m_output, this.m_dagName, amClusterResource);
                     }
                 }
             }
         }
     }
     if (DagTaskHelper.FindServerAdObjectIdInDag(this.m_dag, this.m_mailboxAmServerName) == null)
     {
         StringBuilder stringBuilder = new StringBuilder(string.Format("{0}. srvToRemove={1} dagSvrs=(", this.m_dagName, this.m_mailboxAmServerName.NetbiosName));
         bool          flag          = false;
         foreach (ADObjectId adobjectId in this.m_dag.Servers)
         {
             if (flag)
             {
                 stringBuilder.Append(",");
             }
             else
             {
                 flag = true;
             }
             stringBuilder.Append(adobjectId.Name);
         }
         stringBuilder.Append(")");
         this.m_output.WriteErrorSimple(new DagTaskServerIsNotInDagException(this.m_mailboxServerName, stringBuilder.ToString()));
     }
     base.InternalValidate();
     TaskLogger.LogExit();
 }
Beispiel #3
0
        private List <string> JoinStartedNodes(IEnumerable <Server> serversToStart)
        {
            if (serversToStart == null)
            {
                throw new ArgumentNullException("serversToStart");
            }
            List <string> list = new List <string>(1);

            using (AmCluster amCluster = AmCluster.OpenDagClus(this.m_dag))
            {
                using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup())
                {
                    try
                    {
                        using (DumpClusterTopology dumpClusterTopology = new DumpClusterTopology(amCluster, this.m_output))
                        {
                            dumpClusterTopology.Dump();
                        }
                    }
                    catch (ClusterException ex)
                    {
                        this.m_output.AppendLogMessage("DumpClusterTopology( {0} ) failed with exception = {1}. This is OK.", new object[]
                        {
                            this.m_dag.Name,
                            ex.Message
                        });
                        this.m_output.AppendLogMessage("Ignoring previous error, as it is acceptable if the cluster does not exist yet.", new object[0]);
                    }
                    AmServerName ownerNode = amClusterGroup.OwnerNode;
                    DatabaseTasksHelper.CheckReplayServiceRunningOnNode(ownerNode, new Task.TaskErrorLoggingDelegate(base.WriteError));
                    if (amCluster.CnoName != string.Empty)
                    {
                        using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("Network Name"))
                        {
                            DagTaskHelper.LogCnoState(this.m_output, this.m_dag.Name, amClusterResource);
                        }
                    }
                    foreach (Server server in serversToStart)
                    {
                        bool         flag         = false;
                        AmServerName amServerName = new AmServerName(server);
                        try
                        {
                            if (amCluster.IsEvictedBasedOnMemberShip(amServerName))
                            {
                                this.m_output.WriteProgressSimple(Strings.ProgressJoinNode(amServerName.NetbiosName));
                                this.m_output.AppendLogMessage("ForceCleanup the Node {0}", new object[]
                                {
                                    server.Name
                                });
                                DatabaseAvailabilityGroupAction.ForceCleanupOneNodeLocally(this.m_dag.Name, server, TimeSpan.FromSeconds(15.0), this.m_output);
                                this.m_output.AppendLogMessage("Join the node {0} to the cluster", new object[]
                                {
                                    server.Name
                                });
                                DatabaseAvailabilityGroupAction.JoinOneNode(ownerNode, amServerName, this.m_output);
                                flag = true;
                            }
                            else
                            {
                                this.m_output.AppendLogMessage("{0} is not evicted", new object[]
                                {
                                    amServerName
                                });
                            }
                            if (!AmCluster.IsRunning(amServerName))
                            {
                                try
                                {
                                    this.m_output.AppendLogMessage("{0} cluster service is not running, try to start the service", new object[]
                                    {
                                        server.Name
                                    });
                                    this.m_output.WriteProgressSimple(Strings.ProgressStartClussvc(amServerName.NetbiosName));
                                    DatabaseAvailabilityGroupAction.TryStartClussvcOnNode(amServerName, this.m_output);
                                }
                                catch (InvalidOperationException)
                                {
                                    this.m_output.AppendLogMessage("Got an invalidOperationException, most likely the node {0} is force cleanedup", new object[]
                                    {
                                        amServerName
                                    });
                                    if (flag)
                                    {
                                        this.m_output.AppendLogMessage("STRANGE! we joined {0} but cannot start the service!", new object[]
                                        {
                                            amServerName
                                        });
                                        throw;
                                    }
                                    this.m_output.WriteProgressSimple(Strings.ProgressJoinNode(amServerName.NetbiosName));
                                    DatabaseAvailabilityGroupAction.JoinForceCleanupNode(ownerNode, amServerName, this.m_output);
                                    flag = true;
                                }
                            }
                            if (flag)
                            {
                                ICollection <AmServerName> startedMailboxServers = from server1 in this.m_dag.StartedMailboxServers
                                                                                   select new AmServerName(server1);
                                DatabaseAvailabilityGroupAction.FixIPAddress(new AmServerName(server.Fqdn), this.m_dag, startedMailboxServers, this.m_output);
                            }
                        }
                        catch (LocalizedException ex2)
                        {
                            this.m_output.WriteWarning(Strings.FailedToJoinNode(server.Name, this.m_dag.Name, ex2.Message));
                            list.Add(server.Name);
                        }
                        catch (InvalidOperationException ex3)
                        {
                            this.m_output.WriteWarning(Strings.FailedToJoinNode(server.Name, this.m_dag.Name, ex3.Message));
                            list.Add(server.Name);
                        }
                    }
                }
            }
            return(list);
        }