use of com.twitter.hbc.core.HttpHosts in project ignite by apache.
the class IgniteTwitterStreamerTest method testStatusesFilterEndpointOAuth1.
/**
* @throws Exception Test exception.
*/
public void testStatusesFilterEndpointOAuth1() throws Exception {
try (IgniteDataStreamer<Long, String> dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) {
TwitterStreamerImpl streamer = newStreamerInstance(dataStreamer);
Map<String, String> params = new HashMap<>();
params.put("track", "apache, twitter");
// @ApacheIgnite id.
params.put("follow", "3004445758");
streamer.setApiParams(params);
streamer.setEndpointUrl(MOCK_TWEET_PATH);
streamer.setHosts(new HttpHosts("http://localhost:8080"));
streamer.setThreadsCount(8);
executeStreamer(streamer);
}
}
use of com.twitter.hbc.core.HttpHosts in project ignite by apache.
the class TwitterStreamer method getClient.
/**
* @param tweetQueue Tweet queue.
* @return Client.
*/
protected Client getClient(BlockingQueue<String> tweetQueue) {
StreamingEndpoint endpoint;
HttpHosts hosts;
switch(endpointUrl.toLowerCase()) {
case StatusesFilterEndpoint.PATH:
endpoint = new StatusesFilterEndpoint();
hosts = HttpHosts.STREAM_HOST;
break;
case StatusesFirehoseEndpoint.PATH:
endpoint = new StatusesFirehoseEndpoint();
hosts = HttpHosts.STREAM_HOST;
break;
case StatusesSampleEndpoint.PATH:
endpoint = new StatusesSampleEndpoint();
hosts = HttpHosts.STREAM_HOST;
break;
case UserstreamEndpoint.PATH:
endpoint = new UserstreamEndpoint();
hosts = HttpHosts.USERSTREAM_HOST;
break;
case SitestreamEndpoint.PATH:
String follow = apiParams.remove(SITE_USER_ID_KEY);
List<Long> followers = Lists.newArrayList();
for (String follower : Splitter.on(',').trimResults().omitEmptyStrings().split(follow)) followers.add(Long.valueOf(follower));
endpoint = new SitestreamEndpoint(followers);
hosts = HttpHosts.SITESTREAM_HOST;
break;
default:
endpoint = new DefaultStreamingEndpoint(endpointUrl, HttpConstants.HTTP_GET, false);
hosts = HttpHosts.STREAM_HOST;
}
for (Map.Entry<String, String> entry : apiParams.entrySet()) {
endpoint.addPostParameter(entry.getKey(), entry.getValue());
}
return buildClient(tweetQueue, hosts, endpoint);
}
Aggregations