use of co.cask.cdap.proto.id.StreamId in project cdap by caskdata.
the class ExistingEntitySystemMetadataWriter method writeSystemMetadataForStreams.
private void writeSystemMetadataForStreams(NamespaceId namespace) throws Exception {
for (StreamSpecification streamSpec : store.getAllStreams(namespace)) {
StreamId streamId = namespace.stream(streamSpec.getName());
SystemMetadataWriter writer = new StreamSystemMetadataWriter(metadataStore, streamId, streamAdmin.getConfig(streamId), streamSpec.getDescription());
writer.write();
for (StreamViewId view : streamAdmin.listViews(streamId)) {
writer = new ViewSystemMetadataWriter(metadataStore, view, viewAdmin.get(view), true);
writer.write();
}
}
}
use of co.cask.cdap.proto.id.StreamId in project cdap by caskdata.
the class RemoteLineageWriterTest method testSimpleCase.
@Test
public void testSimpleCase() {
long now = System.currentTimeMillis();
ApplicationId appId = NamespaceId.DEFAULT.app("test_app");
ProgramId flowId = appId.flow("test_flow");
ProgramRunId runId = flowId.run(RunIds.generate(now).getId());
RunId twillRunId = RunIds.fromString(runId.getRun());
DatasetId datasetId = NamespaceId.DEFAULT.dataset("test_dataset");
StreamId streamId = NamespaceId.DEFAULT.stream("test_stream");
Set<Relation> expectedRelations = new HashSet<>();
// test null serialization
remoteLineageWriter.addAccess(runId, datasetId, AccessType.READ, null);
expectedRelations.add(new Relation(datasetId, flowId, AccessType.READ, twillRunId));
Assert.assertEquals(ImmutableSet.of(flowId, datasetId), lineageStore.getEntitiesForRun(runId));
Assert.assertEquals(expectedRelations, lineageStore.getRelations(flowId, now, now + 1, Predicates.<Relation>alwaysTrue()));
remoteLineageWriter.addAccess(runId, streamId, AccessType.READ);
expectedRelations.add(new Relation(streamId, flowId, AccessType.READ, twillRunId));
Assert.assertEquals(expectedRelations, lineageStore.getRelations(flowId, now, now + 1, Predicates.<Relation>alwaysTrue()));
remoteLineageWriter.addAccess(runId, streamId, AccessType.WRITE);
expectedRelations.add(new Relation(streamId, flowId, AccessType.WRITE, twillRunId));
Assert.assertEquals(expectedRelations, lineageStore.getRelations(flowId, now, now + 1, Predicates.<Relation>alwaysTrue()));
}
use of co.cask.cdap.proto.id.StreamId in project cdap by caskdata.
the class SetStreamPropertiesCommand method perform.
@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());
}
use of co.cask.cdap.proto.id.StreamId in project cdap by caskdata.
the class SetStreamTTLCommand method perform.
@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);
}
use of co.cask.cdap.proto.id.StreamId in project cdap by caskdata.
the class TruncateStreamCommand method perform.
@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());
}
Aggregations