Package org.apache.zookeeper.server.quorum

Examples of org.apache.zookeeper.server.quorum.LearnerSessionTracker


    @Test
    public void testLearnerSessionTracker() throws Exception {
        Expirer expirer = new Expirer(1);
        // With local session on
        LearnerSessionTracker tracker = new LearnerSessionTracker(expirer,
                sessionsWithTimeouts, TICK_TIME, expirer.sid, true);

        // Unknown session
        long sessionId = 0xb100ded;
        try {
            tracker.checkSession(sessionId, null);
            Assert.fail("Unknown session should have failed");
        } catch (SessionExpiredException e) {
            // Get expected exception
        }

        // Global session
        sessionsWithTimeouts.put(sessionId, CONNECTION_TIMEOUT);
        try {
            tracker.checkSession(sessionId, null);
        } catch (Exception e) {
            Assert.fail("Global session should not fail");
        }

        // Local session
        sessionId = 0xf005ba11;
        tracker.addSession(sessionId, CONNECTION_TIMEOUT);
        try {
            tracker.checkSession(sessionId, null);
        } catch (Exception e) {
            Assert.fail("Local session should not fail");
        }

        // During session upgrade
        sessionsWithTimeouts.put(sessionId, CONNECTION_TIMEOUT);
        try {
            tracker.checkSession(sessionId, null);
        } catch (Exception e) {
            Assert.fail("Session during upgrade should not fail");
        }

        // With local session off
        tracker = new LearnerSessionTracker(expirer, sessionsWithTimeouts,
                TICK_TIME, expirer.sid, false);

        // Should be noop
        sessionId = 0xdeadbeef;
        try {
            tracker.checkSession(sessionId, null);
        } catch (Exception e) {
            Assert.fail("Should not get any exception");
        }

    }
View Full Code Here


        return self.getId();
    }

    @Override
    public void createSessionTracker() {
        sessionTracker = new LearnerSessionTracker(
                this, getZKDatabase().getSessionWithTimeOuts(),
                this.tickTime, self.getId(), self.areLocalSessionsEnabled());
    }
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.server.quorum.LearnerSessionTracker

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.