Beispiel #1
0
        public unsafe List <IndexingError> ReadErrors()
        {
            var errors = new List <IndexingError>();

            using (_contextPool.AllocateOperationContext(out TransactionOperationContext context))
                using (var tx = context.OpenReadTransaction())
                {
                    var table = tx.InnerTransaction.OpenTable(_errorsSchema, "Errors");

                    foreach (var tvr in table.SeekForwardFrom(_errorsSchema.Indexes[IndexSchema.ErrorTimestampsSlice], Slices.BeforeAllKeys, 0))
                    {
                        var error = new IndexingError();

                        var ptr = tvr.Result.Reader.Read(0, out int size);
                        error.Timestamp = new DateTime(Bits.SwapBytes(*(long *)ptr), DateTimeKind.Utc);

                        ptr = tvr.Result.Reader.Read(1, out size);
                        if (size != 0)
                        {
                            error.Document = context.AllocateStringValue(null, ptr, size);
                        }

                        ptr          = tvr.Result.Reader.Read(2, out size);
                        error.Action = context.AllocateStringValue(null, ptr, size);

                        ptr         = tvr.Result.Reader.Read(3, out size);
                        error.Error = context.AllocateStringValue(null, ptr, size);

                        errors.Add(error);
                    }
                }

            return(errors);
        }
Beispiel #2
0
        public void AddError(int index, string indexName, string key, string error, string component)
        {
            errorsCounter = Interlocked.Increment(ref errorsCounter);

            var indexingError = new IndexingError
            {
                Id        = errorsCounter,
                Document  = key,
                Error     = error,
                Index     = index,
                IndexName = indexName,
                Action    = component,
                Timestamp = SystemTime.UtcNow
            };

            indexingErrors.Enqueue(indexingError);

            TransactionalStorage.Batch(accessor => accessor.Lists.Set("Raven/Indexing/Errors/" + indexName, indexingError.Id.ToString(CultureInfo.InvariantCulture), RavenJObject.FromObject(indexingError), UuidType.Indexing));

            if (indexingErrors.Count <= 50)
            {
                return;
            }

            IndexingError ignored;

            indexingErrors.TryDequeue(out ignored);

            TransactionalStorage.Batch(accessor => accessor.Lists.Remove("Raven/Indexing/Errors/" + ignored.IndexName, ignored.Id.ToString(CultureInfo.InvariantCulture)));
        }
Beispiel #3
0
        private void AddError(int index, string indexName, string key, string error, string component)
        {
            var increment = Interlocked.Increment(ref errorsCounter);

            var indexingError = new IndexingError
            {
                Id = increment,
                Document = key,
                Error = error,
                Index = index,
                IndexName = indexName,
                Action = component,
                Timestamp = SystemTime.UtcNow
            };

            indexingErrors.Enqueue(indexingError);
            IndexingError ignored = null;

            lock (indexingErrorLocks.GetOrAdd(index, new object()))
            {
                using (TransactionalStorage.DisableBatchNesting())
                    TransactionalStorage.Batch(accessor =>
                    {
                        accessor.Lists.Set("Raven/Indexing/Errors/" + indexName, indexingError.Id.ToString(CultureInfo.InvariantCulture), RavenJObject.FromObject(indexingError), UuidType.Indexing);

                        if (indexingErrors.Count <= 50)
                            return;

                        if (indexingErrors.TryDequeue(out ignored) == false)
                            return;

                        if (index != ignored.Index || (SystemTime.UtcNow - ignored.Timestamp).TotalSeconds <= 10)
                            return;

                        accessor.Lists.RemoveAllOlderThan("Raven/Indexing/Errors/" + ignored.IndexName, ignored.Timestamp);
                    });
            }

            if (ignored == null || index == ignored.Index)
                return;

            if ((SystemTime.UtcNow - ignored.Timestamp).TotalSeconds <= 10)
                return;

            lock (indexingErrorLocks.GetOrAdd(ignored.Index, new object()))
            {
                using (TransactionalStorage.DisableBatchNesting())
                    TransactionalStorage.Batch(accessor =>
                    {
                        accessor.Lists.RemoveAllOlderThan("Raven/Indexing/Errors/" + ignored.IndexName, ignored.Timestamp);
                    });
            }
        }
Beispiel #4
0
        public unsafe List <IndexingError> ReadErrors()
        {
            var errors = new List <IndexingError>();

            TransactionOperationContext context;

            using (_contextPool.AllocateOperationContext(out context))
                using (var tx = context.OpenReadTransaction())
                {
                    var table = tx.InnerTransaction.OpenTable(_errorsSchema, "Errors");

                    foreach (var sr in table.SeekForwardFrom(_errorsSchema.Indexes[IndexSchema.ErrorTimestampsSlice], Slices.BeforeAllKeys))
                    {
                        foreach (var tvr in sr.Results)
                        {
                            int size;
                            var error = new IndexingError();

                            var ptr = tvr.Read(0, out size);
                            error.Timestamp = new DateTime(IPAddress.NetworkToHostOrder(*(long *)ptr), DateTimeKind.Utc);

                            ptr            = tvr.Read(1, out size);
                            error.Document = new LazyStringValue(null, ptr, size, context);

                            ptr          = tvr.Read(2, out size);
                            error.Action = new LazyStringValue(null, ptr, size, context);

                            ptr         = tvr.Read(3, out size);
                            error.Error = new LazyStringValue(null, ptr, size, context);

                            errors.Add(error);
                        }
                    }
                }

            return(errors);
        }
Beispiel #5
0
 public IndexErrors()
 {
     Errors = new IndexingError[0];
 }
Beispiel #6
0
 public IndexObjectsResult(IReadOnlyList <object> objectsIndexed, IReadOnlyList <object> objectsNotIndexed, IndexingError error, IReadOnlyList <object> objectsNotIndexedStore = null)
     : this(objectsIndexed, objectsNotIndexed, objectsNotIndexedStore)
 {
     Error = error;
 }
Beispiel #7
0
 protected void OnIndexingError(IndexDocumentData doc, Exception exception)
 {
     IndexingError?.Invoke(null, new NodeIndexingErrorEventArgs(doc.NodeId, doc.VersionId, doc.Path, exception));
 }
Beispiel #8
0
 /// <summary>
 /// Raises the <see cref="E:IndexingError"/> event.
 /// </summary>
 /// <param name="e">The <see cref="Examine.IndexingErrorEventArgs"/> instance containing the event data.</param>
 protected virtual void OnIndexingError(IndexingErrorEventArgs e)
 {
     IndexingError?.Invoke(this, e);
 }