Ejemplo n.º 1
0
        internal override bool Process(JobCache data)
        {
            AnchorUtil.ThrowOnNullArgument(data, "data");
            bool result = false;
            int  num    = 0;
            int  num2   = 0;

            foreach (CacheEntryBase cacheEntryBase in data.Get())
            {
                if (base.StopEvent.WaitOne(0, false))
                {
                    break;
                }
                int config = base.Context.Config.GetConfig <int>("MaximumCacheEntrySchedulerRun");
                if (config >= 0 && num++ >= config)
                {
                    base.Context.Logger.Log(MigrationEventType.Error, "Skipping run of {0} because too many cache entries {1} expected {2}", new object[]
                    {
                        cacheEntryBase,
                        num,
                        config
                    });
                }
                else
                {
                    AnchorLogContext.Current.OrganizationId = cacheEntryBase.OrganizationId;
                    try
                    {
                        AnchorJobProcessorResult anchorJobProcessorResult = AnchorJobProcessorResult.Working;
                        try
                        {
                            cacheEntryBase.ServiceException = null;
                            anchorJobProcessorResult        = this.ProcessEntry(cacheEntryBase);
                            num2 = 0;
                        }
                        catch (TransientException ex)
                        {
                            base.Context.Logger.Log(MigrationEventType.Error, "entry {0} encountered a transient error {1}", new object[]
                            {
                                cacheEntryBase,
                                ex
                            });
                            anchorJobProcessorResult = AnchorJobProcessorResult.Waiting;
                            num2 = 0;
                        }
                        catch (StoragePermanentException ex2)
                        {
                            base.Context.Logger.Log(MigrationEventType.Error, "entry {0} encountered a permanent error {1}", new object[]
                            {
                                cacheEntryBase,
                                ex2
                            });
                            anchorJobProcessorResult = AnchorJobProcessorResult.Waiting;
                            num2 = 0;
                        }
                        catch (MigrationPermanentException ex3)
                        {
                            base.Context.Logger.Log(MigrationEventType.Error, "entry {0} encountered a permanent error {1}", new object[]
                            {
                                cacheEntryBase,
                                ex3
                            });
                            anchorJobProcessorResult = AnchorJobProcessorResult.Waiting;
                            num2 = 0;
                        }
                        catch (Exception ex4)
                        {
                            if (base.Context.Config.GetConfig <bool>("UseWatson"))
                            {
                                ExWatson.SendReport(ex4);
                            }
                            cacheEntryBase.ServiceException = ex4;
                            anchorJobProcessorResult        = AnchorJobProcessorResult.Waiting;
                            num2++;
                            base.Context.Logger.Log(MigrationEventType.Error, "entry {0} encountered an unhandled error {1}, poison count {2} triggering alert notification", new object[]
                            {
                                cacheEntryBase,
                                ex4,
                                num2
                            });
                            if (!AnchorIssueCache.TrySendEventNotification(base.Context, base.Context.Config.GetConfig <string>("CacheEntryPoisonNotificationReason"), cacheEntryBase.ToString(), ResultSeverityLevel.Error))
                            {
                                throw;
                            }
                            if (num2 >= base.Context.Config.GetConfig <int>("CacheEntryPoisonThreshold"))
                            {
                                throw;
                            }
                        }
                        switch (anchorJobProcessorResult)
                        {
                        case AnchorJobProcessorResult.Working:
                            result = true;
                            continue;

                        case AnchorJobProcessorResult.Waiting:
                            continue;

                        case AnchorJobProcessorResult.Failed:
                            base.Context.Logger.Log(MigrationEventType.Error, "marking job cache entry failed.. {0}", new object[]
                            {
                                cacheEntryBase
                            });
                            data.Remove(cacheEntryBase);
                            continue;

                        case AnchorJobProcessorResult.Deleted:
                            base.Context.Logger.Log(MigrationEventType.Information, "Removing deleted job cache entry {0}", new object[]
                            {
                                cacheEntryBase
                            });
                            data.Remove(cacheEntryBase);
                            result = true;
                            continue;
                        }
                        throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid AnchorJobProcessorResult {0}", new object[]
                        {
                            anchorJobProcessorResult
                        }));
                    }
                    finally
                    {
                        AnchorLogContext.Current.OrganizationId = null;
                    }
                }
            }
            return(result);
        }
 // Token: 0x06000099 RID: 153 RVA: 0x00003408 File Offset: 0x00001608
 public AnchorIssueCache(AnchorContext context, JobCache cache)
 {
     this.Context = context;
     this.Cache   = cache;
 }
Ejemplo n.º 3
0
        // Token: 0x0600015E RID: 350 RVA: 0x00005644 File Offset: 0x00003844
        internal override bool Process(JobCache data)
        {
            AnchorUtil.ThrowOnNullArgument(data, "data");
            if (base.LastRunTime == null)
            {
                TimeSpan config = base.Context.Config.GetConfig <TimeSpan>("ScannerInitialTimeDelay");
                if (!config.Equals(TimeSpan.Zero))
                {
                    base.Context.Logger.Log(MigrationEventType.Information, "Sleeping initial delay of {0} on start", new object[]
                    {
                        config
                    });
                    base.StopEvent.WaitOne(config, false);
                }
            }
            this.nextProcessTime = ExDateTime.UtcNow.Add(base.Context.Config.GetConfig <TimeSpan>("ScannerTimeDelay"));
            if (base.Context.Config.GetConfig <bool>("ScannerClearCacheOnRefresh"))
            {
                data.Clear();
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;
            HashSet <ADObjectId> hashSet = new HashSet <ADObjectId>();

            foreach (ADUser aduser in this.GetLocalMailboxUsers())
            {
                hashSet.Add(aduser.ObjectId);
                bool flag = data.Contains(aduser.ObjectId);
                if (data.TryAdd(aduser, false))
                {
                    if (flag)
                    {
                        num2++;
                    }
                    else
                    {
                        num++;
                    }
                }
                else if (flag)
                {
                    num3++;
                }
            }
            foreach (CacheEntryBase cacheEntryBase in data.Get())
            {
                if (!hashSet.Contains(cacheEntryBase.ObjectId))
                {
                    if (data.TryUpdate(cacheEntryBase, false))
                    {
                        num2++;
                    }
                    else
                    {
                        num3++;
                    }
                }
            }
            this.diagnosticMessage = string.Format(" Modified {0}, Added {1}, removed {2} cache entries", num2, num, num3);
            if (num > 0 || num3 > 0)
            {
                base.Context.Logger.Log(MigrationEventType.Information, this.diagnosticMessage, new object[0]);
            }
            else
            {
                base.Context.Logger.Log(MigrationEventType.Verbose, this.diagnosticMessage, new object[0]);
            }
            return(false);
        }
Ejemplo n.º 4
0
 internal abstract bool Process(JobCache data);