public void Put(AddDirectoryCacheRequest cacheRequest)
        {
            ArgumentValidator.ThrowIfNull("cacheRequest", cacheRequest);
            int       retryCount = 0;
            long      apiTime    = 0L;
            Stopwatch stopwatch  = Stopwatch.StartNew();

            ExchangeDirectoryCacheProvider.proxyPool.CallServiceWithRetry(delegate(IPooledServiceProxy <IDirectoryCacheClient> proxy)
            {
                Stopwatch stopwatch2 = Stopwatch.StartNew();
                try
                {
                    retryCount++;
                    this.IsNewProxyObject = string.IsNullOrEmpty(proxy.Tag);
                    CacheResponseContext cacheResponseContext = proxy.Client.PutObject(cacheRequest);
                    proxy.Tag = DateTime.UtcNow.ToString();
                    CachePerformanceTracker.AddPerfData(Operation.WCFBeginOperation, cacheResponseContext.BeginOperationLatency);
                    CachePerformanceTracker.AddPerfData(Operation.WCFEndOperation, cacheResponseContext.EndOperationLatency);
                }
                finally
                {
                    stopwatch2.Stop();
                    CachePerformanceTracker.AddPerfData(Operation.WCFPutOperation, stopwatch2.ElapsedMilliseconds);
                    apiTime = stopwatch2.ElapsedMilliseconds;
                }
            }, string.Format("Adding {0} object to cache", cacheRequest.ObjectType), 3);
            stopwatch.Stop();
            CachePerformanceTracker.AddPerfData(Operation.WCFProxyObjectCreation, stopwatch.ElapsedMilliseconds - apiTime);
            this.RetryCount = retryCount;
        }
예제 #2
0
 // Token: 0x0600092E RID: 2350 RVA: 0x00028DE0 File Offset: 0x00026FE0
 private CacheItemPolicy GetCacheItemPolicy(AddDirectoryCacheRequest cacheRequest)
 {
     return(new CacheItemPolicy
     {
         AbsoluteExpiration = this.GetCacheItemDateTimeOffsetExpiration(cacheRequest.ObjectType, cacheRequest.SecondsTimeout),
         Priority = cacheRequest.Priority
     });
 }
예제 #3
0
 // Token: 0x06000927 RID: 2343 RVA: 0x00028AA4 File Offset: 0x00026CA4
 public IAsyncResult BeginPutObject(AddDirectoryCacheRequest cacheRequest, AsyncCallback callback, object asyncState)
 {
     this.stopwatch = Stopwatch.StartNew();
     return(this.Invoke(delegate
     {
         ArgumentValidator.ThrowIfNull("cacheRequest", cacheRequest);
         CacheResponseContext cacheResponseContext = new CacheResponseContext();
         LazyAsyncResult lazyAsyncResult = new LazyAsyncResult(cacheResponseContext, asyncState, callback);
         ExTraceGlobals.WCFServiceEndpointTracer.TraceDebug <AddDirectoryCacheRequest>((long)this.GetHashCode(), "Begin Put. Request {0}", cacheRequest);
         MSExchangeDirectoryCacheServiceCounters.NumberOfCacheInsertionRequests.Increment();
         Tuple <string, KeyType> tuple = cacheRequest.Keys.Find((Tuple <string, KeyType> x) => KeyType.None != (x.Item2 & KeyType.Guid));
         if (tuple == null || CacheManager.Instance.ADObjectCache.Get(tuple.Item1.ToLower(), null) == null)
         {
             Tuple <string, KeyType> tuple2 = cacheRequest.Keys.Find((Tuple <string, KeyType> x) => KeyType.None != (x.Item2 & KeyType.DistinguishedName));
             if (tuple == null)
             {
                 tuple = tuple2;
             }
             else if (tuple2 != null && CacheManager.Instance.ADObjectCache.Get(tuple2.Item1.ToLower(), null) != null)
             {
                 tuple = tuple2;
             }
         }
         if (tuple == null)
         {
             return lazyAsyncResult;
         }
         string text = tuple.Item1.ToLower();
         cacheRequest.Object.Initialize(true);
         CacheItemPolicy cacheItemPolicy = this.GetCacheItemPolicy(cacheRequest);
         CacheEntry cacheEntry = (CacheEntry)CacheManager.Instance.ADObjectCache.Get(text, null);
         if (cacheEntry == null || cacheEntry.Invalid)
         {
             cacheEntry = new CacheEntry(new List <ObjectTuple>(1));
             cacheEntry.SimpleADObjectList.Add(new ObjectTuple(cacheRequest.ObjectType, cacheRequest.Object));
             CacheManager.Instance.ADObjectCache.Set(text, cacheEntry, cacheItemPolicy, null);
         }
         else
         {
             ObjectTuple objectTuple = null;
             foreach (ObjectTuple objectTuple2 in cacheEntry.SimpleADObjectList)
             {
                 if (objectTuple2.ObjType == cacheRequest.ObjectType)
                 {
                     objectTuple = objectTuple2;
                     objectTuple2.ADObject = cacheRequest.Object;
                     break;
                 }
             }
             if (objectTuple == null)
             {
                 cacheEntry.SimpleADObjectList = new List <ObjectTuple>(cacheEntry.SimpleADObjectList)
                 {
                     new ObjectTuple(cacheRequest.ObjectType, cacheRequest.Object)
                 };
             }
         }
         foreach (Tuple <string, KeyType> tuple3 in cacheRequest.Keys)
         {
             foreach (KeyType keyType in DirectoryCacheService.AllSupportedKeyTypes)
             {
                 if ((keyType & tuple3.Item2) != KeyType.None)
                 {
                     cacheEntry.ClearKey(keyType);
                 }
             }
         }
         foreach (Tuple <string, KeyType> tuple4 in cacheRequest.Keys)
         {
             foreach (KeyType keyType2 in DirectoryCacheService.AllSupportedKeyTypes)
             {
                 if ((keyType2 & tuple4.Item2) != KeyType.None)
                 {
                     string composedKey = this.GetComposedKey(cacheRequest.ForestOrPartitionFqdn, tuple4.Item1, keyType2);
                     cacheEntry[keyType2].Add(composedKey.ToLower());
                     CacheManager.Instance.KeyTable.Set(composedKey, text, cacheItemPolicy, null);
                 }
             }
         }
         this.stopwatch.Stop();
         cacheResponseContext.BeginOperationLatency = this.stopwatch.ElapsedMilliseconds;
         this.stopwatch.Restart();
         callback(lazyAsyncResult);
         return lazyAsyncResult;
     }));
 }