Search in sources :

Example 1 with DefaultStreamingEndpoint

use of com.twitter.hbc.core.endpoint.DefaultStreamingEndpoint 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);
}
Also used : HttpHosts(com.twitter.hbc.core.HttpHosts) DefaultStreamingEndpoint(com.twitter.hbc.core.endpoint.DefaultStreamingEndpoint) StreamingEndpoint(com.twitter.hbc.core.endpoint.StreamingEndpoint) SitestreamEndpoint(com.twitter.hbc.core.endpoint.SitestreamEndpoint) DefaultStreamingEndpoint(com.twitter.hbc.core.endpoint.DefaultStreamingEndpoint) UserstreamEndpoint(com.twitter.hbc.core.endpoint.UserstreamEndpoint) StatusesFirehoseEndpoint(com.twitter.hbc.core.endpoint.StatusesFirehoseEndpoint) StatusesSampleEndpoint(com.twitter.hbc.core.endpoint.StatusesSampleEndpoint) Map(java.util.Map) StatusesFilterEndpoint(com.twitter.hbc.core.endpoint.StatusesFilterEndpoint)

Aggregations

HttpHosts (com.twitter.hbc.core.HttpHosts)1 DefaultStreamingEndpoint (com.twitter.hbc.core.endpoint.DefaultStreamingEndpoint)1 SitestreamEndpoint (com.twitter.hbc.core.endpoint.SitestreamEndpoint)1 StatusesFilterEndpoint (com.twitter.hbc.core.endpoint.StatusesFilterEndpoint)1 StatusesFirehoseEndpoint (com.twitter.hbc.core.endpoint.StatusesFirehoseEndpoint)1 StatusesSampleEndpoint (com.twitter.hbc.core.endpoint.StatusesSampleEndpoint)1 StreamingEndpoint (com.twitter.hbc.core.endpoint.StreamingEndpoint)1 UserstreamEndpoint (com.twitter.hbc.core.endpoint.UserstreamEndpoint)1 Map (java.util.Map)1