Created
February 15, 2015 00:01
-
-
Save DannyDelott/f5794322290dfa723ee9 to your computer and use it in GitHub Desktop.
Clear the processing buffer and update state.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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