public IDocumentStore Initialise() { try { #if !CLIENT if (configuration != null) { var embeddedDatabase = new Raven.Database.DocumentDatabase(configuration); embeddedDatabase.SpinBackgroundWorkers(); DatabaseCommands = new EmbededDatabaseCommands(embeddedDatabase, Conventions); } else #endif { DatabaseCommands = new ServerClient(Url, Conventions, credentials); } if (Conventions.DocumentKeyGenerator == null)// don't overwrite what the user is doing { var generator = new MultiTypeHiLoKeyGenerator(DatabaseCommands, 1024); Conventions.DocumentKeyGenerator = entity => generator.GenerateDocumentKey(Conventions, entity); } } catch (Exception) { Dispose(); throw; } return(this); }
public void Execute(Raven.Database.DocumentDatabase database) { // First step setup diagnostics: DiagnosticsProvider.Initialize(); // And then storage: StorageProvider.Initialize(); var storageDirectory = StorageProvider.GetDirectoryForDatabase(database.Name); log.Info("Setting storage directory for default database to: {0}", storageDirectory.FullName); database.Configuration.DataDirectory = storageDirectory.FullName; // Setup replication: var selfInstance = InstanceEnumerator.EnumerateInstances().First(i => i.IsSelf); if (selfInstance.InstanceType == InstanceType.ReadWrite) { ReplicationUtilities.UpdateReplication(selfInstance, InstanceEnumerator, database); } }
public IDocumentStore Initialize() { try { #if !CLIENT if (configuration != null) { DocumentDatabase = new Raven.Database.DocumentDatabase(configuration); DocumentDatabase.SpinBackgroundWorkers(); databaseCommandsGenerator = () => new EmbededDatabaseCommands(DocumentDatabase, Conventions); } else #endif { databaseCommandsGenerator = ()=>new ServerClient(Url, Conventions, credentials); asyncDatabaseCommandsGenerator = ()=>new AsyncServerClient(Url, Conventions, credentials); } if(Conventions.DocumentKeyGenerator == null)// don't overwrite what the user is doing { var generator = new MultiTypeHiLoKeyGenerator(DatabaseCommands, 1024); Conventions.DocumentKeyGenerator = entity => generator.GenerateDocumentKey(Conventions, entity); } } catch (Exception) { Dispose(); throw; } return this; }