Permalink
Browse files

Recovery early stop

  • Loading branch information...
dgomezferro committed Apr 16, 2012
1 parent 90440d3 commit cc4de962204da96e2860d30da6cc024d000e8869
@@ -211,9 +211,9 @@ public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> entri
} else {
while(entries.hasMoreElements()){
LedgerEntry le = entries.nextElement();
- lp.execute(ByteBuffer.wrap(le.getEntry()));
+ boolean recovered = lp.execute(ByteBuffer.wrap(le.getEntry()));
- if(le.getEntryId() == 0){
+ if(recovered || le.getEntryId() == 0){
((BookKeeperStateBuilder.Context) ctx).setState(lp.getState());
}
}
@@ -279,10 +279,8 @@ public void loggerInitComplete(int rc, StateLogger sl, Object ctx){
try{
synchronized(ctx){
- int counter = 0;
- while(!ctx.isReady() || (counter > 10)){
- ctx.wait(1000);
- counter++;
+ while(!ctx.isReady()){
+ ctx.wait();
}
}
} catch (InterruptedException e) {
@@ -48,8 +48,14 @@
super(timestampOracle);
}
- void execute(ByteBuffer bb){
- boolean done = false;
+ /**
+ * Execute a logged entry (several logged ops)
+ * @param bb Serialized operations
+ * @return true if the recovery is finished
+ */
+ boolean execute(ByteBuffer bb){
+ boolean done = !bb.hasRemaining();
+ boolean recovered = false;
while(!done){
byte op = bb.get();
long timestamp, startTimestamp, commitTimestamp;
@@ -65,7 +71,9 @@ void execute(ByteBuffer bb){
startTimestamp = bb.getLong();
commitTimestamp = bb.getLong();
processCommit(startTimestamp, commitTimestamp);
-
+ if (commitTimestamp < largestDeletedTimestamp) {
+ recovered = true;
+ }
break;
case LARGESTDELETEDTIMESTAMP:
timestamp = bb.getLong();
@@ -85,6 +93,7 @@ void execute(ByteBuffer bb){
}
if(bb.remaining() == 0) done = true;
}
+ return recovered;
}
/**

0 comments on commit cc4de96

Please sign in to comment.