示例#1
0
文件: General.cs 项目: pali88/ravendb
 public DocumentStorageActions(
     JET_INSTANCE instance,
     string database,
     TableColumnsCache tableColumnsCache,
     OrderedPartCollection <AbstractDocumentCodec> documentCodecs,
     IUuidGenerator uuidGenerator,
     IDocumentCacher cacher,
     EsentTransactionContext transactionContext,
     TransactionalStorage transactionalStorage
     )
 {
     this.tableColumnsCache             = tableColumnsCache;
     this.documentCodecs                = documentCodecs;
     this.uuidGenerator                 = uuidGenerator;
     this.cacher                        = cacher;
     this.transactionalStorage          = transactionalStorage;
     this.transactionContext            = transactionContext;
     scheduledReductionsPerViewAndLevel = transactionalStorage.GetScheduledReductionsPerViewAndLevel();
     try
     {
         if (transactionContext == null)
         {
             session     = new Session(instance);
             transaction = new Transaction(session);
             sessionAndTransactionDisposer = () =>
             {
                 if (transaction != null)
                 {
                     transaction.Dispose();
                 }
                 if (session != null)
                 {
                     session.Dispose();
                 }
             };
         }
         else
         {
             session     = transactionContext.Session;
             transaction = transactionContext.Transaction;
             var disposable = transactionContext.EnterSessionContext();
             sessionAndTransactionDisposer = disposable.Dispose;
         }
         Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
     }
     catch (Exception ex)
     {
         string location;
         try
         {
             location = new StackTrace(true).ToString();
         }
         catch (Exception)
         {
             location = "cannot get stack trace";
         }
         logger.WarnException("Error when trying to open a new DocumentStorageActions from \r\n" + location, ex);
         try
         {
             Dispose();
         }
         catch (Exception e)
         {
             logger.WarnException("Error on dispose when the ctor threw an exception, resources may have leaked", e);
         }
         throw;
     }
 }
示例#2
0
        public StorageActionsAccessor(IUuidGenerator generator, OrderedPartCollection <AbstractDocumentCodec> documentCodecs, IDocumentCacher documentCacher, Reference <WriteBatch> writeBatchReference, Reference <SnapshotReader> snapshotReference, TableStorage storage, TransactionalStorage transactionalStorage, IBufferPool bufferPool)
        {
            Documents   = new DocumentsStorageActions(generator, documentCodecs, documentCacher, writeBatchReference, snapshotReference, storage, bufferPool);
            Queue       = new QueueStorageActions(storage, generator, snapshotReference, writeBatchReference, bufferPool);
            Tasks       = new TasksStorageActions(storage, generator, snapshotReference, writeBatchReference, bufferPool);
            Staleness   = new StalenessStorageActions(storage, snapshotReference, writeBatchReference, bufferPool);
            Attachments = new AttachmentsStorageActions(storage.Attachments, writeBatchReference, snapshotReference, generator, storage, transactionalStorage, bufferPool);
            var generalStorageActions = new GeneralStorageActions(storage, writeBatchReference, snapshotReference, bufferPool, this);

            General   = generalStorageActions;
            Lists     = new ListsStorageActions(storage, generator, snapshotReference, writeBatchReference, bufferPool, generalStorageActions);
            Indexing  = new IndexingStorageActions(storage, generator, snapshotReference, writeBatchReference, this, bufferPool, generalStorageActions);
            MapReduce = new MappedResultsStorageActions(storage, generator, documentCodecs, snapshotReference, writeBatchReference, bufferPool, this, transactionalStorage.GetScheduledReductionsPerViewAndLevel(), generalStorageActions);
        }