Skip to content
Browse files

Make early stop condition checking explicit

Create separate function that checks whether the early stop condition has been met.
  • Loading branch information...
1 parent 6e04725 commit d67ea2ee54e0447ca329acb59692741febe09677 @dgomezferro committed
View
6 src/main/java/com/yahoo/omid/tso/persistence/BookKeeperStateBuilder.java
@@ -229,9 +229,9 @@ public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> entri
} else {
while(entries.hasMoreElements()){
LedgerEntry le = entries.nextElement();
- boolean recovered = lp.execute(ByteBuffer.wrap(le.getEntry()));
-
- if(recovered || le.getEntryId() == 0){
+ lp.execute(ByteBuffer.wrap(le.getEntry()));
+
+ if(lp.finishedRecovery() || le.getEntryId() == 0){
((BookKeeperStateBuilder.Context) ctx).setState(lp.getState());
}
}
View
14 src/main/java/com/yahoo/omid/tso/persistence/LoggerProtocol.java
@@ -60,9 +60,8 @@
/**
* Execute a logged entry (several logged ops)
* @param bb Serialized operations
- * @return true if the recovery is finished
*/
- synchronized boolean execute(ByteBuffer bb){
+ synchronized void execute(ByteBuffer bb){
boolean done = !bb.hasRemaining();
while(!done){
byte op = bb.get();
@@ -116,7 +115,16 @@ synchronized boolean execute(ByteBuffer bb){
}
if(bb.remaining() == 0) done = true;
}
- return (oracle && commits && aborts) || consumed;
+ }
+
+ /**
+ * Checks whether all the required information has been recovered
+ * from the log.
+ *
+ * @return true if the recovery has finished
+ */
+ public boolean finishedRecovery() {
+ return (oracle && commits && aborts) || consumed;
}
/**

0 comments on commit d67ea2e

Please sign in to comment.
Something went wrong with that request. Please try again.