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

In this commit, i've continued to try to find and fix more errors related to...

In this commit, i've continued to try to find and fix more errors related to the updating of delayed replicas. I have managed to fix three of them, but the code is merely "patched". If there is a leader change, SMaRt will go haywire. This version o the code should not be used for other purpose then testing.

I added more debug messages, and I will keep looking at the code during the weekend. I expect to fix some more bugs that i found during that period. I will also produce more debug logs so i can try to find more bugs.
上级 abc101fc
......@@ -204,6 +204,35 @@ public final class ExecutionManager {
outOfContextLock.lock();
int consId = msg.getNumber();
int lastConsId = tomLayer.getLastExec();
int msgType = msg.getPaxosType();
boolean isRetrievingState = tomLayer.isRetrievingState();
System.out.println("Esta a obter estado? " + isRetrievingState);
System.out.print("Recebi uma mensagem do eid " + consId + " do tipo ");
switch (msgType) {
case MessageFactory.PROPOSE:
System.out.println("PROPOSE");
break;
case MessageFactory.WEAK:
System.out.println("WEAK");
break;
case MessageFactory.STRONG:
System.out.println("STRONG");
break;
case MessageFactory.DECIDE:
System.out.println("DECIDE");
break;
case MessageFactory.FREEZE:
System.out.println("FREEZE");
break;
case MessageFactory.COLLECT:
System.out.println("COLLECT");
break;
default:
System.out.println();
break;
}
boolean canProcessTheMessage = false;
......@@ -214,7 +243,7 @@ public final class ExecutionManager {
// Isto serve para re-direccionar as mensagens para o out of context
// enquanto a replica esta a receber o estado das outras e a actualizar-se
tomLayer.isRetrievingState() ||
isRetrievingState ||
/******************************************************************/
......@@ -239,12 +268,13 @@ public final class ExecutionManager {
// Isto serve para re-direccionar as mensagens para o out of context
// enquanto a replica esta a receber o estado das outras e a actualizar-se
tomLayer.isRetrievingState() ||
isRetrievingState ||
/******************************************************************/
consId > (lastConsId + 1)
) {
System.out.println("<Out of context message>");
Logger.println("(ExecutionManager.checkLimits) adding message for execution "+consId+" to out of context");
//store it as an ahead of time message (out of context)
addOutOfContextMessage(msg);
......@@ -265,6 +295,7 @@ public final class ExecutionManager {
//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 */
System.out.println("<Out of highmark>");
Logger.println("(ExecutionManager.checkLimits) adding message for execution "+consId+" to out of context");
addOutOfContextMessage(msg);
tomLayer.requestState(me, otherAcceptors, msg.getSender(), consId);
......
......@@ -102,6 +102,7 @@ public class LeaderModule {
* @return The replica ID of the leader
*/
public int getLeader(int c, int r) {
/***
List<ConsInfo> list = leaderInfos.get(c);
if (list == null) {
//there are no information for the execution c
......@@ -126,6 +127,8 @@ public class LeaderModule {
}
}
return -1;
/***/
return 0;
}
/**
......
......@@ -147,7 +147,7 @@ public class DeliveryThread extends Thread {
//requests[i] = (TOMMessage) ois.readObject();
tomLayer.clientsManager.requestOrdered(requests[i]);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
......@@ -189,7 +189,7 @@ public class DeliveryThread extends Thread {
}
*/
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
......@@ -289,7 +289,7 @@ public class DeliveryThread extends Thread {
//requests[i] = (TOMMessage) ois.readObject();
tomLayer.clientsManager.requestOrdered(requests[i]);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
} else {
......@@ -311,13 +311,16 @@ public class DeliveryThread extends Thread {
//define the last stable consensus... the stable consensus can
//be removed from the leaderManager and the executionManager
/**
if (cons.getId() > 2) {
int stableConsensus = cons.getId() - 3;
System.out.println("Last stable consensus: " + stableConsensus);
tomLayer.lm.removeStableConsenusInfos(stableConsensus);
tomLayer.execManager.removeExecution(stableConsensus);
}
/**/
//define that end of this execution
tomLayer.setInExec(-1);
......@@ -366,7 +369,7 @@ public class DeliveryThread extends Thread {
Logger.println("(DeliveryThread.run) All finished for " + cons.getId() + ", took " + (System.currentTimeMillis() - startTime));
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
/** ISTO E CODIGO DO JOAO, PARA TRATAR DA TRANSFERENCIA DE ESTADO */
deliverLock.unlock();
......
......@@ -36,6 +36,7 @@ import navigators.smart.tom.ServiceReplica;
public class CounterServer extends ServiceReplica {
private int counter = 0;
private int iterations = 0;
public CounterServer(int id) {
super(id);
......@@ -44,10 +45,11 @@ public class CounterServer extends ServiceReplica {
@Override
public byte[] executeCommand(int clientId, long timestamp, byte[] nonces, byte[] command) {
iterations++;
try {
int increment = new DataInputStream(new ByteArrayInputStream(command)).readInt();
counter += increment;
System.out.println("[server] Counter incremented: " + counter);
System.out.println("[server] (" + iterations + ") Counter incremented: " + counter);
ByteArrayOutputStream out = new ByteArrayOutputStream(4);
new DataOutputStream(out).writeInt(counter);
return out.toByteArray();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册