• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Hosts类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.twitter.hbc.core.Hosts的典型用法代码示例。如果您正苦于以下问题:Java Hosts类的具体用法?Java Hosts怎么用?Java Hosts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Hosts类属于com.twitter.hbc.core包,在下文中一共展示了Hosts类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: configureStreamClient

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
private static BasicClient configureStreamClient(BlockingQueue<String> msgQueue, String twitterKeys, List<Long> userIds, List<String> terms) {
    Hosts hosts = new HttpHosts(Constants.STREAM_HOST);
    StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint()
            .followings(userIds)
            .trackTerms(terms);
    endpoint.stallWarnings(false);

    String[] keys = twitterKeys.split(":");
    Authentication auth = new OAuth1(keys[0], keys[1], keys[2], keys[3]);

    ClientBuilder builder = new ClientBuilder()
            .name("Neo4j-Twitter-Stream")
            .hosts(hosts)
            .authentication(auth)
            .endpoint(endpoint)
            .processor(new StringDelimitedProcessor(msgQueue));

    return builder.build();
}
 
开发者ID:neo4j-examples,项目名称:neo4j-twitter-stream,代码行数:20,代码来源:TwitterStreamProcessor.java


示例2: getTwitterClient

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
private  Client getTwitterClient(Properties props, BlockingQueue<String> messageQueue) {

        String clientName = props.getProperty("clientName");
        String consumerKey = props.getProperty("consumerKey");
        String consumerSecret = props.getProperty("consumerSecret");
        String token = props.getProperty("token");
        String tokenSecret = props.getProperty("tokenSecret");
        List<String> searchTerms = Arrays.asList(props.getProperty("searchTerms").split(","));

        Authentication authentication = new OAuth1(consumerKey,consumerSecret,token,tokenSecret);
        Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
        StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();

        hosebirdEndpoint.trackTerms(searchTerms);

        ClientBuilder clientBuilder = new ClientBuilder();
        clientBuilder.name(clientName)
                .hosts(hosebirdHosts)
                .authentication(authentication)
                .endpoint(hosebirdEndpoint)
                .processor(new StringDelimitedProcessor(messageQueue));

          return clientBuilder.build();

    }
 
开发者ID:bbejeck,项目名称:kafka-streams,代码行数:26,代码来源:TwitterDataSource.java


示例3: ClientBase

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
ClientBase(String name, HttpClient client, Hosts hosts, StreamingEndpoint endpoint, Authentication auth,
           HosebirdMessageProcessor processor, ReconnectionManager manager, RateTracker rateTracker,
           @Nullable BlockingQueue<Event> eventsQueue) {
    this.client = Preconditions.checkNotNull(client);
    this.name = Preconditions.checkNotNull(name);

    this.endpoint = Preconditions.checkNotNull(endpoint);
    this.hosts = Preconditions.checkNotNull(hosts);
    this.auth = Preconditions.checkNotNull(auth);

    this.processor = Preconditions.checkNotNull(processor);
    this.reconnectionManager = Preconditions.checkNotNull(manager);
    this.rateTracker = Preconditions.checkNotNull(rateTracker);

    this.eventsQueue = eventsQueue;

    this.exitEvent = new AtomicReference<Event>();

    this.isRunning = new CountDownLatch(1);
    this.statsReporter = new StatsReporter();

    this.connectionEstablished = new AtomicBoolean(false);
    this.reconnect = new AtomicBoolean(false);
}
 
开发者ID:LaurentTardif,项目名称:AgileGrenoble2015,代码行数:25,代码来源:ClientBase.java


示例4: setupHosebirdClient

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
public static void setupHosebirdClient() {
       /** Declare the host you want to connect to, the endpoint, and authentication (basic auth or oauth) */
	Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
	StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();

       // Optional: set up some followings and track terms
	List<Long> followings = Lists.newArrayList(1234L, 566788L);
	List<String> terms = Lists.newArrayList("twitter", "api");
	endpoint.followings(followings);
	endpoint.trackTerms(terms);

	Authentication hosebirdAuth = new OAuth1(
       		Helper.properties().getProperty("consumerKey"),
       		Helper.properties().getProperty("consumerSecret"),
       		Helper.properties().getProperty("token"),
       		Helper.properties().getProperty("secret"));

       ClientBuilder builder = new ClientBuilder()
        .name("Hosebird-Client-01")		// optional: mainly for the logs
        .hosts(hosebirdHosts)
        .authentication(hosebirdAuth)
        .endpoint(endpoint)
        .processor(new StringDelimitedProcessor(msgQueue));

	hosebirdClient = builder.build();
}
 
开发者ID:twitterdev,项目名称:twttr-kinesis,代码行数:27,代码来源:TweetCollector.java


示例5: BasicClient

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
public BasicClient(String name, Hosts hosts, StreamingEndpoint endpoint, Authentication auth, boolean enableGZip, HosebirdMessageProcessor processor,
                   ReconnectionManager reconnectionManager, RateTracker rateTracker, ExecutorService executorService,
                   @Nullable BlockingQueue<Event> eventsQueue, HttpParams params, SchemeRegistry schemeRegistry) {
  Preconditions.checkNotNull(auth);
  HttpClient client;
  if (enableGZip) {
    client = new RestartableHttpClient(auth, enableGZip, params, schemeRegistry);
  } else {
    DefaultHttpClient defaultClient = new DefaultHttpClient(new PoolingClientConnectionManager(schemeRegistry), params);

    /** Set auth **/
    auth.setupConnection(defaultClient);
    client = defaultClient;
  }

  this.canRun = new AtomicBoolean(true);
  this.executorService = executorService;
  this.clientBase = new ClientBase(name, client, hosts, endpoint, auth, processor, reconnectionManager, rateTracker, eventsQueue);
}
 
开发者ID:twitter,项目名称:hbc,代码行数:20,代码来源:BasicClient.java


示例6: ClientBase

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
ClientBase(String name, HttpClient client, Hosts hosts, StreamingEndpoint endpoint, Authentication auth,
           HosebirdMessageProcessor processor, ReconnectionManager manager, RateTracker rateTracker,
           @Nullable BlockingQueue<Event> eventsQueue) {
  this.client = Preconditions.checkNotNull(client);
  this.name = Preconditions.checkNotNull(name);

  this.endpoint = Preconditions.checkNotNull(endpoint);
  this.hosts = Preconditions.checkNotNull(hosts);
  this.auth = Preconditions.checkNotNull(auth);

  this.processor = Preconditions.checkNotNull(processor);
  this.reconnectionManager = Preconditions.checkNotNull(manager);
  this.rateTracker = Preconditions.checkNotNull(rateTracker);

  this.eventsQueue = eventsQueue;

  this.exitEvent = new AtomicReference<Event>();

  this.isRunning = new CountDownLatch(1);
  this.statsReporter = new StatsReporter();

  this.connectionEstablished = new AtomicBoolean(false);
  this.reconnect = new AtomicBoolean(false);
}
 
开发者ID:twitter,项目名称:hbc,代码行数:25,代码来源:ClientBase.java


示例7: subscribe

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
public void subscribe(final StatusStreamHandler listener, String... terms) {
	/**
	 * Set up your blocking queues: Be sure to size these properly based on
	 * expected TPS of your stream
	 */
	BlockingQueue<String> msgQueue = new LinkedBlockingQueue<String>(100000);
	BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>(1000);

	/**
	 * Declare the host you want to connect to, the endpoint, and
	 * authentication (basic auth or oauth)
	 */
	Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
	StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();
	hosebirdEndpoint.trackTerms(Lists.newArrayList(terms));

	Authentication hosebirdAuth = oAuth();

	ClientBuilder builder = new ClientBuilder().name("Hosebird-Client-01")
			// optional: mainly for the logs
			.hosts(hosebirdHosts).authentication(hosebirdAuth).endpoint(hosebirdEndpoint)
			.processor(new StringDelimitedProcessor(msgQueue)).eventMessageQueue(eventQueue);
	Client client = builder.build();

	final ExecutorService executorService = Executors.newFixedThreadPool(1);
	final Twitter4jStatusClient t4jClient = new Twitter4jStatusClient(client, msgQueue,
			Lists.newArrayList(listener), executorService);
	t4jClient.connect();

	// Call this once for every thread you want to spin off for processing
	// the raw messages.
	// This should be called at least once.
	t4jClient.process(); // required to start processing the messages
}
 
开发者ID:cyriux,项目名称:hexagonal-sentimental,代码行数:35,代码来源:TwitterStream.java


示例8: TwitterClient

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
public TwitterClient() {
	/** Set up your blocking queues: Be sure to size these properly based on expected TPS of your stream */
	BlockingQueue<String> msgQueue = new LinkedBlockingQueue<String>(100000);
	BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>(1000);

	/** Declare the host you want to connect to, the endpoint, and authentication (basic auth or oauth) */
	Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
	StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();
	// Optional: set up some followings and track terms
	List<Long> followings = Lists.newArrayList(1234L, 566788L);
	List<String> terms = Lists.newArrayList("twitter", "api");
	hosebirdEndpoint.followings(followings);
	hosebirdEndpoint.trackTerms(terms);

	// These secrets should be read from a config file
	Authentication hosebirdAuth = new OAuth1("consumerKey", "consumerSecret", "token", "secret");

	ClientBuilder builder = new ClientBuilder()
	  .name("Hosebird-Client-01")                              // optional: mainly for the logs
	  .hosts(hosebirdHosts)
	  .authentication(hosebirdAuth)
	  .endpoint(new StatusesSampleEndpoint())
	  .processor(new StringDelimitedProcessor(msgQueue))
	  .eventMessageQueue(eventQueue);                          // optional: use this if you want to process client events

	Client hosebirdClient = builder.build();
	// Attempts to establish a connection.
	hosebirdClient.connect();
}
 
开发者ID:flaxsearch,项目名称:hackday,代码行数:30,代码来源:TwitterClient.java


示例9: start

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
@Start
public void start() {
    queue = new LinkedBlockingQueue<>(100000);
    BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<>(1000);

    // Declare the host you want to connect to, the endpoint, and authentication (basic auth or oauth)
    Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
    StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();

    // set up some track terms
    if (trackTerms != null && !trackTerms.isEmpty()) {
        hosebirdEndpoint.trackTerms(Lists.newArrayList(trackTerms.split(" ")));
    }
    // set up some followings
    if (followingIDs != null && !followingIDs.isEmpty()) {
        Set<Long> followings = new HashSet<>();
        for (String id: followingIDs.split(" ")) {
            followings.add(Long.parseLong(id));
        }
        hosebirdEndpoint.followings(Lists.newArrayList(followings));
    }

    // These secrets should be read from a config file
    Authentication hosebirdAuth = new OAuth1(consumerKey, consumerSecret, token, secret);

    ClientBuilder builder = new ClientBuilder()
            .name("twitter-client")
            .hosts(hosebirdHosts)
            .authentication(hosebirdAuth)
            .endpoint(hosebirdEndpoint)
            .processor(new StringDelimitedProcessor(queue))
            .eventMessageQueue(eventQueue);

    client = builder.build();
    // Attempts to establish a connection.
    client.connect();

    executor.submit(() -> {
        while (client != null && !client.isDone()) {
            try {
                String msg = queue.poll(5000, TimeUnit.MILLISECONDS);
                if (msg != null) {
                    out.send(msg, null);
                }
            } catch (InterruptedException e) {
                Log.warn("Twitter messages blocking queue interrupted while waiting.");
            }
        }
    });
}
 
开发者ID:kevoree,项目名称:kevoree-library,代码行数:51,代码来源:Twitter.java


示例10: SitestreamController

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
/**
 * Construct a sitestream controller.
 */
public SitestreamController(HttpClient client, Hosts hosts, Authentication auth) {
  this.client = Preconditions.checkNotNull(client);
  this.hosts = Preconditions.checkNotNull(hosts);
  this.auth = Preconditions.checkNotNull(auth);
}
 
开发者ID:twitter,项目名称:hbc,代码行数:9,代码来源:SitestreamController.java


示例11: main

import com.twitter.hbc.core.Hosts; //导入依赖的package包/类
public static void main(String[] args)  throws InterruptedException {

        BlockingQueue<String> msgQueue = new LinkedBlockingDeque<>();



        Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
        StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();
        List<String> terms = Lists.newArrayList("superman vs batman","#supermanvsbatman");
        hosebirdEndpoint.trackTerms(terms);




        Authentication hosebirdAuth  = new OAuth1("18qydWMuiUohwCtQpp1MOFCFr",
                                                  "YrYhYd09LKZLbhsKT1o4XcEPl6HiAoNykiOxYBq0dAB8t0vRCo",
                                                  "16972669-KSvyDEMc7dussPfW6a9Ru65L4eWGj637ciHLHZLyn",
                                                  "ky53NE6cbBvtNLopto7o9gVyHDejSB2kPsRhHGKEd1MrS");


        ClientBuilder clientBuilder = new ClientBuilder();
        clientBuilder.name("bbejeck-hosebird")
                     .hosts(hosebirdHosts)
                     .authentication(hosebirdAuth)
                     .endpoint(hosebirdEndpoint)
                     .processor(new StringDelimitedProcessor(msgQueue));

        Client hosebirdClient = clientBuilder.build();
        hosebirdClient.connect();

        for (int msgRead = 0; msgRead < 100; msgRead++) {
            String msg = msgQueue.take();
            System.out.println(msg);
        }

        hosebirdClient.stop();

    }
 
开发者ID:bbejeck,项目名称:kafka-streams,代码行数:39,代码来源:HoseBirdTester.java



注:本文中的com.twitter.hbc.core.Hosts类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SourceChannel类代码示例发布时间:2022-05-22
下一篇:
Java MetaData类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap