forked from I2P_Developers/i2p.i2p
remove static logs
This commit is contained in:
@ -69,7 +69,7 @@ import net.i2p.util.Log;
|
|||||||
public class BlockFile {
|
public class BlockFile {
|
||||||
public static final int PAGESIZE = 1024;
|
public static final int PAGESIZE = 1024;
|
||||||
public static final long OFFSET_MOUNTED = 20;
|
public static final long OFFSET_MOUNTED = 20;
|
||||||
public static final Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
|
public final Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
|
||||||
|
|
||||||
public final RandomAccessInterface file;
|
public final RandomAccessInterface file;
|
||||||
|
|
||||||
|
@ -30,6 +30,9 @@ package net.metanotion.io.block;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.i2p.I2PAppContext;
|
||||||
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
import net.metanotion.io.RandomAccessInterface;
|
import net.metanotion.io.RandomAccessInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +83,8 @@ class FreeListBlock {
|
|||||||
branches[good++] = fpg;
|
branches[good++] = fpg;
|
||||||
}
|
}
|
||||||
if (good != len) {
|
if (good != len) {
|
||||||
BlockFile.log.error((len - good) + " bad pages in " + this);
|
Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
|
||||||
|
log.error((len - good) + " bad pages in " + this);
|
||||||
len = good;
|
len = good;
|
||||||
writeBlock();
|
writeBlock();
|
||||||
}
|
}
|
||||||
@ -146,7 +150,8 @@ class FreeListBlock {
|
|||||||
if (len >= MAX_SIZE)
|
if (len >= MAX_SIZE)
|
||||||
throw new IllegalStateException("full");
|
throw new IllegalStateException("full");
|
||||||
if (getMagic(freePage) == MAGIC_FREE) {
|
if (getMagic(freePage) == MAGIC_FREE) {
|
||||||
BlockFile.log.error("Double free page " + freePage, new Exception());
|
Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
|
||||||
|
log.error("Double free page " + freePage, new Exception());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
branches[len++] = freePage;
|
branches[len++] = freePage;
|
||||||
|
@ -82,13 +82,13 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
bottom = bsl.spanHash.get(Integer.valueOf(spanPage));
|
bottom = bsl.spanHash.get(Integer.valueOf(spanPage));
|
||||||
if (bottom == null) {
|
if (bottom == null) {
|
||||||
// FIXME recover better?
|
// FIXME recover better?
|
||||||
BlockFile.log.error("No span found in cache???");
|
bf.log.error("No span found in cache???");
|
||||||
throw new IOException("No span found in cache???");
|
throw new IOException("No span found in cache???");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.levels = new BSkipLevels[maxLen];
|
this.levels = new BSkipLevels[maxLen];
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Reading New BSkipLevels with " + nonNull + " / " + maxLen + " valid levels page " + levelPage);
|
bf.log.debug("Reading New BSkipLevels with " + nonNull + " / " + maxLen + " valid levels page " + levelPage);
|
||||||
// We have to read now because new BSkipLevels() will move the file pointer
|
// We have to read now because new BSkipLevels() will move the file pointer
|
||||||
int[] lps = new int[nonNull];
|
int[] lps = new int[nonNull];
|
||||||
for(int i = 0; i < nonNull; i++) {
|
for(int i = 0; i < nonNull; i++) {
|
||||||
@ -108,7 +108,7 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
levels[i] = new BSkipLevels(bf, lp, bsl);
|
levels[i] = new BSkipLevels(bf, lp, bsl);
|
||||||
bsl.levelHash.put(Integer.valueOf(lp), levels[i]);
|
bsl.levelHash.put(Integer.valueOf(lp), levels[i]);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
BlockFile.log.error("Corrupt database, bad level " + i +
|
bf.log.error("Corrupt database, bad level " + i +
|
||||||
" at page " + lp, ioe);
|
" at page " + lp, ioe);
|
||||||
levels[i] = null;
|
levels[i] = null;
|
||||||
fail = true;
|
fail = true;
|
||||||
@ -119,7 +119,7 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
Comparable nextKey = levels[i].key();
|
Comparable nextKey = levels[i].key();
|
||||||
if (ourKey != null && nextKey != null &&
|
if (ourKey != null && nextKey != null &&
|
||||||
ourKey.compareTo(nextKey) >= 0) {
|
ourKey.compareTo(nextKey) >= 0) {
|
||||||
BlockFile.log.warn("Corrupt database, level out of order " + this +
|
bf.log.warn("Corrupt database, level out of order " + this +
|
||||||
' ' + print() +
|
' ' + print() +
|
||||||
" i = " + i + ' ' + levels[i]);
|
" i = " + i + ' ' + levels[i]);
|
||||||
// This will be fixed in blvlfix() via BlockFile.getIndex()
|
// This will be fixed in blvlfix() via BlockFile.getIndex()
|
||||||
@ -128,8 +128,8 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
}
|
}
|
||||||
// TODO also check that the level[] array is not out-of-order
|
// TODO also check that the level[] array is not out-of-order
|
||||||
} else {
|
} else {
|
||||||
if (BlockFile.log.shouldLog(Log.WARN))
|
if (bf.log.shouldLog(Log.WARN))
|
||||||
BlockFile.log.warn("WTF " + this + " i = " + i + " of " + nonNull + " / " + maxLen + " valid levels but page is zero");
|
bf.log.warn("WTF " + this + " i = " + i + " of " + nonNull + " / " + maxLen + " valid levels but page is zero");
|
||||||
levels[i] = null;
|
levels[i] = null;
|
||||||
fail = true;
|
fail = true;
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
if (fail && bf.file.canWrite()) {
|
if (fail && bf.file.canWrite()) {
|
||||||
// corruption is actually fixed in blvlfix() via BlockFile.getIndex()
|
// corruption is actually fixed in blvlfix() via BlockFile.getIndex()
|
||||||
// after instantiation is complete
|
// after instantiation is complete
|
||||||
BlockFile.log.error("Repairing corruption of " + this +
|
bf.log.error("Repairing corruption of " + this +
|
||||||
' ' + print());
|
' ' + print());
|
||||||
flush();
|
flush();
|
||||||
// if the removed levels have no other links to them, they and their data
|
// if the removed levels have no other links to them, they and their data
|
||||||
@ -157,7 +157,7 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
@Override
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
if (isKilled) {
|
if (isKilled) {
|
||||||
BlockFile.log.error("Already killed!! " + this, new Exception());
|
bf.log.error("Already killed!! " + this, new Exception());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -180,11 +180,11 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
@Override
|
@Override
|
||||||
public void killInstance() {
|
public void killInstance() {
|
||||||
if (isKilled) {
|
if (isKilled) {
|
||||||
BlockFile.log.error("Already killed!! " + this, new Exception());
|
bf.log.error("Already killed!! " + this, new Exception());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Killing " + this + ' ' + print(), new Exception());
|
bf.log.debug("Killing " + this + ' ' + print(), new Exception());
|
||||||
isKilled = true;
|
isKilled = true;
|
||||||
bsl.levelHash.remove(Integer.valueOf(levelPage));
|
bsl.levelHash.remove(Integer.valueOf(levelPage));
|
||||||
bf.freePage(levelPage);
|
bf.freePage(levelPage);
|
||||||
@ -197,8 +197,8 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
BSkipList bsl = (BSkipList) sl;
|
BSkipList bsl = (BSkipList) sl;
|
||||||
int page = bf.allocPage();
|
int page = bf.allocPage();
|
||||||
BSkipLevels.init(bf, page, bss.page, levels);
|
BSkipLevels.init(bf, page, bss.page, levels);
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("New BSkipLevels height " + levels + " page " + page);
|
bf.log.debug("New BSkipLevels height " + levels + " page " + page);
|
||||||
return new BSkipLevels(bf, page, bsl);
|
return new BSkipLevels(bf, page, bsl);
|
||||||
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
|
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
|
||||||
}
|
}
|
||||||
@ -228,13 +228,13 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
*/
|
*/
|
||||||
private boolean blvlfix() {
|
private boolean blvlfix() {
|
||||||
TreeSet<SkipLevels> lvls = new TreeSet(new LevelComparator());
|
TreeSet<SkipLevels> lvls = new TreeSet(new LevelComparator());
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Starting level search");
|
bf.log.debug("Starting level search");
|
||||||
getAllLevels(this, lvls);
|
getAllLevels(this, lvls);
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Finished level search, found " + lvls.size() + " levels");
|
bf.log.debug("Finished level search, found " + lvls.size() + " levels");
|
||||||
if (!this.equals(lvls.last())) {
|
if (!this.equals(lvls.last())) {
|
||||||
BlockFile.log.error("First level is out of order! " + print());
|
bf.log.error("First level is out of order! " + print());
|
||||||
// TODO switch stack and other fields for the skiplist - hard to test
|
// TODO switch stack and other fields for the skiplist - hard to test
|
||||||
}
|
}
|
||||||
// traverse the levels, back-to-front
|
// traverse the levels, back-to-front
|
||||||
@ -242,17 +242,17 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
SkipLevels after = null;
|
SkipLevels after = null;
|
||||||
for (SkipLevels lv : lvls) {
|
for (SkipLevels lv : lvls) {
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Checking " + lv.print());
|
bf.log.debug("Checking " + lv.print());
|
||||||
if (after != null) {
|
if (after != null) {
|
||||||
int min = Math.min(after.levels.length, lv.levels.length);
|
int min = Math.min(after.levels.length, lv.levels.length);
|
||||||
for (int i = 0; i < min; i++) {
|
for (int i = 0; i < min; i++) {
|
||||||
SkipLevels cur = lv.levels[i];
|
SkipLevels cur = lv.levels[i];
|
||||||
if (cur != after) {
|
if (cur != after) {
|
||||||
if (cur != null)
|
if (cur != null)
|
||||||
BlockFile.log.warn("Level " + i + " was wrong, fixing for " + lv.print());
|
bf.log.warn("Level " + i + " was wrong, fixing for " + lv.print());
|
||||||
else
|
else
|
||||||
BlockFile.log.warn("Level " + i + " was null, fixing for " + lv.print());
|
bf.log.warn("Level " + i + " was null, fixing for " + lv.print());
|
||||||
lv.levels[i] = after;
|
lv.levels[i] = after;
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
for (int i = 0; i < lv.levels.length; i++) {
|
for (int i = 0; i < lv.levels.length; i++) {
|
||||||
if (lv.levels[i] != null) {
|
if (lv.levels[i] != null) {
|
||||||
lv.levels[i] = null;
|
lv.levels[i] = null;
|
||||||
BlockFile.log.warn("Last level " + i + " was non-null, fixing for " + lv.print());
|
bf.log.warn("Last level " + i + " was non-null, fixing for " + lv.print());
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,8 +273,8 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
}
|
}
|
||||||
after = lv;
|
after = lv;
|
||||||
}
|
}
|
||||||
if (BlockFile.log.shouldLog(Log.INFO))
|
if (bf.log.shouldLog(Log.INFO))
|
||||||
BlockFile.log.info("Checked " + lvls.size() + " levels");
|
bf.log.info("Checked " + lvls.size() + " levels");
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,16 +286,16 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
* @since 0.8.8
|
* @since 0.8.8
|
||||||
*/
|
*/
|
||||||
private void getAllLevels(SkipLevels l, Set lvlSet) {
|
private void getAllLevels(SkipLevels l, Set lvlSet) {
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("GAL " + l.print());
|
bf.log.debug("GAL " + l.print());
|
||||||
// Do level 0 without recursion, on the assumption everything is findable
|
// Do level 0 without recursion, on the assumption everything is findable
|
||||||
// from the root
|
// from the root
|
||||||
SkipLevels cur = l;
|
SkipLevels cur = l;
|
||||||
while (cur != null && lvlSet.add(cur)) {
|
while (cur != null && lvlSet.add(cur)) {
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Adding " + cur.print());
|
bf.log.debug("Adding " + cur.print());
|
||||||
if (!cur.equals(this) && cur.key() == null && BlockFile.log.shouldLog(Log.WARN))
|
if (!cur.equals(this) && cur.key() == null && bf.log.shouldLog(Log.WARN))
|
||||||
BlockFile.log.debug("Null KEY!!! " + cur.print());
|
bf.log.debug("Null KEY!!! " + cur.print());
|
||||||
cur = cur.levels[0];
|
cur = cur.levels[0];
|
||||||
}
|
}
|
||||||
// If there were no nulls at level 0 in the middle,
|
// If there were no nulls at level 0 in the middle,
|
||||||
@ -333,23 +333,23 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean blvlck(boolean fix, int width, SkipLevels[] prevLevels) {
|
public boolean blvlck(boolean fix, int width, SkipLevels[] prevLevels) {
|
||||||
BlockFile.log.warn(" Skip level at width " + width);
|
bf.log.warn(" Skip level at width " + width);
|
||||||
BlockFile.log.warn(" levels " + this.levels.length);
|
bf.log.warn(" levels " + this.levels.length);
|
||||||
BlockFile.log.warn(" first key " + this.key());
|
bf.log.warn(" first key " + this.key());
|
||||||
BlockFile.log.warn(" spanPage " + this.spanPage);
|
bf.log.warn(" spanPage " + this.spanPage);
|
||||||
BlockFile.log.warn(" levelPage " + this.levelPage);
|
bf.log.warn(" levelPage " + this.levelPage);
|
||||||
SkipLevels higher = null;
|
SkipLevels higher = null;
|
||||||
for (int i = levels.length - 1; i >= 0; i--) {
|
for (int i = levels.length - 1; i >= 0; i--) {
|
||||||
if (levels[i] != null) {
|
if (levels[i] != null) {
|
||||||
BlockFile.log.info(" level " + i + " -> " + levels[i].key() + " ");
|
bf.log.info(" level " + i + " -> " + levels[i].key() + " ");
|
||||||
if (higher != null) {
|
if (higher != null) {
|
||||||
if (higher.key().compareTo(key()) < 0)
|
if (higher.key().compareTo(key()) < 0)
|
||||||
BlockFile.log.warn(" Higher level has lower key " + higher.key());
|
bf.log.warn(" Higher level has lower key " + higher.key());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BlockFile.log.info(" level " + i + " empty");
|
bf.log.info(" level " + i + " empty");
|
||||||
if (higher != null)
|
if (higher != null)
|
||||||
BlockFile.log.warn(" Higher level is not empty, key is " + higher.key());
|
bf.log.warn(" Higher level is not empty, key is " + higher.key());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prevLevels != null) {
|
if (prevLevels != null) {
|
||||||
@ -359,13 +359,13 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
prevLevels[i] = levels[i];
|
prevLevels[i] = levels[i];
|
||||||
} else if (prevLevels[i] != null) {
|
} else if (prevLevels[i] != null) {
|
||||||
// skipping over us
|
// skipping over us
|
||||||
BlockFile.log.warn(" Previous levels is non-null " + prevLevels[i].key() + " but not pointing to us at level " + i);
|
bf.log.warn(" Previous levels is non-null " + prevLevels[i].key() + " but not pointing to us at level " + i);
|
||||||
// replace so we only get one error
|
// replace so we only get one error
|
||||||
prevLevels[i] = levels[i];
|
prevLevels[i] = levels[i];
|
||||||
} else {
|
} else {
|
||||||
// dead end in the middle
|
// dead end in the middle
|
||||||
if (levels[i] != null) {
|
if (levels[i] != null) {
|
||||||
BlockFile.log.warn(" Previous levels is null but we are non-null " + levels[i].key() + " at level " + i);
|
bf.log.warn(" Previous levels is null but we are non-null " + levels[i].key() + " at level " + i);
|
||||||
// replace so we only get one error
|
// replace so we only get one error
|
||||||
prevLevels[i] = levels[i];
|
prevLevels[i] = levels[i];
|
||||||
}
|
}
|
||||||
|
@ -96,12 +96,12 @@ public class BSkipList extends SkipList {
|
|||||||
for (BSkipSpan ss : spanHash.values()) {
|
for (BSkipSpan ss : spanHash.values()) {
|
||||||
total += ss.nKeys;
|
total += ss.nKeys;
|
||||||
}
|
}
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Loaded " + this + " cached " + levelHash.size() + " levels and " + spanHash.size() + " spans with " + total + " entries");
|
bf.log.debug("Loaded " + this + " cached " + levelHash.size() + " levels and " + spanHash.size() + " spans with " + total + " entries");
|
||||||
if (bf.file.canWrite() &&
|
if (bf.file.canWrite() &&
|
||||||
(levelCount != levelHash.size() || spans != spanHash.size() || size != total)) {
|
(levelCount != levelHash.size() || spans != spanHash.size() || size != total)) {
|
||||||
if (BlockFile.log.shouldLog(Log.WARN))
|
if (bf.log.shouldLog(Log.WARN))
|
||||||
BlockFile.log.warn("On-disk counts were " + levelCount + " / " + spans + " / " + size + ", correcting");
|
bf.log.warn("On-disk counts were " + levelCount + " / " + spans + " / " + size + ", correcting");
|
||||||
size = total;
|
size = total;
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ public class BSkipList extends SkipList {
|
|||||||
if (!bf.file.canWrite())
|
if (!bf.file.canWrite())
|
||||||
return;
|
return;
|
||||||
if (isClosed) {
|
if (isClosed) {
|
||||||
BlockFile.log.error("Already closed!! " + this, new Exception());
|
bf.log.error("Already closed!! " + this, new Exception());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -139,7 +139,7 @@ public class BSkipList extends SkipList {
|
|||||||
/** must be open (do not call close() first) */
|
/** must be open (do not call close() first) */
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
if (isClosed) {
|
if (isClosed) {
|
||||||
BlockFile.log.error("Already closed!! " + this, new Exception());
|
bf.log.error("Already closed!! " + this, new Exception());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SkipLevels curLevel = stack;
|
SkipLevels curLevel = stack;
|
||||||
@ -229,16 +229,16 @@ public class BSkipList extends SkipList {
|
|||||||
* @return true if the levels were modified.
|
* @return true if the levels were modified.
|
||||||
*/
|
*/
|
||||||
public boolean bslck(boolean fix, boolean isMeta) {
|
public boolean bslck(boolean fix, boolean isMeta) {
|
||||||
BlockFile.log.info(" size " + this.size);
|
bf.log.info(" size " + this.size);
|
||||||
BlockFile.log.info(" spans " + this.spanHash.size());
|
bf.log.info(" spans " + this.spanHash.size());
|
||||||
BlockFile.log.info(" levels " + this.levelHash.size());
|
bf.log.info(" levels " + this.levelHash.size());
|
||||||
BlockFile.log.info(" skipPage " + this.skipPage);
|
bf.log.info(" skipPage " + this.skipPage);
|
||||||
BlockFile.log.info(" firstSpanPage " + this.firstSpanPage);
|
bf.log.info(" firstSpanPage " + this.firstSpanPage);
|
||||||
BlockFile.log.info(" firstLevelPage " + this.firstLevelPage);
|
bf.log.info(" firstLevelPage " + this.firstLevelPage);
|
||||||
BlockFile.log.info(" maxLevels " + this.maxLevels());
|
bf.log.info(" maxLevels " + this.maxLevels());
|
||||||
//printSL();
|
//printSL();
|
||||||
//print();
|
//print();
|
||||||
//BlockFile.log.info("*** Lvlck() ***");
|
//bf.log.info("*** Lvlck() ***");
|
||||||
boolean rv = stack.blvlck(fix);
|
boolean rv = stack.blvlck(fix);
|
||||||
/****
|
/****
|
||||||
int items = 0;
|
int items = 0;
|
||||||
@ -246,16 +246,16 @@ public class BSkipList extends SkipList {
|
|||||||
String key = (String) iter.nextKey();
|
String key = (String) iter.nextKey();
|
||||||
if (isMeta) {
|
if (isMeta) {
|
||||||
int sz = ((Integer) iter.next()).intValue();
|
int sz = ((Integer) iter.next()).intValue();
|
||||||
BlockFile.log.info(" Item " + key.toString() + " page " + sz);
|
bf.log.info(" Item " + key.toString() + " page " + sz);
|
||||||
} else {
|
} else {
|
||||||
String cls= iter.next().getClass().getSimpleName();
|
String cls= iter.next().getClass().getSimpleName();
|
||||||
BlockFile.log.info(" Item " + key.toString() + " class " + cls);
|
bf.log.info(" Item " + key.toString() + " class " + cls);
|
||||||
}
|
}
|
||||||
items++;
|
items++;
|
||||||
}
|
}
|
||||||
BlockFile.log.warn(" actual size " + items);
|
bf.log.warn(" actual size " + items);
|
||||||
if (items != this.size)
|
if (items != this.size)
|
||||||
BlockFile.log.warn("****** size mismatch, header = " + this.size + " actual = " + items);
|
bf.log.warn("****** size mismatch, header = " + this.size + " actual = " + items);
|
||||||
****/
|
****/
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -100,18 +100,18 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
@Override
|
@Override
|
||||||
public void killInstance() {
|
public void killInstance() {
|
||||||
if (isKilled) {
|
if (isKilled) {
|
||||||
BlockFile.log.error("Already killed!! " + this, new Exception());
|
bf.log.error("Already killed!! " + this, new Exception());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Killing " + this);
|
bf.log.debug("Killing " + this);
|
||||||
isKilled = true;
|
isKilled = true;
|
||||||
try {
|
try {
|
||||||
int curPage = overflowPage;
|
int curPage = overflowPage;
|
||||||
bf.freePage(page);
|
bf.freePage(page);
|
||||||
freeContinuationPages(curPage);
|
freeContinuationPages(curPage);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
BlockFile.log.error("Error freeing " + this, ioe);
|
bf.log.error("Error freeing " + this, ioe);
|
||||||
}
|
}
|
||||||
bsl.spanHash.remove(Integer.valueOf(this.page));
|
bsl.spanHash.remove(Integer.valueOf(this.page));
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
*/
|
*/
|
||||||
private void fflush() {
|
private void fflush() {
|
||||||
if (isKilled) {
|
if (isKilled) {
|
||||||
BlockFile.log.error("Already killed!! " + this, new Exception());
|
bf.log.error("Already killed!! " + this, new Exception());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -163,7 +163,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
bf.file.writeShort((short) keys.length);
|
bf.file.writeShort((short) keys.length);
|
||||||
bf.file.writeShort((short) nKeys);
|
bf.file.writeShort((short) nKeys);
|
||||||
if (nKeys <= 0 && prev != null)
|
if (nKeys <= 0 && prev != null)
|
||||||
BlockFile.log.error("Flushing with no entries?" + this, new Exception());
|
bf.log.error("Flushing with no entries?" + this, new Exception());
|
||||||
|
|
||||||
int ksz, vsz;
|
int ksz, vsz;
|
||||||
int curPage = this.page;
|
int curPage = this.page;
|
||||||
@ -193,7 +193,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
}
|
}
|
||||||
// Drop bad entry without throwing exception
|
// Drop bad entry without throwing exception
|
||||||
if (keys[i] == null || vals[i] == null) {
|
if (keys[i] == null || vals[i] == null) {
|
||||||
BlockFile.log.error("Dropping null data in entry " + i + " page " + curPage +
|
bf.log.error("Dropping null data in entry " + i + " page " + curPage +
|
||||||
" key=" + this.keys[i] + " val=" + this.vals[i]);
|
" key=" + this.keys[i] + " val=" + this.vals[i]);
|
||||||
nKeys--;
|
nKeys--;
|
||||||
i--;
|
i--;
|
||||||
@ -203,7 +203,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
valData = this.valSer.getBytes(vals[i]);
|
valData = this.valSer.getBytes(vals[i]);
|
||||||
// Drop bad entry without throwing exception
|
// Drop bad entry without throwing exception
|
||||||
if (keyData.length > 65535 || valData.length > 65535) {
|
if (keyData.length > 65535 || valData.length > 65535) {
|
||||||
BlockFile.log.error("Dropping huge data in entry " + i + " page " + curPage +
|
bf.log.error("Dropping huge data in entry " + i + " page " + curPage +
|
||||||
" keylen=" + keyData.length + " vallen=" + valData.length);
|
" keylen=" + keyData.length + " vallen=" + valData.length);
|
||||||
nKeys--;
|
nKeys--;
|
||||||
i--;
|
i--;
|
||||||
@ -227,10 +227,10 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
this.overflowPage = 0;
|
this.overflowPage = 0;
|
||||||
try {
|
try {
|
||||||
int freed = freeContinuationPages(curNextPage[0]);
|
int freed = freeContinuationPages(curNextPage[0]);
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Freed " + freed + " continuation pages");
|
bf.log.debug("Freed " + freed + " continuation pages");
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
BlockFile.log.error("Error freeing " + this, ioe);
|
bf.log.error("Error freeing " + this, ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
|
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
|
||||||
@ -268,7 +268,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
bss.spanSize = bf.file.readUnsignedShort();
|
bss.spanSize = bf.file.readUnsignedShort();
|
||||||
bss.nKeys = bf.file.readUnsignedShort();
|
bss.nKeys = bf.file.readUnsignedShort();
|
||||||
if(bss.spanSize < 1 || bss.spanSize > SkipSpan.MAX_SIZE || bss.nKeys > bss.spanSize) {
|
if(bss.spanSize < 1 || bss.spanSize > SkipSpan.MAX_SIZE || bss.nKeys > bss.spanSize) {
|
||||||
BlockFile.log.error("Invalid span size " + bss.nKeys + " / "+ bss.spanSize);
|
bf.log.error("Invalid span size " + bss.nKeys + " / "+ bss.spanSize);
|
||||||
bss.nKeys = 0;
|
bss.nKeys = 0;
|
||||||
bss.spanSize = bf.spanSize;
|
bss.spanSize = bf.spanSize;
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
BlockFile.pageSeek(this.bf.file, curNextPage[0]);
|
BlockFile.pageSeek(this.bf.file, curNextPage[0]);
|
||||||
int magic = bf.file.readInt();
|
int magic = bf.file.readInt();
|
||||||
if (magic != BlockFile.MAGIC_CONT) {
|
if (magic != BlockFile.MAGIC_CONT) {
|
||||||
BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Bad SkipSpan magic number 0x" + Integer.toHexString(magic) + " on page " + curNextPage[0]);
|
bf.log.error("Lost " + (this.nKeys - i) + " entries - Bad SkipSpan magic number 0x" + Integer.toHexString(magic) + " on page " + curNextPage[0]);
|
||||||
lostEntries(i, curPage);
|
lostEntries(i, curPage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
curPage = this.bf.readMultiPageData(k, curPage, pageCounter, curNextPage);
|
curPage = this.bf.readMultiPageData(k, curPage, pageCounter, curNextPage);
|
||||||
curPage = this.bf.readMultiPageData(v, curPage, pageCounter, curNextPage);
|
curPage = this.bf.readMultiPageData(v, curPage, pageCounter, curNextPage);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
|
bf.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
|
||||||
lostEntries(i, lastGood);
|
lostEntries(i, lastGood);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -333,7 +333,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
this.vals[i] = this.valSer.construct(v);
|
this.vals[i] = this.valSer.construct(v);
|
||||||
// Drop bad entry without throwing exception
|
// Drop bad entry without throwing exception
|
||||||
if (this.keys[i] == null || this.vals[i] == null) {
|
if (this.keys[i] == null || this.vals[i] == null) {
|
||||||
BlockFile.log.error("Null deserialized data in entry " + i + " page " + curPage +
|
bf.log.error("Null deserialized data in entry " + i + " page " + curPage +
|
||||||
" key=" + this.keys[i] + " val=" + this.vals[i]);
|
" key=" + this.keys[i] + " val=" + this.vals[i]);
|
||||||
fail++;
|
fail++;
|
||||||
nKeys--;
|
nKeys--;
|
||||||
@ -343,7 +343,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
}
|
}
|
||||||
// free any excess overflow pages?
|
// free any excess overflow pages?
|
||||||
if (fail > 0) {
|
if (fail > 0) {
|
||||||
BlockFile.log.error("Repairing corruption of " + fail + " entries");
|
bf.log.error("Repairing corruption of " + fail + " entries");
|
||||||
if (flushOnError)
|
if (flushOnError)
|
||||||
fflush();
|
fflush();
|
||||||
// FIXME can't get there from here
|
// FIXME can't get there from here
|
||||||
@ -375,7 +375,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
}
|
}
|
||||||
bf.file.writeShort(this.nKeys);
|
bf.file.writeShort(this.nKeys);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
BlockFile.log.error("Error while recovering from corruption of " + this, ioe);
|
bf.log.error("Error while recovering from corruption of " + this, ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SkipSpan newInstance(SkipList sl) {
|
public SkipSpan newInstance(SkipList sl) {
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Splitting page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
|
bf.log.debug("Splitting page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
|
||||||
try {
|
try {
|
||||||
int newPage = bf.allocPage();
|
int newPage = bf.allocPage();
|
||||||
init(bf, newPage, bf.spanSize);
|
init(bf, newPage, bf.spanSize);
|
||||||
@ -86,11 +86,11 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
this.firstKey = keys[0];
|
this.firstKey = keys[0];
|
||||||
this.keys = null;
|
this.keys = null;
|
||||||
this.vals = null;
|
this.vals = null;
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Flushed data for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
|
bf.log.debug("Flushed data for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
|
||||||
} else if (BlockFile.log.shouldLog(Log.DEBUG)) {
|
} else if (bf.log.shouldLog(Log.DEBUG)) {
|
||||||
// if keys is null, we are (hopefully) just updating the prev/next pages on an unloaded span
|
// if keys is null, we are (hopefully) just updating the prev/next pages on an unloaded span
|
||||||
BlockFile.log.debug("Flushed pointers for for unloaded page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
|
bf.log.debug("Flushed pointers for for unloaded page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,8 +103,8 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
super.loadData();
|
super.loadData();
|
||||||
if (this.nKeys > 0)
|
if (this.nKeys > 0)
|
||||||
this.firstKey = this.keys[0];
|
this.firstKey = this.keys[0];
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Loaded data for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize + " first key: " + this.firstKey);
|
bf.log.debug("Loaded data for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize + " first key: " + this.firstKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,11 +127,11 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
curPage = this.bf.readMultiPageData(k, curPage, pageCounter, curNextPage);
|
curPage = this.bf.readMultiPageData(k, curPage, pageCounter, curNextPage);
|
||||||
this.firstKey = (Comparable) this.keySer.construct(k);
|
this.firstKey = (Comparable) this.keySer.construct(k);
|
||||||
if (this.firstKey == null) {
|
if (this.firstKey == null) {
|
||||||
BlockFile.log.error("Null deserialized first key in page " + curPage);
|
bf.log.error("Null deserialized first key in page " + curPage);
|
||||||
repair(1);
|
repair(1);
|
||||||
}
|
}
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Loaded header for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize + " first key: " + this.firstKey);
|
bf.log.debug("Loaded header for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize + " first key: " + this.firstKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,7 +174,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
BlockFile.pageSeek(this.bf.file, curNextPage[0]);
|
BlockFile.pageSeek(this.bf.file, curNextPage[0]);
|
||||||
int magic = bf.file.readInt();
|
int magic = bf.file.readInt();
|
||||||
if (magic != BlockFile.MAGIC_CONT) {
|
if (magic != BlockFile.MAGIC_CONT) {
|
||||||
BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Bad SkipSpan magic number 0x" + Integer.toHexString(magic) + " on page " + curNextPage[0]);
|
bf.log.error("Lost " + (this.nKeys - i) + " entries - Bad SkipSpan magic number 0x" + Integer.toHexString(magic) + " on page " + curNextPage[0]);
|
||||||
lostEntries(i, curPage);
|
lostEntries(i, curPage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
try {
|
try {
|
||||||
curPage = this.bf.readMultiPageData(k, curPage, pageCounter, curNextPage);
|
curPage = this.bf.readMultiPageData(k, curPage, pageCounter, curNextPage);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
|
bf.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
|
||||||
lostEntries(i, curPage);
|
lostEntries(i, curPage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
if (ckey == null) {
|
if (ckey == null) {
|
||||||
// skip the value and keep going
|
// skip the value and keep going
|
||||||
curPage = this.bf.skipMultiPageBytes(vsz, curPage, pageCounter, curNextPage);
|
curPage = this.bf.skipMultiPageBytes(vsz, curPage, pageCounter, curNextPage);
|
||||||
BlockFile.log.error("Null deserialized key in entry " + i + " page " + curPage);
|
bf.log.error("Null deserialized key in entry " + i + " page " + curPage);
|
||||||
fail++;
|
fail++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -209,13 +209,13 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
try {
|
try {
|
||||||
curPage = this.bf.readMultiPageData(v, curPage, pageCounter, curNextPage);
|
curPage = this.bf.readMultiPageData(v, curPage, pageCounter, curNextPage);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
|
bf.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
|
||||||
lostEntries(i, curPage);
|
lostEntries(i, curPage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Object rv = this.valSer.construct(v);
|
Object rv = this.valSer.construct(v);
|
||||||
if (rv == null) {
|
if (rv == null) {
|
||||||
BlockFile.log.error("Null deserialized value in entry " + i + " page " + curPage +
|
bf.log.error("Null deserialized value in entry " + i + " page " + curPage +
|
||||||
" key=" + ckey);
|
" key=" + ckey);
|
||||||
fail++;
|
fail++;
|
||||||
}
|
}
|
||||||
@ -245,9 +245,9 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
if (this.nKeys > 0)
|
if (this.nKeys > 0)
|
||||||
this.firstKey = this.keys[0];
|
this.firstKey = this.keys[0];
|
||||||
flush();
|
flush();
|
||||||
BlockFile.log.error("Repaired corruption of " + fail + " entries");
|
bf.log.error("Repaired corruption of " + fail + " entries");
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
BlockFile.log.error("Failed to repair corruption of " + fail + " entries", ioe);
|
bf.log.error("Failed to repair corruption of " + fail + " entries", ioe);
|
||||||
}
|
}
|
||||||
*****/
|
*****/
|
||||||
}
|
}
|
||||||
@ -258,8 +258,8 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
|
|
||||||
public IBSkipSpan(BlockFile bf, BSkipList bsl, int spanPage, Serializer key, Serializer val) throws IOException {
|
public IBSkipSpan(BlockFile bf, BSkipList bsl, int spanPage, Serializer key, Serializer val) throws IOException {
|
||||||
super(bf, bsl);
|
super(bf, bsl);
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("New ibss page " + spanPage);
|
bf.log.debug("New ibss page " + spanPage);
|
||||||
BSkipSpan.loadInit(this, bf, bsl, spanPage, key, val);
|
BSkipSpan.loadInit(this, bf, bsl, spanPage, key, val);
|
||||||
loadFirstKey();
|
loadFirstKey();
|
||||||
this.next = null;
|
this.next = null;
|
||||||
@ -287,7 +287,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
previousFirstKey.compareTo(nextFirstKey) >= 0) {
|
previousFirstKey.compareTo(nextFirstKey) >= 0) {
|
||||||
// TODO remove, but if we are at the bottom of a level
|
// TODO remove, but if we are at the bottom of a level
|
||||||
// we have to remove the level too, which is a mess
|
// we have to remove the level too, which is a mess
|
||||||
BlockFile.log.error("Corrupt database, span out of order " + ((BSkipSpan)bss.prev).page +
|
bf.log.error("Corrupt database, span out of order " + ((BSkipSpan)bss.prev).page +
|
||||||
" first key " + previousFirstKey +
|
" first key " + previousFirstKey +
|
||||||
" next page " + bss.page +
|
" next page " + bss.page +
|
||||||
" first key " + nextFirstKey);
|
" first key " + nextFirstKey);
|
||||||
@ -317,7 +317,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
previousFirstKey.compareTo(nextFirstKey) >= 0) {
|
previousFirstKey.compareTo(nextFirstKey) >= 0) {
|
||||||
// TODO remove, but if we are at the bottom of a level
|
// TODO remove, but if we are at the bottom of a level
|
||||||
// we have to remove the level too, which is a mess
|
// we have to remove the level too, which is a mess
|
||||||
BlockFile.log.error("Corrupt database, span out of order " + bss.page +
|
bf.log.error("Corrupt database, span out of order " + bss.page +
|
||||||
" first key " + previousFirstKey +
|
" first key " + previousFirstKey +
|
||||||
" next page " + ((BSkipSpan)bss.next).page +
|
" next page " + ((BSkipSpan)bss.next).page +
|
||||||
" first key " + nextFirstKey);
|
" first key " + nextFirstKey);
|
||||||
@ -386,16 +386,16 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object[] remove(Comparable key, SkipList sl) {
|
public Object[] remove(Comparable key, SkipList sl) {
|
||||||
if (BlockFile.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
BlockFile.log.debug("Remove " + key + " in " + this);
|
bf.log.debug("Remove " + key + " in " + this);
|
||||||
if (nKeys <= 0)
|
if (nKeys <= 0)
|
||||||
return null;
|
return null;
|
||||||
try {
|
try {
|
||||||
seekAndLoadData();
|
seekAndLoadData();
|
||||||
if (this.nKeys == 1 && this.prev == null && this.next != null && this.next.keys == null) {
|
if (this.nKeys == 1 && this.prev == null && this.next != null && this.next.keys == null) {
|
||||||
// fix for NPE in SkipSpan if next is not loaded
|
// fix for NPE in SkipSpan if next is not loaded
|
||||||
if (BlockFile.log.shouldLog(Log.INFO))
|
if (bf.log.shouldLog(Log.INFO))
|
||||||
BlockFile.log.info("Loading next data for remove");
|
bf.log.info("Loading next data for remove");
|
||||||
((IBSkipSpan)this.next).seekAndLoadData();
|
((IBSkipSpan)this.next).seekAndLoadData();
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
@ -30,6 +30,7 @@ package net.metanotion.util.skiplist;
|
|||||||
|
|
||||||
import net.metanotion.io.block.BlockFile;
|
import net.metanotion.io.block.BlockFile;
|
||||||
|
|
||||||
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
public class SkipLevels {
|
public class SkipLevels {
|
||||||
@ -45,6 +46,7 @@ public class SkipLevels {
|
|||||||
public SkipLevels[] levels;
|
public SkipLevels[] levels;
|
||||||
// bottom is final
|
// bottom is final
|
||||||
public SkipSpan bottom;
|
public SkipSpan bottom;
|
||||||
|
private final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
|
||||||
|
|
||||||
public SkipLevels newInstance(int levels, SkipSpan ss, SkipList sl) { return new SkipLevels(levels, ss); }
|
public SkipLevels newInstance(int levels, SkipSpan ss, SkipList sl) { return new SkipLevels(levels, ss); }
|
||||||
public void killInstance() { }
|
public void killInstance() { }
|
||||||
@ -158,13 +160,13 @@ public class SkipLevels {
|
|||||||
SkipSpan ssres = (SkipSpan)res[1];
|
SkipSpan ssres = (SkipSpan)res[1];
|
||||||
if (bottom.firstKey().equals(ssres.firstKey())) {
|
if (bottom.firstKey().equals(ssres.firstKey())) {
|
||||||
// bottom copied the next span to itself
|
// bottom copied the next span to itself
|
||||||
if (BlockFile.log.shouldLog(Log.INFO)) {
|
if (_log.shouldLog(Log.INFO)) {
|
||||||
BlockFile.log.info("First Level, bottom.remove() copied and did not return itself!!!! in remove " + key);
|
_log.info("First Level, bottom.remove() copied and did not return itself!!!! in remove " + key);
|
||||||
BlockFile.log.info("Us: " + print());
|
_log.info("Us: " + print());
|
||||||
BlockFile.log.info("next: " + levels[0].print());
|
_log.info("next: " + levels[0].print());
|
||||||
BlockFile.log.info("ssres.firstKey(): " + ssres.firstKey());
|
_log.info("ssres.firstKey(): " + ssres.firstKey());
|
||||||
BlockFile.log.info("ssres.keys[0]: " + ssres.keys[0]);
|
_log.info("ssres.keys[0]: " + ssres.keys[0]);
|
||||||
BlockFile.log.info("FIXUP TIME");
|
_log.info("FIXUP TIME");
|
||||||
}
|
}
|
||||||
|
|
||||||
SkipLevels replace = levels[0];
|
SkipLevels replace = levels[0];
|
||||||
@ -174,16 +176,16 @@ public class SkipLevels {
|
|||||||
if (i >= replace.levels.length)
|
if (i >= replace.levels.length)
|
||||||
break;
|
break;
|
||||||
if (levels[i].key().equals(replace.key())) {
|
if (levels[i].key().equals(replace.key())) {
|
||||||
if (BlockFile.log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
BlockFile.log.info("equal level " + i);
|
_log.info("equal level " + i);
|
||||||
levels[i] = replace.levels[i];
|
levels[i] = replace.levels[i];
|
||||||
} else if (BlockFile.log.shouldLog(Log.INFO)) {
|
} else if (_log.shouldLog(Log.INFO)) {
|
||||||
BlockFile.log.info("not equal level " + i + ' ' + levels[i].key());
|
_log.info("not equal level " + i + ' ' + levels[i].key());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.flush();
|
this.flush();
|
||||||
if (BlockFile.log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
BlockFile.log.info("new Us: " + print());
|
_log.info("new Us: " + print());
|
||||||
replace.killInstance();
|
replace.killInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,11 +195,11 @@ public class SkipLevels {
|
|||||||
if((bottom.nKeys == 0) && (sl.first != bottom)) {
|
if((bottom.nKeys == 0) && (sl.first != bottom)) {
|
||||||
// from debugging other problems
|
// from debugging other problems
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
BlockFile.log.warn("WTF killing with no return value " + print());
|
_log.warn("WTF killing with no return value " + print());
|
||||||
} else if (res[1] == null) {
|
} else if (res[1] == null) {
|
||||||
BlockFile.log.warn("WTF killing with no return value 1 " + print());
|
_log.warn("WTF killing with no return value 1 " + print());
|
||||||
} else if (res[1] != this) {
|
} else if (res[1] != this) {
|
||||||
BlockFile.log.warn("WTF killing with return value not us " + res[1] + ' ' + print());
|
_log.warn("WTF killing with return value not us " + res[1] + ' ' + print());
|
||||||
}
|
}
|
||||||
this.killInstance();
|
this.killInstance();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user