Permalink
Browse files

Handle exceptions and errors better.

Summary:
1. There were places where exceptions were silenty eaten up. This
   is a probem when debugging error cases.
2. The System was not shutting down cleanly wen ti encountered
   errors. The System.exit() hangs because it waits for an elegant
   shutdown to occur, which involves all threads to voluntarily
   exit. Instead, invoke Runtime.halt.
3. The bin/linkench was not picking up the libraries stored in the
   lib directory.

Test Plan: Run linkbench.

Differential Revision: https://reviews.facebook.net/D8835
  • Loading branch information...
1 parent ae82ed7 commit eb8400fa859d70d4a5b600555c538809fa264c30 @dhruba dhruba committed Feb 22, 2013
View
@@ -72,7 +72,7 @@ for f in $LINKBENCH_HOME/lib/*.jar; do
done
# add libs to CLASSPATH
-for f in $LINKBENCH_HOME/lib/build/lib/*.jar; do
+for f in $LINKBENCH_HOME/build/lib/*.jar; do
CLASSPATH=${CLASSPATH}:$f;
done
@@ -441,7 +441,7 @@ public void run() {
Logger threadLog = Logger.getLogger(ConfigUtil.LINKBENCH_LOGGER);
threadLog.error("Unrecoverable exception in" +
" worker thread:", e);
- System.exit(1);
+ Runtime.getRuntime().halt(1);
}
doneSignal.countDown();
}
@@ -81,7 +81,7 @@
private final Logger logger = Logger.getLogger(ConfigUtil.LINKBENCH_LOGGER);
- private void openConnection() {
+ private void openConnection() throws Exception {
try {
assocClient = clientManager.createClient(
new FramedClientConnector(fromParts(host, Integer.parseInt(port))),
@@ -90,7 +90,9 @@ private void openConnection() {
new FramedClientConnector(fromParts(host, Integer.parseInt(port) + 1)),
RocksService.class).get();
} catch (Exception e) {
- logger.error("Error in open!");
+ logger.error("Error in open! Host " + host + " port " + port +
+ " " + e);
+ throw e;
}
}
@@ -148,7 +150,7 @@ public void clearErrors(int threadID) {
close();
openConnection();
} catch (Throwable e) {
- logger.error("Error in Reopen!");
+ logger.error("Error in Reopen!" + e);
e.printStackTrace();
}
}
@@ -158,7 +160,7 @@ public boolean addLink(String dbid, Link l, boolean noinverse) {
try {
return addLinkImpl(dbid, l, noinverse);
} catch (Exception ex) {
- logger.error("addlink failed!");
+ logger.error("addlink failed! " + ex);
return false;
}
}
@@ -205,7 +207,7 @@ public boolean deleteLink(String dbid, long id1, long link_type, long id2,
try {
return deleteLinkImpl(dbid, id1, link_type, id2, noinverse, expunge);
} catch (Exception ex) {
- logger.error("deletelink failed!");
+ logger.error("deletelink failed! " + ex);
return false;
}
}
@@ -238,7 +240,7 @@ public Link getLink(String dbid, long id1, long link_type, long id2) {
try {
return getLinkImpl(dbid, id1, link_type, id2);
} catch (Exception ex) {
- logger.error("getLink failed!");
+ logger.error("getLink failed! " + ex);
return null;
}
}
@@ -259,7 +261,7 @@ private Link getLinkImpl(String dbid, long id1, long link_type, long id2)
try {
return multigetLinksImpl(dbid, id1, link_type, id2s);
} catch (Exception ex) {
- logger.error("multigetlinks failed!");
+ logger.error("multigetlinks failed! " + ex);
return null;
}
}
@@ -298,7 +300,7 @@ private Link getLinkImpl(String dbid, long id1, long link_type, long id2)
return getLinkListImpl(dbid, id1, link_type, minTimestamp,
maxTimestamp, offset, limit);
} catch (Exception ex) {
- logger.error("getLinkList failed!");
+ logger.error("getLinkList failed! " + ex);
return null;
}
}
@@ -327,7 +329,7 @@ public long countLinks(String dbid, long id1, long link_type) {
try {
return countLinksImpl(dbid, id1, link_type);
} catch (Exception ex) {
- logger.error("countLinks failed!");
+ logger.error("countLinks failed! " + ex);
return -1;
}
}
@@ -358,7 +360,7 @@ public void addBulkLinks(String dbid, List<Link> links, boolean noinverse) {
try {
addBulkLinksImpl(dbid, links, noinverse);
} catch (Exception ex) {
- logger.error("addBulkLinks failed!");
+ logger.error("addBulkLinks failed! " + ex);
}
}
@@ -375,7 +377,7 @@ public void addBulkCounts(String dbid, List<LinkCount> counts) {
try {
addBulkCountsImpl(dbid, counts);
} catch (Exception ex) {
- logger.error("addbulkCounts failed!");
+ logger.error("addbulkCounts failed! " + ex);
}
}
@@ -423,7 +425,7 @@ public long addNode(String dbid, Node node) {
try {
return addNodeImpl(dbid, node);
} catch (Exception ex) {
- logger.error("addNode failed!");
+ logger.error("addNode failed! " + ex);
return -1;
}
}
@@ -439,7 +441,7 @@ private long addNodeImpl(String dbid, Node node) throws Exception {
try {
return bulkAddNodesImpl(dbid, nodes);
} catch (Exception ex) {
- logger.error("bulkAddNodes failed!");
+ logger.error("bulkAddNodes failed! " + ex);
return null;
}
}
@@ -473,7 +475,7 @@ public Node getNode(String dbid, int type, long id) {
try {
return getNodeImpl(dbid, type, id);
} catch (Exception ex) {
- logger.error("getnode failed!");
+ logger.error("getnode failed! " + ex);
return null;
}
}
@@ -509,7 +511,7 @@ public boolean updateNode(String dbid, Node node) throws Exception {
try {
return updateNodeImpl(dbid, node);
} catch (Exception ex) {
- logger.error("updateNode failed!");
+ logger.error("updateNode failed! " + ex);
return false;
}
}
@@ -523,7 +525,7 @@ public boolean deleteNode(String dbid, int type, long id) throws Exception {
try {
return deleteNodeImpl(dbid, type, id);
} catch (Exception ex) {
- logger.error("deleteNode failed!");
+ logger.error("deleteNode failed! " + ex);
return false;
}
}

0 comments on commit eb8400f

Please sign in to comment.