public Task CreateDatabaseAsync(DatabaseDocument databaseDocument) { RavenJObject doc; var req = adminRequest.CreateDatabase(databaseDocument, out doc); return(req.WriteAsync(doc.ToString(Formatting.Indented))); }
public async Task CreateDatabaseAsync(DatabaseDocument databaseDocument) { RavenJObject doc; using (var req = adminRequest.CreateDatabase(databaseDocument, out doc)) { await req.WriteAsync(doc.ToString(Formatting.Indented)).ConfigureAwait(false); } }
public async Task CreateDatabaseAsync(DatabaseDocument databaseDocument, CancellationToken token = default(CancellationToken)) { RavenJObject doc; using (var req = adminRequest.CreateDatabase(databaseDocument, out doc)) { await req.WriteAsync(doc.ToString(Formatting.Indented)).WithCancellation(token).ConfigureAwait(false); } }
public async Task CanUpdateDatabaseOnAllNodes(int numberOfNodes) { var clusterStores = CreateRaftCluster(numberOfNodes); using (var store1 = clusterStores[0]) { // arrange var requestCreator = new AdminRequestCreator((url, method) => store1.DatabaseCommands.ForSystemDatabase().CreateRequest(url, method), null); store1.DatabaseCommands.GlobalAdmin.CreateDatabase(new DatabaseDocument { Id = "Northwind", Settings = { { "Raven/DataDir", "~/Databases/Northwind" }, { "Raven/ActiveBundles", "Replication" } } }); var key = Constants.Database.Prefix + "Northwind"; clusterStores.ForEach(store => WaitForDocument(store.DatabaseCommands.ForSystemDatabase(), key)); // act - try to add new setting var databaseUpdateDocument = new DatabaseDocument { Id = "Northwind", Settings = { { "Raven/DataDir", "~/Databases/Northwind" }, { "Raven/ActiveBundles", "Replication" }, { "Raven/New", "testing" } } }; var existingDbEtag = store1.DatabaseCommands.ForSystemDatabase().Get(key).Etag; RavenJObject doc; using (var req = requestCreator.CreateDatabase(databaseUpdateDocument, out doc)) { req.AddHeader("If-None-Match", existingDbEtag); await req.WriteAsync(doc.ToString(Formatting.Indented)).ConfigureAwait(false); } // assert clusterStores.ForEach(store => { WaitFor(store.DatabaseCommands, commands => { var databaseDocument = commands.ForSystemDatabase().Get(key); var settings = databaseDocument.DataAsJson.Value <RavenJObject>("Settings"); return("testing" == settings.Value <string>("Raven/New")); }); }); } }