Search in sources :

Example 6 with NodeNotFoundException

use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.

the class ClusterHealthCheckThread method getNotification.

protected Notification getNotification() throws NodeNotFoundException {
    Notification notification = notificationService.buildNow();
    notification.addType(Notification.Type.NO_INPUT_RUNNING);
    notification.addSeverity(Notification.Severity.URGENT);
    notification.addNode(nodeId.toString());
    return notification;
}
Also used : Notification(org.graylog2.notifications.Notification)

Example 7 with NodeNotFoundException

use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.

the class ClusterSystemResource method threadDump.

@GET
@Timed
@ApiOperation(value = "Get a thread dump of the given node")
@RequiresPermissions(RestPermissions.THREADS_DUMP)
@Path("{nodeId}/threaddump")
public SystemThreadDumpResponse threadDump(@ApiParam(name = "nodeId", value = "The id of the node to get a thread dump.", required = true) @PathParam("nodeId") String nodeId) throws IOException, NodeNotFoundException {
    final Node targetNode = nodeService.byNodeId(nodeId);
    final RemoteSystemResource remoteSystemResource = remoteInterfaceProvider.get(targetNode, this.authenticationToken, RemoteSystemResource.class);
    final Response<SystemThreadDumpResponse> response = remoteSystemResource.threadDump().execute();
    if (response.isSuccessful()) {
        return response.body();
    } else {
        LOG.warn("Unable to get thread dump on node {}: {}", nodeId, response.message());
        throw new WebApplicationException(response.message(), BAD_GATEWAY);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) RemoteSystemResource(org.graylog2.shared.rest.resources.system.RemoteSystemResource) Node(org.graylog2.cluster.Node) SystemThreadDumpResponse(org.graylog2.rest.models.system.responses.SystemThreadDumpResponse) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 8 with NodeNotFoundException

use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.

the class ClusterSystemResource method processBufferDump.

@GET
@Timed
@ApiOperation(value = "Get a process buffer dump of the given node")
@RequiresPermissions(RestPermissions.PROCESSBUFFER_DUMP)
@Path("{nodeId}/processbufferdump")
public SystemProcessBufferDumpResponse processBufferDump(@ApiParam(name = "nodeId", value = "The id of the node to get a process buffer dump.", required = true) @PathParam("nodeId") String nodeId) throws IOException, NodeNotFoundException {
    final Node targetNode = nodeService.byNodeId(nodeId);
    final RemoteSystemResource remoteSystemResource = remoteInterfaceProvider.get(targetNode, this.authenticationToken, RemoteSystemResource.class);
    final Response<SystemProcessBufferDumpResponse> response = remoteSystemResource.processBufferDump().execute();
    if (response.isSuccessful()) {
        return response.body();
    } else {
        LOG.warn("Unable to get process buffer dump on node {}: {}", nodeId, response.message());
        throw new WebApplicationException(response.message(), BAD_GATEWAY);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) RemoteSystemResource(org.graylog2.shared.rest.resources.system.RemoteSystemResource) Node(org.graylog2.cluster.Node) SystemProcessBufferDumpResponse(org.graylog2.rest.models.system.responses.SystemProcessBufferDumpResponse) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 9 with NodeNotFoundException

use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.

the class ClusterJournalResource method get.

@GET
@Timed
@ApiOperation(value = "Get message journal information of a given node")
@RequiresPermissions(RestPermissions.JOURNAL_READ)
public JournalSummaryResponse get(@ApiParam(name = "nodeId", value = "The id of the node to get message journal information.", required = true) @PathParam("nodeId") String nodeId) throws IOException, NodeNotFoundException {
    final Node targetNode = nodeService.byNodeId(nodeId);
    final RemoteJournalResource remoteJournalResource = remoteInterfaceProvider.get(targetNode, this.authenticationToken, RemoteJournalResource.class);
    final Response<JournalSummaryResponse> response = remoteJournalResource.get().execute();
    if (response.isSuccessful()) {
        return response.body();
    } else {
        LOG.warn("Unable to get message journal information on node {}: {}", nodeId, response.message());
        throw new WebApplicationException(response.message(), BAD_GATEWAY);
    }
}
Also used : RemoteJournalResource(org.graylog2.rest.resources.system.RemoteJournalResource) WebApplicationException(javax.ws.rs.WebApplicationException) Node(org.graylog2.cluster.Node) JournalSummaryResponse(org.graylog2.rest.resources.system.responses.JournalSummaryResponse) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 10 with NodeNotFoundException

use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.

the class ClusterLoadBalancerStatusResource method override.

@PUT
@Timed
@RequiresAuthentication
@RequiresPermissions(RestPermissions.LBSTATUS_CHANGE)
@ApiOperation(value = "Override load balancer status of this graylog-server node. Next lifecycle " + "change will override it again to its default. Set to ALIVE, DEAD, or THROTTLED.")
@Path("/override/{status}")
@NoAuditEvent("this is a proxy resource, the audit event will be emitted on the target node")
public void override(@ApiParam(name = "nodeId", value = "The id of the node whose LB status will be changed", required = true) @PathParam("nodeId") String nodeId, @ApiParam(name = "status") @PathParam("status") String status) throws IOException, NodeNotFoundException {
    final Node targetNode = nodeService.byNodeId(nodeId);
    RemoteLoadBalancerStatusResource remoteLoadBalancerStatusResource = remoteInterfaceProvider.get(targetNode, this.authenticationToken, RemoteLoadBalancerStatusResource.class);
    final Response response = remoteLoadBalancerStatusResource.override(status).execute();
    if (!response.isSuccessful()) {
        LOG.warn("Unable to override load balancer status on node {}: {}", nodeId, response.message());
        throw new WebApplicationException(response.message(), BAD_GATEWAY);
    }
}
Also used : Response(retrofit2.Response) WebApplicationException(javax.ws.rs.WebApplicationException) RemoteLoadBalancerStatusResource(org.graylog2.shared.rest.resources.system.RemoteLoadBalancerStatusResource) Node(org.graylog2.cluster.Node) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) RequiresAuthentication(org.apache.shiro.authz.annotation.RequiresAuthentication) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent)

Aggregations

Node (org.graylog2.cluster.Node)9 Timed (com.codahale.metrics.annotation.Timed)8 ApiOperation (io.swagger.annotations.ApiOperation)7 WebApplicationException (javax.ws.rs.WebApplicationException)7 GET (javax.ws.rs.GET)5 Path (javax.ws.rs.Path)5 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)4 RemoteSystemResource (org.graylog2.shared.rest.resources.system.RemoteSystemResource)3 PUT (javax.ws.rs.PUT)2 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)2 Notification (org.graylog2.notifications.Notification)2 Response (retrofit2.Response)2 ApiResponses (io.swagger.annotations.ApiResponses)1 POST (javax.ws.rs.POST)1 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)1 AuditEvent (org.graylog2.audit.jersey.AuditEvent)1 NodeNotFoundException (org.graylog2.cluster.NodeNotFoundException)1 PluginList (org.graylog2.rest.models.system.plugins.responses.PluginList)1 SystemJVMResponse (org.graylog2.rest.models.system.responses.SystemJVMResponse)1 SystemProcessBufferDumpResponse (org.graylog2.rest.models.system.responses.SystemProcessBufferDumpResponse)1