提交 a5f97ca0 编写于 作者: L liquidsnake@sapo.pt

In this commit I started to clean up the code that I wrote. I also added some...

In this commit I started to clean up the code that I wrote. I also added some debug messages which are produced with the Logger object.
上级 6c1cc9db
...@@ -74,12 +74,11 @@ public class Consensus { ...@@ -74,12 +74,11 @@ public class Consensus {
*/ */
public byte[] getDecision() { public byte[] getDecision() {
System.out.println("[Consensus.getDecision]");
if(decision == null) { if(decision == null) {
waitForPropose(); waitForPropose();
decision = decisionRound.propValue; decision = decisionRound.propValue;
} }
System.out.println("[/Consensus.getDecision]");
return decision; return decision;
} }
...@@ -89,12 +88,10 @@ public class Consensus { ...@@ -89,12 +88,10 @@ public class Consensus {
*/ */
public Object getDeserializedDecision() { public Object getDeserializedDecision() {
System.out.println("[Consensus.getDeserializedDecision]");
if(deserializedDecision == null) { if(deserializedDecision == null) {
waitForPropose(); waitForPropose();
deserializedDecision = decisionRound.deserializedPropValue; deserializedDecision = decisionRound.deserializedPropValue;
} }
System.out.println("[/Consensus.getDeserializedDecision]");
return deserializedDecision; return deserializedDecision;
} }
......
...@@ -240,12 +240,10 @@ public final class ExecutionManager { ...@@ -240,12 +240,10 @@ public final class ExecutionManager {
type = ""; type = "";
break; break;
} }
System.out.println("Esta a obter estado? " + isRetrievingState); if (isRetrievingState) Logger.println("(ExecutionManager.checkLimits) I'm waiting for a state");
Logger.println("Recebi uma mensagem do eid " + consId + " do tipo " + type); Logger.println("(ExecutionManager.checkLimits) I received a message for execution " + consId + " of type " + type);
Logger.println("Estou no EID " + currentConsId); Logger.println("(ExecutionManager.checkLimits) I'm at execution " + currentConsId);
Logger.println("Ultimo EID " + lastConsId); Logger.println("(ExecutionManager.checkLimits) My last las execution is" + lastConsId);
Logger.println("Paxos highmark " + paxosHighMark);
Logger.println("Revival highmark " + revivalHighMark);
boolean canProcessTheMessage = false; boolean canProcessTheMessage = false;
...@@ -289,8 +287,8 @@ public final class ExecutionManager { ...@@ -289,8 +287,8 @@ public final class ExecutionManager {
consId > (lastConsId + 1) consId > (lastConsId + 1)
) { ) {
System.out.println("<Out of context message>");
Logger.println("(ExecutionManager.checkLimits) adding message for execution "+consId+" to out of context"); Logger.println("(ExecutionManager.checkLimits) Message for execution "+consId+" is out of context, adding it to out of context set");
//store it as an ahead of time message (out of context) //store it as an ahead of time message (out of context)
addOutOfContextMessage(msg); addOutOfContextMessage(msg);
} else { } else {
...@@ -318,8 +316,7 @@ public final class ExecutionManager { ...@@ -318,8 +316,7 @@ public final class ExecutionManager {
//TODO: at this point a new state should be recovered from other correct replicas //TODO: at this point a new state should be recovered from other correct replicas
/** ISTO E CODIGO DO JOAO, PARA TRATAR DA TRANSFERENCIA DE ESTADO */ /** ISTO E CODIGO DO JOAO, PARA TRATAR DA TRANSFERENCIA DE ESTADO */
System.out.println("<Out of highmark>"); Logger.println("(ExecutionManager.checkLimits) Message for execution "+consId+" is beyond the paxos highmark, adding it to out of context set");
Logger.println("(ExecutionManager.checkLimits) adding message for execution "+consId+" to out of context");
addOutOfContextMessage(msg); addOutOfContextMessage(msg);
tomLayer.requestState(me, getOtherAcceptors(), msg.getSender(), consId); tomLayer.requestState(me, getOtherAcceptors(), msg.getSender(), consId);
/******************************************************************/ /******************************************************************/
......
...@@ -203,28 +203,27 @@ public class Acceptor { ...@@ -203,28 +203,27 @@ public class Acceptor {
// If message's round is 0, and the sender is the leader for the message's round, // If message's round is 0, and the sender is the leader for the message's round,
// execute the propose // execute the propose
int teste = leaderModule.getLeader(eid, msg.getRound()); int teste = leaderModule.getLeader(eid, msg.getRound());
System.out.println("Quem e o lider: " + teste);
if (msg.getRound() == 0 && teste == p) { if (msg.getRound() == 0 && teste == p) {
System.out.println("A executar executePropose (1)");
executePropose(round, value); executePropose(round, value);
} else { } else {
Proof proof = (Proof) msg.getProof(); Proof proof = (Proof) msg.getProof();
if (proof != null) { if (proof != null) {
System.out.println("As provas nao estao a nulo");
// Get valid proofs // Get valid proofs
CollectProof[] collected = verifier.checkValid(eid, msg.getRound() - 1, proof.getProofs()); CollectProof[] collected = verifier.checkValid(eid, msg.getRound() - 1, proof.getProofs());
if (verifier.isTheLeader(p, collected)) { // Is the replica that sent this message the leader? if (verifier.isTheLeader(p, collected)) { // Is the replica that sent this message the leader?
System.out.println("O proprio lider enviou esta mensagem");
leaderModule.addLeaderInfo(eid, msg.getRound(), p); leaderModule.addLeaderInfo(eid, msg.getRound(), p);
// Is the proposed value good according to the PaW algorithm? // Is the proposed value good according to the PaW algorithm?
if (value != null && (verifier.good(value, collected, true))) { if (value != null && (verifier.good(value, collected, true))) {
System.out.println("A executar executePropose (2)");
executePropose(round, value); executePropose(round, value);
} else if (checkAndDiscardConsensus(eid, collected, true)) { } else if (checkAndDiscardConsensus(eid, collected, true)) {
leaderModule.addLeaderInfo(eid, 0, p); leaderModule.addLeaderInfo(eid, 0, p);
...@@ -237,7 +236,7 @@ public class Acceptor { ...@@ -237,7 +236,7 @@ public class Acceptor {
if (tomLayer.getInExec() == eid + 1) { // Is this message from the previous execution? if (tomLayer.getInExec() == eid + 1) { // Is this message from the previous execution?
Execution nextExecution = manager.getExecution(eid + 1); Execution nextExecution = manager.getExecution(eid + 1);
nextExecution.removeRounds(nextRoundNumber - 1); nextExecution.removeRounds(nextRoundNumber - 1);
System.out.println("A executar executePropose (3)");
executePropose(nextExecution.getRound(nextRoundNumber), value); executePropose(nextExecution.getRound(nextRoundNumber), value);
} else { } else {
nextProp = new AcceptedPropose(eid + 1, round.getNumber(), value, proof); nextProp = new AcceptedPropose(eid + 1, round.getNumber(), value, proof);
...@@ -489,7 +488,7 @@ public class Acceptor { ...@@ -489,7 +488,7 @@ public class Acceptor {
execution.lock.lock(); execution.lock.lock();
Logger.println("(Acceptor.timeout) timeout for round " + round.getNumber() + " of consensus " + execution.getId()); Logger.println("(Acceptor.timeout) timeout for round " + round.getNumber() + " of consensus " + execution.getId());
System.out.println(round); //System.out.println(round);
if (!round.getExecution().isDecided() && !round.isFrozen() && !round.isRemoved()) { if (!round.getExecution().isDecided() && !round.isFrozen() && !round.isRemoved()) {
doFreeze(round); doFreeze(round);
......
...@@ -93,7 +93,7 @@ public class StateManager { ...@@ -93,7 +93,7 @@ public class StateManager {
count++; count++;
} }
} }
//System.out.println("Replicas counted for eid " + eid + ": " + count);
return count > f; return count > f;
} }
public boolean moreThenF_Replies() { public boolean moreThenF_Replies() {
......
...@@ -84,12 +84,12 @@ public class DeliveryThread extends Thread { ...@@ -84,12 +84,12 @@ public class DeliveryThread extends Thread {
public void deliverLock() { public void deliverLock() {
deliverLock.lock(); deliverLock.lock();
Logger.println("Obti o deliver lock"); Logger.println("(DeliveryThread.deliverLock) Deliver lock obtained");
} }
public void deliverUnlock() { public void deliverUnlock() {
deliverLock.unlock(); deliverLock.unlock();
Logger.println("Soltei o deliver lock"); Logger.println("(DeliveryThread.deliverUnlock) Deliver Released");
} }
public void canDeliver() { public void canDeliver() {
...@@ -99,14 +99,14 @@ public class DeliveryThread extends Thread { ...@@ -99,14 +99,14 @@ public class DeliveryThread extends Thread {
//deliverLock.lock(); //deliverLock.lock();
System.out.println("Vou actualizar-me"); int lastCheckpointEid = state.getLastCheckpointEid();
int lastEid = state.getLastEid();
receiver.setState(state.getState()); Logger.println("(DeliveryThread.update) I'm going to update myself from EID " + lastCheckpointEid + " to EID " + lastEid);
tomLayer.lm.addLeaderInfo(state.getLastCheckpointEid(), state.getLastCheckpointRound(), state.getLastCheckpointLeader()); receiver.setState(state.getState());
int lastCheckpointEid = state.getLastCheckpointEid(); tomLayer.lm.addLeaderInfo(lastCheckpointEid, state.getLastCheckpointRound(), state.getLastCheckpointLeader());
int lastEid = state.getLastEid();
for (int eid = lastCheckpointEid + 1; eid <= lastEid; eid++) { for (int eid = lastCheckpointEid + 1; eid <= lastEid; eid++) {
...@@ -351,8 +351,6 @@ public class DeliveryThread extends Thread { ...@@ -351,8 +351,6 @@ public class DeliveryThread extends Thread {
if (cons.getId() > 2) { if (cons.getId() > 2) {
int stableConsensus = cons.getId() - 3; int stableConsensus = cons.getId() - 3;
System.out.println("Last stable consensus: " + stableConsensus);
tomLayer.lm.removeStableConsenusInfos(stableConsensus); tomLayer.lm.removeStableConsenusInfos(stableConsensus);
tomLayer.execManager.removeExecution(stableConsensus); tomLayer.execManager.removeExecution(stableConsensus);
} }
...@@ -385,9 +383,8 @@ public class DeliveryThread extends Thread { ...@@ -385,9 +383,8 @@ public class DeliveryThread extends Thread {
/** ISTO E CODIGO DO JOAO, PARA TRATAR DOS CHECKPOINTS */ /** ISTO E CODIGO DO JOAO, PARA TRATAR DOS CHECKPOINTS */
System.out.println("[DeliveryThread.run]"); Logger.println("(DeliveryThread.run) I just delivered the batch of EID " + cons.getId());
System.out.println("Acabei de entregar o batch do EID " + cons.getId());
System.out.println("[/DeliveryThread.run]");
if (conf.getCheckpoint_period() > 0) { if (conf.getCheckpoint_period() > 0) {
if ((cons.getId() > 0) && ((cons.getId() % conf.getCheckpoint_period()) == 0)) { if ((cons.getId() > 0) && ((cons.getId() % conf.getCheckpoint_period()) == 0)) {
Logger.println("(DeliveryThread.run) Performing checkpoint for consensus " + cons.getId()); Logger.println("(DeliveryThread.run) Performing checkpoint for consensus " + cons.getId());
......
...@@ -34,35 +34,16 @@ public class OutOfContextMessageThread extends Thread { ...@@ -34,35 +34,16 @@ public class OutOfContextMessageThread extends Thread {
private TOMLayer tomLayer; // TOM layer private TOMLayer tomLayer; // TOM layer
/** ISTO E CODIGO DO JOAO, PARA TRATAR DA TRANSFERENCIA DE ESTADO */ /** ISTO E CODIGO DO JOAO, PARA TRATAR DA TRANSFERENCIA DE ESTADO */
private int updateCount = 0;
private ReentrantLock outOfContextLock = new ReentrantLock(); private ReentrantLock outOfContextLock = new ReentrantLock();
private ReentrantLock updatesLock = new ReentrantLock();
public void addUpdate() {
updatesLock.lock();
updateCount++;
updatesLock.unlock();
}
private void removeUpdate() {
updatesLock.lock();
updateCount--;
updatesLock.unlock();
}
private int UpdatesCount() {
updatesLock.lock();
int value = updateCount;
updatesLock.unlock();
return value;
}
public void OutOfContextLock() { public void OutOfContextLock() {
outOfContextLock.lock(); outOfContextLock.lock();
//Logger.println("(OutOfContextMessageThread.OutOfContextLock) Out of context lock obtained");
} }
public void OutOfContextUnlock() { public void OutOfContextUnlock() {
outOfContextLock.unlock(); outOfContextLock.unlock();
//Logger.println("(OutOfContextMessageThread.OutOfContextUnlock) Out of context lock released");
} }
/******************************************************************/ /******************************************************************/
...@@ -91,8 +72,6 @@ public class OutOfContextMessageThread extends Thread { ...@@ -91,8 +72,6 @@ public class OutOfContextMessageThread extends Thread {
if (execution == null || !execution.isDecided()) { if (execution == null || !execution.isDecided()) {
/** ISTO E CODIGO DO JOAO, PARA TRATAR DA TRANSFERENCIA DE ESTADO */ /** ISTO E CODIGO DO JOAO, PARA TRATAR DA TRANSFERENCIA DE ESTADO */
//if (UpdatesCount() > 0) removeUpdate();
//else
if (!outOfContextLock.isLocked()) if (!outOfContextLock.isLocked())
/******************************************************************/ /******************************************************************/
tomLayer.waitForPaxosToFinish(); tomLayer.waitForPaxosToFinish();
......
...@@ -910,6 +910,8 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -910,6 +910,8 @@ public final class TOMLayer extends Thread implements RequestReceiver {
lockState.lock(); lockState.lock();
Logger.println("(TOMLayer.saveState) Saving state of EID " + lastEid + ", round " + decisionRound + " and leader " + leader);
log.newCheckpoint(state); log.newCheckpoint(state);
log.setLastEid(-1); log.setLastEid(-1);
log.setLastCheckpointEid(lastEid); log.setLastCheckpointEid(lastEid);
...@@ -932,13 +934,17 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -932,13 +934,17 @@ public final class TOMLayer extends Thread implements RequestReceiver {
/************************* TESTE *************************/ /************************* TESTE *************************/
lockState.unlock(); lockState.unlock();
Logger.println("(TOMLayer.saveState) Finished saving state of EID " + lastEid + ", round " + decisionRound + " and leader " + leader);
} }
public void saveBatch(byte[] batch, int lastEid, int decisionRound, int leader) { public void saveBatch(byte[] batch, int lastEid, int decisionRound, int leader) {
StateLog log = stateManager.getLog(); StateLog log = stateManager.getLog();
lockState.lock(); lockState.lock();
Logger.println("(TOMLayer.saveBatch) Saving batch of EID " + lastEid + ", round " + decisionRound + " and leader " + leader);
log.addMessageBatch(batch, decisionRound, leader); log.addMessageBatch(batch, decisionRound, leader);
log.setLastEid(lastEid); log.setLastEid(lastEid);
...@@ -959,29 +965,33 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -959,29 +965,33 @@ public final class TOMLayer extends Thread implements RequestReceiver {
/************************* TESTE *************************/ /************************* TESTE *************************/
lockState.unlock(); lockState.unlock();
Logger.println("(TOMLayer.saveBatch) Finished saving batch of EID " + lastEid + ", round " + decisionRound + " and leader " + leader);
} }
/** ISTO E CODIGO DO JOAO, PARA TRATAR DA TRANSFERENCIA DE ESTADO */ /** ISTO E CODIGO DO JOAO, PARA TRATAR DA TRANSFERENCIA DE ESTADO */
public void requestState(int me, int[] otherAcceptors, int sender, int eid) { public void requestState(int me, int[] otherAcceptors, int sender, int eid) {
/************************* TESTE *************************/ /************************* TESTE *************************
System.out.println("[TOMLayer.requestState]"); System.out.println("[TOMLayer.requestState]");
System.out.println("Mensagem adiantada! (eid " + eid + " vindo de " + sender + ") "); System.out.println("Mensagem adiantada! (eid " + eid + " vindo de " + sender + ") ");
/************************* TESTE *************************/ /************************* TESTE *************************/
if (stateManager.getWaiting() == -1) { if (stateManager.getWaiting() == -1) {
Logger.println("(TOMLayer.requestState) I'm not waiting for any state, so I will keep record of this message");
stateManager.addEID(sender, eid); stateManager.addEID(sender, eid);
/************************* TESTE *************************/ /************************* TESTE *************************
System.out.println("Nao estou a espera"); System.out.println("Nao estou a espera");
System.out.println("Numero de mensagens recebidas para este EID de replicas diferentes: " + stateManager.moreThenF_EIDs(eid)); System.out.println("Numero de mensagens recebidas para este EID de replicas diferentes: " + stateManager.moreThenF_EIDs(eid));
/************************* TESTE *************************/ /************************* TESTE *************************/
if (stateManager.getLastEID() < eid && stateManager.moreThenF_EIDs(eid)) { if (stateManager.getLastEID() < eid && stateManager.moreThenF_EIDs(eid)) {
/************************* TESTE *************************/ Logger.println("(TOMLayer.requestState) I have now more than " + conf.getF() + " messages for EID " + eid + " which are beyond EID " + stateManager.getLastEID());
/************************* TESTE *************************
System.out.println("Recebi mais de " + conf.getF() + " mensagens para eid " + eid + " que sao posteriores a " + stateManager.getLastEID()); System.out.println("Recebi mais de " + conf.getF() + " mensagens para eid " + eid + " que sao posteriores a " + stateManager.getLastEID());
/************************* TESTE *************************/ /************************* TESTE *************************/
...@@ -992,7 +1002,8 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -992,7 +1002,8 @@ public final class TOMLayer extends Thread implements RequestReceiver {
SMMessage smsg = new SMMessage(me, eid - 1, TOMUtil.SM_REQUEST, null); SMMessage smsg = new SMMessage(me, eid - 1, TOMUtil.SM_REQUEST, null);
communication.send(otherAcceptors, smsg); communication.send(otherAcceptors, smsg);
/************************* TESTE *************************/ Logger.println("(TOMLayer.saveBatch) I just sent a request to the other replicas for the state up to EID " + (eid - 1));
/************************* TESTE *************************
System.out.println("Enviei um pedido!"); System.out.println("Enviei um pedido!");
System.out.println("Quem envia: " + smsg.getSender()); System.out.println("Quem envia: " + smsg.getSender());
...@@ -1003,7 +1014,7 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1003,7 +1014,7 @@ public final class TOMLayer extends Thread implements RequestReceiver {
/************************* TESTE *************************/ /************************* TESTE *************************/
} }
} }
/************************* TESTE *************************/ /************************* TESTE *************************
System.out.println("[/TOMLayer.requestState]"); System.out.println("[/TOMLayer.requestState]");
/************************* TESTE *************************/ /************************* TESTE *************************/
} }
...@@ -1012,7 +1023,8 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1012,7 +1023,8 @@ public final class TOMLayer extends Thread implements RequestReceiver {
lockState.lock(); lockState.lock();
/************************* TESTE *************************/ Logger.println("(TOMLayer.SMRequestDeliver) I received a state request for EID " + msg.getEid() + " from replica " + msg.getSender());
/************************* TESTE *************************
System.out.println("[TOMLayer.SMRequestDeliver]"); System.out.println("[TOMLayer.SMRequestDeliver]");
System.out.println("Recebi um pedido de estado!"); System.out.println("Recebi um pedido de estado!");
System.out.println("Estado pedido: " + msg.getEid()); System.out.println("Estado pedido: " + msg.getEid());
...@@ -1025,7 +1037,8 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1025,7 +1037,8 @@ public final class TOMLayer extends Thread implements RequestReceiver {
lockState.unlock(); lockState.unlock();
if (state == null) { if (state == null) {
/************************* TESTE *************************/ Logger.println("(TOMLayer.SMRequestDeliver) I don't have the state requested :-(");
/************************* TESTE *************************
System.out.println("Nao tenho o estado pedido!"); System.out.println("Nao tenho o estado pedido!");
/************************* TESTE *************************/ /************************* TESTE *************************/
state = new TransferableState(); state = new TransferableState();
...@@ -1035,20 +1048,21 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1035,20 +1048,21 @@ public final class TOMLayer extends Thread implements RequestReceiver {
SMMessage smsg = new SMMessage(execManager.getProcessId(), msg.getEid(), TOMUtil.SM_REPLY, state); SMMessage smsg = new SMMessage(execManager.getProcessId(), msg.getEid(), TOMUtil.SM_REPLY, state);
communication.send(targets, smsg); communication.send(targets, smsg);
/************************* TESTE *************************/ Logger.println("(TOMLayer.SMRequestDeliver) I sent the state for checkpoint " + state.getLastCheckpointEid() + " with batches until EID " + state.getLastEid());
/************************* TESTE *************************
System.out.println("Quem envia: " + smsg.getSender()); System.out.println("Quem envia: " + smsg.getSender());
System.out.println("Que tipo: " + smsg.getType()); System.out.println("Que tipo: " + smsg.getType());
System.out.println("Que EID: " + smsg.getEid()); System.out.println("Que EID: " + smsg.getEid());
//System.exit(0); //System.exit(0);
/************************* TESTE *************************/ /************************* TESTE *************************/
/************************* TESTE *************************/ /************************* TESTE *************************
System.out.println("[/TOMLayer.SMRequestDeliver]"); System.out.println("[/TOMLayer.SMRequestDeliver]");
/************************* TESTE *************************/ /************************* TESTE *************************/
} }
public void SMReplyDeliver(SMMessage msg) { public void SMReplyDeliver(SMMessage msg) {
/************************* TESTE *************************/ /************************* TESTE *************************
System.out.println("[TOMLayer.SMReplyDeliver]"); System.out.println("[TOMLayer.SMReplyDeliver]");
System.out.println("Recebi uma resposta de uma replica!"); System.out.println("Recebi uma resposta de uma replica!");
System.out.println("[reply] Esta resposta tem o estado? " + msg.getState().hasState()); System.out.println("[reply] Esta resposta tem o estado? " + msg.getState().hasState());
...@@ -1070,17 +1084,22 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1070,17 +1084,22 @@ public final class TOMLayer extends Thread implements RequestReceiver {
else System.out.println("[reply] Nao ha estado"); else System.out.println("[reply] Nao ha estado");
/************************* TESTE *************************/ /************************* TESTE *************************/
Logger.println("(TOMLayer.SMReplyDeliver) I received a state reply for EID " + msg.getEid() + " from replica " + msg.getSender());
if (stateManager.getWaiting() != -1 && msg.getEid() == stateManager.getWaiting()) { if (stateManager.getWaiting() != -1 && msg.getEid() == stateManager.getWaiting()) {
/************************* TESTE *************************/ /************************* TESTE *************************
System.out.println("A resposta e referente ao eid que estou a espera! (" + msg.getEid() + ")"); System.out.println("A resposta e referente ao eid que estou a espera! (" + msg.getEid() + ")");
/************************* TESTE *************************/ /************************* TESTE *************************/
Logger.println("(TOMLayer.SMReplyDeliver) The reply is for the EID that I want!");
stateManager.addState(msg.getSender(),msg.getState()); stateManager.addState(msg.getSender(),msg.getState());
if (stateManager.moreThenF_Replies()) { if (stateManager.moreThenF_Replies()) {
/************************* TESTE *************************/ Logger.println("(TOMLayer.SMReplyDeliver) I have more than " + conf.getF() + " equal replies!");
/************************* TESTE *************************
System.out.println("Ja tenho mais que " + conf.getF() + " respostas iguais!"); System.out.println("Ja tenho mais que " + conf.getF() + " respostas iguais!");
/************************* TESTE *************************/ /************************* TESTE *************************/
...@@ -1088,7 +1107,7 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1088,7 +1107,7 @@ public final class TOMLayer extends Thread implements RequestReceiver {
if (state != null) { if (state != null) {
/************************* TESTE *************************/ /************************* TESTE *************************
System.out.println("As respostas desse estado são validas!"); System.out.println("As respostas desse estado são validas!");
System.out.println("[state] Esta resposta tem o estado? " + state.hasState()); System.out.println("[state] Esta resposta tem o estado? " + state.hasState());
...@@ -1112,10 +1131,13 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1112,10 +1131,13 @@ public final class TOMLayer extends Thread implements RequestReceiver {
//System.exit(0); //System.exit(0);
/************************* TESTE *************************/ /************************* TESTE *************************/
Logger.println("(TOMLayer.SMReplyDeliver) The state of those replies is good!");
lockState.lock(); lockState.lock();
stateManager.getLog().update(state); stateManager.getLog().update(state);
/************************* TESTE *************************/ /************************* TESTE *************************
System.out.println("[log] Estado pedido: " + msg.getEid()); System.out.println("[log] Estado pedido: " + msg.getEid());
System.out.println("[log] EID do ultimo checkpoint: " + stateManager.getLog().getLastCheckpointEid()); System.out.println("[log] EID do ultimo checkpoint: " + stateManager.getLog().getLastCheckpointEid());
System.out.println("[log] EID do ultimo batch recebido: " + stateManager.getLog().getLastEid()); System.out.println("[log] EID do ultimo batch recebido: " + stateManager.getLog().getLastEid());
...@@ -1135,18 +1157,18 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1135,18 +1157,18 @@ public final class TOMLayer extends Thread implements RequestReceiver {
lockState.unlock(); lockState.unlock();
System.out.println("Desbloqueei o lock para o log do estado"); //System.out.println("Desbloqueei o lock para o log do estado");
dt.deliverLock(); dt.deliverLock();
System.out.println("Bloqueei o lock entre esta thread e a delivery thread"); //System.out.println("Bloqueei o lock entre esta thread e a delivery thread");
ot.OutOfContextLock(); ot.OutOfContextLock();
System.out.println("Bloqueei o lock entre esta thread e a out of context thread"); //System.out.println("Bloqueei o lock entre esta thread e a out of context thread");
stateManager.setWaiting(-1); stateManager.setWaiting(-1);
System.out.println("Ja nao estou a espera de nenhum estado, e vou actualizar-me"); //System.out.println("Ja nao estou a espera de nenhum estado, e vou actualizar-me");
dt.update(state); dt.update(state);
...@@ -1159,8 +1181,9 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1159,8 +1181,9 @@ public final class TOMLayer extends Thread implements RequestReceiver {
} else if ((conf.getN() / 2) < stateManager.getReplies()) { } else if ((conf.getN() / 2) < stateManager.getReplies()) {
/************************* TESTE *************************/ Logger.println("(TOMLayer.SMReplyDeliver) I have more than " + conf.getN() + " messages that are no good!");
/************************* TESTE *************************
System.out.println("Tenho mais de 2F respostas que nao servem para nada!"); System.out.println("Tenho mais de 2F respostas que nao servem para nada!");
//System.exit(0); //System.exit(0);
/************************* TESTE *************************/ /************************* TESTE *************************/
...@@ -1170,7 +1193,7 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1170,7 +1193,7 @@ public final class TOMLayer extends Thread implements RequestReceiver {
} }
} }
} }
/************************* TESTE *************************/ /************************* TESTE *************************
System.out.println("[/TOMLayer.SMReplyDeliver]"); System.out.println("[/TOMLayer.SMReplyDeliver]");
/************************* TESTE *************************/ /************************* TESTE *************************/
} }
...@@ -1180,7 +1203,7 @@ public final class TOMLayer extends Thread implements RequestReceiver { ...@@ -1180,7 +1203,7 @@ public final class TOMLayer extends Thread implements RequestReceiver {
} }
public void setNoExec() { public void setNoExec() {
Logger.println("(TOMLayer.setInExec_Update) modifying inExec from " + this.inExecution + " to " + -1); Logger.println("(TOMLayer.setNoExec) modifying inExec from " + this.inExecution + " to " + -1);
proposeLock.lock(); proposeLock.lock();
this.inExecution = -1; this.inExecution = -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册