Example usage for java.io ObjectOutputStream writeInt

List of usage examples for java.io ObjectOutputStream writeInt

Introduction

In this page you can find the example usage for java.io ObjectOutputStream writeInt.

Prototype

public void writeInt(int val) throws IOException 

Source Link

Document

Writes a 32 bit int.

Usage

From source file:com.phoenixst.plexus.DefaultGraph.java

/**
 *  Serialize this <code>DefaultGraph</code>.
 *
 *  @serialData the number of nodes (int), all the nodes, the
 *  number of edges (int), all the edges.
 *///from  w w w  . j  a  v  a 2s  .c  o  m
private void writeObject(ObjectOutputStream out) throws IOException {
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Serializing " + instanceString);
    }
    out.defaultWriteObject();
    out.writeInt(nodeMap.size());
    for (Iterator i = nodeMap.keySet().iterator(); i.hasNext();) {
        out.writeObject(i.next());
    }
    out.writeInt(edgeSize);
    for (Iterator i = edgeCollection.iterator(); i.hasNext();) {
        out.writeObject(i.next());
    }
}

From source file:org.domainmath.gui.MainFrame.java

private void createRootWindow() {
    viewMap.addView(0, fileTabView);//w ww.  ja  va2s  . c o m
    viewMap.addView(1, pathsView);
    viewMap.addView(2, pkgView);
    viewMap.addView(3, consoleView);
    viewMap.addView(4, arrayEditorView);
    viewMap.addView(5, workspaceView);
    viewMap.addView(6, filesView);
    viewMap.addView(7, historyView);
    viewMap.addView(8, debuggerView);
    viewMap.addView(9, quickHelpView);

    MixedViewHandler handler = new MixedViewHandler(viewMap, new ViewSerializer() {

        @Override
        public void writeView(View view, ObjectOutputStream out) throws IOException {
            out.writeInt(((DynamicView) view).getId());
        }

        @Override
        public View readView(ObjectInputStream in) throws IOException {
            return getDynamicView(in.readInt());
        }
    });
    rootWindow = DockingUtil.createRootWindow(viewMap, handler, true);

    properties.addSuperObject(currentTheme.getRootWindowProperties());
    properties.addSuperObject(titleBarStyleProperties);
    rootWindow.getRootWindowProperties().addSuperObject(properties);

    rootWindow.getWindowBar(Direction.DOWN).setEnabled(true);

    rootWindow.addListener(new DockingWindowAdapter() {
        @Override
        public void windowAdded(DockingWindow addedToWindow, DockingWindow addedWindow) {
            updateViews(addedWindow, true);
        }

        @Override
        public void windowRemoved(DockingWindow removedFromWindow, DockingWindow removedWindow) {
            updateViews(removedWindow, false);
        }

        @Override
        public void windowClosing(DockingWindow window) throws OperationAbortedException {
        }

        @Override
        public void windowDocking(DockingWindow window) throws OperationAbortedException {
        }

        @Override
        public void windowUndocking(DockingWindow window) throws OperationAbortedException {
        }
    });

    rootWindow.addTabMouseButtonListener(DockingWindowActionMouseButtonListener.MIDDLE_BUTTON_CLOSE_LISTENER);
}

From source file:bftsmart.tom.core.TOMLayer.java

private void evaluateStops(int nextReg) {

    boolean enterFirstPhase = this.controller.getStaticConf().isBFT();
    boolean condition = false;
    ObjectOutputStream out = null;
    ByteArrayOutputStream bos = null;

    // pass to the leader change phase if more than f messages have been received already
    if (enterFirstPhase && lcManager.getStopsSize(nextReg) > this.controller.getQuorumF()
            && lcManager.getNextReg() == lcManager.getLastReg()) {

        Logger.println("(TOMLayer.evaluateStops) initialize synch phase");
        requestsTimer.Enabled(false);/*  www.ja  v  a  2  s .co  m*/
        requestsTimer.stopTimer();

        lcManager.setNextReg(lcManager.getLastReg() + 1); // define next timestamp

        int regency = lcManager.getNextReg();

        // store information about message I am going to send
        lcManager.addStop(regency, this.controller.getStaticConf().getProcessId());

        execManager.stop(); // stop execution of consensus

        try { // serialize conent to send in the STOP message
            bos = new ByteArrayOutputStream();
            out = new ObjectOutputStream(bos);

            if (lcManager.getCurrentRequestTimedOut() != null) {

                //TODO: If this is null, there was no timeout. What shall be done then?
                out.writeBoolean(true);
                byte[] msgs = bb.makeBatch(lcManager.getCurrentRequestTimedOut(), 0, 0, controller);
                out.writeObject(msgs);
            } else {
                out.writeBoolean(false);
            }

            out.flush();
            bos.flush();

            byte[] payload = bos.toByteArray();
            out.close();
            bos.close();

            // send message STOP
            Logger.println("(TOMLayer.evaluateStops) sending STOP message to install regency " + regency);
            communication.send(this.controller.getCurrentViewOtherAcceptors(), new LCMessage(
                    this.controller.getStaticConf().getProcessId(), TOMUtil.STOP, regency, payload));

        } catch (IOException ex) {
            ex.printStackTrace();
            java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                out.close();
                bos.close();
            } catch (IOException ex) {
                ex.printStackTrace();
                java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    if (this.controller.getStaticConf().isBFT()) {
        condition = lcManager.getStopsSize(nextReg) > this.controller.getCertificateQuorum()
                && lcManager.getNextReg() > lcManager.getLastReg();
    } else {
        condition = (lcManager.getStopsSize(nextReg) > this.controller.getQuorumAccept()
                && lcManager.getNextReg() > lcManager.getLastReg());
    }
    // May I proceed to the synchronization phase?
    //if (lcManager.getStopsSize(nextReg) > this.reconfManager.getQuorum2F() && lcManager.getNextReg() > lcManager.getLastReg()) {
    if (condition) {

        Logger.println("(TOMLayer.evaluateStops) installing regency " + lcManager.getNextReg());
        lcManager.setLastReg(lcManager.getNextReg()); // define last timestamp

        int regency = lcManager.getLastReg();

        // avoid a memory leak
        lcManager.removeStops(nextReg);

        requestsTimer.Enabled(true);
        requestsTimer.setShortTimeout(-1);
        //requestsTimer.setTimeout(requestsTimer.getTimeout() * 2);
        requestsTimer.startTimer();

        //int leader = regency % this.reconfManager.getCurrentViewN(); // new leader
        int leader = lcManager.getNewLeader();
        int in = getInExec(); // eid to execute
        int last = getLastExec(); // last eid decided

        lm.setNewLeader(leader);

        // If I am not the leader, I have to send a STOPDATE message to it
        if (leader != this.controller.getStaticConf().getProcessId()) {

            try { // serialize content of the SYNC message

                bos = new ByteArrayOutputStream();
                out = new ObjectOutputStream(bos);

                if (last > -1) { // content of the last decided eid

                    out.writeBoolean(true);
                    out.writeInt(last);
                    Execution exec = execManager.getExecution(last);
                    //byte[] decision = exec.getLearner().getDecision();

                    ////// ISTO E PARA APANHAR UM BUG!!!!!
                    if (exec.getDecisionRound() == null || exec.getDecisionRound().propValue == null) {

                        System.out.println("[DEBUG INFO FOR LAST EID #1]");

                        if (exec.getDecisionRound() == null) {
                            System.out.println("No decision round for eid " + last);
                        } else {
                            System.out.println(
                                    "round for eid: " + last + ": " + exec.getDecisionRound().toString());

                            if (exec.getDecisionRound().propValue == null)
                                System.out.println("No propose for eid " + last);
                            else {
                                System.out.println("Propose hash for eid " + last + ": " + Base64
                                        .encodeBase64String(computeHash(exec.getDecisionRound().propValue)));
                            }
                        }

                        return;
                    }

                    byte[] decision = exec.getDecisionRound().propValue;
                    Set<PaxosMessage> proof = exec.getDecisionRound().getProof();

                    out.writeObject(decision);
                    out.writeObject(proof);
                    // TODO: WILL BE NECESSARY TO ADD A PROOF!!!

                }

                else
                    out.writeBoolean(false);

                if (in > -1) { // content of eid in execution

                    Execution exec = execManager.getExecution(in);

                    TimestampValuePair quorumWrites = exec.getQuorumWrites();
                    HashSet<TimestampValuePair> writeSet = exec.getWriteSet();

                    CollectData collect = new CollectData(this.controller.getStaticConf().getProcessId(), in,
                            quorumWrites, writeSet);

                    SignedObject signedCollect = sign(collect);

                    out.writeObject(signedCollect);

                }

                else {

                    CollectData collect = new CollectData(this.controller.getStaticConf().getProcessId(), -1,
                            new TimestampValuePair(-1, new byte[0]), new HashSet<TimestampValuePair>());

                    SignedObject signedCollect = sign(collect);

                    out.writeObject(signedCollect);

                }

                out.flush();
                bos.flush();

                byte[] payload = bos.toByteArray();
                out.close();
                bos.close();

                int[] b = new int[1];
                b[0] = leader;

                Logger.println("(TOMLayer.evaluateStops) sending STOPDATA of regency " + regency);
                // send message SYNC to the new leader
                communication.send(b, new LCMessage(this.controller.getStaticConf().getProcessId(),
                        TOMUtil.STOPDATA, regency, payload));

                //TODO: Turn on timeout again

            } catch (IOException ex) {
                ex.printStackTrace();
                java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                try {
                    out.close();
                    bos.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                    java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

        } else { // If leader, I will store information that I would send in a SYNC message

            Logger.println("(TOMLayer.evaluateStops) I'm the leader for this new regency");
            LastEidData lastData = null;
            CollectData collect = null;

            if (last > -1) { // content of the last decided eid 
                Execution exec = execManager.getExecution(last);
                //byte[] decision = exec.getLearner().getDecision();

                ////// ISTO E PARA APANHAR UM BUG!!!!!
                if (exec.getDecisionRound() == null || exec.getDecisionRound().propValue == null) {

                    System.out.println("[DEBUG INFO FOR LAST EID #2]");

                    if (exec.getDecisionRound() == null)
                        System.out.println("No decision round for eid " + last);
                    else
                        System.out
                                .println("round for eid: " + last + ": " + exec.getDecisionRound().toString());
                    if (exec.getDecisionRound().propValue == null)
                        System.out.println("No propose for eid " + last);
                    else {
                        System.out.println("Propose hash for eid " + last + ": "
                                + Base64.encodeBase64String(computeHash(exec.getDecisionRound().propValue)));
                    }

                    return;
                }

                byte[] decision = exec.getDecisionRound().propValue;
                Set<PaxosMessage> proof = exec.getDecisionRound().getProof();

                lastData = new LastEidData(this.controller.getStaticConf().getProcessId(), last, decision,
                        proof);
                // TODO: WILL BE NECESSARY TO ADD A PROOF!!!

            } else {
                lastData = new LastEidData(this.controller.getStaticConf().getProcessId(), last, null, null);
            }
            lcManager.addLastEid(regency, lastData);

            if (in > -1) { // content of eid being executed
                Execution exec = execManager.getExecution(in);

                TimestampValuePair quorumWrites = exec.getQuorumWrites();
                HashSet<TimestampValuePair> writeSet = exec.getWriteSet();

                collect = new CollectData(this.controller.getStaticConf().getProcessId(), in, quorumWrites,
                        writeSet);

            } else {
                collect = new CollectData(this.controller.getStaticConf().getProcessId(), -1,
                        new TimestampValuePair(-1, new byte[0]), new HashSet<TimestampValuePair>());
            }

            SignedObject signedCollect = sign(collect);

            lcManager.addCollect(regency, signedCollect);
        }

    }
}

From source file:bftsmart.tom.core.Synchronizer.java

private void startSynchronization(int nextReg) {

    boolean condition;
    ObjectOutputStream out = null;
    ByteArrayOutputStream bos = null;

    if (this.controller.getStaticConf().isBFT()) {
        condition = lcManager.getStopsSize(nextReg) > this.controller.getCurrentViewF();
    } else {//from w  ww . ja va2 s  .c om
        condition = lcManager.getStopsSize(nextReg) > 0;
    }

    // Ask to start the synchronizations phase if enough messages have been received already
    if (condition && lcManager.getNextReg() == lcManager.getLastReg()) {

        Logger.println("(Synchronizer.startSynchronization) initialize synch phase");
        requestsTimer.Enabled(false);
        requestsTimer.stopTimer();

        lcManager.setNextReg(lcManager.getLastReg() + 1); // define next timestamp

        int regency = lcManager.getNextReg();

        // store information about message I am going to send
        lcManager.addStop(regency, this.controller.getStaticConf().getProcessId());

        //execManager.stop(); // stop execution of consensus

        //Get requests that timed out and the requests received in STOP messages
        //and add those STOPed requests to the client manager
        addSTOPedRequestsToClientManager();
        List<TOMMessage> messages = getRequestsToRelay();

        try { // serialize conent to send in the STOP message
            bos = new ByteArrayOutputStream();
            out = new ObjectOutputStream(bos);

            // Do I have messages to send in the STOP message?
            if (messages != null && messages.size() > 0) {

                //TODO: If this is null, there was no timeout nor STOP messages.
                //What shall be done then?
                out.writeBoolean(true);
                byte[] serialized = bb.makeBatch(messages, 0, 0, controller);
                out.writeObject(serialized);
            } else {
                out.writeBoolean(false);
                System.out.println(
                        "(Synchronizer.startSynchronization) Strange... did not include any request in my STOP message for regency "
                                + regency);
            }

            out.flush();
            bos.flush();

            byte[] payload = bos.toByteArray();
            out.close();
            bos.close();

            // send message STOP
            System.out.println("(Synchronizer.startSynchronization) sending STOP message to install regency "
                    + regency + " with " + (messages != null ? messages.size() : 0) + " request(s) to relay");

            LCMessage stop = new LCMessage(this.controller.getStaticConf().getProcessId(), TOMUtil.STOP,
                    regency, payload);
            requestsTimer.setSTOP(regency, stop); // make replica re-transmit the stop message until a new regency is installed
            communication.send(this.controller.getCurrentViewOtherAcceptors(), stop);

        } catch (IOException ex) {
            ex.printStackTrace();
            java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                out.close();
                bos.close();
            } catch (IOException ex) {
                ex.printStackTrace();
                java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    if (this.controller.getStaticConf().isBFT()) {
        condition = lcManager.getStopsSize(nextReg) > (2 * this.controller.getCurrentViewF());
    } else {
        condition = lcManager.getStopsSize(nextReg) > this.controller.getCurrentViewF();
    }

    // Did the synchronization phase really started?
    //if (lcManager.getStopsSize(nextReg) > this.reconfManager.getQuorum2F() && lcManager.getNextReg() > lcManager.getLastReg()) {
    if (condition && lcManager.getNextReg() > lcManager.getLastReg()) {

        if (!execManager.stopped())
            execManager.stop(); // stop consensus execution if more than f replicas sent a STOP message

        Logger.println("(Synchronizer.startSynchronization) installing regency " + lcManager.getNextReg());
        lcManager.setLastReg(lcManager.getNextReg()); // define last timestamp

        int regency = lcManager.getLastReg();

        // avoid memory leaks
        lcManager.removeStops(nextReg);
        lcManager.clearCurrentRequestTimedOut();
        lcManager.clearRequestsFromSTOP();

        requestsTimer.Enabled(true);
        requestsTimer.setShortTimeout(-1);
        requestsTimer.startTimer();

        //int leader = regency % this.reconfManager.getCurrentViewN(); // new leader
        int leader = lcManager.getNewLeader();
        int in = tom.getInExec(); // cid to execute
        int last = tom.getLastExec(); // last cid decided

        execManager.setNewLeader(leader);

        // If I am not the leader, I have to send a STOPDATA message to the elected leader
        if (leader != this.controller.getStaticConf().getProcessId()) {

            try { // serialize content of the STOPDATA message

                bos = new ByteArrayOutputStream();
                out = new ObjectOutputStream(bos);

                Consensus cons = null;

                // content of the last decided CID
                if (last > -1)
                    cons = execManager.getConsensus(last);

                //Do I have info on my last executed consensus?
                if (cons != null && cons.getDecisionEpoch() != null
                        && cons.getDecisionEpoch().propValue != null) {

                    out.writeBoolean(true);
                    out.writeInt(last);
                    //byte[] decision = exec.getLearner().getDecision();

                    byte[] decision = cons.getDecisionEpoch().propValue;
                    Set<ConsensusMessage> proof = cons.getDecisionEpoch().getProof();

                    out.writeObject(decision);
                    out.writeObject(proof);
                    // TODO: WILL BE NECESSARY TO ADD A PROOF!!!

                } else {
                    out.writeBoolean(false);

                    ////// THIS IS TO CATCH A BUG!!!!!
                    if (last > -1) {
                        System.out.println("[DEBUG INFO FOR LAST CID #1]");

                        if (cons == null) {
                            if (last > -1)
                                System.out.println("No consensus instance for cid " + last);

                        } else if (cons.getDecisionEpoch() == null) {
                            System.out.println("No decision epoch for cid " + last);
                        } else {
                            System.out.println(
                                    "epoch for cid: " + last + ": " + cons.getDecisionEpoch().toString());

                            if (cons.getDecisionEpoch().propValue == null) {
                                System.out.println("No propose for cid " + last);
                            } else {
                                System.out.println(
                                        "Propose hash for cid " + last + ": " + Base64.encodeBase64String(
                                                tom.computeHash(cons.getDecisionEpoch().propValue)));
                            }
                        }
                    }

                }

                if (in > -1) { // content of cid in execution

                    cons = execManager.getConsensus(in);

                    //cons.incEts(); // make the consensus advance to the next epoch
                    cons.setETS(regency); // make the consensus advance to the next epoch

                    //int ets = cons.getEts();
                    //cons.createEpoch(ets, controller);
                    cons.createEpoch(regency, controller);
                    //Logger.println("(Synchronizer.startSynchronization) incrementing ets of consensus " + cons.getId() + " to " + ets);
                    Logger.println("(Synchronizer.startSynchronization) incrementing ets of consensus "
                            + cons.getId() + " to " + regency);

                    TimestampValuePair quorumWrites;
                    if (cons.getQuorumWrites() != null) {

                        quorumWrites = cons.getQuorumWrites();

                    } else {

                        quorumWrites = new TimestampValuePair(0, new byte[0]);
                    }

                    HashSet<TimestampValuePair> writeSet = cons.getWriteSet();

                    //CollectData collect = new CollectData(this.controller.getStaticConf().getProcessId(), in, ets, quorumWrites, writeSet);
                    CollectData collect = new CollectData(this.controller.getStaticConf().getProcessId(), in,
                            regency, quorumWrites, writeSet);

                    SignedObject signedCollect = tom.sign(collect);

                    out.writeObject(signedCollect);

                } else {

                    cons = execManager.getConsensus(last + 1);

                    //cons.incEts(); // make the consensus advance to the next epoch
                    cons.setETS(regency); // make the consensus advance to the next epoch

                    //int ets = cons.getEts();
                    //cons.createEpoch(ets, controller);
                    cons.createEpoch(regency, controller);
                    //Logger.println("(Synchronizer.startSynchronization) incrementing ets of consensus " + cons.getId() + " to " + ets);
                    Logger.println("(Synchronizer.startSynchronization) incrementing ets of consensus "
                            + cons.getId() + " to " + regency);

                    //CollectData collect = new CollectData(this.controller.getStaticConf().getProcessId(), last + 1, ets, new TimestampValuePair(0, new byte[0]), new HashSet<TimestampValuePair>());
                    CollectData collect = new CollectData(this.controller.getStaticConf().getProcessId(),
                            last + 1, regency, new TimestampValuePair(0, new byte[0]),
                            new HashSet<TimestampValuePair>());

                    SignedObject signedCollect = tom.sign(collect);

                    out.writeObject(signedCollect);

                }

                out.flush();
                bos.flush();

                byte[] payload = bos.toByteArray();
                out.close();
                bos.close();

                int[] b = new int[1];
                b[0] = leader;

                System.out
                        .println("(Synchronizer.startSynchronization) sending STOPDATA of regency " + regency);
                // send message SYNC to the new leader
                communication.send(b, new LCMessage(this.controller.getStaticConf().getProcessId(),
                        TOMUtil.STOPDATA, regency, payload));

                //TODO: Turn on timeout again?
            } catch (IOException ex) {
                ex.printStackTrace();
                java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                try {
                    out.close();
                    bos.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                    java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            // the replica might have received a SYNC that was out of context at the time it was received, but now can be processed
            Set<LCMessage> sync = getOutOfContextLC(TOMUtil.SYNC, regency);

            Logger.println(
                    "(Synchronizer.startSynchronization) Checking if there are out of context SYNC for regency "
                            + regency);

            if (sync.size() > 0) {
                System.out.println(
                        "(Synchronizer.startSynchronization) Processing out of context SYNC for regency "
                                + regency);
            } else {
                Logger.println(
                        "(Synchronizer.startSynchronization) No out of context SYNC for regency " + regency);
            }

            for (LCMessage m : sync) {
                if (m.getSender() == execManager.getCurrentLeader()) {
                    processSYNC(m.getPayload(), regency);
                    return; // makes no sense to continue, since there is only one SYNC message
                }
            }

        } else { // If leader, I will store information that I would send in a SYNC message

            Logger.println("(Synchronizer.startSynchronization) I'm the leader for this new regency");
            CertifiedDecision lastDec = null;
            CollectData collect = null;

            Consensus cons = null;

            //Content of the last decided CID
            if (last > -1)
                cons = execManager.getConsensus(last);

            //Do I have info on my last executed consensus?
            if (cons != null && cons.getDecisionEpoch() != null && cons.getDecisionEpoch().propValue != null) {
                //byte[] decision = exec.getLearner().getDecision();

                byte[] decision = cons.getDecisionEpoch().propValue;
                Set<ConsensusMessage> proof = cons.getDecisionEpoch().getProof();

                lastDec = new CertifiedDecision(this.controller.getStaticConf().getProcessId(), last, decision,
                        proof);
                // TODO: WILL BE NECESSARY TO ADD A PROOF!!!??

            } else {
                lastDec = new CertifiedDecision(this.controller.getStaticConf().getProcessId(), last, null,
                        null);

                ////// THIS IS TO CATCH A BUG!!!!!
                if (last > -1) {
                    System.out.println("[DEBUG INFO FOR LAST CID #2]");

                    if (cons == null) {
                        if (last > -1)
                            System.out.println("No consensus instance for cid " + last);

                    } else if (cons.getDecisionEpoch() == null) {
                        System.out.println("No decision epoch for cid " + last);
                    } else {
                        System.out
                                .println("epoch for cid: " + last + ": " + cons.getDecisionEpoch().toString());
                    }
                    if (cons.getDecisionEpoch().propValue == null) {
                        System.out.println("No propose for cid " + last);
                    } else {
                        System.out.println("Propose hash for cid " + last + ": " + Base64
                                .encodeBase64String(tom.computeHash(cons.getDecisionEpoch().propValue)));
                    }
                }

            }
            lcManager.addLastCID(regency, lastDec);

            if (in > -1) { // content of cid being executed
                cons = execManager.getConsensus(in);

                //cons.incEts(); // make the consensus advance to the next epoch
                cons.setETS(regency); // make the consensus advance to the next epoch

                //int ets = cons.getEts();
                //cons.createEpoch(ets, controller);
                cons.createEpoch(regency, controller);
                //Logger.println("(Synchronizer.startSynchronization) incrementing ets of consensus " + cons.getId() + " to " + ets);
                Logger.println("(Synchronizer.startSynchronization) incrementing ets of consensus "
                        + cons.getId() + " to " + regency);

                TimestampValuePair quorumWrites;

                if (cons.getQuorumWrites() != null) {

                    quorumWrites = cons.getQuorumWrites();
                } else {
                    quorumWrites = new TimestampValuePair(0, new byte[0]);
                }

                HashSet<TimestampValuePair> writeSet = cons.getWriteSet();

                //collect = new CollectData(this.controller.getStaticConf().getProcessId(), in, ets, quorumWrites, writeSet);
                collect = new CollectData(this.controller.getStaticConf().getProcessId(), in, regency,
                        quorumWrites, writeSet);

            } else {

                cons = execManager.getConsensus(last + 1);

                //cons.incEts(); // make the consensus advance to the next epoch
                cons.setETS(regency); // make the consensus advance to the next epoch

                //int ets = cons.getEts();
                //cons.createEpoch(ets, controller);
                cons.createEpoch(regency, controller);
                //Logger.println("(Synchronizer.startSynchronization) incrementing ets of consensus " + cons.getId() + " to " + ets);
                Logger.println("(Synchronizer.startSynchronization) incrementing ets of consensus "
                        + cons.getId() + " to " + regency);

                //collect = new CollectData(this.controller.getStaticConf().getProcessId(), last + 1, ets, new TimestampValuePair(0, new byte[0]), new HashSet<TimestampValuePair>());
                collect = new CollectData(this.controller.getStaticConf().getProcessId(), last + 1, regency,
                        new TimestampValuePair(0, new byte[0]), new HashSet<TimestampValuePair>());
            }

            SignedObject signedCollect = tom.sign(collect);

            lcManager.addCollect(regency, signedCollect);

            // the replica might have received STOPDATAs that were out of context at the time they were received, but now can be processed
            Set<LCMessage> stopdatas = getOutOfContextLC(TOMUtil.STOPDATA, regency);

            Logger.println(
                    "(Synchronizer.startSynchronization) Checking if there are out of context STOPDATAs for regency "
                            + regency);
            if (stopdatas.size() > 0) {
                System.out.println("(Synchronizer.startSynchronization) Processing " + stopdatas.size()
                        + " out of context STOPDATAs for regency " + regency);
            } else {
                Logger.println("(Synchronizer.startSynchronization) No out of context STOPDATAs for regency "
                        + regency);
            }

            for (LCMessage m : stopdatas) {
                processSTOPDATA(m, regency);
            }

        }

    }
}