private IndexProgressData CreateIndexingProgress(QueryResult result)
        {
            if (_profile.Initialized)
            {
                return(new IndexProgressData
                {
                    CompleteInPercents = 100
                });
            }
            IStorage <IndexProgress> indexProgressStorage = _profile.Get <IndexProgress>(typeof(IndexProgress).Name);
            IndexProgress            indexProgress        = indexProgressStorage.FirstOrDefault();

            if (indexProgress == null)
            {
                return(new IndexProgressData
                {
                    CompleteInPercents = 0
                });
            }
            int    allEntities        = indexProgress.LastGeneralId + indexProgress.LastCommentId;
            double completeInPercents = allEntities != 0 ? (double)((result.LastIndexedEntityId + result.LastIndexedCommentId) * 100) / allEntities : 0;

            return(new IndexProgressData {
                CompleteInPercents = Math.Round(completeInPercents, 2)
            });
        }
        public void Handle(CommentQueryResult message)
        {
            IStorage <IndexProgress> storage       = _profileReadonly.Get <IndexProgress>(typeof(IndexProgress).Name);
            IndexProgress            indexProgress = storage.FirstOrDefault();

            if (indexProgress != null)
            {
                indexProgress.LastCommentId = message.Dtos.Any() ? message.Dtos[0].ID.GetValueOrDefault() : 0;
                storage.Update(indexProgress, _ => true);
            }
            SendLocal(new IndexExistingEntitiesLocalMessage {
                OuterSagaId = Data.Id
            });
        }
Esempio n. 3
0
        private void doProgressIndexHDD()
        {
            string progress;

            if (indexLineCount > 0)
            {
                progress = "Working, {0} lines processed.";
                progress = string.Format(progress, indexLineCount);
            }
            else
            {
                progress = "Done: {0} lines.";
                progress = string.Format(progress, -indexLineCount);
            }
            IndexProgress res = new IndexProgress {
                Progress = progress, Done = indexLineCount < 0
            };

            // Tell our caller
            Res = res;
        }
        public static void WriteIndexProgress(this BlittableJsonTextWriter writer, JsonOperationContext context, IndexProgress progress)
        {
            writer.WriteStartObject();

            writer.WritePropertyName(nameof(progress.IsStale));
            writer.WriteBool(progress.IsStale);
            writer.WriteComma();

            writer.WritePropertyName(nameof(progress.Collections));
            if (progress.Collections != null)
            {
                writer.WriteStartObject();
                var isFirst = true;
                foreach (var kvp in progress.Collections)
                {
                    if (isFirst == false)
                    {
                        writer.WriteComma();
                    }

                    isFirst = false;

                    writer.WritePropertyName(kvp.Key);

                    writer.WriteStartObject();

                    writer.WritePropertyName(nameof(kvp.Value.LastProcessedDocumentEtag));
                    writer.WriteInteger(kvp.Value.LastProcessedDocumentEtag);
                    writer.WriteComma();

                    writer.WritePropertyName(nameof(kvp.Value.LastProcessedTombstoneEtag));
                    writer.WriteInteger(kvp.Value.LastProcessedTombstoneEtag);
                    writer.WriteComma();

                    writer.WritePropertyName(nameof(kvp.Value.NumberOfDocumentsToProcess));
                    writer.WriteInteger(kvp.Value.NumberOfDocumentsToProcess);
                    writer.WriteComma();

                    writer.WritePropertyName(nameof(kvp.Value.NumberOfTombstonesToProcess));
                    writer.WriteInteger(kvp.Value.NumberOfTombstonesToProcess);
                    writer.WriteComma();

                    writer.WritePropertyName(nameof(kvp.Value.TotalNumberOfDocuments));
                    writer.WriteInteger(kvp.Value.TotalNumberOfDocuments);
                    writer.WriteComma();

                    writer.WritePropertyName(nameof(kvp.Value.TotalNumberOfTombstones));
                    writer.WriteInteger(kvp.Value.TotalNumberOfTombstones);

                    writer.WriteEndObject();
                }
                writer.WriteEndObject();
            }
            else
            {
                writer.WriteNull();
            }
            writer.WriteComma();

            writer.WritePropertyName(nameof(progress.Name));
            writer.WriteString(progress.Name);
            writer.WriteComma();

            writer.WritePropertyName(nameof(progress.Type));
            writer.WriteString(progress.Type.ToString());
            writer.WriteComma();

            writer.WritePropertyName(nameof(progress.Etag));
            writer.WriteInteger(progress.Etag);

            writer.WriteEndObject();
        }