Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Iterate over ledgerEntries in reverse order

fix #7
  • Loading branch information...
commit 5276509fcbc7400d12acfb117ffcf12c78a43266 1 parent 50ed427
@dgomezferro authored
View
9 src/main/java/com/yahoo/omid/tso/persistence/BookKeeperStateBuilder.java
@@ -19,6 +19,7 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -43,7 +44,6 @@
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.yahoo.omid.tso.TSOServerConfig;
import com.yahoo.omid.tso.TSOState;
@@ -233,11 +233,12 @@ public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> entri
LOG.error("Error while reading ledger entries." + BKException.getMessage(rc));
context.setState(null);
} else {
- while(entries.hasMoreElements()){
- LedgerEntry le = entries.nextElement();
+ List<LedgerEntry> entryList = Collections.list(entries);
+ for (LedgerEntry le : Lists.reverse(entryList)) {
ByteBuffer entry = ByteBuffer.wrap(le.getEntry());
- context.readEntries.add(entry);
+ // Add entries to readEntries for later execution
+ context.readEntries.add(entry.duplicate());
lp.scan(entry);
if(lp.finishedScan() || le.getEntryId() == 0){
View
2  src/main/java/com/yahoo/omid/tso/persistence/LogParser.java
@@ -14,7 +14,7 @@
import org.slf4j.LoggerFactory;
public class LogParser {
- private static final Logger LOG = LoggerFactory.getLogger(LoggerProtocol.class);
+ private static final Logger LOG = LoggerFactory.getLogger(LogParser.class);
LogParser() {
}
Please sign in to comment.
Something went wrong with that request. Please try again.