public static void RunConfigurationUpdaterRpcAsync(string serverFqdn, Database database, ReplayConfigChangeHints changeHint, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskWarningLoggingDelegate writeWarning) { try { ReplayRpcClientHelper.NotifyChangedReplayConfigurationAsync(serverFqdn, database.Guid, changeHint); } catch (TaskServerTransientException ex) { writeWarning(Strings.RunConfigUpdaterRpcFailedWarning(serverFqdn, database.Name, ex.Message)); } catch (TaskServerException ex2) { writeWarning(Strings.RunConfigUpdaterRpcFailedWarning(serverFqdn, database.Name, ex2.Message)); } }
protected override void RpcOperation() { Database database = this.DataObject.GetDatabase <Database>(); if (base.IsActivationRpcSupported) { DatabaseCopyActionFlags flags = DatabaseCopyActionFlags.Replication | DatabaseCopyActionFlags.Activation; if (this.ReplicationOnly) { flags = DatabaseCopyActionFlags.Replication; } ReplayRpcClientHelper.RequestResume2(base.GetServerFqdn(), database.Guid, (uint)flags); return; } ReplayRpcClientWrapper.RequestResume(base.GetServerFqdn(), database.Guid); }
private Dictionary <Guid, RpcDatabaseCopyStatus2> GetCopyStatusRpcResults() { Dictionary <Guid, RpcDatabaseCopyStatus2> result = null; ServerVersion adminDisplayVersion = ReplicationCheckGlobals.Server.AdminDisplayVersion; if (ReplicationCheckGlobals.WriteVerboseDelegate != null) { ReplicationCheckGlobals.WriteVerboseDelegate(Strings.TestRHUseCopyStatusRpc(adminDisplayVersion.ToString(), ReplayRpcVersionControl.GetCopyStatusEx2SupportVersion.ToString())); } RpcDatabaseCopyStatus2[] copyStatus = ReplayRpcClientHelper.GetCopyStatus(base.ServerName, ReplicationCheckGlobals.RunningInMonitoringContext ? RpcGetDatabaseCopyStatusFlags2.None : RpcGetDatabaseCopyStatusFlags2.ReadThrough, null); if (copyStatus != null && copyStatus.Length > 0) { result = ReplayRpcClientHelper.ParseStatusResults(copyStatus); if (ReplicationCheckGlobals.WriteVerboseDelegate != null) { ReplicationCheckGlobals.WriteVerboseDelegate(Strings.TestRHRpcQueryAllDone(copyStatus.Length)); } } return(result); }
public static void RunConfigurationUpdaterRpc(string serverFqdn, Database database, ServerVersion serverVersion, ReplayConfigChangeHints changeHint, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskWarningLoggingDelegate writeWarning) { string name = database.Name; if (ReplayRpcVersionControl.IsRunConfigUpdaterRpcSupported(serverVersion)) { writeVerbose(Strings.RunConfigUpdaterRpcVerbose(serverFqdn, name)); try { ReplayRpcClientHelper.NotifyChangedReplayConfiguration(serverFqdn, database.Guid, serverVersion, true, false, changeHint); } catch (TaskServerTransientException ex) { writeWarning(Strings.RunConfigUpdaterRpcFailedWarning(serverFqdn, name, ex.Message)); } catch (TaskServerException ex2) { writeWarning(Strings.RunConfigUpdaterRpcFailedWarning(serverFqdn, name, ex2.Message)); } } }
protected override void RpcOperation() { Database database = this.DataObject.GetDatabase <Database>(); if (!base.IsActivationRpcSupported) { ReplayRpcClientWrapper.RequestSuspend(base.GetServerFqdn(), database.Guid, this.SuspendComment); return; } DatabaseCopyActionFlags flags = DatabaseCopyActionFlags.Replication | DatabaseCopyActionFlags.Activation; if (this.ActivationOnly) { flags = DatabaseCopyActionFlags.Activation; } if (base.IsRequestSuspend3RpcSupported) { ReplayRpcClientHelper.RequestSuspend3(base.GetServerFqdn(), database.Guid, this.SuspendComment, (uint)flags, 2U); return; } ReplayRpcClientWrapper.RequestSuspend2(base.GetServerFqdn(), database.Guid, this.SuspendComment, (uint)flags); }
private void PreventMoveOfActiveSeedingSource(AmServerName server, Database[] databases) { if (this.SkipActiveCopyChecks) { TaskLogger.Trace("PreventMoveOfActiveSeedingSource: Check skipped because -SkipActiveCopyChecks flag is specified.", new object[0]); return; } Exception ex = null; RpcDatabaseCopyStatus2[] array = null; try { Guid[] array2 = null; if (databases != null && databases.Length > 0) { array2 = new Guid[databases.Length]; for (int i = 0; i < databases.Length; i++) { array2[i] = databases[i].Guid; } } array = ReplayRpcClientHelper.GetCopyStatus(server.Fqdn, RpcGetDatabaseCopyStatusFlags2.ReadThrough, array2); } catch (TaskServerTransientException ex2) { ex = ex2; } catch (TaskServerException ex3) { ex = ex3; } if (ex != null) { TaskLogger.Trace("PreventMoveOfActiveSeedingSource: Check failed because of exception: {2}", new object[] { ex }); base.WriteError(new ErrorMoveUnableToGetCopyStatusException(server.NetbiosName, ex.Message), ErrorCategory.InvalidOperation, server.Fqdn); } foreach (RpcDatabaseCopyStatus2 rpcDatabaseCopyStatus in array) { if (SharedHelper.StringIEquals(rpcDatabaseCopyStatus.ActiveDatabaseCopy, server.NetbiosName) && rpcDatabaseCopyStatus.SeedingSource) { if (!rpcDatabaseCopyStatus.SeedingSourceForDB) { if (rpcDatabaseCopyStatus.SeedingSourceForDB || rpcDatabaseCopyStatus.SeedingSourceForCI) { goto IL_1B6; } } try { IADDatabase iaddatabase = AmHelper.FindDatabaseByGuid(rpcDatabaseCopyStatus.DBGuid); TaskLogger.Trace("PreventMoveOfActiveSeedingSource: Check failed for {0}\\{1} because it is seeding source.", new object[] { iaddatabase.Name, rpcDatabaseCopyStatus.MailboxServer }); base.WriteError(new ErrorMoveActiveCopyIsSeedingSourceException(iaddatabase.Name, rpcDatabaseCopyStatus.MailboxServer), ErrorCategory.InvalidOperation, iaddatabase.Identity); } catch (AmDatabaseNotFoundException ex4) { TaskLogger.Trace("PreventMoveOfActiveSeedingSource: Check failed for '{0}' because it is not found in AD. Error: {1}", new object[] { rpcDatabaseCopyStatus.DBGuid, ex4.Message }); base.WriteError(new ErrorMoveActiveCopyNotFoundException(rpcDatabaseCopyStatus.DBGuid, ex4.Message), ErrorCategory.InvalidOperation, rpcDatabaseCopyStatus.DBGuid); } } IL_1B6 :; } }
internal override void ProcessRecordWorker(ReplayConfiguration replayConfiguration) { ExTraceGlobals.CmdletsTracer.TraceDebug <ObjectId, string>((long)this.GetHashCode(), "Suspend-DBC: ProcessRecordWorker: {0}, {1}", this.DataObject.Identity, this.SuspendComment); ExTraceGlobals.PFDTracer.TracePfd <int, ObjectId, string>((long)this.GetHashCode(), "PFD CRS {0} Suspend-DBC Initiated for : ProcessRecordWorker: {1}, {2}", 25051, this.DataObject.Identity, this.SuspendComment); if (this.EnableReplayLag) { Database database = this.DataObject.GetDatabase <Database>(); ReplayRpcClientHelper.RpccEnableReplayLag(base.Server.Name, database.Guid, ActionInitiatorType.Administrator); return; } if (this.SuspendComment != null && this.SuspendComment.Length > 512) { ExTraceGlobals.CmdletsTracer.TraceDebug((long)this.GetHashCode(), "Suspend-DBC {0}: ProcessRecordWorker: SuspendComment length (length={1}, max length={2}) is too long: {3}", new object[] { this.DataObject.Identity, this.SuspendComment.Length, 512, this.SuspendComment }); base.WriteError(new SuspendCommentTooLongException(this.SuspendComment.Length, 512), ErrorCategory.InvalidOperation, this.Identity); } if (!base.Stopping) { if (!base.UseRpc) { this.m_suspendThread = this.BeginSuspendUsingState(replayConfiguration); } else { this.m_suspendThread = base.BeginRpcOperation(); } try { TimeSpan timeSpan = base.UseRpc ? DatabaseCopyStateAction.TimeoutRpc : SuspendDatabaseCopy.Timeout; if (!this.m_suspendThread.Join(timeSpan)) { ExTraceGlobals.CmdletsTracer.TraceDebug <TimeSpan>((long)this.GetHashCode(), "Suspend-DBC: suspend is being slow: timeout={0}", timeSpan); this.WriteWarning(Strings.SuspendSgcTimeout); if (!base.UseRpc) { this.m_suspendThread.Join(); } else { this.m_event.WaitOne(); } } } finally { if (this.m_Exception != null) { if (this.m_Terminating) { base.ThrowTerminatingError(this.m_Exception, ErrorCategory.NotSpecified, null); } else { ErrorCategory category; this.TranslateException(ref this.m_Exception, out category); if (this.m_Exception is ReplayServiceSuspendWantedSetException) { base.WriteWarning(this.m_Exception.Message); this.m_fSuccess = true; } else if (this.m_Exception is ReplayServiceSuspendRpcPartialSuccessCatalogFailedException) { base.WriteWarning(this.m_Exception.Message); this.m_fSuccess = true; } else if (!this.m_fFallbackToState) { this.WriteError(this.m_Exception, category, null, false); } else if (!base.Stopping) { ExTraceGlobals.CmdletsTracer.TraceDebug <ObjectId>((long)this.GetHashCode(), "ProcessRecordWorker: There was an RPC connection error, so now falling back to Suspend through the State, for {0}.", this.DataObject.Identity); this.WriteWarning(Strings.SuspendSgcFallbackToState(this.DataObject.Identity.ToString(), this.m_Exception.Message)); } } } } } if (!this.m_fSuccess && base.Stopping) { ExTraceGlobals.CmdletsTracer.TraceDebug <ObjectId>((long)this.GetHashCode(), "Suspend was cancelled for {0}", this.DataObject.Identity); return; } if (!base.UseRpc && this.m_Exception == null && this.m_fSuccess) { replayConfiguration.ReplayState.SuspendMessage = this.SuspendComment; } else if (base.UseRpc && this.m_fFallbackToState) { ReplayConfiguration replayConfiguration2 = base.ConstructReplayConfiguration(this.DataObject.GetDatabase <Database>()); replayConfiguration2.ReplayState.SuspendLockRemote.EnterSuspend(); replayConfiguration2.ReplayState.SuspendMessage = this.SuspendComment; this.m_fSuccess = true; } if (this.m_fSuccess) { ExTraceGlobals.CmdletsTracer.TraceDebug <string, ObjectId>((long)this.GetHashCode(), "Suspended ({0}) for {1}", this.SuspendComment, this.DataObject.Identity); ExTraceGlobals.PFDTracer.TracePfd <int, string, ObjectId>((long)this.GetHashCode(), "PFD CRS {0} Sucessfully Suspended ({1}) for {2}", 20955, this.SuspendComment, this.DataObject.Identity); if (this.m_fFallbackToState) { ReplayEventLogConstants.Tuple_SuspendMarkedForDatabaseCopy.LogEvent(null, new object[] { this.DataObject.Identity }); } } TaskLogger.LogExit(); }
private DatabaseCopyStatusEntry[] PrepareStatusEntryFromRpc(Server server, Collection <DatabaseCopy> databaseCopies) { DatabaseCopyStatusEntry[] array = new DatabaseCopyStatusEntry[databaseCopies.Count]; Guid[] array2 = new Guid[databaseCopies.Count]; for (int i = 0; i < databaseCopies.Count; i++) { DatabaseCopy databaseCopy3 = databaseCopies[i]; Database database = databaseCopy3.GetDatabase <Database>(); array2[i] = database.Guid; array[i] = this.ConstructNewSatusEntry(databaseCopy3); } RpcGetDatabaseCopyStatusFlags2 rpcGetDatabaseCopyStatusFlags = RpcGetDatabaseCopyStatusFlags2.None; if (!this.UseServerCache) { rpcGetDatabaseCopyStatusFlags |= RpcGetDatabaseCopyStatusFlags2.ReadThrough; } try { IEnumerable <string> source = from databaseCopy in databaseCopies select databaseCopy.DatabaseName; base.WriteVerbose(Strings.GetDbcsRpcQuery(server.Fqdn, string.Join(",", source.ToArray <string>()))); RpcDatabaseCopyStatus2[] copyStatus = ReplayRpcClientHelper.GetCopyStatus(server.Fqdn, rpcGetDatabaseCopyStatusFlags, array2); if (copyStatus != null && copyStatus.Length > 0) { base.WriteVerbose(Strings.GetDbcsRpcQueryAllDone(copyStatus.Length)); Dictionary <Guid, RpcDatabaseCopyStatus2> dictionary = new Dictionary <Guid, RpcDatabaseCopyStatus2>(copyStatus.Length); for (int j = 0; j < copyStatus.Length; j++) { dictionary[copyStatus[j].DBGuid] = copyStatus[j]; } for (int k = 0; k < array2.Length; k++) { RpcDatabaseCopyStatus2 copyStatus2; if (dictionary.TryGetValue(array2[k], out copyStatus2)) { GetMailboxDatabaseCopyStatus.GetEntryFromStatus(copyStatus2, array[k]); } else if (!databaseCopies[k].IsValid) { ExTraceGlobals.CmdletsTracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "GetCopyStatus() didn't find replica instance for database {0} on server {1}. The DatabaseCopy is misconfigured in the Active Directory!", array2[k], server.Fqdn); this.UpdateMisconfiguredCopyStatusEntry(array[k], databaseCopies[k]); } else { ExTraceGlobals.CmdletsTracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "GetCopyStatus() didn't find replica instance for database {0} on server {1}.", array2[k], server.Fqdn); this.UpdateCopyStatusNoReplicaInstance(array[k]); } } } } catch (ArgumentException ex) { ExTraceGlobals.CmdletsTracer.TraceError <ArgumentException>((long)this.GetHashCode(), "GetMailboxDatabaseCopyStatus: ArgumentException: {0}", ex); this.WriteError(ex, ErrorCategory.ReadError, null, false); } catch (TaskServerTransientException ex2) { ExTraceGlobals.CmdletsTracer.TraceError <TaskServerTransientException>((long)this.GetHashCode(), "GetMailboxDatabaseCopyStatus: ArgumentException: {0}", ex2); this.WriteError(ex2, ErrorCategory.ReadError, null, false); } catch (TaskServerException ex3) { ExTraceGlobals.CmdletsTracer.TraceError <TaskServerException>((long)this.GetHashCode(), "GetMailboxDatabaseCopyStatus: ReplayServiceRpcException: {0}", ex3); if (ex3 is ReplayServiceDownException) { base.WriteVerbose(Strings.GetDbcsDetectReplayServiceDown(server.Fqdn, ex3.Message)); for (int l = 0; l < array.Length; l++) { DatabaseCopyStatusEntry databaseCopyStatusEntry = array[l]; DatabaseCopy databaseCopy2 = databaseCopies[l]; if (!databaseCopy2.IsValid) { this.UpdateMisconfiguredCopyStatusEntry(databaseCopyStatusEntry, databaseCopy2); } else { databaseCopyStatusEntry.Status = CopyStatus.ServiceDown; databaseCopyStatusEntry.m_errorMessage = ex3.Message; databaseCopyStatusEntry.m_extendedErrorInfo = new ExtendedErrorInfo(ex3); } } } else if (ex3 is ReplayServiceRpcUnknownInstanceException) { ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "GetCopyStatus() was not able to find any replica instances on server {0}.", server.Fqdn); for (int m = 0; m < array.Length; m++) { if (!databaseCopies[m].IsValid) { this.UpdateMisconfiguredCopyStatusEntry(array[m], databaseCopies[m]); } else { this.UpdateCopyStatusNoReplicaInstance(array[m]); } } } else { this.WriteError(ex3, ErrorCategory.ReadError, null, false); } } return(array); }
internal override void ProcessRecordWorker(ReplayConfiguration replayConfiguration) { ExTraceGlobals.CmdletsTracer.TraceDebug <ObjectId>((long)this.GetHashCode(), "Resume-DBC: InternalProcessRecord: {0}", this.DataObject.Identity); ExTraceGlobals.PFDTracer.TracePfd <int, ObjectId>((long)this.GetHashCode(), "PFD CRS {0} Resume-DBC initiated for : InternalProcessRecord: {1}", 28635, this.DataObject.Identity); if (this.DisableReplayLag) { Database database = this.DataObject.GetDatabase <Database>(); ReplayRpcClientHelper.RpccDisableReplayLag(base.Server.Name, database.Guid, this.DisableReplayLagReason, ActionInitiatorType.Administrator); return; } if (!base.UseRpc) { this.ResumeUsingState(replayConfiguration); } else if (!base.Stopping) { Thread thread = base.BeginRpcOperation(); try { TimeSpan timeoutRpc = DatabaseCopyStateAction.TimeoutRpc; if (!thread.Join(timeoutRpc)) { ExTraceGlobals.CmdletsTracer.TraceDebug <TimeSpan>((long)this.GetHashCode(), "Resume-DBC: resume is being slow: timeout={0}", timeoutRpc); this.WriteWarning(Strings.ResumeSgcTimeout); this.m_event.WaitOne(); } } finally { if (this.m_Exception != null) { ErrorCategory category; this.TranslateException(ref this.m_Exception, out category); if (this.m_Exception is ReplayServiceSuspendWantedClearedException) { base.WriteWarning(this.m_Exception.Message); this.m_fSuccess = true; } else if (this.m_Exception is ReplayServiceResumeRpcPartialSuccessCatalogFailedException) { base.WriteWarning(this.m_Exception.Message); this.m_fSuccess = true; } else if (this.m_Exception is ReplayServiceResumeRpcFailedSeedingException) { base.WriteWarning(this.m_Exception.Message); } else if (!this.m_fFallbackToState) { this.WriteError(this.m_Exception, category, null, false); } else if (!base.Stopping) { ExTraceGlobals.CmdletsTracer.TraceDebug <ObjectId>((long)this.GetHashCode(), "ProcessRecordWorker: There was an RPC connection error, so now falling back to Resume through the State, for {0}.", this.DataObject.Identity); this.WriteWarning(Strings.ResumeSgcFallbackToState(this.DataObject.Identity.ToString(), this.m_Exception.Message)); } } } if (!this.m_fSuccess && base.Stopping) { ExTraceGlobals.CmdletsTracer.TraceDebug <ObjectId>((long)this.GetHashCode(), "Resume was cancelled for {0}", this.DataObject.Identity); return; } if (!this.m_fSuccess && this.m_fFallbackToState) { ReplayConfiguration replayConfiguration2 = base.ConstructReplayConfiguration(this.DataObject.GetDatabase <Database>()); this.ResumeUsingState(replayConfiguration2); } } ExTraceGlobals.CmdletsTracer.TraceDebug <ObjectId>((long)this.GetHashCode(), "ResumeReplay() for {0}", this.DataObject.Identity); if (this.m_fSuccess) { ExTraceGlobals.PFDTracer.TracePfd <int, ObjectId>((long)this.GetHashCode(), "PFD CRS {0} Sucessfully ResumeReplay() for {1}", 24539, this.DataObject.Identity); if (this.m_fFallbackToState) { ReplayEventLogConstants.Tuple_ResumeMarkedForDatabaseCopy.LogEvent(null, new object[] { this.DataObject.Identity }); } } }