private void history() { info("History"); for (Pair<Action, Long> p : actions) { if (p.getRight() != NoId) log.info(String.format("%s: %-12s %d", label, p.getLeft(), p.getRight())); else log.info(String.format("%s: %-12s", label, p.getLeft())); } }
/** Copy from the journal file to the real file */ /*package*/ void append() { Iterator<Pair<NodeId, Node>> iter = nodeTableJournal.all(); Pair<NodeId, Node> firstPair = null; Pair<NodeId, Node> lastPair = null; for (; iter.hasNext(); ) { Pair<NodeId, Node> x = iter.next(); if (firstPair == null) firstPair = x; lastPair = x; NodeId nodeId = x.getLeft(); Node node = x.getRight(); debug(" append: %s -> %s", x, mapFromJournal(nodeId)); // This does the write. NodeId nodeId2 = base.getAllocateNodeId(node); if (!nodeId2.equals(mapFromJournal(nodeId))) inconsistent(node, nodeId, nodeId2); } }
// Debugging only private void dump() { System.err.println(">>>>>>>>>>"); System.err.println("label = " + label); System.err.println("txn = " + txn); System.err.println("offset = " + allocOffset); System.err.println("journalStartOffset = " + journalObjFileStartOffset); System.err.println("journal = " + journalObjFile.getLabel()); if (true) return; System.err.println("nodeTableJournal >>>"); Iterator<Pair<NodeId, Node>> iter = nodeTableJournal.all(); for (; iter.hasNext(); ) { Pair<NodeId, Node> x = iter.next(); NodeId nodeId = x.getLeft(); Node node = x.getRight(); NodeId mapped = mapFromJournal(nodeId); // debug("append: %s -> %s", x, mapFromJournal(nodeId)) ; // This does the write. NodeId nodeId2 = base.getAllocateNodeId(node); System.err.println(x + " mapped=" + mapped + " getAlloc=" + nodeId2); } System.err.println("journal >>>"); Iterator<Pair<Long, ByteBuffer>> iter1 = this.journalObjFile.all(); for (; iter1.hasNext(); ) { Pair<Long, ByteBuffer> p = iter1.next(); System.err.println(p.getLeft() + " : " + p.getRight()); ByteBufferLib.print(System.err, p.getRight()); } System.err.println("nodeIndex >>>"); Iterator<Record> iter2 = this.nodeIndex.iterator(); for (; iter2.hasNext(); ) { Record r = iter2.next(); System.err.println(r); } System.err.println("<<<<<<<<<<"); }