private void OnPostShutdown(HttpEntityManager entity, UriTemplateMatch match) { if (entity.User != null && entity.User.IsInRole(SystemRoles.Admins)) { Log.Info("Request shut down of node because shutdown command has been received."); Publish(new ClientMessage.RequestShutdown(exitProcess: true)); entity.ReplyStatus(HttpStatusCode.OK, "OK", LogReplyError); } else { entity.ReplyStatus(HttpStatusCode.Unauthorized, "Unauthorized", LogReplyError); } }
private void OnPostScavenge(HttpEntityManager entity, UriTemplateMatch match) { if (entity.User != null && entity.User.IsInRole(SystemRoles.Admins)) { Log.Info("Request scavenging because /admin/scavenge request has been received."); Publish(new ClientMessage.ScavengeDatabase(new NoopEnvelope(), Guid.Empty, entity.User)); entity.ReplyStatus(HttpStatusCode.OK, "OK", LogReplyError); } else { entity.ReplyStatus(HttpStatusCode.Unauthorized, "Unauthorized", LogReplyError); } }
protected RequestParams SendOk(HttpEntityManager httpEntityManager) { httpEntityManager.ReplyStatus(HttpStatusCode.OK, "OK", e => Log.Debug("Error while closing http connection (ok): {0}.", e.Message)); return new RequestParams(done: true); }
protected RequestParams SendBadRequest(HttpEntityManager httpEntityManager, string reason) { httpEntityManager.ReplyStatus(HttpStatusCode.BadRequest, reason, e => Log.Debug("Error while closing http connection (bad request): {0}.", e.Message)); return new RequestParams(done: true); }
protected RequestParams SendTooBig(HttpEntityManager httpEntityManager) { httpEntityManager.ReplyStatus(HttpStatusCode.RequestEntityTooLarge, "Too large events received. Limit is 4mb", e => Log.Debug("Too large events received over HTTP")); return new RequestParams(done: true); }
private void AckMessages(HttpEntityManager http, UriTemplateMatch match) { var envelope = new NoopEnvelope(); var groupname = match.BoundVariables["subscription"]; var stream = match.BoundVariables["stream"]; var messageIds = match.BoundVariables["messageIds"]; var ids = new List<Guid>(); foreach (var messageId in messageIds.Split(new[] { ',' })) { Guid id; if (!Guid.TryParse(messageId, out id)) { http.ReplyStatus(HttpStatusCode.BadRequest, "messageid should be a properly formed guid", exception => { }); return; } ids.Add(id); } var cmd = new ClientMessage.PersistentSubscriptionAckEvents( Guid.NewGuid(), Guid.NewGuid(), envelope, BuildSubscriptionGroupKey(stream, groupname), ids.ToArray(), http.User); Publish(cmd); http.ReplyStatus(HttpStatusCode.Accepted, "", exception => { }); }
private void OnGetHistogram(HttpEntityManager entity, UriTemplateMatch match) { var name = match.BoundVariables["name"]; var histogram = Histograms.HistogramService.GetHistogram(name); if (histogram == null) { entity.ReplyStatus(HttpStatusCode.NotFound, "Not found", _ => { }); return; } var writer = new StringWriter(); lock (histogram) { histogram.outputPercentileDistribution(writer, outputValueUnitScalingRatio: 1000.0*1000.0); } var response = Encoding.ASCII.GetBytes(writer.ToString()); entity.Reply(response, HttpStatusCode.OK, "OK", ContentType.PlainText, Encoding.ASCII, null, _ => { }); }
protected void SendOk(HttpEntityManager httpEntityManager) { httpEntityManager.ReplyStatus(HttpStatusCode.OK, "OK", e => Log.Debug("Error while closing http connection (ok): {0}.", e.Message)); }
private void NackMessage(HttpEntityManager http, UriTemplateMatch match) { var envelope = new NoopEnvelope(); var groupname = match.BoundVariables["subscription"]; var stream = match.BoundVariables["stream"]; var messageId = match.BoundVariables["messageId"]; var nakAction = GetNackAction(http, match); var id = Guid.NewGuid(); if (!Guid.TryParse(messageId, out id)) { http.ReplyStatus(HttpStatusCode.BadRequest, "messageid should be a properly formed guid", exception => { }); return; } var cmd = new ClientMessage.PersistentSubscriptionNackEvents( Guid.NewGuid(), Guid.NewGuid(), envelope, BuildSubscriptionGroupKey(stream, groupname), "Nacked from HTTP", nakAction, new[] { id }, http.User); Publish(cmd); http.ReplyStatus(HttpStatusCode.Accepted, "", exception => { }); }
private void OnPostScavenge(HttpEntityManager entity, UriTemplateMatch match) { Log.Info("Request scavenging because /admin/scavenge request has been received."); Publish(new SystemMessage.ScavengeDatabase()); entity.ReplyStatus(HttpStatusCode.OK, "OK", e => Log.ErrorException(e, "Error while closing http connection (admin controller)")); }
private void OnPostShutdown(HttpEntityManager entity, UriTemplateMatch match) { Log.Info("Request shut down of node because shutdown command has been received."); Publish(new ClientMessage.RequestShutdown(exitProcess: true)); entity.ReplyStatus(HttpStatusCode.OK, "OK", e => Log.ErrorException(e, "Error while closing http connection (admin controller)")); }