Package org.graylog2.restclient.models

Examples of org.graylog2.restclient.models.UniversalSearch


            user.setSubject(new Subject.Builder(SecurityUtils.getSecurityManager())
                    .principals(new SimplePrincipalCollection(user.getName(), "REST realm"))
                    .authenticated(true)
                    .buildSubject());
        } catch (IOException e) {
            throw new Graylog2ServerUnavailableException("Could not connect to Graylog2 Server.", e);
        } catch (APIException e) {
            if (e.getCause() != null && e.getCause() instanceof ConnectException) {
                throw new Graylog2ServerUnavailableException("Could not connect to Graylog2 Server.", e);
            } else {
                throw new AuthenticationException("Unable to communicate with graylog2-server backend", e);
            }
        } catch (PlayException e) {
            log.error("Misconfigured play application. Please make sure your application.secret is longer than 16 characters!", e);
View Full Code Here


    }

    @Override
    public F.Promise<Result> onError(Http.RequestHeader request, Throwable t) {
        if (t.getCause() instanceof Graylog2MasterUnavailableException) {
            final ServerNodes serverNodes = injector.getInstance(ServerNodes.class);
            final List<Node> configuredNodes = serverNodes.getConfiguredNodes();
            final List<Node> nodesEverConnectedTo = serverNodes.all(true);

            return F.Promise.<Result>pure(internalServerError(
                            views.html.disconnected.no_master.render(Http.Context.current(), configuredNodes, nodesEverConnectedTo, serverNodes))
            );
        }
View Full Code Here

*/
public class VersionTest {

    @Test
    public void testGetName() throws Exception {
        assertTrue(new Version(0, 20, 0).toString().startsWith("0.20.0"));
        assertTrue(new Version(1, 0, 0, "preview.1").toString().startsWith("1.0.0-preview.1"));
    }
View Full Code Here

        assertTrue(new Version(1, 0, 0, "preview.1").toString().startsWith("1.0.0-preview.1"));
    }

    @Test
    public void testEquals() throws Exception {
        assertTrue(new Version(0, 20, 0).equals(new Version(0, 20, 0)));
        assertTrue(new Version(0, 20, 0, "preview.1").equals(new Version(0, 20, 0, "preview.1")));
        assertTrue(new Version(1, 2, 3).equals(new Version(1, 2, 3)));

        Version v = new Version(0, 20, 0);
        assertTrue(v.equals(v));

        assertFalse(new Version(0, 20, 0).equals(new Version(0, 20, 1)));
        assertFalse(new Version(0, 20, 0, "preview.1").equals(new Version(0, 20, 0, "preview.2")));
        assertFalse(new Version(0, 20, 0).equals(null));
    }
View Full Code Here

        String fields = Tools.stringSearchParamOrEmpty(request, "fields");
        int width = request.getQueryString("width") == null ? -1 : Integer.valueOf(request.getQueryString("width"));

        String filter = search.getFilter();
        String query = search.getQuery();
        TimeRange timeRange = search.getTimeRange();

        // TODO we desperately need to pass the streamid and then build the filter here, instead of passing the filter and then trying to reassemble the streamid.
        if (filter != null && filter.startsWith("streams:")) {
            return routes.StreamSearchController.index(
                    filter.split(":")[1],
                    query,
                    timeRange.getType().toString().toLowerCase(),
                    relative,
                    from,
                    to,
                    keyword,
                    interval,
                    page,
                    "",
                    sortField,
                    sortOrder,
                    fields,
                    width
            );
        } else {
            return routes.SearchController.index(
                    query,
                    timeRange.getType().toString().toLowerCase(),
                    relative,
                    from,
                    to,
                    keyword,
                    interval,
View Full Code Here

        String to = Tools.stringSearchParamOrEmpty(request, "to");
        String keyword = Tools.stringSearchParamOrEmpty(request, "keyword");
        String fields = Tools.stringSearchParamOrEmpty(request, "fields");

        String query = search.getQuery();
        TimeRange timeRange = search.getTimeRange();

        if (stream == null) {
            return routes.SearchController.exportAsCsv(
                    query,
                    "",
                    timeRange.getType().toString().toLowerCase(),
                    relative,
                    from,
                    to,
                    keyword,
                    fields
            );
        } else {
            return routes.StreamSearchController.exportAsCsv(
                    query,
                    stream.getId(),
                    timeRange.getType().toString().toLowerCase(),
                    relative,
                    from,
                    to,
                    keyword,
                    fields
View Full Code Here

    @Test
    public void testTransportAddressPathNormalization() {
        setupNodes(AddressNodeId.create("http://localhost:65535"));
        api.setHttpClient(client);
        final Node node = serverNodes.any();
        assertEquals("transport address should have no path", "http://localhost:65535", node.getTransportAddress());
    }
View Full Code Here

    @Test
    public void testFailureCountSingleExecute() throws Exception {
        setupNodes(AddressNodeId.create("http://localhost:65535"));
        api.setHttpClient(client);

        final Node node = serverNodes.any();

        try {
            api.put().path("/").node(node).execute();
        } catch (Graylog2ServerUnavailableException e) {
            Node failedNode = serverNodes.any(true);
            assertFalse("Node should be from configuration", failedNode.isActive());
            assertEquals(1, failedNode.getFailureCount());
        }
    }
View Full Code Here

        final Map<Node, EmptyResponse> emptyResponses = api.put().path("/").executeOnAll();

        assertTrue("Request should have failed", emptyResponses.isEmpty());
        final List<Node> nodes = serverNodes.all(true);
        Node failedNode = nodes.get(0);
        Node failedNode2 = nodes.get(1);
        assertFalse("Node should be inactive" , failedNode.isActive());
        assertFalse("Node should be inactive", failedNode2.isActive());
        assertEquals(1, failedNode.getFailureCount());
        assertEquals(1, failedNode2.getFailureCount());
    }
View Full Code Here

    public void testNodeObjectsRememberedByAddress() throws Exception {
        final AddressNodeId addressNodeId = AddressNodeId.create("http://localhost:65535", UUID.randomUUID().toString());
        setupNodes(addressNodeId);

        api.setHttpClient(client);
        final Node firstNode = serverNodes.any();

        Throwable t = null;
        try {
            api.put().path("/").node(firstNode).execute();
        } catch (Graylog2ServerUnavailableException e) {
            t = e;
        }
        assertNotNull("Should have thrown an Graylog2ServerUnavailableException", t);
        assertEquals("First node failure count should be 1", 1, firstNode.getFailureCount());

        final Node.Factory nodeFactory = injector.getInstance(Node.Factory.class);
        final NodeSummaryResponse r1 = new NodeSummaryResponse();
        r1.transportAddress = "http://localhost:65534";
        r1.id = UUID.randomUUID().toString();

        final Node newNode = nodeFactory.fromSummaryResponse(r1);
        newNode.touch();
        final NodeSummaryResponse r2 = new NodeSummaryResponse();
        r2.transportAddress = firstNode.getTransportAddress();
        r2.id = firstNode.getNodeId();
        final Node sameAsInitialNode = nodeFactory.fromSummaryResponse(r2);
        sameAsInitialNode.touch();
        serverNodes.put(ImmutableList.of(newNode, sameAsInitialNode));

        final Map<Node, EmptyResponse> responses = api.put().nodes(serverNodes.all().toArray(new Node[0])).path("/").executeOnAll();

        assertTrue(responses.isEmpty());
View Full Code Here

TOP

Related Classes of org.graylog2.restclient.models.UniversalSearch

Copyright © 2018 www.massapicom. 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.