private ClientConfiguration GetServerClientConfiguration(out long index) { using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { using (context.OpenReadTransaction()) { var clientConfigurationJson = ServerStore.Cluster.Read(context, Constants.Configuration.ClientId, out index); return(clientConfigurationJson != null ? JsonDeserializationServer.ClientConfiguration(clientConfigurationJson) : null); } } }
public async Task PutClientConfiguration() { await ServerStore.EnsureNotPassiveAsync(); using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext ctx)) { var clientConfigurationJson = await ctx.ReadForMemoryAsync(RequestBodyStream(), Constants.Configuration.ClientId); var clientConfiguration = JsonDeserializationServer.ClientConfiguration(clientConfigurationJson); var res = await ServerStore.PutValueInClusterAsync(new PutClientConfigurationCommand(clientConfiguration, GetRaftRequestIdFromQuery())); await ServerStore.Cluster.WaitForIndexNotification(res.Index); NoContentStatus(HttpStatusCode.Created); } }
public async Task PutClientConfiguration() { ServerStore.EnsureNotPassive(); using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext ctx)) { var clientConfigurationJson = ctx.ReadForDisk(RequestBodyStream(), Constants.Configuration.ClientId); var clientConfiguration = JsonDeserializationServer.ClientConfiguration(clientConfigurationJson); var res = await ServerStore.PutValueInClusterAsync(new PutClientConfigurationCommand(clientConfiguration)); await ServerStore.Cluster.WaitForIndexNotification(res.Index); NoContentStatus(); HttpContext.Response.StatusCode = (int)HttpStatusCode.Created; } }
public async Task PutClientConfiguration() { ServerStore.EnsureNotPassive(); using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { var clientConfigurationJson = context.ReadForDisk(RequestBodyStream(), Constants.Configuration.ClientId); var clientConfiguration = JsonDeserializationServer.ClientConfiguration(clientConfigurationJson); await UpdateDatabaseRecord(context, record => { record.Client = clientConfiguration; record.Client.Etag++; // we don't care _what_ the value is, just that it is changing }); } NoContentStatus(); HttpContext.Response.StatusCode = (int)HttpStatusCode.Created; }
public async Task PutClientConfiguration() { ServerStore.EnsureNotPassive(); using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { var clientConfigurationJson = context.ReadForDisk(RequestBodyStream(), Constants.Configuration.ClientId); var clientConfiguration = JsonDeserializationServer.ClientConfiguration(clientConfigurationJson); await UpdateDatabaseRecord(context, record => { var oldClientEtag = record.Client?.Etag ?? 0; record.Client = clientConfiguration; record.Client.Etag = ++oldClientEtag; }, GetRaftRequestIdFromQuery()); } NoContentStatus(); HttpContext.Response.StatusCode = (int)HttpStatusCode.Created; }
public async Task PutClientConfiguration() { await ServerStore.EnsureNotPassiveAsync(); using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { var clientConfigurationJson = context.ReadForDisk(RequestBodyStream(), Constants.Configuration.ClientId); var clientConfiguration = JsonDeserializationServer.ClientConfiguration(clientConfigurationJson); await UpdateDatabaseRecord(context, (record, index) => { record.Client = clientConfiguration; record.Client.Etag = index; }, GetRaftRequestIdFromQuery()); } NoContentStatus(); HttpContext.Response.Headers[Constants.Headers.RefreshClientConfiguration] = "true"; HttpContext.Response.StatusCode = (int)HttpStatusCode.Created; }
public async Task PutClientConfiguration() { ServerStore.EnsureNotPassive(); using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { var clientConfigurationJson = context.ReadForDisk(RequestBodyStream(), Constants.Configuration.ClientId); var clientConfiguration = JsonDeserializationServer.ClientConfiguration(clientConfigurationJson); using (context.OpenReadTransaction()) { var record = ServerStore.Cluster.ReadDatabase(context, Database.Name, out long index); record.Client = clientConfiguration; record.Client.Etag++; // we don't care _what_ the value is, just that it is changing var result = await ServerStore.WriteDatabaseRecordAsync(Database.Name, record, index); await Database.RachisLogIndexNotifications.WaitForIndexNotification(result.Index); } NoContentStatus(); HttpContext.Response.StatusCode = (int)HttpStatusCode.Created; } }