Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // create user_pages of 100 users per page
- List<int[]> followersPages = paginateIDList(ids);
- // iterate the pages
- ResponseList<User> users = null;
- int[] page = null;
- Iterator<int[]> iterator = followersPages.iterator();
- while (iterator.hasNext()) {
- try {
- page = iterator.next();
- // lookup the users for current page
- users = twitter.lookupUsers(page);
- // store each user's profile
- for (User currUser : users) {
- // log a heartbeat message
- heartBeat();
- storeUserProfile(currUser);
- }
- // throttle the requests after every Twitter call
- throttleRequests(twitter);
- } catch (TwitterException e) {
- logger.error(ERR_USERBATCH_FAILED, e);
- // log the IDs from the page that is failing
- if (page != null)
- logger.error("Page(" + page.length + "): "
- + Arrays.toString(page));
- if (ids != null)
- logger.error("Ids(" + ids.length + ")");
- // throw new ServletException(ERR_USERBATCH_FAILED, e);
- // just log the error but continue with the execution
- } catch (InterruptedException e) {
- logger.error(ERR_THROTTLE_FAILED, e);
- throw new ServletException(ERR_THROTTLE_FAILED, e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement