Examples of Periodical


Examples of org.graylog2.plugin.periodical.Periodical

        String packageName = Periodical.class.getPackage().toString();
        Reflections reflections = new Reflections("org.graylog2.shared.periodical");

        for (Class<? extends Periodical> type : reflections.getSubTypesOf(Periodical.class)) {
            try {
                Periodical periodical = instantiationService.getInstance(type);

                periodical.initialize();

                if (periodical.masterOnly() && !serverStatus.hasCapability(ServerStatus.Capability.MASTER)) {
                    LOG.info("Not starting [{}] periodical. Only started on graylog2-server master nodes.", periodical.getClass().getCanonicalName());
                    continue;
                }

                if (!periodical.startOnThisNode()) {
                    LOG.info("Not starting [{}] periodical. Not configured to run on this node.", periodical.getClass().getCanonicalName());
                    continue;
                }

                // Register and start.
                periodicals.registerAndStart(periodical);
View Full Code Here

Examples of org.graylog2.plugin.periodical.Periodical

        assertEquals(periodicals.getAll().size(), 1, "getAll() did not return a copy of the periodicals List");
    }

    @Test
    public void testGetAllStoppedOnGracefulShutdown() throws Exception {
        final Periodical periodical2 = mock(Periodical.class);
        when(periodical2.stopOnGracefulShutdown()).thenReturn(true);

        periodicals.registerAndStart(periodical);
        periodicals.registerAndStart(periodical2);

        List<Periodical> allStoppedOnGracefulShutdown = periodicals.getAllStoppedOnGracefulShutdown();
View Full Code Here

Examples of org.graylog2.plugin.periodical.Periodical

        assertEquals(periodicals.getFutures().size(), 1);
    }

    @Test
    public void testGetFuturesReturnsACopyOfTheMap() throws Exception {
        final Periodical periodical2 = mock(Periodical.class);

        periodicals.registerAndStart(periodical);

        periodicals.getFutures().put(periodical2, null);
View Full Code Here

Examples of org.graylog2.plugin.periodical.Periodical

    @Test
    public void testExceptionIsNotUncaught() {

        final Logger logger = mock(Logger.class);
        final Periodical periodical1 = new Periodical() {
            @Override
            public boolean runsForever() {
                return false;
            }

            @Override
            public boolean stopOnGracefulShutdown() {
                return false;
            }

            @Override
            public boolean masterOnly() {
                return false;
            }

            @Override
            public boolean startOnThisNode() {
                return true;
            }

            @Override
            public boolean isDaemon() {
                return false;
            }

            @Override
            public int getInitialDelaySeconds() {
                return 0;
            }

            @Override
            public int getPeriodSeconds() {
                return 1;
            }

            @Override
            protected Logger getLogger() {
                return logger;
            }

            @Override
            public void doRun() {
                throw new NullPointerException();
            }
        };

        try {
            periodical1.run();
            // the uncaught exception from doRun should have been logged
            verify(logger, atLeastOnce()).error(anyString(), any(Throwable.class));
        } catch (Exception e) {
            fail("run() should never propagate an unchecked exception!", e);
        }
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.