@Override public void addStream(StreamId streamId) throws Exception { streams.put(streamId.getNamespace(), streamId.getEntityName()); }
private ExecutorService createScanExecutor(StreamId streamId) { ThreadFactory threadFactory = Threads.newDaemonThreadFactory(String.format("stream-%s-%s-consumer-scanner-", streamId.getNamespace(), streamId.getEntityName())); ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 20, 60, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), threadFactory); executor.allowCoreThreadTimeOut(true); return executor; } }
protected StreamSizeAggregator(StreamId streamId, long baseCount, int streamThresholdMB, Cancellable cancellable) { this.streamWriterSizes = Maps.newHashMap(); this.streamBaseCount = new AtomicLong(baseCount); this.streamInitSize = baseCount; this.streamThresholdMB = new AtomicInteger(streamThresholdMB); this.cancellable = cancellable; this.streamId = streamId; this.streamFeed = new NotificationFeedId(streamId.getNamespace(), Constants.Notification.Stream.STREAM_FEED_CATEGORY, String.format("%sSize", streamId.getEntityName())); }
protected StreamSizeAggregator(StreamId streamId, long baseCount, int streamThresholdMB, Cancellable cancellable) { this.streamId = streamId; this.streamInitSize = baseCount; this.streamBaseCount = new AtomicLong(baseCount); this.cancellable = cancellable; this.streamFeed = new NotificationFeedId( streamId.getNamespace(), Constants.Notification.Stream.STREAM_FEED_CATEGORY, String.format("%sSize", streamId.getEntityName())); this.streamThresholdMB = new AtomicInteger(streamThresholdMB); }
/** * Creates a {@link ContentWriterFactory} based on the request size. Used by the batch endpoint. */ private ContentWriterFactory createContentWriterFactory(StreamId streamId, HttpRequest request) throws IOException { String contentType = request.headers().get(HttpHeaderNames.CONTENT_TYPE, ""); // The content-type is guaranteed to be non-empty, otherwise the batch request itself will fail. Map<String, String> headers = getHeaders(request, streamId.getEntityName(), ImmutableMap.<String, String>builder().put("content.type", contentType)); StreamConfig config = streamAdmin.getConfig(streamId); return new LengthBasedContentWriterFactory(config, streamWriter, headers, batchBufferThreshold, impersonator); }
public static QueueName fromStream(StreamId streamId) { return fromStream(streamId.getNamespace(), streamId.getEntityName()); }
@Override public boolean streamExists(StreamId streamId) throws Exception { return streams.containsEntry(streamId.getNamespace(), streamId.getEntityName()); }
protected QueryHandle doEnableExploreStream(StreamId stream, String tableName, FormatSpecification format) throws ExploreException { HttpResponse response = doPost(String.format( "namespaces/%s/data/explore/streams/%s/tables/%s/enable", stream.getNamespace(), stream.getEntityName(), tableName), format == null ? null : GSON.toJson(format), null); if (response.getResponseCode() == HttpURLConnection.HTTP_OK) { return QueryHandle.fromId(parseResponseAsMap(response, "handle")); } throw new ExploreException(String.format("Cannot enable explore on stream %s with table %s. Reason: %s", stream.getEntityName(), tableName, response)); }
protected QueryHandle doDisableExploreStream(StreamId stream, String tableName) throws ExploreException { HttpResponse response = doPost(String.format("namespaces/%s/data/explore/streams/%s/tables/%s/disable", stream.getNamespace(), stream.getEntityName(), tableName), null, null); if (response.getResponseCode() == HttpURLConnection.HTTP_OK) { return QueryHandle.fromId(parseResponseAsMap(response, "handle")); } throw new ExploreException(String.format("Cannot disable explore on stream %s with table %s. Reason: %s", stream.getEntityName(), tableName, response)); }
/** * Returns the location for the given stream. */ private Location getStreamLocation(StreamId streamId) throws IOException { return getStreamBaseLocation(streamId.getParent()).append(streamId.getEntityName()); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); streamClient.delete(streamId); output.printf("Successfully deleted stream '%s'\n", streamId.getEntityName()); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); streamClient.truncate(streamId); output.printf("Successfully truncated stream '%s'\n", streamId.getEntityName()); }
private void addStream(MDSKey.Builder keyBuilder, StreamId stream) { keyBuilder.add(STREAM_MARKER) .add(stream.getNamespace()) .add(stream.getEntityName()); }
@Override public StreamSpecification getStream(StreamId streamId) throws Exception { if (!streamExists(streamId)) { return null; } return new StreamSpecification.Builder().setName(streamId.getEntityName()).create(); }
private MDSKey getKey(StreamId id) { return new MDSKey.Builder() .add(TYPE_STREAM_VIEW, id.getNamespace(), id.getEntityName()) .build(); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); String streamEvent = arguments.get(ArgumentName.STREAM_EVENT.toString()); streamClient.sendEvent(streamId, streamEvent); output.printf("Successfully sent stream event to stream '%s'\n", streamId.getEntityName()); }
@Override public MDSKey getKey(StreamId streamId) { return new MDSKey.Builder() .add(streamId.getNamespace()) .add(streamId.getEntityName()) .build(); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); long ttlInSeconds = arguments.getLong(ArgumentName.TTL_IN_SECONDS.toString()); streamClient.setTTL(streamId, ttlInSeconds); output.printf("Successfully set TTL of stream '%s' to %d\n", streamId.getEntityName(), ttlInSeconds); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); String description = arguments.get(ArgumentName.STREAM_DESCRIPTION.toString()); streamClient.setDescription(streamId, description); output.printf("Successfully set stream description of stream '%s' to '%s'\n", streamId.getEntityName(), description); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); int notificationThresholdMB = arguments.getInt(ArgumentName.NOTIFICATION_THRESHOLD_MB.toString()); streamClient.setStreamProperties(streamId, new StreamProperties(null, null, notificationThresholdMB)); output.printf("Successfully set notification threshold of stream '%s' to %dMB\n", streamId.getEntityName(), notificationThresholdMB); }