streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject git commit: if no ids are present, poll the logged-in user
Date Mon, 21 Jul 2014 20:09:49 GMT
Repository: incubator-streams
Updated Branches:
  refs/heads/STREAMS-46 e8511ada0 -> e0cb5ec25


if no ids are present, poll the logged-in user


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/e0cb5ec2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/e0cb5ec2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/e0cb5ec2

Branch: refs/heads/STREAMS-46
Commit: e0cb5ec25c6a58b45684b77935ddd57ec503a592
Parents: e8511ad
Author: sblackmon <sblackmon@w2odigital.com>
Authored: Mon Jul 21 15:09:46 2014 -0500
Committer: sblackmon <sblackmon@w2odigital.com>
Committed: Mon Jul 21 15:09:46 2014 -0500

----------------------------------------------------------------------
 .../provider/FacebookUserstreamProvider.java    | 24 ++++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/e0cb5ec2/streams-contrib/streams-provider-facebook/src/main/java/com/facebook/provider/FacebookUserstreamProvider.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-facebook/src/main/java/com/facebook/provider/FacebookUserstreamProvider.java
b/streams-contrib/streams-provider-facebook/src/main/java/com/facebook/provider/FacebookUserstreamProvider.java
index af7868b..b0bf082 100644
--- a/streams-contrib/streams-provider-facebook/src/main/java/com/facebook/provider/FacebookUserstreamProvider.java
+++ b/streams-contrib/streams-provider-facebook/src/main/java/com/facebook/provider/FacebookUserstreamProvider.java
@@ -142,10 +142,17 @@ public class FacebookUserstreamProvider implements StreamsProvider,
Serializable
             for( String id : configuration.getInfo()) {
                 executor.submit(new FacebookFeedPollingTask(this, id));
             }
+            running.set(true);
         } else {
-            executor.submit(new FacebookFeedPollingTask(this));
+            try {
+                String id = client.getMe().getId();
+                executor.submit(new FacebookFeedPollingTask(this, id));
+                running.set(true);
+            } catch (FacebookException e) {
+                LOGGER.error(e.getMessage());
+                running.set(false);
+            }
         }
-        running.set(true);
     }
 
     public StreamsResultSet readCurrent() {
@@ -279,14 +286,12 @@ public class FacebookUserstreamProvider implements StreamsProvider,
Serializable
             while (provider.isRunning()) {
                 ResponseList<Post> postResponseList;
                 try {
-                    if( id != null )
-                        postResponseList = client.getFeed(id);
-                    else
-                        postResponseList = client.getHome();
+                    postResponseList = client.getFeed(id);
 
                     Set<Post> update = Sets.newHashSet(postResponseList);
                     Set<Post> repeats = Sets.intersection(priorPollResult, Sets.newHashSet(update));
                     Set<Post> entrySet = Sets.difference(update, repeats);
+                    LOGGER.debug(this.id + " response: " + update.size() + " previous: "
+ repeats.size() + " new: " + entrySet.size());
                     for (Post item : entrySet) {
                         String json = DataObjectFactory.getRawJSON(item);
                         org.apache.streams.facebook.Post post = mapper.readValue(json, org.apache.streams.facebook.Post.class);
@@ -299,9 +304,14 @@ public class FacebookUserstreamProvider implements StreamsProvider, Serializable
                         }
                     }
                     priorPollResult = update;
-                    Thread.sleep(configuration.getPollIntervalMillis());
                 } catch (Exception e) {
                     e.printStackTrace();
+                } finally {
+                    try {
+                        Thread.sleep(configuration.getPollIntervalMillis());
+                    } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+                    }
                 }
             }
         }


Mime
View raw message