コード例 #1
0
        /// <summary>
        /// Overloaded constructor. Takes the properties as a map.
        /// </summary>
        /// <param name="cacheSchemes">collection of cache schemes (config properties).</param>
        /// <param name="properties">properties collection for this cache.</param>
        /// <param name="listener">cache events listener</param>
        /// <param name="timeSched">scheduler to use for periodic tasks</param>
        public IndexedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context)
            : base(cacheClasses, parentCache, properties, listener, context)
        {
            IDictionary props = null;

            if (properties.Contains("indexes"))
            {
                props = properties["indexes"] as IDictionary;
            }

            _queryIndexManager = new QueryIndexManager(props, this, _context.CacheRoot.Name);
            if (!_queryIndexManager.Initialize())
            {
                _queryIndexManager = null;
            }


            //+Numan16122014
            _cacheStore.ISizableQueryIndexManager      = _queryIndexManager;
            _cacheStore.ISizableEvictionIndexManager   = _evictionPolicy;
            _cacheStore.ISizableExpirationIndexManager = _context.ExpiryMgr;

            _stats.MaxCount = _cacheStore.MaxCount;
            _stats.MaxSize  = _cacheStore.MaxSize;

            //+Numan16122014

            if (_context.PerfStatsColl != null)
            {
                if (_queryIndexManager != null)
                {
                    _context.PerfStatsColl.SetQueryIndexSize(_queryIndexManager.IndexInMemorySize);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or
 /// resetting unmanaged resources.
 /// </summary>
 public override void Dispose()
 {
     base.Dispose();
     if (_queryIndexManager != null)
     {
         _queryIndexManager.Dispose();
         _queryIndexManager = null;
     }
 }
コード例 #3
0
        public async Task Test_GetAllIndexesAsync()
        {
            using var response = ResourceHelper.ReadResourceAsStream(@"Documents\Query\Management\query-index-partition-response.json");

            var buffer = new byte[response.Length];

            response.Read(buffer, 0, buffer.Length);

            var handlerMock = new Mock <HttpMessageHandler>();

            handlerMock.Protected().Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.IsAny <HttpRequestMessage>(),
                ItExpr.IsAny <CancellationToken>()).ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new ByteArrayContent(buffer)
            });

            var httpClient = new HttpClient(handlerMock.Object)
            {
                BaseAddress = new Uri("http://localhost:8091")
            };
            var httpClientFactory = new MockHttpClientFactory(httpClient);

            var mockServiceUriProvider = new Mock <IServiceUriProvider>();

            mockServiceUriProvider
            .Setup(m => m.GetRandomQueryUri())
            .Returns(new Uri("http://localhost:8093"));

            var serializer = new DefaultSerializer();
            var client     = new QueryClient(httpClientFactory, mockServiceUriProvider.Object, serializer,
                                             new Mock <ILogger <QueryClient> >().Object, NoopRequestTracer.Instance);

            var manager = new QueryIndexManager(client, new Mock <ILogger <QueryIndexManager> >().Object,
                                                new Redactor(new TypedRedactor(RedactionLevel.None)));

            var result = await manager.GetAllIndexesAsync("default");

            var queryIndices     = result as QueryIndex[] ?? result.ToArray();
            var rowWithPartition = queryIndices.FirstOrDefault(x => x.Partition == "HASH(`_type`)");

            Assert.NotNull(rowWithPartition);

            var rowWithCondition = queryIndices.FirstOrDefault(x => x.Condition == "(`_type` = \"User\")");

            Assert.NotNull(rowWithCondition);

            var rowWithIndexKey = queryIndices.FirstOrDefault(x => x.IndexKey.Contains("`airportname`"));

            Assert.Equal("`airportname`", rowWithIndexKey.IndexKey.First());
        }
コード例 #4
0
        /// <summary>
        /// Construtor padrão.
        /// </summary>
        /// <param name="cacheClasses"></param>
        /// <param name="parentCache">Cache pai.</param>
        /// <param name="properties">Propriedades de configuração da instancia.</param>
        /// <param name="listener"></param>
        /// <param name="context"></param>
        /// <param name="activeQueryAnalyzer"></param>
        public IndexedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, ActiveQueryAnalyzer activeQueryAnalyzer) : base(cacheClasses, parentCache, properties, listener, context, activeQueryAnalyzer)
        {
            _grpIndexManager = new GroupIndexManager();
            IDictionary props = null;

            if (properties.Contains("indexes"))
            {
                props = properties["indexes"] as IDictionary;
            }
            _queryIndexManager = new NamedTagIndexManager(props, this, base._context.CacheRoot.Name);
            if (!_queryIndexManager.Initialize())
            {
                _queryIndexManager = null;
            }
        }
コード例 #5
0
 /// <summary>
 /// Libera a instancia.
 /// </summary>
 public override void Dispose()
 {
     base.Dispose();
     if (_queryIndexManager != null)
     {
         _queryIndexManager.Dispose();
         _queryIndexManager = null;
     }
     if (_grpIndexManager != null)
     {
         _grpIndexManager.Dispose();
         _grpIndexManager = null;
     }
     GC.Collect();
 }
コード例 #6
0
        /// <summary>
        /// Overloaded constructor. Takes the properties as a map.
        /// </summary>
        /// <param name="cacheSchemes">collection of cache schemes (config properties).</param>
        /// <param name="properties">properties collection for this cache.</param>
        /// <param name="listener">cache events listener</param>
        /// <param name="timeSched">scheduler to use for periodic tasks</param>
        public IndexedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context

                                 , ActiveQueryAnalyzer activeQueryAnalyzer

                                 )
            : base(cacheClasses, parentCache, properties, listener, context

                   , activeQueryAnalyzer

                   )
        {
            _grpIndexManager = new GroupIndexManager();


            IDictionary props = null;

            if (properties.Contains("indexes"))
            {
                props = properties["indexes"] as IDictionary;
            }

            _queryIndexManager = new NamedTagIndexManager(props, this, _context.CacheRoot.Name);

            if (!_queryIndexManager.Initialize(null))
            {
                _queryIndexManager = null;
            }

            _cacheStore.ISizableQueryIndexManager      = _queryIndexManager;
            _cacheStore.ISizableGroupIndexManager      = _grpIndexManager;
            _cacheStore.ISizableEvictionIndexManager   = _evictionPolicy;
            _cacheStore.ISizableExpirationIndexManager = _context.ExpiryMgr;

            _stats.MaxCount = _cacheStore.MaxCount;
            _stats.MaxSize  = _cacheStore.MaxSize;

            if (_context.PerfStatsColl != null)
            {
                if (_queryIndexManager != null)
                {
                    _context.PerfStatsColl.SetQueryIndexSize(_queryIndexManager.IndexInMemorySize);
                }

                _context.PerfStatsColl.SetGroupIndexSize(_grpIndexManager.IndexInMemorySize);
            }
        }