streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject [13/18] git commit: STREAMS 121 | Added javadoc comments
Date Mon, 21 Jul 2014 04:49:28 GMT
STREAMS 121 | Added javadoc comments


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

Branch: refs/heads/master
Commit: 95f6d5d9bc9069258717a9880e491ce55ae343e2
Parents: 7760393
Author: rebanks <rebanks@w2odigital.com>
Authored: Fri Jul 11 16:29:55 2014 -0500
Committer: rebanks <rebanks@w2odigital.com>
Committed: Fri Jul 11 16:29:55 2014 -0500

----------------------------------------------------------------------
 .../provider/InstagramRecentMediaCollector.java | 32 +++++++++++++++++++-
 .../provider/InstagramRecentMediaProvider.java  |  6 +++-
 2 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/95f6d5d9/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaCollector.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaCollector.java
b/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaCollector.java
index 7eb3fcd..928ff9e 100644
--- a/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaCollector.java
+++ b/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaCollector.java
@@ -13,6 +13,11 @@ import java.util.Queue;
 import java.util.Set;
 
 /**
+ * Executes on all of the Instagram requests to collect the media feed data.
+ *
+ * If errors/exceptions occur when trying to gather data for a particular user, that user
is skipped and the collector
+ * move on to the next user.  If a rate limit exception occurs it employs an exponential
back off strategy for up to
+ * 5 attempts.
  *
  */
 public class InstagramRecentMediaCollector implements Runnable {
@@ -34,10 +39,19 @@ public class InstagramRecentMediaCollector implements Runnable {
         this.isCompleted = false;
     }
 
+    /**
+     * Set instagram client
+     * @param instagramClient
+     */
     protected void setInstagramClient(Instagram instagramClient) {
         this.instagramClient = instagramClient;
     }
 
+    /**
+     * Gets the user ids from the {@link org.apache.streams.instagram.InstagramUserInformationConfiguration}
and
+     * converts them to {@link java.lang.Long}
+     * @return
+     */
     protected Set<Long> getUserIds() {
         Set<Long> userIds = Sets.newHashSet();
         for(String id : config.getUserIds()) {
@@ -50,6 +64,14 @@ public class InstagramRecentMediaCollector implements Runnable {
         return userIds;
     }
 
+    /**
+     * Determins the course of action to take when Instagram returns an exception to a request.
 If it is a rate limit
+     * exception, it implements an exponentional back off strategy.  If it is anyother exception,
it is logged and
+     * rethrown.
+     * @param instaExec exception to handle
+     * @param attempt number of attempts that have occured to pull this users information
+     * @throws InstagramException
+     */
     protected void handleInstagramException(InstagramException instaExec, int attempt) throws
InstagramException {
         LOGGER.debug("RemainingApiLimitStatus: {}", instaExec.getRemainingLimitStatus());
         if(instaExec.getRemainingLimitStatus() == 0) { //rate limit exception
@@ -66,6 +88,10 @@ public class InstagramRecentMediaCollector implements Runnable {
         }
     }
 
+    /**
+     * Gets the MediaFeedData for this particular user and adds it to the share queued.
+     * @param userId
+     */
     private void getUserMedia(Long userId) {
         MediaFeed feed = null;
         int attempts = 0;
@@ -97,7 +123,7 @@ public class InstagramRecentMediaCollector implements Runnable {
             LOGGER.error("User id, {}, returned a NULL media feed from instagram.", userId);
         } else {
             for(MediaFeedData data : userFeed.getData()) {
-                synchronized (this.dataQueue) {
+                synchronized (this.dataQueue) { //unnecessary
                     while(!this.dataQueue.offer(data)) {
                         Thread.yield();
                     }
@@ -106,6 +132,10 @@ public class InstagramRecentMediaCollector implements Runnable {
         }
     }
 
+    /**
+     *
+     * @return true when the collector has queued all of available media feed data for the
provided users.
+     */
     public boolean isCompleted() {
         return this.isCompleted;
     }

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/95f6d5d9/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaProvider.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaProvider.java
b/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaProvider.java
index 3354e54..e5fa464 100644
--- a/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaProvider.java
+++ b/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/provider/InstagramRecentMediaProvider.java
@@ -17,7 +17,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
 /**
- * Created by rebanks on 7/9/14.
+ * Instagram {@link org.apache.streams.core.StreamsProvider} that provides the recent media
data for a group of users
  */
 public class InstagramRecentMediaProvider implements StreamsProvider {
 
@@ -44,6 +44,10 @@ public class InstagramRecentMediaProvider implements StreamsProvider {
         this.executorService.submit(this.dataCollector);
     }
 
+    /**
+     * EXPOSED FOR TESTING
+     * @return
+     */
     protected InstagramRecentMediaCollector getInstagramRecentMediaCollector() {
         return new InstagramRecentMediaCollector(this.mediaFeedQueue, this.config);
     }


Mime
View raw message