Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Close stores properly at end of load and request
Browse files Browse the repository at this point in the history
Summary: Previously linkbench load and request didn't clean up stores nicely

Test Plan: ant test passes

Reviewers: emayanke, dhruba

Reviewed By: emayanke

Differential Revision: https://reviews.facebook.net/D8289
  • Loading branch information
Tim Armstrong committed Jan 31, 2013
1 parent f3eebfa commit 6438dae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/java/com/facebook/LinkBench/LinkBenchRequest.java
Expand Up @@ -760,6 +760,7 @@ public void run() {
e.getMessage(), e);
aborted = true;
}
closeStores();
return;
}

Expand All @@ -779,7 +780,7 @@ public void run() {
logger.error(String.format("Requester #%d aborting: %d failed requests" +
" (out of %d total) ", requesterID, errors, requestsDone));
aborted = true;
return;
break;
}
}

Expand Down Expand Up @@ -852,7 +853,17 @@ public void run() {
" not found = " + numnotfound +
" history queries = " + numHistoryQueries + "/" +
stats.getCount(LinkBenchOp.GET_LINKS_LIST));
closeStores();
}

/**
* Close datastores before finishing
*/
private void closeStores() {
linkStore.close();
if (nodeStore != null && nodeStore != linkStore) {
nodeStore.close();
}
}

private void displayStats(long lastStatDisplay_ms, long now_ms) {
Expand Down
1 change: 1 addition & 0 deletions src/java/com/facebook/LinkBench/NodeLoader.java
Expand Up @@ -148,6 +148,7 @@ public void run() {

logger.info("Loading of nodes [" + startId + "," + maxId + ") done");
displayAndResetStats();
nodeStore.close();
}

private void displayAndResetStats() {
Expand Down
5 changes: 5 additions & 0 deletions src/java/com/facebook/LinkBench/NodeStore.java
Expand Up @@ -92,4 +92,9 @@ public void initialize(Properties p,
public boolean deleteNode(String dbid, int type, long id) throws Exception;

public void clearErrors(int loaderId);

/**
* Close the node store and clean up any resources
*/
public void close();
}

0 comments on commit 6438dae

Please sign in to comment.