Search in sources :

Example 1 with KafkaJournalConfiguration

use of org.graylog2.plugin.KafkaJournalConfiguration 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)1 ApiOperation (io.swagger.annotations.ApiOperation)1 GET (javax.ws.rs.GET)1 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)1 LogSegment (org.graylog.shaded.kafka09.log.LogSegment)1 ThrottleState (org.graylog2.plugin.ThrottleState)1 LocalKafkaJournal (org.graylog2.shared.journal.LocalKafkaJournal)1 DateTime (org.joda.time.DateTime)1