コード例 #1
0
 public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit)
 {
     this.configuration = configuration;
     this.onCommit      = onCommit;
     documentCacher     = new DocumentCacher(configuration);
     exitLockDisposable = new DisposableAction(() => Monitor.Exit(this));
 }
コード例 #2
0
ファイル: General.cs プロジェクト: carlosagsmendes/ravendb
		public DocumentStorageActions(
			JET_INSTANCE instance,
			string database,
			TableColumnsCache tableColumnsCache,
			OrderedPartCollection<AbstractDocumentCodec> documentCodecs,
			IUuidGenerator uuidGenerator,
			IDocumentCacher cacher,
			TransactionalStorage transactionalStorage)
		{
			this.tableColumnsCache = tableColumnsCache;
			this.documentCodecs = documentCodecs;
			this.uuidGenerator = uuidGenerator;
			this.cacher = cacher;
			this.transactionalStorage = transactionalStorage;
			try
			{
				session = new Session(instance);
				transaction = new Transaction(session);
				Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
			}
			catch (Exception)
			{
				Dispose();
				throw;
			}
		}
コード例 #3
0
        public void ClearCaches()
        {
            var oldDocumentCacher = documentCacher;

            documentCacher = CreateDocumentCacher(configuration);
            oldDocumentCacher.Dispose();
        }
コード例 #4
0
        public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit, Action onStorageInaccessible, Action onNestedTransactionEnter, Action onNestedTransactionExit)
        {
            configuration.Container.SatisfyImportsOnce(this);

            if (configuration.CacheDocumentsInMemory == false)
            {
                documentCacher = new NullDocumentCacher();
            }
            else
            {
                documentCacher = new DocumentCacher(configuration);
            }

            database           = configuration.DataDirectory;
            this.configuration = configuration;
            this.onCommit      = onCommit;

            path = database;
            if (Path.IsPathRooted(database) == false)
            {
                path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, database);
            }
            database = Path.Combine(path, "Data");

            RecoverFromFailedCompact(database);

            new TransactionalStorageConfigurator(configuration, this).LimitSystemCache();

            uniquePrefix = Interlocked.Increment(ref instanceCounter) + "-" + Base62Util.Base62Random();
            CreateInstance(out instance, uniquePrefix + "-" + database);
            this.onNestedTransactionEnter = onNestedTransactionEnter;
            this.onNestedTransactionExit  = onNestedTransactionExit;
        }
コード例 #5
0
ファイル: General.cs プロジェクト: thoemmi/ravendb
 public DocumentStorageActions(
     JET_INSTANCE instance,
     string database,
     TableColumnsCache tableColumnsCache,
     OrderedPartCollection <AbstractDocumentCodec> documentCodecs,
     IUuidGenerator uuidGenerator,
     IDocumentCacher cacher,
     TransactionalStorage transactionalStorage)
 {
     this.tableColumnsCache    = tableColumnsCache;
     this.documentCodecs       = documentCodecs;
     this.uuidGenerator        = uuidGenerator;
     this.cacher               = cacher;
     this.transactionalStorage = transactionalStorage;
     try
     {
         session     = new Session(instance);
         transaction = new Transaction(session);
         Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
     }
     catch (Exception)
     {
         Dispose();
         throw;
     }
 }
コード例 #6
0
		public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit)
		{
			this.configuration = configuration;
			this.onCommit = onCommit;
			documentCacher = new DocumentCacher(configuration);
		    exitLockDisposable = new DisposableAction(() => Monitor.Exit(this));
		}
コード例 #7
0
 public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit)
 {
     this.configuration = configuration;
     this.onCommit      = onCommit;
     documentCacher     = new DocumentCacher(configuration);
     exitLockDisposable = new DisposableAction(() => Monitor.Exit(this));
     bufferPool         = new BufferPool(configuration.Storage.Voron.MaxBufferPoolSize * 1024 * 1024 * 1024, int.MaxValue); // 2GB max buffer size (voron limit)
 }
コード例 #8
0
		public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit)
		{
			this.configuration = configuration;
			this.onCommit = onCommit;
			documentCacher = new DocumentCacher(configuration);
			exitLockDisposable = new DisposableAction(() => Monitor.Exit(this));
            bufferPool = new BufferPool(configuration.Storage.Voron.MaxBufferPoolSize * 1024 * 1024 * 1024, int.MaxValue); // 2GB max buffer size (voron limit)
		}
コード例 #9
0
ファイル: General.cs プロジェクト: dkardach/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;

            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)
            {
                logger.WarnException("Error when trying to open a new DocumentStorageActions", ex);
                try
                {
                    Dispose();
                }
                catch (Exception e)
                {
                    logger.WarnException("Error on dispose when the ctor threw an exception, resources may have leaked", e);
                }
                throw;
            }
        }
コード例 #10
0
 public DocumentsStorageActions(TableStorage storage,
                                IUuidGenerator generator,
                                OrderedPartCollection <AbstractDocumentCodec> documentCodecs,
                                IDocumentCacher documentCacher)
 {
     this.storage        = storage;
     this.generator      = generator;
     this.documentCodecs = documentCodecs;
     this.documentCacher = documentCacher;
 }
コード例 #11
0
ファイル: General.cs プロジェクト: 925coder/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;

			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)
			{
			    logger.WarnException("Error when trying to open a new DocumentStorageActions", ex);
			    try
			    {
			        Dispose();
			    }
			    catch (Exception e)
			    {
			        logger.WarnException("Error on dispose when the ctor threw an exception, resources may have leaked", e);
			    }
				throw;
			}
		}
コード例 #12
0
		public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit, Action onStorageInaccessible)
		{
			this.configuration = configuration;
			this.onCommit = onCommit;
			this.onStorageInaccessible = onStorageInaccessible;

			RecoverFromFailedCompact(configuration.DataDirectory);

			documentCacher = new DocumentCacher(configuration);
			exitLockDisposable = new DisposableAction(() => Monitor.Exit(this));
            bufferPool = new BufferPool(configuration.Storage.Voron.MaxBufferPoolSize * 1024 * 1024 * 1024, int.MaxValue); // 2GB max buffer size (voron limit)
		}
コード例 #13
0
        public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit, Action onStorageInaccessible)
        {
            this.configuration         = configuration;
            this.onCommit              = onCommit;
            this.onStorageInaccessible = onStorageInaccessible;

            RecoverFromFailedCompact(configuration.DataDirectory);

            documentCacher     = new DocumentCacher(configuration);
            exitLockDisposable = new DisposableAction(() => Monitor.Exit(this));
            bufferPool         = new BufferPool(configuration.Storage.Voron.MaxBufferPoolSize * 1024 * 1024 * 1024, int.MaxValue); // 2GB max buffer size (voron limit)
        }
コード例 #14
0
		public StorageActionsAccessor(TableStorage storage, IUuidGenerator generator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs, IDocumentCacher documentCacher)
		{
			General = new GeneralStorageActions(storage);
			Attachments = new AttachmentsStorageActions(storage, generator);
			Transactions = new TransactionStorageActions(storage, generator, documentCodecs);
			Documents = new DocumentsStorageActions(storage, Transactions, generator, documentCodecs, documentCacher);
			Indexing = new IndexingStorageActions(storage);
			MappedResults = new MappedResultsStorageAction(storage, generator);
			Queue = new QueueStorageActions(storage, generator);
			Tasks = new TasksStorageActions(storage, generator);
			Staleness = new StalenessStorageActions(storage);
		}
コード例 #15
0
		public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit)
		{
			documentCacher = new DocumentCacher(configuration);
			database = configuration.DataDirectory;
			this.configuration = configuration;
			this.onCommit = onCommit;
			path = database;
			if (Path.IsPathRooted(database) == false)
				path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, database);
			database = Path.Combine(path, "Data");

			new TransactionalStorageConfigurator(configuration).LimitSystemCache();

			Api.JetCreateInstance(out instance, database + Guid.NewGuid());
		}
コード例 #16
0
        public TransactionalStorage(RavenConfiguration configuration, Action onCommit, Action onStorageInaccessible, Action onNestedTransactionEnter, Action onNestedTransactionExit)
        {
            this.configuration         = configuration;
            this.onCommit              = onCommit;
            this.onStorageInaccessible = onStorageInaccessible;

            RecoverFromFailedCompact(configuration.Core.DataDirectory);

            documentCacher     = new DocumentCacher(configuration);
            exitLockDisposable = new DisposableAction(() => Monitor.Exit(this));
            bufferPool         = new BufferPool(
                configuration.Storage.MaxBufferPoolSize.GetValue(SizeUnit.Bytes),
                int.MaxValue); // 2GB max buffer size (voron limit)
            this.onNestedTransactionEnter = onNestedTransactionEnter;
            this.onNestedTransactionExit  = onNestedTransactionExit;
        }
コード例 #17
0
        public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit)
        {
            documentCacher     = new DocumentCacher(configuration);
            database           = configuration.DataDirectory;
            this.configuration = configuration;
            this.onCommit      = onCommit;
            path = database;
            if (Path.IsPathRooted(database) == false)
            {
                path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, database);
            }
            database = Path.Combine(path, "Data");

            new TransactionalStorageConfigurator(configuration).LimitSystemCache();

            Api.JetCreateInstance(out instance, database + Guid.NewGuid());
        }
コード例 #18
0
        public DocumentsStorageActions(IUuidGenerator uuidGenerator,
                                       OrderedPartCollection <AbstractDocumentCodec> documentCodecs,
                                       IDocumentCacher documentCacher,
                                       Reference <WriteBatch> writeBatch,
                                       Reference <SnapshotReader> snapshot,
                                       TableStorage tableStorage,
                                       IBufferPool bufferPool)
            : base(snapshot, bufferPool)
        {
            this.uuidGenerator  = uuidGenerator;
            this.documentCodecs = documentCodecs;
            this.documentCacher = documentCacher;
            this.writeBatch     = writeBatch;
            this.tableStorage   = tableStorage;

            metadataIndex = tableStorage.Documents.GetIndex(Tables.Documents.Indices.Metadata);
        }
コード例 #19
0
        private IDocumentCacher CreateDocumentCacher(InMemoryRavenConfiguration configuration)
        {
            if (configuration.CacheDocumentsInMemory == false)
            {
                documentCacher = new NullDocumentCacher();
            }
            else if (configuration.CustomMemoryCacher != null)
            {
                documentCacher = configuration.CustomMemoryCacher(configuration);
            }
            else
            {
                documentCacher = new DocumentCacher(configuration);
            }

            return(documentCacher);
        }
コード例 #20
0
		public DocumentsStorageActions(IUuidGenerator uuidGenerator,
			OrderedPartCollection<AbstractDocumentCodec> documentCodecs,
			IDocumentCacher documentCacher,
			Reference<WriteBatch> writeBatch,
			Reference<SnapshotReader> snapshot,
            TableStorage tableStorage, 
            IBufferPool bufferPool)
			: base(snapshot, bufferPool)
		{
			this.uuidGenerator = uuidGenerator;
			this.documentCodecs = documentCodecs;
			this.documentCacher = documentCacher;
			this.writeBatch = writeBatch;
			this.tableStorage = tableStorage;

			metadataIndex = tableStorage.Documents.GetIndex(Tables.Documents.Indices.Metadata);
		}
コード例 #21
0
		public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit)
		{
			configuration.Container.SatisfyImportsOnce(this);
			documentCacher = new DocumentCacher(configuration);
			database = configuration.DataDirectory;
			this.configuration = configuration;
			this.onCommit = onCommit;
			path = database;
			if (Path.IsPathRooted(database) == false)
				path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, database);
			database = Path.Combine(path, "Data");

			RecoverFromFailedCompact(database);

			new TransactionalStorageConfigurator(configuration, this).LimitSystemCache();

			uniquePrefix = Interlocked.Increment(ref instanceCounter) + "-" + Base62Util.Base62Random();
			CreateInstance(out instance, uniquePrefix + "-" + database);
		}
コード例 #22
0
 public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit)
 {
     this.configuration = configuration;
     this.onCommit      = onCommit;
     documentCacher     = new DocumentCacher(configuration);
 }
コード例 #23
0
		public void ClearCaches()
		{
		    var oldDocumentCacher = documentCacher;
		    documentCacher = new DocumentCacher(configuration);
		    oldDocumentCacher.Dispose();
		}
コード例 #24
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);
        }
コード例 #25
0
		public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit)
		{
			this.configuration = configuration;
			this.onCommit = onCommit;
			documentCacher = new DocumentCacher(configuration);
		}
コード例 #26
0
 public StorageActionsAccessor(TableStorage storage, IUuidGenerator generator, OrderedPartCollection <AbstractDocumentCodec> documentCodecs, IDocumentCacher documentCacher)
 {
     General       = new GeneralStorageActions(storage);
     Attachments   = new AttachmentsStorageActions(storage, generator);
     Transactions  = new TransactionStorageActions(storage, generator, documentCodecs);
     Documents     = new DocumentsStorageActions(storage, Transactions, generator, documentCodecs, documentCacher);
     Indexing      = new IndexingStorageActions(storage);
     MappedResults = new MappedResultsStorageAction(storage, generator);
     Queue         = new QueueStorageActions(storage, generator);
     Tasks         = new TasksStorageActions(storage, generator);
     Staleness     = new StalenessStorageActions(storage);
 }