public override void Delete(RequestIndexEntryProvider requestIndexEntryProvider, MRSRequestWrapper instance) { ADHandler.Delete(requestIndexEntryProvider.ConfigSession, instance); }
private static void CleanADOrphanAndInconsistencyForNonMoves(IConfigurationSession configSession, MRSRequestType requestType, RequestJobProvider rjProvider, Guid dbGuid) { ADObjectId requestQueueId = new ADObjectId(dbGuid); RequestIndexEntryQueryFilter requestIndexEntryQueryFilter = new RequestIndexEntryQueryFilter(); requestIndexEntryQueryFilter.IndexId = new RequestIndexId(RequestIndexLocation.AD); requestIndexEntryQueryFilter.RequestType = requestType; requestIndexEntryQueryFilter.RequestQueueId = requestQueueId; MRSRequestWrapper[] array = ADHandler.Find(configSession, requestIndexEntryQueryFilter, null, true, null); if (array != null && array.Length > 0) { bool needUpdateAD = false; MRSRequestWrapper[] array2 = array; for (int i = 0; i < array2.Length; i++) { MRSRequestWrapper request = array2[i]; CommonUtils.CatchKnownExceptions(delegate { needUpdateAD = false; if (request.Status != RequestStatus.None) { RequestStatisticsBase requestStatisticsBase = (RequestStatisticsBase)rjProvider.Read <RequestStatisticsBase>(new RequestJobObjectId(request.RequestGuid, dbGuid, null)); if (requestStatisticsBase == null || (!requestStatisticsBase.IsFake && requestStatisticsBase.Status == RequestStatus.None)) { MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():AD orphan {0} found for DB {1}", new object[] { request.RequestGuid, dbGuid }); ADHandler.Delete(configSession, request); return; } if (requestStatisticsBase.IsFake) { MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():request {0} is uplevel/Fake, ignoring it", new object[] { request.RequestGuid }); return; } if (requestStatisticsBase.IndexEntries == null || requestStatisticsBase.IndexEntries.Count == 0) { MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():request {0} has been removed from AD, ignoring it", new object[] { request.RequestGuid }); return; } if (requestStatisticsBase.TimeTracker.GetCurrentDurationChunk() > ADInconsistencyCheck.updateLatencyThreshhold) { if (requestStatisticsBase.Status != requestStatisticsBase.IndexEntries[0].Status) { MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():AD inconsistency {0} found for DB {1}, AD status is {2} but store status is {3}", new object[] { request.RequestGuid, dbGuid, request.Status, requestStatisticsBase.Status }); request.Status = requestStatisticsBase.Status; needUpdateAD = true; } if (requestStatisticsBase.Flags != requestStatisticsBase.IndexEntries[0].Flags) { MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():AD inconsistency {0} found for DB {1}, AD flags is {2} but store flags is {3}", new object[] { request.RequestGuid, dbGuid, request.Flags, requestStatisticsBase.Flags }); request.Flags = requestStatisticsBase.Flags; needUpdateAD = true; } if (needUpdateAD) { ADHandler.Save(configSession, request); return; } } } else { MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():request {0} for {1} has been removed from AD, store orphan will be handled by MRS pick up job logic", new object[] { request.RequestGuid, dbGuid }); } }, delegate(Exception f) { MrsTracer.Service.Error("CleanADOrphanAndInconsistencyForRequests() failed for DB {0}. Request type {1} Request guid {2} Error: {3}", new object[] { dbGuid, requestType.ToString(), request.RequestGuid, CommonUtils.FullExceptionMessage(f, true) }); MRSService.LogEvent(MRSEventLogConstants.Tuple_ScanADInconsistencyRequestFailEvent, new object[] { dbGuid, requestType.ToString(), request.RequestGuid, CommonUtils.FullExceptionMessage(f, true) }); }); } return; } MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests(): No {0} requests found for DB {1}", new object[] { requestType, dbGuid }); }