@Override public void close() { this.running = false; LOG.info("Closing source"); if (client != null) { // client seems to be thread-safe client.stop(); } // leave main method synchronized (waitLock) { waitLock.notify(); } }
.build(); client.connect(); running = true;
client.connect(); if (client.isDone()) { System.out.println("Client connection closed unexpectedly: " + client.getExitEvent().getMessage()); break; client.stop(); System.out.printf("The client read %d messages!\n", client.getStatsTracker().getNumMessages());
if (twitterConnector.getClient().isDone()) { System.out.println("Client connection closed unexpectedly: " + twitterConnector.getClient().getExitEvent().getMessage()); return null;
public void run() { while (!client.isDone()) { try { String msg = msgQueue.take(); Utils.printInfo(new JSONObject(msg)); String text = Utils.getCleanText(new JSONObject(msg)); // Need to convert the text to a Tweet datastructure for the classifier to work String decision = classifier.discreteValue(new Tweet(text)); System.out.println("\t***Sentiment classification: " + decision); } catch (InterruptedException e) { e.printStackTrace(); } } client.stop(); } }
@Override public void stop() { stop(DEFAULT_STOP_TIMEOUT_MILLIS); }
@Override public void open() throws TexeraException { if (cursor != CLOSED) { return; } try { twitterConnector.getClient().connect(); cursor = OPENED; } catch (Exception e) { throw new DataflowException(e.getMessage(), e); } }
client.stop();
controller.addUser(t4jClient.getStreamId(), 987765L); client.stop();
.build(); client.connect(); running = true;
void destroy() { if (client != null) { client.stop(); } } }
@Before public void setUp() throws Exception { String dummyKeyword = "is"; List<String> keyWordList = new ArrayList<>(Arrays.asList(dummyKeyword)); twitterConnector = new TwitterConnector(keyWordList, null, null, null, null, null, null); twitterConnector.getClient().connect(); }
@Override public void close() { if (client != null) { client.stop(); } }
@Override protected void init(@Nonnull Context context) { StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint(); endpoint.trackTerms(terms); String consumerKey = properties.getProperty("consumerKey"); String consumerSecret = properties.getProperty("consumerSecret"); String token = properties.getProperty("token"); String tokenSecret = properties.getProperty("tokenSecret"); if (isMissing(consumerKey) || isMissing(consumerSecret) || isMissing(token) || isMissing(tokenSecret)) { throw new IllegalArgumentException("Twitter credentials are missing!"); } Authentication auth = new OAuth1(consumerKey, consumerSecret, token, tokenSecret); client = new ClientBuilder() .hosts(Constants.STREAM_HOST) .endpoint(endpoint) .authentication(auth) .processor(new StringDelimitedProcessor(queue)) .build(); client.connect(); }
@Override public void close() { this.running = false; LOG.info("Closing source"); if (client != null) { // client seems to be thread-safe client.stop(); } // leave main method synchronized (waitLock) { waitLock.notify(); } }
TwitterSource(Properties properties, List<String> terms) { StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint().trackTerms(terms); String consumerKey = properties.getProperty("consumerKey"); String consumerSecret = properties.getProperty("consumerSecret"); String token = properties.getProperty("token"); String tokenSecret = properties.getProperty("tokenSecret"); if (isMissing(consumerKey) || isMissing(consumerSecret) || isMissing(token) || isMissing(tokenSecret)) { throw new IllegalArgumentException("Twitter credentials are missing!"); } Authentication auth = new OAuth1(consumerKey, consumerSecret, token, tokenSecret); client = new ClientBuilder() .hosts(Constants.STREAM_HOST) .endpoint(endpoint) .authentication(auth) .processor(new StringDelimitedProcessor(queue)) .build(); client.connect(); }
@Override public void close() throws TexeraException { if (cursor == CLOSED) { return; } twitterConnector.getClient().stop(); cursor = CLOSED; }