Example #1
0
		public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, string name, TransportState recievedTransportState = null)
		{
		    this.Name = name;
			this.systemConfiguration = systemConfiguration;

		    var storageType = systemConfiguration.FileSystem.DefaultStorageTypeName;

            storage = CreateTransactionalStorage(storageType, systemConfiguration);
			search = new IndexStorage(systemConfiguration.FileSystem.IndexStoragePath, systemConfiguration.Settings);
			sigGenerator = new SigGenerator();
			var replicationHiLo = new SynchronizationHiLo(storage);
			var sequenceActions = new SequenceActions(storage);
			transportState = recievedTransportState ?? new TransportState();
			notificationPublisher = new NotificationPublisher(transportState);
			fileLockManager = new FileLockManager();
			storage.Initialize();
			search.Initialize();
			var uuidGenerator = new UuidGenerator(sequenceActions);
			historian = new Historian(storage, replicationHiLo, uuidGenerator);
			BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024);
			conflictArtifactManager = new ConflictArtifactManager(storage, search);
			conflictDetector = new ConflictDetector();
			conflictResolver = new ConflictResolver(storage, new CompositionContainer(systemConfiguration.Catalog));
			synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration);
			storageOperationsTask = new StorageOperationsTask(storage, search, notificationPublisher);
            metricsCounters = new MetricsCountersManager();

			AppDomain.CurrentDomain.ProcessExit += ShouldDispose;
			AppDomain.CurrentDomain.DomainUnload += ShouldDispose;
		}
Example #2
0
        public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, string name, TransportState recievedTransportState = null)
        {
            this.Name = name;
            this.systemConfiguration = systemConfiguration;

            var storageType = systemConfiguration.FileSystem.DefaultStorageTypeName;

            storage      = CreateTransactionalStorage(storageType, systemConfiguration);
            search       = new IndexStorage(systemConfiguration.FileSystem.IndexStoragePath, systemConfiguration.Settings);
            sigGenerator = new SigGenerator();
            var replicationHiLo = new SynchronizationHiLo(storage);
            var sequenceActions = new SequenceActions(storage);

            transportState        = recievedTransportState ?? new TransportState();
            notificationPublisher = new NotificationPublisher(transportState);
            fileLockManager       = new FileLockManager();
            storage.Initialize();
            search.Initialize();
            var uuidGenerator = new UuidGenerator(sequenceActions);

            historian  = new Historian(storage, replicationHiLo, uuidGenerator);
            BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024);
            conflictArtifactManager = new ConflictArtifactManager(storage, search);
            conflictDetector        = new ConflictDetector();
            conflictResolver        = new ConflictResolver(storage, new CompositionContainer(systemConfiguration.Catalog));
            synchronizationTask     = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration);
            storageOperationsTask   = new StorageOperationsTask(storage, search, notificationPublisher);
            metricsCounters         = new MetricsCountersManager();

            AppDomain.CurrentDomain.ProcessExit  += ShouldDispose;
            AppDomain.CurrentDomain.DomainUnload += ShouldDispose;
        }
Example #3
0
        private static void when_there_are_multiple_map_results_for_multiple_indexes(ITransactionalStorage transactionalStorage)
        {
            transactionalStorage.Initialize(new DummyUuidGenerator());

            transactionalStorage.Batch(accessor =>
            {
                accessor.Indexing.AddIndex("a", true);
                accessor.Indexing.AddIndex("b", true);
                accessor.Indexing.AddIndex("c", true);

                accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
                accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
                accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
                accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
                accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
                accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
            });

            transactionalStorage.Batch(actionsAccessor =>
            {
                Assert.True(actionsAccessor.Staleness.IsReduceStale("a"));
                Assert.True(actionsAccessor.Staleness.IsReduceStale("b"));
                Assert.True(actionsAccessor.Staleness.IsReduceStale("c"));
            });
        }
Example #4
0
        private static void when_there_are_updates_to_map_reduce_results(ITransactionalStorage transactionalStorage)
        {
            var dummyUuidGenerator = new DummyUuidGenerator();

            transactionalStorage.Initialize(dummyUuidGenerator);
            Guid a = Guid.Empty;
            Guid b = Guid.Empty;
            Guid c = Guid.Empty;

            transactionalStorage.Batch(accessor =>
            {
                accessor.Indexing.AddIndex("a", true);
                accessor.Indexing.AddIndex("b", true);
                accessor.Indexing.AddIndex("c", true);

                accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
                a = dummyUuidGenerator.CreateSequentialUuid();
                accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
                accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
                b = dummyUuidGenerator.CreateSequentialUuid();
                accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
                accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
                c = dummyUuidGenerator.CreateSequentialUuid();
                accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
            });

            transactionalStorage.Batch(actionsAccessor =>
            {
                Assert.Equal(1, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("a", a, false, 100).Count());
                Assert.Equal(1, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("b", b, false, 100).Count());
                Assert.Equal(1, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("c", c, false, 100).Count());
            });
        }
Example #5
0
        private static void when_there_are_multiple_map_results_and_we_ask_for_results(ITransactionalStorage transactionalStorage)
        {
            transactionalStorage.Initialize(new DummyUuidGenerator());

            transactionalStorage.Batch(accessor =>
            {
                accessor.Indexing.AddIndex("a", true);
                accessor.Indexing.AddIndex("b", true);
                accessor.Indexing.AddIndex("c", true);

                accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
                accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
                accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
                accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
                accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
                accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
            });

            transactionalStorage.Batch(actionsAccessor =>
            {
                Assert.Equal(2, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("a", Guid.Empty, false, 100).Count());
                Assert.Equal(2, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("b", Guid.Empty, false, 100).Count());
                Assert.Equal(2, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("c", Guid.Empty, false, 100).Count());
            });
        }
Example #6
0
		private static void when_there_are_multiple_map_results_for_multiple_indexes(ITransactionalStorage transactionalStorage)
		{
			transactionalStorage.Initialize(new DummyUuidGenerator());

			transactionalStorage.Batch(accessor =>
			{
				accessor.Indexing.AddIndex("a",true);
				accessor.Indexing.AddIndex("b", true);
				accessor.Indexing.AddIndex("c", true);

				accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
			});

			transactionalStorage.Batch(actionsAccessor =>
			{
				Assert.True(actionsAccessor.Staleness.IsReduceStale("a"));
				Assert.True(actionsAccessor.Staleness.IsReduceStale("b"));
				Assert.True(actionsAccessor.Staleness.IsReduceStale("c"));
			});
		}
Example #7
0
 public ViewStorage()
 {
     transactionalStorage = new TransactionalStorage(new RavenConfiguration
     {
         DataDirectory = "raven.db.test.esent",
         RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
     }, () => { });
     transactionalStorage.Initialize(new DummyUuidGenerator());
 }
Example #8
0
        public static bool TryToCreateTransactionalStorage(InMemoryRavenConfiguration ravenConfiguration,
                                                           bool hasCompression, EncryptionConfiguration encryption, bool isRavenFs,
                                                           out ITransactionalStorage storage, out Database.FileSystem.Storage.ITransactionalStorage fileStorage)
        {
            storage     = null;
            fileStorage = null;
            if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, Voron.Impl.Constants.DatabaseFilename)))
            {
                if (isRavenFs)
                {
                    fileStorage = RavenFileSystem.CreateTransactionalStorage(ravenConfiguration);
                }
                else
                {
                    storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.VoronTypeName, () => { }, () => { });
                }
            }
            else if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, "Data.jfm")))
            {
                if (isRavenFs)
                {
                    fileStorage = RavenFileSystem.CreateTransactionalStorage(ravenConfiguration);
                }
                else
                {
                    storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.EsentTypeName, () => { }, () => { });
                }
            }
            if (storage == null && fileStorage == null)
            {
                return(false);
            }
            if (isRavenFs)
            {
                var filesOrderedPartCollection = new OrderedPartCollection <Database.FileSystem.Plugins.AbstractFileCodec>();
                fileStorage.Initialize(new UuidGenerator(), filesOrderedPartCollection);
                return(true);
            }
            var orderedPartCollection = new OrderedPartCollection <AbstractDocumentCodec>();

            if (encryption != null)
            {
                var documentEncryption = new DocumentEncryption();
                documentEncryption.SetSettings(new EncryptionSettings(encryption.EncryptionKey, encryption.SymmetricAlgorithmType,
                                                                      encryption.EncryptIndexes, encryption.PreferedEncryptionKeyBitsSize));
                orderedPartCollection.Add(documentEncryption);
            }
            if (hasCompression)
            {
                orderedPartCollection.Add(new DocumentCompression());
            }
            storage.Initialize(new SequentialUuidGenerator {
                EtagBase = 0
            }, orderedPartCollection);

            return(true);
        }
Example #9
0
		public ViewStorage()
		{
			transactionalStorage = new TransactionalStorage(new RavenConfiguration
			{
				DataDirectory = DataDir,
				RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
			}, () => { });
			transactionalStorage.Initialize(new DummyUuidGenerator());
		}
Example #10
0
		public ViewStorage()
		{
			transactionalStorage = new TransactionalStorage(new RavenConfiguration
			{
				DataDirectory = "raven.db.test.esent",
				RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
			}, () => { });
			transactionalStorage.Initialize();
		}
        public void Initialize()
        {
            var generator = new UuidGenerator();

            storage.Initialize(generator, FileCodecs);
            generator.EtagBase = new SequenceActions(storage).GetNextValue("Raven/Etag");

            historian = new Historian(storage, new SynchronizationHiLo(storage));

            InitializeTriggersExceptIndexCodecs();

            search.Initialize(this);

            SecondStageInitialization();
        }
Example #12
0
        public void Initialize()
        {
            storage.Initialize(FileCodecs);

            var replicationHiLo = new SynchronizationHiLo(storage);
            var sequenceActions = new SequenceActions(storage);
            var uuidGenerator   = new UuidGenerator(sequenceActions);

            historian = new Historian(storage, replicationHiLo, uuidGenerator);

            search.Initialize(this);

            InitializeTriggersExceptIndexCodecs();
            SecondStageInitialization();
        }
Example #13
0
        public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, TransportState transportState, string name)
        {
            this.Name = name;
            this.systemConfiguration = systemConfiguration;

            var storageType = systemConfiguration.DefaultFileSystemStorageTypeName;

            if (string.Equals(InMemoryRavenConfiguration.VoronTypeName, storageType, StringComparison.OrdinalIgnoreCase) == false)
            {
                if (Directory.Exists(systemConfiguration.FileSystemDataDirectory) &&
                    Directory.EnumerateFileSystemEntries(systemConfiguration.FileSystemDataDirectory).Any())
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "We do not allow to run on a storage engine other then Voron, while we are in the early pre-release phase of RavenDB 3.0. You are currently running on {0}",
                                  storageType));
                }

                Trace.WriteLine("Forcing filesystem to run on Voron - pre release behavior only, mind " + Path.GetFileName(Path.GetDirectoryName(systemConfiguration.FileSystemDataDirectory)));
                storageType = InMemoryRavenConfiguration.VoronTypeName;
            }

            storage      = CreateTransactionalStorage(storageType, systemConfiguration);
            search       = new IndexStorage(systemConfiguration.FileSystemIndexStoragePath, systemConfiguration.Settings);
            sigGenerator = new SigGenerator();
            var replicationHiLo = new SynchronizationHiLo(storage);
            var sequenceActions = new SequenceActions(storage);

            this.transportState   = transportState;
            notificationPublisher = new NotificationPublisher(transportState);
            fileLockManager       = new FileLockManager();
            storage.Initialize();
            search.Initialize();
            var uuidGenerator = new UuidGenerator(sequenceActions);

            historian  = new Historian(storage, replicationHiLo, uuidGenerator);
            BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024);
            conflictArtifactManager = new ConflictArtifactManager(storage, search);
            conflictDetector        = new ConflictDetector();
            conflictResolver        = new ConflictResolver();
            synchronizationTask     = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration);
            storageOperationsTask   = new StorageOperationsTask(storage, search, notificationPublisher);
            metricsCounters         = new MetricsCountersManager();

            AppDomain.CurrentDomain.ProcessExit  += ShouldDispose;
            AppDomain.CurrentDomain.DomainUnload += ShouldDispose;
        }
Example #14
0
        public static bool TryToCreateTransactionalStorage(InMemoryRavenConfiguration ravenConfiguration,
                                                           bool hasCompression, EncryptionConfiguration encryption, out ITransactionalStorage storage)
        {
            storage = null;
            if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, Voron.Impl.Constants.DatabaseFilename)))
            {
                storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.VoronTypeName, () => { }, () => { });
            }
            else if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, "Data")))
            {
                storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.EsentTypeName, () => { }, () => { });
            }

            if (storage == null)
            {
                return(false);
            }

            var orderedPartCollection = new OrderedPartCollection <AbstractDocumentCodec>();

            if (encryption != null)
            {
                var documentEncryption = new DocumentEncryption();
                documentEncryption.SetSettings(new EncryptionSettings(encryption.EncryptionKey, encryption.SymmetricAlgorithmType,
                                                                      encryption.EncryptIndexes, encryption.PreferedEncryptionKeyBitsSize));
                orderedPartCollection.Add(documentEncryption);
            }
            if (hasCompression)
            {
                orderedPartCollection.Add(new DocumentCompression());
            }

            uuidGenerator = new SequentialUuidGenerator();
            storage.Initialize(uuidGenerator, orderedPartCollection);

            /*
             * Added configuration steps
             */
            storage.Batch(actions =>
            {
                var nextIdentityValue  = actions.General.GetNextIdentityValue("Raven/Etag");
                uuidGenerator.EtagBase = nextIdentityValue;
            });

            return(true);
        }
Example #15
0
        public void Initialize()
        {
            try
            {
                var generator = new UuidGenerator();
                storage.Initialize(generator, FileCodecs, storagePath =>
                {
                    if (configuration.RunInMemory)
                    {
                        return;
                    }

                    var resourceTypeFile = Path.Combine(storagePath, Constants.FileSystem.FsResourceMarker);

                    if (File.Exists(resourceTypeFile) == false)
                    {
                        using (File.Create(resourceTypeFile)) { }
                    }
                });
                generator.EtagBase = new SequenceActions(storage).GetNextValue("Raven/Etag");

                historian = new Historian(storage, new SynchronizationHiLo(storage));

                InitializeTriggersExceptIndexCodecs();

                search.Initialize(this);

                SecondStageInitialization();

                synchronizationTask.Start();
            }
            catch (Exception e)
            {
                Log.ErrorException(string.Format("Could not create file system '{0}'", Name ?? "unknown name"), e);
                try
                {
                    Dispose();
                }
                catch (Exception ex)
                {
                    Log.FatalException("Failed to dispose when already getting an error during file system initialization", ex);
                }
                throw;
            }
        }
Example #16
0
		public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, TransportState transportState, string name)
		{
		    this.Name = name;
			this.systemConfiguration = systemConfiguration;

		    var storageType = systemConfiguration.DefaultFileSystemStorageTypeName;
            if (string.Equals(InMemoryRavenConfiguration.VoronTypeName, storageType, StringComparison.OrdinalIgnoreCase) == false)
            {
                if (Directory.Exists(systemConfiguration.FileSystemDataDirectory) &&
                        Directory.EnumerateFileSystemEntries(systemConfiguration.FileSystemDataDirectory).Any())
                    throw new InvalidOperationException(
                        string.Format(
                            "We do not allow to run on a storage engine other then Voron, while we are in the early pre-release phase of RavenDB 3.0. You are currently running on {0}",
                            storageType));

                Trace.WriteLine("Forcing filesystem to run on Voron - pre release behavior only, mind " + Path.GetFileName(Path.GetDirectoryName(systemConfiguration.FileSystemDataDirectory)));
                storageType = InMemoryRavenConfiguration.VoronTypeName;
            }

            storage = CreateTransactionalStorage(storageType, systemConfiguration.FileSystemDataDirectory, systemConfiguration.Settings);
			search = new IndexStorage(systemConfiguration.FileSystemIndexStoragePath, systemConfiguration.Settings);
			sigGenerator = new SigGenerator();
			var replicationHiLo = new SynchronizationHiLo(storage);
			var sequenceActions = new SequenceActions(storage);
			this.transportState = transportState;
			notificationPublisher = new NotificationPublisher(transportState);
			fileLockManager = new FileLockManager();
			storage.Initialize();
			search.Initialize();
			var uuidGenerator = new UuidGenerator(sequenceActions);
			historian = new Historian(storage, replicationHiLo, uuidGenerator);
			BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024);
			conflictArtifactManager = new ConflictArtifactManager(storage, search);
			conflictDetector = new ConflictDetector();
			conflictResolver = new ConflictResolver();
			synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration);
			storageOperationsTask = new StorageOperationsTask(storage, search, notificationPublisher);
            metricsCounters = new MetricsCountersManager();

			AppDomain.CurrentDomain.ProcessExit += ShouldDispose;
			AppDomain.CurrentDomain.DomainUnload += ShouldDispose;
		}
Example #17
0
 public static bool TryToCreateTransactionalStorage(InMemoryRavenConfiguration ravenConfiguration, out ITransactionalStorage storage)
 {
     storage = null;
     if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, Voron.Impl.Constants.DatabaseFilename)))
     {
         storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.VoronTypeName, () => { }, () => { });
     }
     else if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, "Data")))
     {
         storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.EsentTypeName, () => { }, () => { });
     }
     if (storage != null)
     {
         storage.Initialize(new SequentialUuidGenerator {
             EtagBase = 0
         }, new OrderedPartCollection <AbstractDocumentCodec>());
         return(true);
     }
     return(false);
 }
Example #18
0
 public static bool TryToCreateTransactionalStorage(InMemoryRavenConfiguration ravenConfiguration, out ITransactionalStorage storage)
 {
     storage = null;
     if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, Voron.Impl.Constants.DatabaseFilename)))
         storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.VoronTypeName, () => { }, () => { });
     else if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, "Data")))
         storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.EsentTypeName, () => { }, () => { });
     if (storage != null)
     {
         storage.Initialize(new SequentialUuidGenerator {EtagBase = 0}, new OrderedPartCollection<AbstractDocumentCodec>());
         return true;
     }
     return false;
 }
Example #19
0
        public static bool TryToCreateTransactionalStorage(InMemoryRavenConfiguration ravenConfiguration,
            bool hasCompression, EncryptionConfiguration encryption, out ITransactionalStorage storage)
        {
            storage = null;
            if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, Voron.Impl.Constants.DatabaseFilename)))
                storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.VoronTypeName, () => { }, () => { });
            else if (File.Exists(Path.Combine(ravenConfiguration.DataDirectory, "Data")))
                storage = ravenConfiguration.CreateTransactionalStorage(InMemoryRavenConfiguration.EsentTypeName, () => { }, () => { });

            if (storage == null)
                return false;

            var orderedPartCollection = new OrderedPartCollection<AbstractDocumentCodec>();
            if (encryption != null)
            {
                var documentEncryption = new DocumentEncryption();
                documentEncryption.SetSettings(new EncryptionSettings(encryption.EncryptionKey, encryption.SymmetricAlgorithmType,
                    encryption.EncryptIndexes, encryption.PreferedEncryptionKeyBitsSize));
                orderedPartCollection.Add(documentEncryption);
            }
            if (hasCompression)
            {
                orderedPartCollection.Add(new DocumentCompression());
            }
                
            storage.Initialize(new SequentialUuidGenerator {EtagBase = 0}, orderedPartCollection);
            return true;
        }
Example #20
0
		private static void when_there_are_multiple_map_results_and_we_ask_for_results(ITransactionalStorage transactionalStorage)
		{
			transactionalStorage.Initialize(new DummyUuidGenerator());

			transactionalStorage.Batch(accessor =>
			{
				accessor.Indexing.AddIndex("a", true);
				accessor.Indexing.AddIndex("b", true);
				accessor.Indexing.AddIndex("c", true);

				accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
			});

			transactionalStorage.Batch(actionsAccessor =>
			{
				Assert.Equal(2, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("a", Guid.Empty).Count());
				Assert.Equal(2, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("b", Guid.Empty).Count());
				Assert.Equal(2, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("c", Guid.Empty).Count());
			});
		}
Example #21
0
		private static void when_there_are_updates_to_map_reduce_results(ITransactionalStorage transactionalStorage)
		{
			var dummyUuidGenerator = new DummyUuidGenerator();
			transactionalStorage.Initialize(dummyUuidGenerator);
			Guid a = Guid.Empty;
			Guid b = Guid.Empty;
			Guid c = Guid.Empty;
			transactionalStorage.Batch(accessor =>
			{
				accessor.Indexing.AddIndex("a", true);
				accessor.Indexing.AddIndex("b", true);
				accessor.Indexing.AddIndex("c", true);

				accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				a = dummyUuidGenerator.CreateSequentialUuid();
				accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				b = dummyUuidGenerator.CreateSequentialUuid();
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
				c = dummyUuidGenerator.CreateSequentialUuid();
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
			});

			transactionalStorage.Batch(actionsAccessor =>
			{
				Assert.Equal(1, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("a", a).Count());
				Assert.Equal(1, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("b", b).Count());
				Assert.Equal(1, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("c", c).Count());
			});
		}