public StorageActionsAccessor(TableColumnsCache tableColumnsCache, JET_INSTANCE instance, string databaseName, UuidGenerator uuidGenerator, OrderedPartCollection<AbstractFileCodec> fileCodecs) { this.tableColumnsCache = tableColumnsCache; this.uuidGenerator = uuidGenerator; this.fileCodecs = fileCodecs; try { session = new Session(instance); transaction = new Transaction(session); Api.JetOpenDatabase(session, databaseName, null, out database, OpenDatabaseGrbit.None); } catch (Exception original) { log.WarnException("Could not create accessor", original); try { Dispose(); } catch (Exception e) { log.WarnException("Could not properly dispose accessor after exception in ctor.", e); } throw; } }
protected ITransactionalStorage NewTransactionalStorage(string requestedStorage, bool runInMemory = true, string path = null, UuidGenerator uuidGenerator = null) { path = path ?? NewDataPath(); var configuration = new InMemoryRavenConfiguration { FileSystem = { DataDirectory = path }, Settings = new NameValueCollection { { Constants.RunInMemory, runInMemory.ToString() } } }; ITransactionalStorage storage; switch (requestedStorage) { case "esent": storage = new Raven.Database.FileSystem.Storage.Esent.TransactionalStorage(configuration); break; case "voron": storage = new Raven.Database.FileSystem.Storage.Voron.TransactionalStorage(configuration); break; default: throw new NotSupportedException(string.Format("Given storage type ({0}) is not supported.", requestedStorage)); } storages.Add(storage); storage.Initialize(uuidGenerator ?? new UuidGenerator(), new OrderedPartCollection<AbstractFileCodec>()); return storage; }
public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, string name, TransportState recievedTransportState = null) { this.Name = name; this.systemConfiguration = systemConfiguration; storage = CreateTransactionalStorage(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; }
public StorageActionsAccessor(TableStorage storage, Reference<WriteBatch> writeBatch, Reference<SnapshotReader> snapshot, IdGenerator generator, IBufferPool bufferPool, UuidGenerator uuidGenerator, OrderedPartCollection<AbstractFileCodec> fileCodecs) : base(snapshot, generator, bufferPool) { this.storage = storage; this.writeBatch = writeBatch; this.uuidGenerator = uuidGenerator; this.fileCodecs = fileCodecs; }
public void Initialize () { this.storage.Initialize(); var replicationHiLo = new SynchronizationHiLo(storage); var sequenceActions = new SequenceActions(storage); var uuidGenerator = new UuidGenerator(sequenceActions); this.historian = new Historian(storage, replicationHiLo, uuidGenerator); this.search.Initialize(this); }
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(); synchronizationTask.Start(); }
public void Initialize(UuidGenerator generator, OrderedPartCollection<AbstractFileCodec> codecs) { if(codecs == null) throw new ArgumentException("codecs"); uuidGenerator = generator; fileCodecs = codecs; try { new TransactionalStorageConfigurator(configuration).ConfigureInstance(instance, path); Api.JetInit(ref instance); EnsureDatabaseIsCreatedAndAttachToDatabase(); SetIdFromDb(); tableColumnsCache.InitColumDictionaries(instance, database); } catch (Exception e) { Dispose(); throw new InvalidOperationException("Could not open transactional storage: " + database, e); } }
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(); }
public Historian(ITransactionalStorage storage, SynchronizationHiLo synchronizationHiLo, UuidGenerator uuidGenerator) { this.storage = storage; this.uuidGenerator = uuidGenerator; this.synchronizationHiLo = synchronizationHiLo; }
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; } }
public void Initialize(UuidGenerator generator, OrderedPartCollection<AbstractFileCodec> codecs) { if (codecs == null) throw new ArgumentNullException("codecs"); fileCodecs = codecs; uuidGenerator = generator; bool runInMemory; bool.TryParse(settings[Constants.RunInMemory], out runInMemory); var persistenceSource = runInMemory ? StorageEnvironmentOptions.CreateMemoryOnly() : CreateStorageOptionsFromConfiguration(path, settings); tableStorage = new TableStorage(persistenceSource, bufferPool); var schemaCreator = new SchemaCreator(configuration, tableStorage, Output, Log); schemaCreator.CreateSchema(); schemaCreator.SetupDatabaseIdAndSchemaVersion(); schemaCreator.UpdateSchemaIfNecessary(); SetupDatabaseId(); idGenerator = new IdGenerator(tableStorage); }
public void GetFilesAfterWhereFileEtagsHaveDifferentRestartValues(string requestedStorage) { var etagGenerator = new UuidGenerator(); using (var storage = NewTransactionalStorage(requestedStorage, uuidGenerator: etagGenerator)) { storage.Batch(accessor => accessor.PutFile("/file1", null, new RavenJObject())); etagGenerator.EtagBase = 7; storage.Batch(accessor => accessor.PutFile("/file2", 10, new RavenJObject())); etagGenerator.EtagBase = 12; storage.Batch(accessor => accessor.PutFile("/file3", null, new RavenJObject())); etagGenerator.EtagBase = 300; storage.Batch(accessor => accessor.PutFile("/file4", 10, new RavenJObject())); etagGenerator.EtagBase = 450; storage.Batch(accessor => accessor.PutFile("/file5", null, new RavenJObject())); etagGenerator.EtagBase = 1024; storage.Batch(accessor => accessor.PutFile("/file6", 10, new RavenJObject())); etagGenerator.EtagBase = 3333; storage.Batch(accessor => accessor.PutFile("/file7", null, new RavenJObject())); etagGenerator.EtagBase = 10000; storage.Batch(accessor => accessor.PutFile("/file8", 10, new RavenJObject())); storage.Batch(accessor => { var files = accessor .GetFilesAfter(Etag.Empty, 10) .ToList(); Assert.Equal(8, files.Count); Assert.Equal("file1", files[0].Name); Assert.Equal("file2", files[1].Name); Assert.Equal("file3", files[2].Name); Assert.Equal("file4", files[3].Name); Assert.Equal("file5", files[4].Name); Assert.Equal("file6", files[5].Name); Assert.Equal("file7", files[6].Name); Assert.Equal("file8", files[7].Name); files = accessor .GetFilesAfter(files[4].Etag, 100) .ToList(); Assert.Equal(3, files.Count); Assert.Equal("file6", files[0].Name); Assert.Equal("file7", files[1].Name); Assert.Equal("file8", files[2].Name); }); } }