public void processRequest(Request request) throws RequestProcessorException { // LOG.warn("Ack>>> cxid = " + request.cxid + " type = " + // request.type + " id = " + request.sessionId); // request.addRQRec(">prop"); /* In the following IF-THEN-ELSE block, we process syncs on the leader. * If the sync is coming from a follower, then the follower * handler adds it to syncHandler. Otherwise, if it is a client of * the leader that issued the sync command, then syncHandler won't * contain the handler. In this case, we add it to syncHandler, and * call processRequest on the next processor. */ if (request instanceof LearnerSyncRequest){ zks.getLeader().processSync((LearnerSyncRequest)request); } else { nextProcessor.processRequest(request); if (request.getHdr() != null) { // We need to sync and get consensus on any transactions try { zks.getLeader().propose(request); } catch (XidRolloverException e) { throw new RequestProcessorException(e.getMessage(), e); } syncProcessor.processRequest(request); } } }
public void processRequest(Request request) throws RequestProcessorException { // LOG.warn("Ack>>> cxid = " + request.cxid + " type = " + // request.type + " id = " + request.sessionId); // request.addRQRec(">prop"); /* In the following IF-THEN-ELSE block, we process syncs on the leader. * If the sync is coming from a follower, then the follower * handler adds it to syncHandler. Otherwise, if it is a client of * the leader that issued the sync command, then syncHandler won't * contain the handler. In this case, we add it to syncHandler, and * call processRequest on the next processor. */ if(request instanceof LearnerSyncRequest){ zks.getLeader().processSync((LearnerSyncRequest)request); } else { nextProcessor.processRequest(request); if (request.hdr != null) { // We need to sync and get consensus on any transactions try { zks.getLeader().propose(request); } catch (XidRolloverException e) { throw new RequestProcessorException(e.getMessage(), e); } syncProcessor.processRequest(request); } } }
@Test public void testGetProposalSize() throws IOException, Leader.XidRolloverException { // Arrange Request req = createMockRequest(); // Act leader.propose(req); // Assert byte[] data = SerializeUtils.serializeRequest(req); assertEquals(data.length, leaderBean.getLastProposalSize()); assertEquals(data.length, leaderBean.getMinProposalSize()); assertEquals(data.length, leaderBean.getMaxProposalSize()); }
@Test public void testResetProposalStats() throws IOException, Leader.XidRolloverException { // Arrange int initialProposalSize = leaderBean.getLastProposalSize(); Request req = createMockRequest(); // Act leader.propose(req); // Assert assertNotEquals(initialProposalSize, leaderBean.getLastProposalSize()); leaderBean.resetProposalStatistics(); assertEquals(initialProposalSize, leaderBean.getLastProposalSize()); assertEquals(initialProposalSize, leaderBean.getMinProposalSize()); assertEquals(initialProposalSize, leaderBean.getMaxProposalSize()); }
l.propose(new Request(1, 1, ZooDefs.OpCode.create, new TxnHeader(1, 1, zxid, 1, ZooDefs.OpCode.create), new CreateTxn("/test", "hola".getBytes(), null, true, 0), zxid));
public void processRequest(Request request) { // LOG.warn("Ack>>> cxid = " + request.cxid + " type = " + // request.type + " id = " + request.sessionId); // request.addRQRec(">prop"); /* In the following IF-THEN-ELSE block, we process syncs on the leader. * If the sync is coming from a follower, then the follower * handler adds it to syncHandler. Otherwise, if it is a client of * the leader that issued the sync command, then syncHandler won't * contain the handler. In this case, we add it to syncHandler, and * call processRequest on the next processor. */ if(request instanceof LearnerSyncRequest){ zks.getLeader().processSync((LearnerSyncRequest)request); } else { nextProcessor.processRequest(request); if (request.hdr != null) { // We need to sync and get consensus on any transactions zks.getLeader().propose(request); syncProcessor.processRequest(request); } } }