Search in sources :

Example 1 with JournalSummaryResponse

use of org.graylog2.rest.resources.system.responses.JournalSummaryResponse 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 2 with JournalSummaryResponse

use of org.graylog2.rest.resources.system.responses.JournalSummaryResponse in project graylog2-server by Graylog2.

the class JournalResource method show.

@GET
@Timed
@ApiOperation(value = "Get current state of the journal on this node.")
@RequiresPermissions(RestPermissions.JOURNAL_READ)
public JournalSummaryResponse show() {
    if (!journalEnabled) {
        return JournalSummaryResponse.createDisabled();
    }
    if (journal instanceof LocalKafkaJournal) {
        final LocalKafkaJournal kafkaJournal = (LocalKafkaJournal) journal;
        final ThrottleState throttleState = kafkaJournal.getThrottleState();
        long oldestSegment = Long.MAX_VALUE;
        for (final LogSegment segment : kafkaJournal.getSegments()) {
            oldestSegment = Math.min(oldestSegment, segment.created());
        }
        return JournalSummaryResponse.createEnabled(throttleState.appendEventsPerSec, throttleState.readEventsPerSec, throttleState.uncommittedJournalEntries, Size.bytes(throttleState.journalSize), Size.bytes(throttleState.journalSizeLimit), kafkaJournal.numberOfSegments(), new DateTime(oldestSegment, DateTimeZone.UTC), KafkaJournalConfigurationSummary.of(kafkaJournalConfiguration));
    }
    log.warn("Unknown Journal implementation {} in use, cannot get information about it. Pretending journal is disabled.", journal.getClass());
    return JournalSummaryResponse.createDisabled();
}
Also used : LogSegment(org.graylog.shaded.kafka09.log.LogSegment) ThrottleState(org.graylog2.plugin.ThrottleState) LocalKafkaJournal(org.graylog2.shared.journal.LocalKafkaJournal) DateTime(org.joda.time.DateTime) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)2 ApiOperation (io.swagger.annotations.ApiOperation)2 GET (javax.ws.rs.GET)2 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)2 WebApplicationException (javax.ws.rs.WebApplicationException)1 LogSegment (org.graylog.shaded.kafka09.log.LogSegment)1 Node (org.graylog2.cluster.Node)1 ThrottleState (org.graylog2.plugin.ThrottleState)1 RemoteJournalResource (org.graylog2.rest.resources.system.RemoteJournalResource)1 JournalSummaryResponse (org.graylog2.rest.resources.system.responses.JournalSummaryResponse)1 LocalKafkaJournal (org.graylog2.shared.journal.LocalKafkaJournal)1 DateTime (org.joda.time.DateTime)1