Esempio n. 1
0
 // Token: 0x06000925 RID: 2341 RVA: 0x000285E4 File Offset: 0x000267E4
 public IAsyncResult BeginGetObject(DirectoryCacheRequest cacheRequest, AsyncCallback callback, object asyncState)
 {
     this.stopwatch = Stopwatch.StartNew();
     return(this.Invoke(delegate
     {
         ArgumentValidator.ThrowIfNull("cacheRequest", cacheRequest);
         if (cacheRequest.ObjectType == ObjectType.ADRawEntry && cacheRequest.Properties == null)
         {
             throw new ArgumentException("properties cannot be null when request object type is ADRawEntry");
         }
         MSExchangeDirectoryCacheServiceCounters.NumberOfCacheReadRequests.Increment();
         GetObjectContext getObjectContext = new GetObjectContext();
         getObjectContext.ResultState = ADCacheResultState.NotFound;
         LazyAsyncResult lazyAsyncResult = new LazyAsyncResult(getObjectContext, asyncState, callback);
         ExTraceGlobals.WCFServiceEndpointTracer.TraceDebug <DirectoryCacheRequest>((long)this.GetHashCode(), "Begin GetObject. Request {0}", cacheRequest);
         MSExchangeDirectoryCacheServiceCounters.CacheHitRatioBase.Increment();
         ObjectTuple objectTuple = null;
         foreach (Tuple <string, KeyType> tuple in cacheRequest.Keys)
         {
             CacheEntry cacheEntry = null;
             foreach (KeyType keyType in DirectoryCacheService.AllSupportedKeyTypes)
             {
                 if ((keyType & tuple.Item2) != KeyType.None)
                 {
                     string composedKey = this.GetComposedKey(cacheRequest.ForestOrPartitionFqdn, tuple.Item1, keyType);
                     string text = (string)CacheManager.Instance.KeyTable.Get(composedKey, null);
                     if (text != null)
                     {
                         cacheEntry = (CacheEntry)CacheManager.Instance.ADObjectCache.Get(text, null);
                         if (cacheEntry != null && cacheEntry[keyType].Contains(composedKey.ToLower()))
                         {
                             break;
                         }
                         if (cacheEntry != null)
                         {
                             if (ExTraceGlobals.WCFServiceEndpointTracer.IsTraceEnabled(TraceType.DebugTrace))
                             {
                                 string keyValues = string.Empty;
                                 cacheEntry[keyType].ForEach(delegate(string keyVal)
                                 {
                                     keyValues += keyVal;
                                     keyValues += ",";
                                 });
                                 ExTraceGlobals.WCFServiceEndpointTracer.TraceDebug <string, string>((long)this.GetHashCode(), "the key {0} does not match the cacheEntry's one {1}", composedKey, keyValues);
                             }
                             cacheEntry = null;
                         }
                     }
                 }
             }
             if (cacheEntry != null)
             {
                 if (cacheEntry.Invalid)
                 {
                     break;
                 }
                 foreach (ObjectTuple objectTuple2 in cacheEntry.SimpleADObjectList)
                 {
                     if (objectTuple2.ObjType == cacheRequest.ObjectType)
                     {
                         objectTuple = objectTuple2;
                         break;
                     }
                 }
                 if (objectTuple == null)
                 {
                     break;
                 }
                 if (cacheRequest.Properties != null)
                 {
                     foreach (string key in cacheRequest.Properties)
                     {
                         if (!objectTuple.ADObject.Properties.ContainsKey(key))
                         {
                             objectTuple = null;
                             getObjectContext.ResultState = ADCacheResultState.PropertiesMissing;
                             ADProviderPerf.UpdateDirectoryADRawCachePropertiesMismatchRate(true);
                             break;
                         }
                     }
                 }
                 if (objectTuple == null)
                 {
                     break;
                 }
                 getObjectContext.Object = objectTuple.ADObject;
                 getObjectContext.ResultState = ADCacheResultState.Succeed;
                 if (cacheRequest.Properties != null)
                 {
                     ADProviderPerf.UpdateDirectoryADRawCachePropertiesMismatchRate(false);
                     break;
                 }
                 break;
             }
         }
         ExTraceGlobals.WCFServiceEndpointTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Begin GetObject. Request {0}. Was Cache {1}", cacheRequest.RequestId, (getObjectContext.Object != null) ? "HIT" : "MISS");
         ADProviderPerf.UpdateDirectoryCacheHitRatio(null != getObjectContext.Object, cacheRequest.ObjectType);
         this.stopwatch.Stop();
         getObjectContext.BeginOperationLatency = this.stopwatch.ElapsedMilliseconds;
         this.stopwatch.Restart();
         callback(lazyAsyncResult);
         return lazyAsyncResult;
     }));
 }
Esempio n. 2
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;
     }));
 }