Package org.apache.zookeeper.server

Examples of org.apache.zookeeper.server.MockNIOServerCnxn


            quorumPeer.follower = new MyFollower(quorumPeer, fzks);
            final SelectionKey sk = new FakeSK();
            // Simulate a socket channel between a client and a follower
            final SocketChannel socketChannel = createClientSocketChannel();
            // Create the NIOServerCnxn that will handle the client requests
            final MockNIOServerCnxn nioCnxn = new MockNIOServerCnxn(fzks,
                    socketChannel, sk, serverCnxnFactory);
            // Send the connection request as a client do
            nioCnxn.doIO(sk);
            // Send the invalid session packet to the follower
            QuorumPacket qp = createInvalidSessionPacket();
            quorumPeer.follower.processPacket(qp);
            // OK, now the follower knows that the session is invalid, let's try
            // to
            // send it the watches
            nioCnxn.doIO(sk);
            // wait for the the request processor to do his job
            Thread.sleep(1000L);
            // Session has not been re-validated !
            // If session has not been validated, there must be NO watches
            int watchCount = database.getDataTree().getWatchCount();
View Full Code Here


            quorumPeer.follower = new MyFollower(quorumPeer, fzks);
            LOG.info("Follower created");
            // Simulate a socket channel between a client and a follower
            final SocketChannel socketChannel = createClientSocketChannel();
            // Create the NIOServerCnxn that will handle the client requests
            final MockNIOServerCnxn nioCnxn = new MockNIOServerCnxn(fzks,
                    socketChannel, sk, serverCnxnFactory, selectorThread);
            sk.attach(nioCnxn);
            // Send the connection request as a client do
            nioCnxn.doIO(sk);
            LOG.info("Client connection sent");
            // Send the valid or invalid session packet to the follower
            QuorumPacket qp = createValidateSessionPacketResponse(!sessionTimedout);
            quorumPeer.follower.processPacket(qp);
            LOG.info("Session validation sent");
            // OK, now the follower knows that the session is valid or invalid, let's try
            // to send the watches
            nioCnxn.doIO(sk);
            // wait for the the request processor to do his job
            Thread.sleep(1000L);
            LOG.info("Watches processed");
            // If session has not been validated, there must be NO watches
            int watchCount = database.getDataTree().getWatchCount();
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.server.MockNIOServerCnxn

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.