/** * Returns a {@link StreamManager} for the specified stream in the default namespace * * @param streamName the specified stream * @return {@link StreamManager} for the specified stream in the default namespace */ protected final StreamManager getStreamManager(String streamName) { return getStreamManager(NamespaceId.DEFAULT.stream(streamName)); }
public StreamInputFormatProvider(NamespaceId namespaceId, Input.StreamInput streamInput, StreamAdmin streamAdmin) { this.streamId = namespaceId.stream(streamInput.getName()); this.streamInput = streamInput; this.streamAdmin = streamAdmin; }
@Override public EntityId apply(StreamSpecification input) { return namespaceId.stream(input.getName()); } }, null);
@Override public EntityId apply(StreamDetail input) { return appId.getNamespaceId().stream(input.getName()); } }, null);
@Override public Void call() throws Exception { String namespace = String.format("%s.%s", programId.getApplication(), programId.getProgram()); NamespaceId namespaceId = programId.getNamespaceId(); for (Map.Entry<String, Collection<Long>> entry : streamGroups.asMap().entrySet()) { streamConsumerFactory.dropAll(namespaceId.stream(entry.getKey()), namespace, entry.getValue()); } queueAdmin.dropAllForFlow(programId.getParent().flow(programId.getEntityName())); return null; } });
@Override public Void call() throws Exception { if (streamAdmin.create(namespaceId.stream(spec.getName()), props) != null) { LOG.info("Stream '{}.{}' created successfully.", namespaceId.getNamespace(), spec.getName()); } return null; } });
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); File file = new File(arguments.get(ArgumentName.LOCAL_FILE_PATH.toString())); if (!file.isFile()) { throw new IllegalArgumentException("Not a file: " + file); } StreamProperties streamProperties; try (Reader reader = Files.newReader(file, Charsets.UTF_8)) { streamProperties = GSON.fromJson(reader, StreamProperties.class); } catch (Exception e) { throw new IllegalArgumentException("Stream properties are malformed.", e); } streamClient.setStreamProperties(streamId, streamProperties); output.printf("Successfully set properties of 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.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()); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { String streamId = arguments.get(ArgumentName.NEW_STREAM.toString()); StreamProperties streamProperties = null; if (arguments.hasArgument(ArgumentName.LOCAL_FILE_PATH.toString())) { File file = new File(arguments.get(ArgumentName.LOCAL_FILE_PATH.toString())); try (Reader reader = Files.newReader(file, Charsets.UTF_8)) { streamProperties = GSON.fromJson(reader, StreamProperties.class); } catch (FileNotFoundException e) { throw new IllegalArgumentException("Not a file: " + file); } catch (Exception e) { throw new IllegalArgumentException("Stream properties are malformed.", e); } } streamClient.create(cliConfig.getCurrentNamespace().stream(streamId), streamProperties); output.printf("Successfully created stream with ID '%s'\n", streamId); }
@Override public void dropAllInNamespace(NamespaceId namespace) throws Exception { for (StreamSpecification stream : delegate.listStreams(namespace)) { ensureAccess(namespace.stream(stream.getName()), Action.ADMIN); } delegate.dropAllInNamespace(namespace); }
@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())); 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 void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); StreamViewId view = streamId.view(arguments.get(ArgumentName.VIEW.toString())); client.delete(view); output.printf("Successfully deleted stream-view '%s'\n", view.getEntityName()); }
@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); }
@Override public void dropAllInNamespace(NamespaceId namespace) throws Exception { queueService.resetStreamsWithPrefix(QueueName.prefixForNamedspacedStream(namespace.getNamespace())); for (StreamSpecification spec : streamMetaStore.listStreams(namespace)) { // Remove metadata for the stream StreamId stream = namespace.stream(spec.getName()); metadataStore.removeMetadata(stream.toMetadataEntity()); streamMetaStore.removeStream(stream); } }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); StreamProperties config = streamClient.getConfig(streamId); Table table = Table.builder() .setHeader("ttl", "format", "schema", "notification.threshold.mb", "description") .setRows(ImmutableList.of(config), new RowMaker<StreamProperties>() { @Override public List<?> makeRow(StreamProperties object) { FormatSpecification format = object.getFormat(); return Lists.newArrayList(object.getTTL(), format.getName(), format.getSchema().toString(), object.getNotificationThresholdMB(), object.getDescription()); } }).build(); cliConfig.getTableRenderer().render(cliConfig, output, table); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); ViewDetail detail = client.get(streamId.view(arguments.get(ArgumentName.VIEW.toString()))); Table table = Table.builder() .setHeader("id", "format", "table", "schema", "settings") .setRows(Collections.singletonList(detail), new RowMaker<ViewDetail>() { @Override public List<?> makeRow(ViewDetail object) { return Lists.newArrayList(object.getId(), object.getFormat().getName(), object.getTableName(), GSON.toJson(object.getFormat().getSchema()), GSON.toJson(object.getFormat().getSettings())); } }).build(); cliConfig.getTableRenderer().render(cliConfig, output, table); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString())); List<String> views = client.list(streamId); Table table = Table.builder() .setHeader("id") .setRows(views, new RowMaker<String>() { @Override public List<?> makeRow(String object) { return Lists.newArrayList(object); } }).build(); cliConfig.getTableRenderer().render(cliConfig, output, table); }