Пример #1
0
        public async Task <Operation> CompactDatabaseAsync(string databaseName, CancellationToken token = default(CancellationToken))
        {
            using (var req = adminRequest.CompactDatabase(databaseName))
            {
                var json = await req.ReadResponseJsonAsync().WithCancellation(token).ConfigureAwait(false);

                return(new Operation((AsyncServerClient)innerAsyncServerClient.ForSystemDatabase(), json.Value <long>("OperationId")));
            }
        }
Пример #2
0
        public async Task EnsureDatabaseExistsAsync(string name, bool ignoreFailures = false)
        {
            var serverClient = (AsyncServerClient)(innerAsyncServerClient.ForSystemDatabase());

            var doc = MultiDatabase.CreateDatabaseDocument(name);

            serverClient.ForceReadFromMaster();

            var get = await serverClient.GetAsync(doc.Id).ConfigureAwait(false);

            if (get != null)
            {
                return;
            }

            try
            {
                await serverClient.GlobalAdmin.CreateDatabaseAsync(doc).ConfigureAwait(false);
            }
            catch (Exception)
            {
                if (ignoreFailures == false)
                {
                    throw;
                }
            }
            await new RavenDocumentsByEntityName().ExecuteAsync(serverClient.ForDatabase(name), new DocumentConvention()).ConfigureAwait(false);
        }
Пример #3
0
 public AsyncAdminServerClient(AsyncServerClient asyncServerClient)
 {
     innerAsyncServerClient = asyncServerClient;
     adminRequest           =
         new AdminRequestCreator((url, method) => innerAsyncServerClient.ForSystemDatabase().CreateRequest(url, method),
                                 (currentServerUrl, requestUrl, method) => innerAsyncServerClient.CreateReplicationAwareRequest(currentServerUrl, requestUrl, method));
 }
Пример #4
0
 public AsyncAdminServerClient(AsyncServerClient asyncServerClient)
 {
     innerAsyncServerClient = asyncServerClient;
     adminRequest =
         new AdminRequestCreator((url, method) => innerAsyncServerClient.ForSystemDatabase().CreateRequest(url, method),
                                 (url, method) => innerAsyncServerClient.CreateRequest(url, method),
                                 (currentServerUrl, requestUrl, method) => innerAsyncServerClient.CreateReplicationAwareRequest(currentServerUrl, requestUrl, method));
 }