Package org.graylog2.restclient.lib.metrics

Examples of org.graylog2.restclient.lib.metrics.Meter


    @ApiOperation(value = "Ping - Accepts pings of graylog2-radio nodes.",
            notes = "Every graylog2-radio node is regularly pinging to announce that it is active.")
    @Path("/{radioId}/ping")
    public Response ping(@ApiParam(name = "JSON body", required = true) String body,
                         @ApiParam(name = "radioId", required = true) @PathParam("radioId") String radioId) {
        PingRequest pr;

        try {
            pr = objectMapper.readValue(body, PingRequest.class);
        } catch(IOException e) {
            LOG.error("Error while parsing JSON", e);
View Full Code Here


    @Test
    public void testGetMessage() throws Exception {
        final Request request = new RequestBuilder()
                .setUrl("http://user:password@localhost:1234/some/path?query=foo#fragment")
                .build();
        final APIException apiException = new APIException(request, (Response) null);

        final String message = apiException.getMessage();
        assertThat(message, not(new Contains(":password")));
        assertThat(message, new Contains("user@"));
    }
View Full Code Here

        });
        modules.add(new ModelFactoryModule());
        injector = Guice.createInjector(modules);

        // start the services that need starting
        final ApiClient api = injector.getInstance(ApiClient.class);
        api.start();
        injector.getInstance(ServerNodesRefreshService.class).start();
        // TODO replace with custom AuthenticatedAction filter
        RedirectAuthenticator.userService = injector.getInstance(UserService.class);
        RedirectAuthenticator.sessionService = injector.getInstance(SessionService.class);
View Full Code Here

            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

        }

        if (total.rate == null) {
            this.meter = null;
        } else {
            this.meter = new Meter(total.rate);
        }
    }
View Full Code Here

    public Result internalLogsOfNode(String nodeId) {
        try {
            Map<String, Object> result = Maps.newHashMap();
            Node node = nodeService.loadNode(nodeId);
            Meter meter = (Meter) node.getSingleMetric("org.apache.log4j.Appender.all");
            result.put("total", meter.getTotal());

            return ok(Json.toJson(result));
        } catch (NodeService.NodeNotFoundException e) {
            return status(404, "node not found");
        } catch (IOException e) {
View Full Code Here

            for (String level : levels) {
                String shortName = level.substring(level.lastIndexOf(".") + 1);
                Map<String, Object> meterMap = Maps.newHashMap();

                Meter meter = (Meter) node.getSingleMetric(level);

                meterMap.put("total", meter.getTotal());
                meterMap.put("mean_rate", meter.getMeanFormatted());
                meterMap.put("one_min_rate", meter.getOneMinuteFormatted());

                result.put(shortName, meterMap);
            }

            return ok(Json.toJson(result));
View Full Code Here

TOP

Related Classes of org.graylog2.restclient.lib.metrics.Meter

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.