Skip to content

Instantly share code, notes, and snippets.

@DannyDelott
Created February 15, 2015 00:01
Show Gist options
  • Save DannyDelott/f5794322290dfa723ee9 to your computer and use it in GitHub Desktop.
Save DannyDelott/f5794322290dfa723ee9 to your computer and use it in GitHub Desktop.
Clear the processing buffer and update state.
private static ProcessingListener finishListener = new ProcessingListener() {
@Override
public void onProcessFinished(int bufferId, HashSet urls,
int numScraped) {
// updates list of duplicate urls
synchronized(this) {
duplicateUrls = urls;
}
// prints results to screen
numVinesScraped += numScraped;
if (numScraped != 0) {
System.out.println(“Scraped“ + numScraped + “vine(s) from buffer” + bufferId + “.Total vines is now“ + numVinesScraped + “.”);
}
// clears buffer and resets processing state
switch (bufferId) {
case 1:
buffer1.clearBuffer();
buffer1.setProcessing(false);
break;
case 2:
buffer2.clearBuffer();
buffer2.setProcessing(false);
break;
}
// stops scraping when threshold is reached
if (numVinesScraped >= NUM_VINES_TO_DOWNLOAD &&
(NUM_VINES_TO_DOWNLOAD != -1)) {
twitter.cleanUp();
twitter.shutdown();
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment