List of usage examples for twitter4j StallWarning toString
@Override
public String toString()
From source file:streamflow.spout.twitter.TwitterSampleSpout.java
License:Apache License
@Override public void open(Map config, TopologyContext context, SpoutOutputCollector collector) { this.collector = collector; logger.info(/*from www . j a v a 2 s . c o m*/ "Twitter Sampler Started: Consumer Key = " + consumerKey + ", Consumer Secret = " + consumerSecret + ", Access Token = " + accessToken + ", Access Token Secret = " + accessTokenSecret); if (StringUtils.isNotBlank(consumerKey) && StringUtils.isNotBlank(consumerSecret) && StringUtils.isNotBlank(accessToken) && StringUtils.isNotBlank(accessTokenSecret)) { // Build the twitter config to authenticate the requests ConfigurationBuilder twitterConfig = new ConfigurationBuilder().setOAuthConsumerKey(consumerKey) .setOAuthConsumerSecret(consumerSecret).setOAuthAccessToken(accessToken) .setOAuthAccessTokenSecret(accessTokenSecret).setJSONStoreEnabled(true) .setIncludeEntitiesEnabled(true).setIncludeEntitiesEnabled(true); // Add the proxy settings to the Twitter config if they were specified if (StringUtils.isNotBlank(proxyHost) && proxyPort > 0) { try { twitterConfig.setHttpProxyPort(proxyPort).setHttpProxyHost(proxyHost); } catch (Exception ex) { } } // Status listener which handle the status events and add them to the queue StatusListener listener = new StatusListener() { @Override public void onStatus(Status status) { queue.offer(status); } @Override public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { logger.debug("Twitter Deletion Notice: " + statusDeletionNotice.getUserId()); } @Override public void onTrackLimitationNotice(int numberOfLimitedStatuses) { logger.debug("Twitter On Track Limitation Notice: Number Of Limited Statuses" + numberOfLimitedStatuses); } @Override public void onScrubGeo(long userId, long upToStatusId) { logger.debug("Twitter Scrub Geo: UserID = " + userId + ", UpToStatusId = " + upToStatusId); } @Override public void onException(Exception exception) { logger.debug("Twitter Exception: " + exception.getMessage()); } @Override public void onStallWarning(StallWarning stallWarning) { logger.debug("Twitter Stall Warning: " + stallWarning.toString()); } }; TwitterStreamFactory twitterFactory = new TwitterStreamFactory(twitterConfig.build()); twitterStream = twitterFactory.getInstance(); twitterStream.addListener(listener); twitterStream.sample(); logger.info("Twitter Sample Stream Initialized"); } else { logger.info("Twitter Sampler missing required OAuth properties. " + "Pleast check your settings and try again."); } }