streams-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steveblackmon <...@git.apache.org>
Subject [GitHub] incubator-streams pull request: Streams 115
Date Fri, 25 Jul 2014 17:46:38 GMT
Github user steveblackmon commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/51#discussion_r15414307
  
    --- Diff: streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
---
    @@ -125,101 +104,88 @@ public TwitterTimelineProvider(TwitterStreamConfiguration config,
Class klass) {
         @Override
         public void startStream() {
             LOGGER.debug("{} startStream", STREAMS_ID);
    -        throw new org.apache.commons.lang.NotImplementedException();
    -    }
     
    -    protected void captureTimeline(long currentId) {
    +        Preconditions.checkArgument(idsBatches.hasNext() || screenNameBatches.hasNext());
     
    -        Paging paging = new Paging(1, 200);
    -        List<Status> statuses = null;
    -        boolean KeepGoing = true;
    -        boolean hadFailure = false;
    +        LOGGER.info("readCurrent");
     
    -        do
    -        {
    -            int keepTrying = 0;
    +        while(idsBatches.hasNext())
    +            loadBatch(idsBatches.next());
     
    -            // keep trying to load, give it 5 attempts.
    -            //This value was chosen because it seemed like a reasonable number of times
    -            //to retry capturing a timeline given the sorts of errors that could potentially
    -            //occur (network timeout/interruption, faulty client, etc.)
    -            while (keepTrying < 5)
    -            {
    +        while(screenNameBatches.hasNext())
    +            loadBatch(screenNameBatches.next());
     
    -                try
    -                {
    -                    statuses = client.getUserTimeline(currentId, paging);
    -                    for (Status tStat : statuses) {
    -                        String json = TwitterObjectFactory.getRawJSON(tStat);
    -                        try {
    -                            lock.readLock().lock();
    -                            ComponentUtils.offerUntilSuccess(new StreamsDatum(json),
providerQueue);
    -                        } finally {
    -                            lock.readLock().unlock();
    -                        }
    -                    }
    -
    -                    paging.setPage(paging.getPage() + 1);
    -
    -                    keepTrying = 10;
    -                }
    -                catch(TwitterException twitterException) {
    -                    keepTrying += TwitterErrorHandler.handleTwitterError(client, twitterException);
    -                }
    -                catch(Exception e) {
    -                    keepTrying += TwitterErrorHandler.handleTwitterError(client, e);
    -                }
    -            }
    -        }
    -        while (shouldContinuePulling(statuses));
    +        executor.shutdown();
         }
     
    -    private Map<Long, Long> userPullInfo;
    -
         protected boolean shouldContinuePulling(List<Status> statuses) {
             return (statuses != null) && (statuses.size() > 0);
         }
     
    -    private void sleep()
    -    {
    -        Thread.yield();
    -        try {
    -            // wait one tenth of a millisecond
    -            Thread.yield();
    -            Thread.sleep(1);
    -            Thread.yield();
    -        }
    -        catch(IllegalArgumentException e) {
    -            // passing in static values, this will never happen
    -        }
    -        catch(InterruptedException e) {
    -            // noOp, there must have been an issue sleeping
    +    private void loadBatch(Long[] ids) {
    +        Twitter client = getTwitterClient();
    +        int keepTrying = 0;
    +
    +        // keep trying to load, give it 5 attempts.
    +        //while (keepTrying < 10)
    +        while (keepTrying < 1)
    --- End diff --
    
    Legacy code.  Agreed, removing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message