Examples of Stream


Examples of org.graylog2.plugin.streams.Stream

        assertTrue(messageOutputs.contains(defaultMessageOutput));
        assertTrue(messageOutputs.contains(messageOutput));
    }

    public void testGetOutputsFromTwoStreams() throws Exception {
        final Stream stream1 = mock(Stream.class);
        final Stream stream2 = mock(Stream.class);
        final MessageOutput messageOutput1 = mock(MessageOutput.class);
        final Set<MessageOutput> messageOutputSet1 = new HashSet<MessageOutput>() {{ add(messageOutput1); }};
        final MessageOutput messageOutput2 = mock(MessageOutput.class);
        final Set<MessageOutput> messageOutputSet2 = new HashSet<MessageOutput>() {{ add(messageOutput2); }};
        final Message message = mock(Message.class);
View Full Code Here

Examples of org.graylog2.plugin.streams.Stream

        assertTrue(result.contains(messageOutput2));
    }

    @Test
    public void testGetOutputsWithIdenticalMessageOutputs() throws Exception {
        final Stream stream1 = mock(Stream.class);
        final Stream stream2 = mock(Stream.class);
        final MessageOutput messageOutput = mock(MessageOutput.class);
        final Set<MessageOutput> messageOutputSet = new HashSet<MessageOutput>() {{ add(messageOutput); }};
        final Message message = mock(Message.class);
        final List<Stream> streamList = new ArrayList<Stream>() {{ add(stream1); add(stream2); }};
        when(message.getStreams()).thenReturn(streamList);
View Full Code Here

Examples of org.graylog2.plugin.streams.Stream

    public Response create(@ApiParam(name = "JSON body", required = true) final CreateRequest cr) throws ValidationException {
        checkPermission(RestPermissions.STREAMS_CREATE);

        // Create stream.

        final Stream stream = streamService.create(cr, getCurrentUser().getName());
        stream.setDisabled(true);

        final String id = streamService.save(stream);

        if (cr.rules != null && cr.rules.size() > 0) {
            for (CreateStreamRuleRequest request : cr.rules) {
View Full Code Here

Examples of org.graylog2.plugin.streams.Stream

            @ApiResponse(code = 404, message = "Stream not found."),
            @ApiResponse(code = 400, message = "Invalid ObjectId.")
    })
    public Stream update(@ApiParam(name = "JSON body", required = true) CreateRequest cr, @ApiParam(name = "streamId", required = true) @PathParam("streamId") String streamId) throws NotFoundException, ValidationException {
        checkPermission(RestPermissions.STREAMS_EDIT, streamId);
        final Stream stream = streamService.load(streamId);

        stream.setTitle(cr.title);
        stream.setDescription(cr.description);

        streamService.save(stream);

        return stream;
    }
View Full Code Here

Examples of org.graylog2.plugin.streams.Stream

    })
    public Response list(@ApiParam(name = "streamId", value = "The stream id this new alert condition belongs to.", required = true) @PathParam("streamId") String streamid,
                         @ApiParam(name = "since", value = "Optional parameter to define a lower date boundary. (UNIX timestamp)", required = false) @QueryParam("since") int sinceTs) {
        checkPermission(RestPermissions.STREAMS_READ, streamid);

        Stream stream;
        try {
            stream = streamService.load(streamid);
        } catch (org.graylog2.database.NotFoundException e) {
            throw new WebApplicationException(404);
        }

        final DateTime since;
        if (sinceTs > 0) {
            since = new DateTime(sinceTs*1000L, DateTimeZone.UTC);
        } else {
            since = null;
        }

        List<Map<String,Object>> conditions = Lists.newArrayList();
        for(Alert alert : alertService.loadRecentOfStream(stream.getId(), since)) {
            conditions.add(alert.toMap());
        }

        long total = alertService.totalCountForStream(streamid);

View Full Code Here

Examples of org.graylog2.plugin.streams.Stream

            @ApiResponse(code = 400, message = "Invalid ObjectId.")
    })
    public Response checkConditions(@ApiParam(name = "streamId", value = "The ID of the stream to check.", required = true) @PathParam("streamId") String streamid) {
        checkPermission(RestPermissions.STREAMS_READ, streamid);

        final Stream stream;
        try {
            stream = streamService.load(streamid);
        } catch (org.graylog2.database.NotFoundException e) {
            throw new WebApplicationException(404);
        }

        Map<String, Object> result;
        try {
            result = cache.get(CACHE_KEY_BASE + stream.getId(), new Callable<Map<String, Object>>() {
                @Override
                public Map<String, Object> call() throws Exception {
                    List<Map<String, Object>> results = Lists.newArrayList();
                    int triggered = 0;
                    for (AlertCondition alertCondition : streamService.getAlertConditions(stream)) {
View Full Code Here

Examples of org.graylog2.plugin.streams.Stream

            @ApiResponse(code = 404, message = "Stream not found."),
            @ApiResponse(code = 400, message = "Invalid ObjectId.")
    })
    public Response delete(@ApiParam(name = "streamId", required = true) @PathParam("streamId") String streamId) throws NotFoundException {
        checkPermission(RestPermissions.STREAMS_EDIT, streamId);
        Stream stream = streamService.load(streamId);
        streamService.destroy(stream);

        return Response.noContent().build();
    }
View Full Code Here

Examples of org.graylog2.plugin.streams.Stream

            LOG.error("Missing streamId. Returning HTTP 400.");
            throw new WebApplicationException(400);
        }
        checkPermission(RestPermissions.STREAMS_CHANGESTATE, streamId);

        final Stream stream = streamService.load(streamId);
        streamService.pause(stream);

        return Response.ok().build();
    }
View Full Code Here

Examples of org.graylog2.plugin.streams.Stream

    @Produces(MediaType.APPLICATION_JSON)
    public StreamRuleListResponse get(@ApiParam(name = "streamid", value = "The id of the stream whose stream rules we want.", required = true) @PathParam("streamid") String streamid) {
        List<Map<String, Object>> streamRules = Lists.newArrayList();
        checkPermission(RestPermissions.STREAMS_READ, streamid);

        final Stream stream;
        try {
            stream = streamService.load(streamid);
        } catch (NotFoundException e) {
            throw new javax.ws.rs.NotFoundException("Stream not found!");
        }
View Full Code Here

Examples of org.graylog2.plugin.streams.Stream

            LOG.error("Missing streamId. Returning HTTP 400.");
            throw new WebApplicationException(400);
        }
        checkPermission(RestPermissions.STREAMS_CHANGESTATE, streamId);

        final Stream stream = streamService.load(streamId);
        streamService.resume(stream);

        return Response.ok().build();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.