@Override public StreamingEndpoint createEndpoint() { // this default endpoint initializer returns the sample endpoint: Returning a sample from the firehose (all tweets) StatusesSampleEndpoint endpoint = new StatusesSampleEndpoint(); endpoint.stallWarnings(false); endpoint.delimited(false); return endpoint; } }
/** * * @param location a comma-separated list of longitude,latitude pairs specifying one location * * @return the Location instance for the provided input */ public static Location parseLocation(final String location) { final String[] corSplit = location.split(","); final double swLon = Double.parseDouble(corSplit[0]) ; final double swLat = Double.parseDouble(corSplit[1]) ; final double neLon = Double.parseDouble(corSplit[2]) ; final double neLat = Double.parseDouble(corSplit[3]) ; Location.Coordinate sw = new Location.Coordinate(swLon, swLat) ; Location.Coordinate ne = new Location.Coordinate(neLon, neLat) ; return new Location(sw, ne) ; }
endpoint = new StatusesFilterEndpoint(); endpoint = new StatusesFirehoseEndpoint(); endpoint = new StatusesSampleEndpoint(); endpoint = new UserstreamEndpoint(); followers.add(Long.valueOf(follower)); endpoint = new SitestreamEndpoint(followers); endpoint = new DefaultStreamingEndpoint(endpointUrl, HttpConstants.HTTP_GET, false); endpoint.addPostParameter(entry.getKey(), entry.getValue());
if (ENDPOINT_SAMPLE.getValue().equals(endpointName)) { host = Constants.STREAM_HOST; final StatusesSampleEndpoint sse = new StatusesSampleEndpoint(); streamingEndpoint = sse; if (languages != null) { sse.languages(languages); final StatusesFirehoseEndpoint firehoseEndpoint = new StatusesFirehoseEndpoint(); streamingEndpoint = firehoseEndpoint; if (languages != null) { firehoseEndpoint.languages(languages); final StatusesFilterEndpoint filterEndpoint = new StatusesFilterEndpoint(); filterEndpoint.trackTerms(terms); filterEndpoint.followings(followingIds); filterEndpoint.languages(languages); filterEndpoint.locations(locations);
final List<Location> locations = LocationUtil.parseLocations(input); for (final Location location : locations) { final Coordinate sw = location.southwestCoordinate(); final Coordinate ne = location.northeastCoordinate(); if (sw.longitude() > ne.longitude()) { return new ValidationResult.Builder().input(input).subject(subject).valid(false) .explanation("SW Longitude (" + sw.longitude() + ") must be less than NE Longitude (" + ne.longitude() + ").").build(); if (sw.longitude() == ne.longitude()) { return new ValidationResult.Builder().input(input).subject(subject).valid(false) .explanation("SW Longitude (" + sw.longitude() + ") can not be equal to NE Longitude (" + ne.longitude() + ").").build(); if (sw.latitude() > ne.latitude()) { return new ValidationResult.Builder().input(input).subject(subject).valid(false) .explanation("SW Latitude (" + sw.latitude() + ") must be less than NE Latitude (" + ne.latitude() + ").").build(); if (sw.latitude() == ne.latitude()) { return new ValidationResult.Builder().input(input).subject(subject).valid(false) .explanation("SW Latitude (" + sw.latitude() + ") can not be equal to NE Latitude (" + ne.latitude() + ").").build();
@Override public String toString() { return longitude + "," + latitude(); }
/** * Corresponds to setting `with=followings` when true. * See https://dev.twitter.com/docs/streaming-apis/parameters#with */ public void withFollowings(boolean followings) { if (followings) { addQueryParameter(Constants.WITH_PARAM, Constants.WITH_FOLLOWINGS); } else { removeQueryParameter(Constants.WITH_PARAM); } }
@Override protected void addDefaultParams() { if (this.delimited) { addQueryParameter(Constants.DELIMITED_PARAM, Constants.DELIMITED_VALUE); } else { removeQueryParameter(Constants.DELIMITED_PARAM); } if (this.stallWarnings) { addQueryParameter(Constants.STALL_WARNING_PARAM, Constants.STALL_WARNING_VALUE); } else { removeQueryParameter(Constants.STALL_WARNING_PARAM); } }
session.getProvenanceReporter().receive(flowFile, Constants.STREAM_HOST + client.getEndpoint().getURI());
/** * Control stream endpoints */ public static Endpoint streamInfoEndpoint(String streamId) { return new BaseEndpoint("/site/c/" + streamId + "/info.json", HttpConstants.HTTP_GET); }
@Override public String getPostParamString() { return generateParamString(postParameters); }
@Override public String getQueryParamString() { return generateParamString(queryParameters); }
@Override public String getQueryParamString() { return generateParamString(queryParameters); }
public final String getPath() { return getPath(apiVersion); }
/** * Corresponds to setting `with=user` when true. * See https://dev.twitter.com/docs/streaming-apis/parameters#with */ public void withUser(boolean user) { if (user) { addQueryParameter(Constants.WITH_PARAM, Constants.WITH_USER); } else { removeQueryParameter(Constants.WITH_PARAM); } }
public static Endpoint friendsEndpoint(String streamId) { return new BaseEndpoint("/site/c/" + streamId + "/friends/ids.json", HttpConstants.HTTP_POST); } }
@Override public String getQueryParamString() { return generateParamString(queryParameters); }
public void allReplies(boolean all) { if (all) { addQueryParameter(Constants.REPLIES_PARAM, Constants.REPLIES_ALL); } else { removeQueryParameter(Constants.REPLIES_PARAM); } } }
public static Endpoint addUserEndpoint(String streamId) { return new BaseEndpoint("/site/c/" + streamId + "/add_user.json", HttpConstants.HTTP_POST); }
public static Endpoint removeUserEndpoint(String streamId) { return new BaseEndpoint("/site/c/" + streamId + "/remove_user.json", HttpConstants.HTTP_POST); }