List of usage examples for twitter4j StallWarning getPercentFull
public int getPercentFull()
From source file:com.github.jcustenborder.kafka.connect.twitter.TwitterSourceTask.java
License:Apache License
@Override public void onStallWarning(StallWarning stallWarning) { if (log.isWarnEnabled()) { log.warn("code = '{}' percentFull = '{}' - {}", stallWarning.getCode(), stallWarning.getPercentFull(), stallWarning.getMessage()); }//from w w w . j a va 2 s.c o m }
From source file:org.graylog2.inputs.twitter.TwitterTransport.java
License:Open Source License
@Override public void launch(final MessageInput input) throws MisfireException { final ConfigurationBuilder cb = new ConfigurationBuilder() .setOAuthConsumerKey(configuration.getString(CK_OAUTH_CONSUMER_KEY)) .setOAuthConsumerSecret(configuration.getString(CK_OAUTH_CONSUMER_SECRET)) .setOAuthAccessToken(configuration.getString(CK_OAUTH_ACCESS_TOKEN)) .setOAuthAccessTokenSecret(configuration.getString(CK_OAUTH_ACCESS_TOKEN_SECRET)) .setJSONStoreEnabled(true);/*w w w . j av a 2 s .c o m*/ final StatusListener listener = new StatusListener() { public void onStatus(final Status status) { try { input.processRawMessage(createMessageFromStatus(status)); } catch (IOException e) { LOG.debug("Error while processing tweet status", e); } } private RawMessage createMessageFromStatus(final Status status) throws IOException { return new RawMessage(TwitterObjectFactory.getRawJSON(status).getBytes(StandardCharsets.UTF_8)); } public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { } public void onTrackLimitationNotice(int numberOfLimitedStatuses) { } public void onException(final Exception ex) { LOG.error("Error while reading Twitter stream", ex); } @Override public void onScrubGeo(long lon, long lat) { } @Override public void onStallWarning(StallWarning stallWarning) { LOG.info("Stall warning: {} ({}% full)", stallWarning.getMessage(), stallWarning.getPercentFull()); } }; final String[] track = Iterables.toArray( Splitter.on(',').omitEmptyStrings().trimResults().split(configuration.getString(CK_KEYWORDS)), String.class); final FilterQuery filterQuery = new FilterQuery(); filterQuery.track(track); if (twitterStream == null) { twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); } twitterStream.addListener(listener); twitterStream.filter(filterQuery); }