Exemplo n.º 1
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);

			if (indexingErrors.Count <= 50)
			{
				TransactionalStorage.Batch(accessor => accessor.Lists.Set("Raven/Indexing/Errors/" + indexName, indexingError.Id.ToString(CultureInfo.InvariantCulture), RavenJObject.FromObject(indexingError), UuidType.Indexing));
				return;
			}

			IndexingError ignored;
			indexingErrors.TryDequeue(out ignored);

			if ((SystemTime.UtcNow - ignored.Timestamp).TotalSeconds > 10)
			{
				TransactionalStorage.Batch(accessor =>
				{
					accessor.Lists.Set("Raven/Indexing/Errors/" + indexName, indexingError.Id.ToString(CultureInfo.InvariantCulture), RavenJObject.FromObject(indexingError), UuidType.Indexing);
					accessor.Lists.RemoveAllOlderThan("Raven/Indexing/Errors/" + ignored.IndexName, ignored.Timestamp);
				});
				
			}
		}
Exemplo n.º 2
0
 protected static void PrintServerErrors(IndexingError[] indexingErrors)
 {
     if (indexingErrors.Any())
     {
         Console.WriteLine("Server errors count: " + indexingErrors.Count());
         foreach (var serverError in indexingErrors)
         {
             Console.WriteLine("Server error: " + serverError.ToString());
         }
     }
     else
         Console.WriteLine("No server errors");
 }
Exemplo n.º 3
0
        private 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);
            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);
                    });
            }
        }