本文整理汇总了C#中Raven.Database.Impl.ExceptionAggregator.ThrowIfNeeded方法的典型用法代码示例。如果您正苦于以下问题:C# ExceptionAggregator.ThrowIfNeeded方法的具体用法?C# ExceptionAggregator.ThrowIfNeeded怎么用?C# ExceptionAggregator.ThrowIfNeeded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Database.Impl.ExceptionAggregator
的用法示例。
在下文中一共展示了ExceptionAggregator.ThrowIfNeeded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Dispose
public void Dispose()
{
disposerLock.EnterWriteLock();
try
{
if (disposed)
return;
disposed = true;
var exceptionAggregator = new ExceptionAggregator("Could not properly dispose TransactionalStorage");
exceptionAggregator.Execute(() => current.Dispose());
if (tableStorage != null)
exceptionAggregator.Execute(() => tableStorage.Dispose());
if (bufferPool != null)
exceptionAggregator.Execute(() => bufferPool.Dispose());
exceptionAggregator.ThrowIfNeeded();
}
finally
{
disposerLock.ExitWriteLock();
}
}
示例2: Dispose
public void Dispose()
{
var aggregator = new ExceptionAggregator("Error during ResourceTimerManager disposal.");
foreach (var timer in timers)
{
var t = timer;
aggregator.Execute(() =>
{
if (t != null)
t.Dispose();
});
}
aggregator.ThrowIfNeeded();
}
示例3: Dispose
protected override void Dispose()
{
var exceptionAggregator = new ExceptionAggregator(Log, "Could not dispose of IndexingExecuter");
foreach (var pendingTask in pendingTasks)
{
exceptionAggregator.Execute(pendingTask.Wait);
}
pendingTasks.Clear();
exceptionAggregator.Execute(prefetchingBehavior.Dispose);
if (indexingCompletedEvent != null)
exceptionAggregator.Execute(indexingCompletedEvent.Dispose);
if (indexingSemaphore != null)
exceptionAggregator.Execute(indexingSemaphore.Dispose);
exceptionAggregator.ThrowIfNeeded();
indexingCompletedEvent = null;
indexingSemaphore = null;
}
示例4: Dispose
public void Dispose()
{
var exceptionAggregator = new ExceptionAggregator(Log, string.Format("Could not properly close index storage for file system '{0}'", name));
exceptionAggregator.Execute(() => { if (analyzer != null) analyzer.Close(); });
exceptionAggregator.Execute(() => { if (currentIndexSearcherHolder != null) currentIndexSearcherHolder.SetIndexSearcher(null); });
exceptionAggregator.Execute(() => SafeDispose(crashMarker) );
exceptionAggregator.Execute(() => SafeDispose(writer) );
exceptionAggregator.Execute(() => SafeDispose(directory) );
exceptionAggregator.ThrowIfNeeded();
}
示例5: Dispose
public void Dispose()
{
disposerLock.EnterWriteLock();
try
{
TenantDatabaseModified.Occured -= TenantDatabaseRemoved;
var exceptionAggregator = new ExceptionAggregator(logger, "Could not properly dispose of HttpServer");
exceptionAggregator.Execute(() =>
{
if (databasesCleanupTimer != null)
databasesCleanupTimer.Dispose();
});
exceptionAggregator.Execute(() =>
{
if (listener != null && listener.IsListening)
listener.Stop();
});
disposed = true;
exceptionAggregator.Execute(() =>
{
lock (ResourcesStoresCache)
{
foreach (var documentDatabase in ResourcesStoresCache)
{
var database = documentDatabase.Value;
exceptionAggregator.Execute(database.Dispose);
}
ResourcesStoresCache.Clear();
}
});
exceptionAggregator.Execute(currentConfiguration.Dispose);
exceptionAggregator.Execute(currentDatabase.Dispose);
exceptionAggregator.Execute(currentTenantId.Dispose);
exceptionAggregator.ThrowIfNeeded();
}
finally
{
disposerLock.ExitWriteLock();
}
}
示例6: Dispose
public void Dispose()
{
if (disposed)
return;
// give it 3 seconds to complete requests
for (int i = 0; i < 30 && Interlocked.Read(ref metricsCounters.ConcurrentRequestsCount) > 0; i++)
{
Thread.Sleep(100);
}
AppDomain.CurrentDomain.ProcessExit -= ShouldDispose;
AppDomain.CurrentDomain.DomainUnload -= ShouldDispose;
disposed = true;
var exceptionAggregator = new ExceptionAggregator(Log, "Could not properly dispose RavenFileSystem");
if (synchronizationTask != null)
exceptionAggregator.Execute(synchronizationTask.Dispose);
if (storage != null)
exceptionAggregator.Execute(storage.Dispose);
if (search != null)
exceptionAggregator.Execute(search.Dispose);
if (sigGenerator != null)
exceptionAggregator.Execute(sigGenerator.Dispose);
if (BufferPool != null)
exceptionAggregator.Execute(BufferPool.Dispose);
if (metricsCounters != null)
exceptionAggregator.Execute(metricsCounters.Dispose);
if (Tasks != null)
Tasks.Dispose(exceptionAggregator);
exceptionAggregator.ThrowIfNeeded();
}
示例7: Dispose
public void Dispose()
{
var tryEnterWriteLock = disposerLock.TryEnterWriteLock(TimeSpan.FromMinutes(2));
try
{
if (tryEnterWriteLock == false)
log.Warn("After waiting for 2 minutes, could not acquire disposal lock, will force disposal anyway, pending transactions will all error");
if (disposed)
return;
var exceptionAggregator = new ExceptionAggregator(log, "Could not close database properly");
disposed = true;
exceptionAggregator.Execute(current.Dispose);
if (documentCacher != null)
exceptionAggregator.Execute(documentCacher.Dispose);
if (inFlightTransactionalState != null)
exceptionAggregator.Execute(inFlightTransactionalState.Dispose);
exceptionAggregator.Execute(() =>
{
try
{
Api.JetTerm2(instance, TermGrbit.Complete);
}
catch (Exception e1)
{
log.ErrorException(
"Unexpected error occurred while terminating Esent Storage. Ignoring this error to allow to shutdown RavenDB instance.",
e1);
try
{
log.Warn(
"Will now attempt to perform an abrupt shutdown, because asking nicely didn't work. You might need to run defrag on the database to recover potentially lost space (but no data will be lost).");
Api.JetTerm2(instance, TermGrbit.Abrupt);
}
catch (Exception e2)
{
log.FatalException(
"Couldn't shut down the database server even when using abrupt, something is probably wrong and you'll need to restart the server process to access the database",
e2);
}
}
finally
{
GC.SuppressFinalize(this);
}
});
exceptionAggregator.ThrowIfNeeded();
}
catch (Exception e)
{
log.FatalException("Could not dispose of the transactional storage for " + path, e);
throw;
}
finally
{
if (tryEnterWriteLock)
disposerLock.ExitWriteLock();
}
}
示例8: Dispose
public void Dispose()
{
FlushMapIndexes();
FlushReduceIndexes();
var exceptionAggregator = new ExceptionAggregator(log, "Could not properly close index storage");
exceptionAggregator.Execute(() => Parallel.ForEach(indexes.Values, index => exceptionAggregator.Execute(index.Dispose)));
exceptionAggregator.Execute(() => dummyAnalyzer.Close());
exceptionAggregator.Execute(() =>
{
if (crashMarker != null)
crashMarker.Dispose();
});
exceptionAggregator.ThrowIfNeeded();
}
示例9: Dispose
public void Dispose()
{
if (disposed)
return;
var onDisposing = Disposing;
if (onDisposing != null)
{
try
{
onDisposing(this, EventArgs.Empty);
}
catch (Exception e)
{
log.WarnException("Error when notifying about db disposal, ignoring error and continuing with disposal", e);
}
}
var exceptionAggregator = new ExceptionAggregator(log, "Could not properly dispose of DatabaseDocument");
exceptionAggregator.Execute(() =>
{
AppDomain.CurrentDomain.DomainUnload -= DomainUnloadOrProcessExit;
AppDomain.CurrentDomain.ProcessExit -= DomainUnloadOrProcessExit;
disposed = true;
if (workContext != null)
workContext.StopWorkRude();
});
if (validateLicense != null)
exceptionAggregator.Execute(validateLicense.Dispose);
exceptionAggregator.Execute(() =>
{
if (ExtensionsState == null)
return;
foreach (var value in ExtensionsState.Values.OfType<IDisposable>())
{
exceptionAggregator.Execute(value.Dispose);
}
});
exceptionAggregator.Execute(() =>
{
if (toDispose == null)
return;
foreach (var shouldDispose in toDispose)
{
exceptionAggregator.Execute(shouldDispose.Dispose);
}
});
exceptionAggregator.Execute(() =>
{
foreach (var shouldDispose in pendingTasks)
{
exceptionAggregator.Execute(shouldDispose.Value.Task.Wait);
}
pendingTasks.Clear();
});
exceptionAggregator.Execute(() =>
{
if (indexingBackgroundTask != null)
indexingBackgroundTask.Wait();
});
exceptionAggregator.Execute(() =>
{
if (reducingBackgroundTask != null)
reducingBackgroundTask.Wait();
});
exceptionAggregator.Execute(() =>
{
var disposable = backgroundTaskScheduler as IDisposable;
if (disposable != null)
disposable.Dispose();
});
if (TransactionalStorage != null)
exceptionAggregator.Execute(TransactionalStorage.Dispose);
if (IndexStorage != null)
exceptionAggregator.Execute(IndexStorage.Dispose);
if (Configuration != null)
exceptionAggregator.Execute(Configuration.Dispose);
exceptionAggregator.Execute(disableAllTriggers.Dispose);
if (workContext != null)
exceptionAggregator.Execute(workContext.Dispose);
exceptionAggregator.ThrowIfNeeded();
}
示例10: Close
public void Close()
{
var exceptionAggregator = new ExceptionAggregator(log, "Failed to close response");
exceptionAggregator.Execute(OutputStream.Flush);
exceptionAggregator.Execute(OutputStream.Dispose);
if (StreamsToDispose!= null)
{
foreach (var stream in StreamsToDispose)
{
exceptionAggregator.Execute(stream.Flush);
exceptionAggregator.Execute(stream.Dispose);
}
}
exceptionAggregator.Execute(response.Close);
exceptionAggregator.ThrowIfNeeded();
}
示例11: Dispose
public void Dispose()
{
if (disposed)
return;
var onDisposing = Disposing;
if(onDisposing!=null)
onDisposing(this, EventArgs.Empty);
var exceptionAggregator = new ExceptionAggregator(log, "Could not properly dispose of DatabaseDocument");
exceptionAggregator.Execute(() =>
{
AppDomain.CurrentDomain.DomainUnload -= DomainUnloadOrProcessExit;
AppDomain.CurrentDomain.ProcessExit -= DomainUnloadOrProcessExit;
disposed = true;
workContext.StopWork();
});
exceptionAggregator.Execute(() =>
{
foreach (var value in ExtensionsState.Values.OfType<IDisposable>())
{
exceptionAggregator.Execute(value.Dispose);
}
});
exceptionAggregator.Execute(() =>
{
foreach (var shouldDispose in toDispose)
{
exceptionAggregator.Execute(shouldDispose.Dispose);
}
});
exceptionAggregator.Execute(() =>
{
if (indexingBackgroundTask != null)
indexingBackgroundTask.Wait();
});
exceptionAggregator.Execute(() =>
{
if (reducingBackgroundTask != null)
reducingBackgroundTask.Wait();
});
exceptionAggregator.Execute(() =>
{
var disposable = backgroundTaskScheduler as IDisposable;
if (disposable != null)
disposable.Dispose();
});
if (TransactionalStorage != null)
exceptionAggregator.Execute(TransactionalStorage.Dispose);
if (IndexStorage != null)
exceptionAggregator.Execute(IndexStorage.Dispose);
if (Configuration != null)
exceptionAggregator.Execute(Configuration.Dispose);
exceptionAggregator.Execute(disableAllTriggers.Dispose);
if (workContext != null)
exceptionAggregator.Execute(workContext.Dispose);
exceptionAggregator.ThrowIfNeeded();
}
示例12: Dispose
public void Dispose()
{
disposerLock.EnterWriteLock();
try
{
if (disposed)
return;
var exceptionAggregator = new ExceptionAggregator(log, "Could not close database properly");
disposed = true;
exceptionAggregator.Execute(current.Dispose);
if (documentCacher != null)
exceptionAggregator.Execute(documentCacher.Dispose);
exceptionAggregator.Execute(() =>
{
Api.JetTerm2(instance, TermGrbit.Complete);
GC.SuppressFinalize(this);
});
exceptionAggregator.ThrowIfNeeded();
}
catch (Exception e)
{
log.FatalException("Could not dispose of the transactional storage for " + path, e);
throw;
}
finally
{
disposerLock.ExitWriteLock();
}
}
示例13: Dispose
public void Dispose()
{
var toDispose = new[]
{
documents,
queue,
lists,
directories,
files,
indexesStats,
indexesStatsReduce,
indexesEtags,
scheduledReductions,
mappedResults,
reducedResults,
tasks,
identity,
details,
reduceKeysCounts,
reduceKeysStatus,
indexedDocumentsReferences
};
var aggregator = new ExceptionAggregator("DocumentStorageActions disposal error.");
foreach (var dispose in toDispose)
{
if (dispose == null)
continue;
aggregator.Execute(() => dispose.Dispose());
}
aggregator.Execute(() =>
{
if (Equals(dbid, JET_DBID.Nil) == false && session != null)
Api.JetCloseDatabase(session.JetSesid, dbid, CloseDatabaseGrbit.None);
});
aggregator.Execute(() =>
{
if (sessionAndTransactionDisposer != null)
sessionAndTransactionDisposer();
});
aggregator.ThrowIfNeeded();
}
示例14: Dispose
public void Dispose()
{
var ea = new ExceptionAggregator("Cannot dispose server");
ea.Execute(owinEmbeddedHost.Dispose);
if (server != null)
ea.Execute(server.Dispose);
ea.ThrowIfNeeded();
}
示例15: Dispose
public void Dispose()
{
var tryEnterWriteLock = disposerLock.TryEnterWriteLock(TimeSpan.FromMinutes(2));
try
{
if (tryEnterWriteLock == false)
log.Warn( "After waiting for 2 minutes, could not aqcuire disposal lock, will force disposal anyway, pending transactions will all error");
if (disposed)
return;
var exceptionAggregator = new ExceptionAggregator(log, "Could not close database properly");
disposed = true;
exceptionAggregator.Execute(current.Dispose);
if (documentCacher != null)
exceptionAggregator.Execute(documentCacher.Dispose);
if(inFlightTransactionalState != null)
exceptionAggregator.Execute(inFlightTransactionalState.Dispose);
exceptionAggregator.Execute(() =>
{
Api.JetTerm2(instance, TermGrbit.Complete);
GC.SuppressFinalize(this);
});
exceptionAggregator.ThrowIfNeeded();
}
catch (Exception e)
{
log.FatalException("Could not dispose of the transactional storage for " + path, e);
throw;
}
finally
{
if (tryEnterWriteLock)
disposerLock.ExitWriteLock();
}
}