streams-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfranklin <...@git.apache.org>
Subject [GitHub] incubator-streams pull request: Streams 115
Date Mon, 21 Jul 2014 14:16:43 GMT
Github user mfranklin commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/51#discussion_r15170463
  
    --- Diff: streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
---
    @@ -58,47 +56,43 @@ public void run() {
                 int keepTrying = 0;
     
                 // keep trying to load, give it 5 attempts.
    -            //while (keepTrying < 10)
    -            while (keepTrying < 1)
    +            //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)
                 {
     
                     try
                     {
    -                    statuses = twitter.getUserTimeline(id, paging);
    +                    statuses = client.getUserTimeline(id, paging);
     
                         for (Status tStat : statuses)
                         {
    -                        if( provider.start != null &&
    -                            provider.start.isAfter(new DateTime(tStat.getCreatedAt())))
    -                        {
    -                            // they hit the last date we wanted to collect
    -                            // we can now exit early
    -                            KeepGoing = false;
    -                        }
    -                        // emit the record
    -                        String json = DataObjectFactory.getRawJSON(tStat);
    -
    -                        //provider.offer(json);
    +                        String json = TwitterObjectFactory.getRawJSON(tStat);
     
    +                        try {
    +                            provider.lock.readLock().lock();
    --- End diff --
    
    broken encapsulation.  Rather than accessing the fields of the provider class here, you
could create a method in the provider that contains the logic ass follows
    
    ````
    protected void addDatum(StreamsDatum datum) {
        try {
             lock.readLock().lock();
             ComponentUtils.offerUntilSuccess(datum, providerQueue);
        } finally {
              lock.readLock().unlock();
        }
    }


---
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