Пример #1
0
        protected override bool IsIndexStale(IndexStats indexesStat, IStorageActionsAccessor actions, bool isIdle, Reference<bool> onlyFoundIdleWork)
        {
            var isStale = actions.Staleness.IsMapStale(indexesStat.Id);
            var indexingPriority = indexesStat.Priority;
            if (isStale == false)
                return false;

            if (indexingPriority == IndexingPriority.None)
                return true;


            if ((indexingPriority & IndexingPriority.Normal) == IndexingPriority.Normal)
            {
                onlyFoundIdleWork.Value = false;
                return true;
            }

            if ((indexingPriority & (IndexingPriority.Disabled | IndexingPriority.Error)) != IndexingPriority.None)
                return false;

            if (isIdle == false)
                return false; // everything else is only valid on idle runs

            if ((indexingPriority & IndexingPriority.Idle) == IndexingPriority.Idle)
                return true;

            if ((indexingPriority & IndexingPriority.Abandoned) == IndexingPriority.Abandoned)
            {
                var timeSinceLastIndexing = (SystemTime.UtcNow - indexesStat.LastIndexingTime);

                return (timeSinceLastIndexing > context.Configuration.Indexing.TimeToWaitBeforeRunningAbandonedIndexes.AsTimeSpan);
            }

            throw new InvalidOperationException("Unknown indexing priority for index " + indexesStat.Id + ": " + indexesStat.Priority);
        }
Пример #2
0
        public override void Remove(string[] keys, WorkContext context)
        {
            Write((writer, analyzer, stats) =>
            {
                stats.Operation = IndexingWorkStats.Status.Ignore;
                logIndexing.Debug(() => string.Format("Deleting ({0}) from {1}", string.Join(", ", keys), indexId));
                var batchers = context.IndexUpdateTriggers.Select(x => x.CreateBatcher(indexId))
                               .Where(x => x != null)
                               .ToList();

                keys.Apply(
                    key =>
                    InvokeOnIndexEntryDeletedOnAllBatchers(batchers, new Term(Constants.DocumentIdFieldName, key)));

                writer.DeleteDocuments(keys.Select(k => new Term(Constants.DocumentIdFieldName, k.ToLowerInvariant())).ToArray());
                batchers.ApplyAndIgnoreAllErrors(
                    e =>
                {
                    logIndexing.WarnException("Failed to dispose on index update trigger", e);
                    context.AddError(indexId, null, e.Message, "Dispose Trigger");
                },
                    batcher => batcher.Dispose());

                IndexStats currentIndexStats = null;
                context.TransactionalStorage.Batch(accessor => currentIndexStats = accessor.Indexing.GetIndexStats(indexId));

                return(new IndexedItemsInfo
                {
                    ChangedDocs = keys.Length,
                    HighestETag = currentIndexStats.LastIndexedEtag,
                    DeletedKeys = keys
                });
            });
        }
Пример #3
0
    private void WindowStatus_Load(object sender, EventArgs e)
    {
        indexSettings = new IndexSettings(panel_IndexSettings);
        indexStats    = new IndexStats(indexSettings, panel_IndexStats, btn_EditMode);

        joystickSettings = new JoystickSettings();


        //add all available com port elements to com port combobox
        cmb_comport.Items.AddRange(SerialConnection.GetPortList());
        try { cmb_comport.SelectedIndex = 1; } catch { }                                        //load index 1 (COM5) as default

        //temp, initialize status[0]
        st.status[0] = 1;

        // Load all settings
        graphicsCreator = new GraphicsCreator(pan_graphicsCreator);
        graphicToolbox  = new GraphicToolbox(pan_graphicsCreator, pan_graphicToolbox, rightclickMenu);
        ProgramSaverLoader.Load();

        // Start the st_register send timer
        tim_SendCommandsDelay.Tick += ST_Register.SendCommands;

        //load local IP address into communication tabs ethernet server settings
        txt_comm_serverip.Text   = GetLocalIPAddress();
        txt_comm_serverport.Text = "80";
    }
Пример #4
0
 protected override IndexToWorkOn GetIndexToWorkOn(IndexStats indexesStat)
 {
     return(new IndexToWorkOn
     {
         IndexName = indexesStat.Name,
         LastIndexedEtag = indexesStat.LastReducedEtag ?? Guid.Empty
     });
 }
Пример #5
0
 protected override IndexToWorkOn GetIndexToWorkOn(IndexStats indexesStat)
 {
     return(new IndexToWorkOn
     {
         IndexName = indexesStat.Name,
         LastIndexedEtag = indexesStat.LastIndexedEtag,
     });
 }
Пример #6
0
 protected override IndexToWorkOn GetIndexToWorkOn(IndexStats indexesStat)
 {
     return(new IndexToWorkOn
     {
         IndexId = indexesStat.Id,
         LastIndexedEtag = Etag.Empty
     });
 }
Пример #7
0
        public void Should_mark_index_as_errored_and_throw_on_querying_it_even_its_small()
        {
            using (var store = GetDocumentStore())
            {
                var failingIndex = new Failing_index();
                failingIndex.Execute(store);

                var count = IndexFailureInformation.SufficientNumberOfAttemptsToCheckFailureRate / 2;

                using (var session = store.OpenSession())
                {
                    for (int i = 0; i < count; i++)
                    {
                        var entity = new User();

                        if (i == 0)
                        {
                            entity.Age = 1;
                        }

                        session.Store(entity);
                    }

                    session.SaveChanges();
                }

                WaitForIndexing(store, allowErrors: true);

                IndexStats indexStats = null;

                Assert.True(SpinWait.SpinUntil(() =>
                {
                    // index stats are updated in different transaction so we might need to wait a bit for error state,
                    // note that index state is taken directly from memory so we need to wait for the stats that have some attempts and errors

                    indexStats = store.Maintenance.Send(new GetIndexStatisticsOperation(failingIndex.IndexName));

                    if (indexStats.State == IndexState.Error && indexStats.MapAttempts > 0)
                    {
                        return(true);
                    }

                    Thread.Sleep(10);

                    return(false);
                }, TimeSpan.FromSeconds(15)), "index state was not set to Error");

                Assert.True(indexStats.IsInvalidIndex,
                            $"{(indexStats != null ? $"attempts: {indexStats.MapAttempts}, successes:{indexStats.MapSuccesses}, errors:{indexStats.MapErrors}, errors count: {indexStats.ErrorsCount}" : "index stats is null")}");

                using (var session = store.OpenSession())
                {
                    var ex = Assert.Throws <RavenException>(() => session.Query <User, Failing_index>().ToList());

                    Assert.Contains($"is invalid, out of {count} map attempts, {count - 1} has failed.", ex.Message);
                }
            }
        }
Пример #8
0
 protected override IndexToWorkOn GetIndexToWorkOn(IndexStats indexesStat)
 {
     return(new IndexToWorkOn
     {
         IndexId = indexesStat.Id,
         LastIndexedEtag = indexesStat.LastIndexedEtag,
         LastIndexedTimestamp = indexesStat.LastIndexedTimestamp
     });
 }
Пример #9
0
        public void InitializeBasedOnIndexingResults()
        {
            var indexDefinitions = context.IndexDefinitionStorage.IndexDefinitions.Values.ToList();

            if (indexDefinitions.Count == 0)
            {
                lastCollectionEtags = new ConcurrentDictionary <string, Entry>(StringComparer.InvariantCultureIgnoreCase);
                return;
            }

            var indexesStats = new List <IndexStats>();

            foreach (var definition in indexDefinitions)
            {
                var indexId = definition.IndexId;

                IndexStats stats = null;
                context.Database.TransactionalStorage.Batch(accessor =>
                {
                    var isStale = accessor.Staleness.IsIndexStale(indexId, null, null);
                    if (isStale == false)
                    {
                        stats = accessor.Indexing.GetIndexStats(indexId);
                    }
                });

                if (stats == null)
                {
                    continue;
                }

                var abstractViewGenerator = context.IndexDefinitionStorage.GetViewGenerator(indexId);
                if (abstractViewGenerator == null)
                {
                    continue;
                }

                stats.ForEntityName = abstractViewGenerator.ForEntityNames.ToArray();

                indexesStats.Add(stats);
            }

            var collectionEtags = indexesStats.Where(x => x.ForEntityName.Length > 0)
                                  .SelectMany(x => x.ForEntityName, (stats, collectionName) => new Tuple <string, Etag>(collectionName, stats.LastIndexedEtag))
                                  .GroupBy(x => x.Item1, StringComparer.OrdinalIgnoreCase)
                                  .Select(x => new
            {
                CollectionName = x.Key,
                MaxEtag        = x.Min(y => y.Item2)
            })
                                  .ToDictionary(x => x.CollectionName, y => new Entry {
                Etag = y.MaxEtag, Updated = SystemTime.UtcNow
            });

            lastCollectionEtags = new ConcurrentDictionary <string, Entry>(collectionEtags, StringComparer.OrdinalIgnoreCase);
        }
        public ActionResult DonneesIndex()
        {
            IndexStats stats = new IndexStats
            {
                NombreDemandesVendeur = CalculerNombreDemandesVendeurs(),
                Redevances            = CalculerRedevances(),
                UtilisateursInactifs  = CalculerInactivite(),
            };

            return(Json(stats));
        }
Пример #11
0
        protected IndexStats GetIndexStats(DocumentDatabase database)
        {
            IndexStats stats = null;

            database.TransactionalStorage.Batch(actions =>
            {
                stats = actions.Indexing.GetIndexStats(IndexDefinition.IndexId);
            });

            return(stats);
        }
Пример #12
0
        public void SetCurrentIndexStatsTo(string index)
        {
            var indexPos = Mutator.Indexes.FindValue(index);

            if (indexPos == null)
            {
                throw new InvalidOperationException("Could not find index named: " + index);
            }
            Reader.Position = indexPos.Value;
            current         = new JsonSerializer().Deserialize <IndexStats>(new BsonReader(Reader));
        }
Пример #13
0
        public void IndexThatLoadAttachmentsShouldIndexAllDocuments()
        {
            using (var store = NewDocumentStore(requestedStorage: "esent"))             // the problem occurred only on Esent
            {
                var indexWithAttachments = new RavenDB1316.Attachment_Indexing();
                indexWithAttachments.Execute(store);

                store.DatabaseCommands.PutAttachment("attachment", null,
                                                     new MemoryStream(Encoding.UTF8.GetBytes("this is a test")),
                                                     new RavenJObject());
                var tasks = new List <Task>();

                // here we have to do a big document upload because the problem occurred only when
                // DefaultBackgroundTaskExecuter.ExecuteAllInterleaved method was performed during indexing process

                for (var i = 0; i < 5; i++)
                {
                    tasks.Add(Task.Factory.StartNew(() =>
                    {
                        for (var j = 0; j < 1000; j++)
                        {
                            using (var session = store.OpenSession())
                            {
                                session.Store(new RavenDB1316.Item
                                {
                                    Name    = "A",
                                    Content = "attachment"
                                });
                                session.Store(new RavenDB1316.Item
                                {
                                    Name    = "B",
                                    Content = "attachment"
                                });
                                session.Store(new RavenDB1316.Item
                                {
                                    Name    = "C",
                                    Content = "attachment"
                                });
                                session.SaveChanges();
                            }
                        }
                    }));
                }

                Task.WaitAll(tasks.ToArray());

                WaitForIndexing(store);

                IndexStats indexStats = store.DatabaseCommands.GetStatistics().Indexes.First(x => x.Name == indexWithAttachments.IndexName);

                Assert.Equal(15000, indexStats.DocsCount);
            }
        }
Пример #14
0
		protected override bool IsIndexStale(IndexStats indexesStat, IStorageActionsAccessor actions, bool isIdle, Reference<bool> onlyFoundIdleWork)
		{
			onlyFoundIdleWork.Value = false;
			var isReduceStale = actions.Staleness.IsReduceStale(indexesStat.Id);

			if (isReduceStale == false)
				return false;

			if (indexesStat.Priority.HasFlag(IndexingPriority.Error))
				return false;

			return true;
		}
Пример #15
0
        private static void AddInstanceIndexStats(StoreStats stats, InstanceStatsHolder response)
        {
            foreach (var index in stats.Indexing)
            {
                IndexStats indexStats = null;

                if (response.DatabaseStats != null &&
                    response.DatabaseStats.Indexes != null)
                {
                    indexStats = response.DatabaseStats.Indexes
                                 .Where(idx => idx.Name == index.Name)
                                 .FirstOrDefault();
                }

                var instanceIdxStatus = new InstanceIndexStats()
                {
                    Url = response.Url
                };
                if (indexStats == null)
                {
                    instanceIdxStatus.Exists  = false;
                    instanceIdxStatus.IsStale = true;
                }
                else
                {
                    instanceIdxStatus.Exists = true;
                    if (response.DatabaseStats != null &&
                        response.DatabaseStats.Indexes != null)
                    {
                        instanceIdxStatus.IsStale = response.DatabaseStats.StaleIndexes.Contains(index.Name);
                    }
                    else
                    {
                        instanceIdxStatus.IsStale = true;
                    }

                    if (response.IndexHashCodes != null)
                    {
                        int hashCode;
                        if (response.IndexHashCodes.TryGetValue(indexStats.Name, out hashCode))
                        {
                            instanceIdxStatus.HashCode = hashCode;
                        }
                    }

                    instanceIdxStatus.CopyFrom(indexStats);
                }

                index.Instances.Add(instanceIdxStatus);
            }
        }
Пример #16
0
        protected override bool IsIndexStale(IndexStats indexesStat, Etag synchronizationEtag, IStorageActionsAccessor actions, bool isIdle, Reference <bool> onlyFoundIdleWork)
        {
            if (indexesStat.LastIndexedEtag.CompareTo(synchronizationEtag) > 0)
            {
                return(true);
            }

            var isStale          = actions.Staleness.IsMapStale(indexesStat.Name);
            var indexingPriority = indexesStat.Priority;

            if (isStale == false)
            {
                return(false);
            }

            if (indexingPriority == IndexingPriority.None)
            {
                return(true);
            }

            if (indexingPriority.HasFlag(IndexingPriority.Normal))
            {
                onlyFoundIdleWork.Value = false;
                return(true);
            }

            if (indexingPriority.HasFlag(IndexingPriority.Disabled))
            {
                return(false);
            }

            if (isIdle == false)
            {
                return(false);                // everything else is only valid on idle runs
            }
            if (indexingPriority.HasFlag(IndexingPriority.Idle))
            {
                return(true);
            }

            if (indexingPriority.HasFlag(IndexingPriority.Abandoned))
            {
                var timeSinceLastIndexing = (SystemTime.UtcNow - indexesStat.LastIndexingTime);

                return(timeSinceLastIndexing > context.Configuration.TimeToWaitBeforeRunningAbandonedIndexes);
            }

            throw new InvalidOperationException("Unknown indexing priority for index " + indexesStat.Name + ": " + indexesStat.Priority);
        }
Пример #17
0
        public IndexStats ReadStats(RavenTransaction tx)
        {
            var statsTree = tx.InnerTransaction.ReadTree(IndexSchema.StatsTree);
            var table     = tx.InnerTransaction.OpenTable(_errorsSchema, "Errors");

            var stats = new IndexStats
            {
                CreatedTimestamp = DateTime.FromBinary(statsTree.Read(IndexSchema.CreatedTimestampSlice).Reader.ReadLittleEndianInt64()),
                ErrorsCount      = (int)(table?.NumberOfEntries ?? 0)
            };

            var lastIndexingTime = statsTree.Read(IndexSchema.LastIndexingTimeSlice);

            stats.Collections = new Dictionary <string, IndexStats.CollectionStats>();
            foreach (var collection in _index.Definition.Collections)
            {
                stats.Collections[collection] = new IndexStats.CollectionStats
                {
                    LastProcessedDocumentEtag  = ReadLastIndexedEtag(tx, collection),
                    LastProcessedTombstoneEtag = ReadLastProcessedTombstoneEtag(tx, collection)
                };
            }

            if (lastIndexingTime != null)
            {
                stats.LastIndexingTime = DateTime.FromBinary(lastIndexingTime.Reader.ReadLittleEndianInt64());
                stats.MapAttempts      = statsTree.Read(IndexSchema.MapAttemptsSlice).Reader.ReadLittleEndianInt32();
                stats.MapErrors        = statsTree.Read(IndexSchema.MapErrorsSlice).Reader.ReadLittleEndianInt32();
                stats.MapSuccesses     = statsTree.Read(IndexSchema.MapSuccessesSlice).Reader.ReadLittleEndianInt32();
                stats.MaxNumberOfOutputsPerDocument =
                    statsTree.Read(IndexSchema.MaxNumberOfOutputsPerDocument).Reader.ReadLittleEndianInt32();

                if (_index.Type.IsMapReduce())
                {
                    stats.ReduceAttempts  = statsTree.Read(IndexSchema.ReduceAttemptsSlice)?.Reader.ReadLittleEndianInt32() ?? 0;
                    stats.ReduceSuccesses = statsTree.Read(IndexSchema.ReduceSuccessesSlice)?.Reader.ReadLittleEndianInt32() ?? 0;
                    stats.ReduceErrors    = statsTree.Read(IndexSchema.ReduceErrorsSlice)?.Reader.ReadLittleEndianInt32() ?? 0;
                }

                if (_index.GetReferencedCollections()?.Count > 0)
                {
                    stats.MapReferenceAttempts  = statsTree.Read(IndexSchema.MapReferencedAttemptsSlice)?.Reader.ReadLittleEndianInt32() ?? 0;
                    stats.MapReferenceSuccesses = statsTree.Read(IndexSchema.MapReferenceSuccessesSlice)?.Reader.ReadLittleEndianInt32() ?? 0;
                    stats.MapReferenceErrors    = statsTree.Read(IndexSchema.MapReferenceErrorsSlice)?.Reader.ReadLittleEndianInt32() ?? 0;
                }
            }

            return(stats);
        }
Пример #18
0
        public async Task WillGetIndexStatsFromStorageOrReader()
        {
            using (var store = GetDocumentStore())
            {
                store.Maintenance.Send(new StopIndexingOperation());

                var index = new Users_ByName();
                await index.ExecuteAsync(store);

                var indexInstance = (await GetDatabase(store.Database)).IndexStore.GetIndex(index.IndexName);

                // the indexing was never run so it didn't store entries count in the stats
                // in that case it will open the index reader under the covers to get that count

                IndexStats indexStats = await store.Maintenance.SendAsync(new GetIndexStatisticsOperation(index.IndexName));

                Assert.Equal(0, indexStats.EntriesCount);

                Assert.NotNull(indexInstance.IndexPersistence._lastReader);

                using (var session = store.OpenSession())
                {
                    session.Store(new User()
                    {
                        Name = "Arek"
                    });

                    session.SaveChanges();
                }

                await store.Maintenance.SendAsync(new StartIndexingOperation());

                WaitForIndexing(store);

                // let's force to clean the reader
                indexInstance.IndexPersistence.Clean(IndexCleanup.All);

                Assert.Null(indexInstance.IndexPersistence._lastReader);

                // after the indexing batch has been run we'll get the entries count directly from the storage so no need to recreate the index reader

                Assert.Equal(1, WaitForEntriesCount(store, index.IndexName, 1));

                Assert.Null(indexInstance.IndexPersistence._lastReader);
            }
        }
Пример #19
0
        static void Stats()
        {
            // Search(string indexName, SearchQuery query, out SearchResult result)
            string indexName = InputString("Index name:", null, true);

            if (String.IsNullOrEmpty(indexName))
            {
                return;
            }

            IndexStats stats = _Sdk.GetIndexStats(indexName).Result;

            if (stats != null)
            {
                Console.WriteLine(SerializeJson(stats, true));
            }
        }
Пример #20
0
 public override ElasticResponse RefreshFromConnection(SearchClient cli)
 {
     var health = cli.GetIndexStats();
     if (health.HasData)
     {
         GlobalStats = health.Data.All;
         Shards = health.Data.Shards;
         Indices = health.Data.Indices;
     }
     else
     {
         GlobalStats = new IndexStats();
         Shards = new ShardCountStats();
         Indices = new Dictionary<string, IndexStats>();
     }
     return health;
 }
Пример #21
0
            public override ElasticResponse RefreshFromConnection(SearchClient cli)
            {
                var health = cli.GetIndexStats();

                if (health.HasData)
                {
                    GlobalStats = health.Data.All;
                    Shards      = health.Data.Shards;
                    Indices     = health.Data.Indices;
                }
                else
                {
                    GlobalStats = new IndexStats();
                    Shards      = new ShardCountStats();
                    Indices     = new Dictionary <string, IndexStats>();
                }
                return(health);
            }
Пример #22
0
 public void CopyFrom(IndexStats indexStats)
 {
     // TODO: Use automapper.
     this.IndexingAttempts     = indexStats.IndexingAttempts;
     this.IndexingErrors       = indexStats.IndexingErrors;
     this.IndexingSuccesses    = indexStats.IndexingSuccesses;
     this.LastIndexedEtag      = indexStats.LastIndexedEtag;
     this.LastIndexedTimestamp = indexStats.LastIndexedTimestamp;
     this.LastQueryTimestamp   = indexStats.LastQueryTimestamp;
     this.LastReducedEtag      = indexStats.LastReducedEtag;
     this.LastReducedTimestamp = indexStats.LastReducedTimestamp;
     this.Name = indexStats.Name;
     //this.Performance = indexStats.Performance;
     this.ReduceIndexingAttempts  = indexStats.ReduceIndexingAttempts;
     this.ReduceIndexingErrors    = indexStats.ReduceIndexingErrors;
     this.ReduceIndexingSuccesses = indexStats.ReduceIndexingSuccesses;
     this.TouchCount = indexStats.TouchCount;
 }
        protected void Assert(IndexStats index)
        {
            index.Should().NotBeNull();

            index.Documents.Should().NotBeNull();
            //index.Documents.Count.Should().BeGreaterThan(0);

            index.Store.Should().NotBeNull();
            index.Store.SizeInBytes.Should().BeGreaterOrEqualTo(0);

            if (TestClient.Configuration.InRange(">=7.9.0"))
            {
                index.Store.ReservedInBytes.Should().BeGreaterOrEqualTo(0);
            }

            index.Completion.Should().NotBeNull();
            index.Fielddata.Should().NotBeNull();

            index.Flush.Should().NotBeNull();

            index.Get.Should().NotBeNull();
            index.Indexing.Should().NotBeNull();
            index.Merges.Should().NotBeNull();
            index.QueryCache.Should().NotBeNull();
            index.Recovery.Should().NotBeNull();

            index.Segments.Should().NotBeNull();
            //index.Segments.Count.Should().BeGreaterThan(0);
            //index.Segments.DocValuesMemoryInBytes.Should().BeGreaterThan(0);
            //index.Segments.IndexWriterMaxMemoryInBytes.Should().BeGreaterThan(0);
            //index.Segments.MemoryInBytes.Should().BeGreaterThan(0);
            //index.Segments.NormsMemoryInBytes.Should().BeGreaterThan(0);
            //index.Segments.StoredFieldsMemoryInBytes.Should().BeGreaterThan(0);
            //index.Segments.PointsMemoryInBytes.Should().BeGreaterThan(0);
            //index.Segments.TermsMemoryInBytes.Should().BeGreaterThan(0);

            index.Store.Should().NotBeNull();
            //index.Store.SizeInBytes.Should().BeGreaterThan(0);

            index.Search.Should().NotBeNull();
            index.Translog.Should().NotBeNull();
            index.Warmer.Should().NotBeNull();
        }
Пример #24
0
        private void GetIndexStats(IHttpContext context, string index)
        {
            IndexStats stats = null;

            Database.TransactionalStorage.Batch(accessor =>
            {
                stats = accessor.Indexing.GetIndexStats(index);
            });

            if (stats == null)
            {
                context.SetStatusToNotFound();
                return;
            }

            stats.LastQueryTimestamp = Database.IndexStorage.GetLastQueryTime(index);
            stats.Performance        = Database.IndexStorage.GetIndexingPerformance(index);

            context.WriteJson(stats);
        }
Пример #25
0
        private HttpResponseMessage GetIndexStats(string index)
        {
            IndexStats stats    = null;
            var        instance = Database.IndexStorage.GetIndexInstance(index);

            Database.TransactionalStorage.Batch(accessor =>
            {
                stats = accessor.Indexing.GetIndexStats(instance.indexId);
            });

            if (stats == null)
            {
                return(GetEmptyMessage(HttpStatusCode.NotFound));
            }

            stats.LastQueryTimestamp = Database.IndexStorage.GetLastQueryTime(instance.indexId);
            stats.Performance        = Database.IndexStorage.GetIndexingPerformance(instance.indexId);

            return(GetMessageWithObject(stats));
        }
Пример #26
0
        public void WillNotReindexSameDocumentMultipleTimes()
        {
            using var store = GetDocumentStore();
            using (var session = store.OpenSession())
            {
                session.Store(new Group
                {
                    Groups = new[] { "groups/2" },
                    Users  = new[] { "users/1" }
                }, "groups/1");

                session.Store(new Group
                {
                    Groups = new[] { "groups/3" },
                    Users  = new[] { "users/2" }
                }, "groups/2");

                session.Store(new Group
                {
                    Users = new[] { "users/1" }
                }, "groups/3");
                session.Store(new User {
                    Name = "a"
                }, "users/1");
                session.Store(new User {
                    Name = "b"
                }, "users/2");


                session.SaveChanges();
            }

            new Index().Execute(store);
            WaitForIndexing(store);

            IndexStats stats = store.Maintenance.Send(new GetIndexStatisticsOperation("index"));

            Assert.Equal(3, stats.EntriesCount);
            Assert.Equal(3, stats.MapAttempts);
            Assert.Equal(0, stats.MapReferenceAttempts);
        }
Пример #27
0
        private HttpResponseMessage GetIndexStats(string index)
        {
            IndexStats stats    = null;
            Etag       lastEtag = null;
            var        instance = Database.IndexStorage.GetIndexInstance(index);

            Database.TransactionalStorage.Batch(accessor =>
            {
                stats    = accessor.Indexing.GetIndexStats(instance.indexId);
                lastEtag = accessor.Staleness.GetMostRecentDocumentEtag();
            });

            if (stats == null)
            {
                return(GetEmptyMessage(HttpStatusCode.NotFound));
            }

            stats.LastQueryTimestamp = Database.IndexStorage.GetLastQueryTime(instance.indexId);
            stats.SetLastDocumentEtag(lastEtag);
            return(GetMessageWithObject(stats));
        }
        protected void Assert(IndexStats index)
        {
            index.Should().NotBeNull();

            index.Documents.Should().NotBeNull();
            index.Documents.Count.Should().BeGreaterThan(0);

            index.Store.Should().NotBeNull();
            index.Store.SizeInBytes.Should().BeGreaterThan(0);

            index.Completion.Should().NotBeNull();
            index.Fielddata.Should().NotBeNull();

            index.Flush.Should().NotBeNull();
            index.Flush.Total.Should().BeGreaterThan(0);
            index.Flush.TotalTimeInMilliseconds.Should().BeGreaterThan(0);

            index.Get.Should().NotBeNull();
            index.Indexing.Should().NotBeNull();
            index.Merges.Should().NotBeNull();
            index.Percolate.Should().NotBeNull();
            index.QueryCache.Should().NotBeNull();
            index.Recovery.Should().NotBeNull();

            index.Segments.Should().NotBeNull();
            index.Segments.Count.Should().BeGreaterThan(0);
            index.Segments.DocValuesMemoryInBytes.Should().BeGreaterThan(0);
            index.Segments.IndexWriterMaxMemoryInBytes.Should().BeGreaterThan(0);
            index.Segments.MemoryInBytes.Should().BeGreaterThan(0);
            index.Segments.NormsMemoryInBytes.Should().BeGreaterThan(0);
            index.Segments.StoredFieldsMemoryInBytes.Should().BeGreaterThan(0);
            index.Segments.TermsMemoryInBytes.Should().BeGreaterThan(0);

            index.Store.Should().NotBeNull();
            index.Store.SizeInBytes.Should().BeGreaterThan(0);

            index.Suggest.Should().NotBeNull();
            index.Translog.Should().NotBeNull();
            index.Warmer.Should().NotBeNull();
        }
Пример #29
0
        public void DoesNotOverReduce()
        {
            using (var store = GetDocumentStore())
            {
                Fill(store);

                using (var commands = store.Commands())
                {
                    for (int i = 0; i < 1024; i++)
                    {
                        using (var stream = new MemoryStream(Encoding.UTF8.GetBytes("{'blog_id': " + i + ", 'comments': [{},{},{}]}")))
                        {
                            var json = commands.Context.Sync.ReadForMemory(stream, "blog");
                            commands.Put("blogs/" + i, null, json, new Dictionary <string, object> {
                                { "@collection", "Blogs" }
                            });
                        }
                    }

                    Indexes.WaitForIndexing(store);

                    IndexStats stats = null;

                    Assert.True(SpinWait.SpinUntil(() =>
                    {
                        stats = store.Maintenance.Send(new GetIndexStatisticsOperation("CommentsCountPerBlog"));

                        return(stats.ReduceAttempts != null);
                    }, TimeSpan.FromSeconds(5)));

                    // we add 100 because we might have reduces running in the middle of the operation
                    Assert.True((1024 + 100) >= stats.ReduceAttempts.Value,
                                "1024 + 100 >= " + stats.ReduceAttempts + " failed");
                }
            }
        }
Пример #30
0
 protected override bool IsValidIndex(IndexStats indexesStat)
 {
     return(true);
 }
        public static void WriteIndexStats(this BlittableJsonTextWriter writer, JsonOperationContext context, IndexStats stats)
        {
            var djv = (DynamicJsonValue)TypeConverter.ToBlittableSupportedType(stats);

            writer.WriteObject(context.ReadObject(djv, "index/stats"));
        }