exception cleanup
This commit is contained in:
@ -202,10 +202,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
if (total <= 0)
|
if (total <= 0)
|
||||||
_log.error("Warning - initialized database with zero entries");
|
_log.error("Warning - initialized database with zero entries");
|
||||||
return rv;
|
return rv;
|
||||||
} catch (IOException e) {
|
} catch (RuntimeException e) {
|
||||||
throw e;
|
|
||||||
} catch (Error e) {
|
|
||||||
// blockfile noxiously converts IOEs to Errors with no message
|
|
||||||
throw new IOException(e.toString());
|
throw new IOException(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,10 +244,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
_lists.addAll(skiplists);
|
_lists.addAll(skiplists);
|
||||||
_log.error("DB init took " + DataHelper.formatDuration(_context.clock().now() - start));
|
_log.error("DB init took " + DataHelper.formatDuration(_context.clock().now() - start));
|
||||||
return bf;
|
return bf;
|
||||||
} catch (IOException e) {
|
} catch (RuntimeException e) {
|
||||||
throw e;
|
|
||||||
} catch (Error e) {
|
|
||||||
// blockfile noxiously converts IOEs to Errors with no message
|
|
||||||
throw new IOException(e.toString());
|
throw new IOException(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,8 +266,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
_log.error("DB Lookup error", ioe);
|
_log.error("DB Lookup error", ioe);
|
||||||
// delete index??
|
// delete index??
|
||||||
throw ioe;
|
throw ioe;
|
||||||
} catch (Error e) {
|
} catch (RuntimeException e) {
|
||||||
// blockfile noxiously converts IOEs to Errors with no message
|
|
||||||
_log.error("DB Lookup error", e);
|
_log.error("DB Lookup error", e);
|
||||||
throw new IOException(e.toString());
|
throw new IOException(e.toString());
|
||||||
}
|
}
|
||||||
@ -302,8 +295,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
_log.error("DB add error", ioe);
|
_log.error("DB add error", ioe);
|
||||||
// delete index??
|
// delete index??
|
||||||
throw ioe;
|
throw ioe;
|
||||||
} catch (Error e) {
|
} catch (RuntimeException e) {
|
||||||
// blockfile noxiously converts IOEs to Errors with no message
|
|
||||||
_log.error("DB add error", e);
|
_log.error("DB add error", e);
|
||||||
throw new IOException(e.toString());
|
throw new IOException(e.toString());
|
||||||
}
|
}
|
||||||
@ -312,7 +304,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
/**
|
/**
|
||||||
* Caller must synchronize
|
* Caller must synchronize
|
||||||
* @param source may be null
|
* @param source may be null
|
||||||
* @throws Error
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
private void addEntry(SkipList sl, String key, Destination dest, String source) {
|
private void addEntry(SkipList sl, String key, Destination dest, String source) {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
@ -325,7 +317,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
/**
|
/**
|
||||||
* Caller must synchronize
|
* Caller must synchronize
|
||||||
* @param props may be null
|
* @param props may be null
|
||||||
* @throws Error
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
private static void addEntry(SkipList sl, String key, Destination dest, Properties props) {
|
private static void addEntry(SkipList sl, String key, Destination dest, Properties props) {
|
||||||
DestEntry de = new DestEntry();
|
DestEntry de = new DestEntry();
|
||||||
@ -374,7 +366,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
try {
|
try {
|
||||||
_bf.close();
|
_bf.close();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
} catch (Error e) {
|
} catch (RuntimeException e) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
_raf.close();
|
_raf.close();
|
||||||
@ -488,7 +480,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
BlockfileNamingService bns = new BlockfileNamingService(I2PAppContext.getGlobalContext());
|
BlockfileNamingService bns = new BlockfileNamingService(I2PAppContext.getGlobalContext());
|
||||||
System.out.println("zzz.i2p: " + bns.lookup("zzz.i2p"));
|
//System.out.println("zzz.i2p: " + bns.lookup("zzz.i2p"));
|
||||||
List<String> names = null;
|
List<String> names = null;
|
||||||
try {
|
try {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -25,6 +25,9 @@ Changes for i2p:
|
|||||||
|
|
||||||
- Commented out some System.out.println()
|
- Commented out some System.out.println()
|
||||||
|
|
||||||
|
- Convert Errors without message or cause to RuntimeExceptions with a message and cause
|
||||||
|
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
|
|
||||||
- Change PAGESIZE from default 1024 to 4096? No, wastes too much disk.
|
- Change PAGESIZE from default 1024 to 4096? No, wastes too much disk.
|
||||||
|
@ -91,13 +91,13 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
if(levels[i]==null) { break; }
|
if(levels[i]==null) { break; }
|
||||||
bf.file.writeInt(((BSkipLevels) levels[i]).levelPage);
|
bf.file.writeInt(((BSkipLevels) levels[i]).levelPage);
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) { throw new Error(); }
|
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void killInstance() {
|
public void killInstance() {
|
||||||
try {
|
try {
|
||||||
bf.freePage(levelPage);
|
bf.freePage(levelPage);
|
||||||
} catch (IOException ioe) { throw new Error(); }
|
} catch (IOException ioe) { throw new RuntimeException("Error freeing database page", ioe); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkipLevels newInstance(int levels, SkipSpan ss, SkipList sl) {
|
public SkipLevels newInstance(int levels, SkipSpan ss, SkipList sl) {
|
||||||
@ -107,6 +107,6 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
int page = bf.allocPage();
|
int page = bf.allocPage();
|
||||||
BSkipLevels.init(bf, page, bss.page, levels);
|
BSkipLevels.init(bf, page, bss.page, levels);
|
||||||
return new BSkipLevels(bf, page, bsl);
|
return new BSkipLevels(bf, page, bsl);
|
||||||
} catch (IOException ioe) { throw new Error(); }
|
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class BSkipList extends SkipList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BSkipList(int spanSize, BlockFile bf, int skipPage, Serializer key, Serializer val, boolean fileOnly) throws IOException {
|
public BSkipList(int spanSize, BlockFile bf, int skipPage, Serializer key, Serializer val, boolean fileOnly) throws IOException {
|
||||||
if(spanSize < 1) { throw new Error("Span size too small"); }
|
if(spanSize < 1) { throw new RuntimeException("Span size too small"); }
|
||||||
|
|
||||||
this.skipPage = skipPage;
|
this.skipPage = skipPage;
|
||||||
this.bf = bf;
|
this.bf = bf;
|
||||||
@ -88,7 +88,7 @@ public class BSkipList extends SkipList {
|
|||||||
bf.file.writeInt(size);
|
bf.file.writeInt(size);
|
||||||
bf.file.writeInt(spans);
|
bf.file.writeInt(spans);
|
||||||
|
|
||||||
} catch (IOException ioe) { throw new Error(); }
|
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
|
@ -65,7 +65,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
int newPage = bf.allocPage();
|
int newPage = bf.allocPage();
|
||||||
init(bf, newPage, bf.spanSize);
|
init(bf, newPage, bf.spanSize);
|
||||||
return new BSkipSpan(bf, (BSkipList) sl, newPage, keySer, valSer);
|
return new BSkipSpan(bf, (BSkipList) sl, newPage, keySer, valSer);
|
||||||
} catch (IOException ioe) { throw new Error(); }
|
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void killInstance() {
|
public void killInstance() {
|
||||||
@ -79,7 +79,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
curPage = next;
|
curPage = next;
|
||||||
}
|
}
|
||||||
bf.freePage(page);
|
bf.freePage(page);
|
||||||
} catch(IOException ioe) { throw new Error(); }
|
} catch (IOException ioe) { throw new RuntimeException("Error freeing database page", ioe); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() {
|
public void flush() {
|
||||||
@ -124,7 +124,7 @@ public class BSkipSpan extends SkipSpan {
|
|||||||
}
|
}
|
||||||
BlockFile.pageSeek(bf.file, this.page);
|
BlockFile.pageSeek(bf.file, this.page);
|
||||||
this.overflowPage = bf.file.readInt();
|
this.overflowPage = bf.file.readInt();
|
||||||
} catch(IOException ioe) { throw new Error(); }
|
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void load(BSkipSpan bss, BlockFile bf, BSkipList bsl, int spanPage, Serializer key, Serializer val) throws IOException {
|
private static void load(BSkipSpan bss, BlockFile bf, BSkipList bsl, int spanPage, Serializer key, Serializer val) throws IOException {
|
||||||
|
@ -69,7 +69,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
rv.keys = new Comparable[bf.spanSize];
|
rv.keys = new Comparable[bf.spanSize];
|
||||||
rv.vals = new Object[bf.spanSize];
|
rv.vals = new Object[bf.spanSize];
|
||||||
return rv;
|
return rv;
|
||||||
} catch (IOException ioe) { throw new Error(ioe); }
|
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,7 +247,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
try {
|
try {
|
||||||
seekAndLoadData();
|
seekAndLoadData();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new Error(ioe);
|
throw new RuntimeException("Error reading database", ioe);
|
||||||
}
|
}
|
||||||
SkipSpan rv = super.getSpan(key, search);
|
SkipSpan rv = super.getSpan(key, search);
|
||||||
this.keys = null;
|
this.keys = null;
|
||||||
@ -266,7 +266,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
return next.get(key);
|
return next.get(key);
|
||||||
return getData(key);
|
return getData(key);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new Error(ioe);
|
throw new RuntimeException("Error reading database", ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
try {
|
try {
|
||||||
seekAndLoadData();
|
seekAndLoadData();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new Error(ioe);
|
throw new RuntimeException("Error reading database", ioe);
|
||||||
}
|
}
|
||||||
SkipSpan rv = super.put(key, val, sl);
|
SkipSpan rv = super.put(key, val, sl);
|
||||||
// flush() nulls out the data
|
// flush() nulls out the data
|
||||||
@ -293,7 +293,7 @@ public class IBSkipSpan extends BSkipSpan {
|
|||||||
try {
|
try {
|
||||||
seekAndLoadData();
|
seekAndLoadData();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new Error(ioe);
|
throw new RuntimeException("Error reading database", ioe);
|
||||||
}
|
}
|
||||||
Object[] rv = super.remove(key, sl);
|
Object[] rv = super.remove(key, sl);
|
||||||
// flush() nulls out the data
|
// flush() nulls out the data
|
||||||
|
Reference in New Issue
Block a user