public async Task DeleteServerWideBackupConfigurationCommand() { var name = GetStringQueryString("name", required: true); using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { var(newIndex, _) = await ServerStore.DeleteServerWideBackupConfigurationAsync(name, GetRaftRequestIdFromQuery()); await ServerStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, newIndex); using (var writer = new BlittableJsonTextWriter(context, ResponseBodyStream())) using (context.OpenReadTransaction()) { var deleteResponse = new PutServerWideBackupConfigurationResponse() { Name = name, RaftCommandIndex = newIndex }; HttpContext.Response.StatusCode = (int)HttpStatusCode.OK; context.Write(writer, deleteResponse.ToJson()); writer.Flush(); } } }
public async Task PutServerWideBackupConfigurationCommand() { using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { var configurationBlittable = await context.ReadForMemoryAsync(RequestBodyStream(), "server-wide-backup-configuration"); var configuration = JsonDeserializationCluster.ServerWideBackupConfiguration(configurationBlittable); ServerStore.LicenseManager.AssertCanAddPeriodicBackup(configuration); BackupConfigurationHelper.UpdateLocalPathIfNeeded(configuration, ServerStore); BackupConfigurationHelper.AssertBackupConfiguration(configuration); BackupConfigurationHelper.AssertDestinationAndRegionAreAllowed(configuration, ServerStore); var(newIndex, _) = await ServerStore.PutServerWideBackupConfigurationAsync(configuration, GetRaftRequestIdFromQuery()); await ServerStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, newIndex); using (var writer = new BlittableJsonTextWriter(context, ResponseBodyStream())) using (context.OpenReadTransaction()) { var backupName = ServerStore.Cluster.GetServerWideBackupNameByTaskId(context, newIndex); if (backupName == null) { throw new InvalidOperationException($"Backup name is null for server-wide backup with task id: {newIndex}"); } var putResponse = new PutServerWideBackupConfigurationResponse() { Name = backupName, RaftCommandIndex = newIndex }; HttpContext.Response.StatusCode = (int)HttpStatusCode.Created; context.Write(writer, putResponse.ToJson()); writer.Flush(); } } }
public async Task ToggleTaskState() { var disable = GetBoolValueQueryString("disable") ?? true; var taskName = GetStringQueryString("taskName", required: false); using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) using (context.OpenReadTransaction()) { // Get existing task var serveWideBackupBlittable = ServerStore.Cluster.GetServerWideBackupConfigurations(context, taskName).FirstOrDefault(); if (serveWideBackupBlittable == null) { throw new InvalidOperationException($"Server-Wide Backup Task: {taskName} was not found in the server."); } // Toggle ServerWideBackupConfiguration serverWideBackup = JsonDeserializationServer.ServerWideBackupConfiguration(serveWideBackupBlittable); serverWideBackup.Disabled = disable; // Save task var(newIndex, _) = await ServerStore.PutServerWideBackupConfigurationAsync(serverWideBackup, GetRaftRequestIdFromQuery()); await ServerStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, newIndex); using (var writer = new BlittableJsonTextWriter(context, ResponseBodyStream())) { var toggleResponse = new PutServerWideBackupConfigurationResponse() { Name = taskName, RaftCommandIndex = newIndex }; context.Write(writer, toggleResponse.ToJson()); writer.Flush(); } } }