Search in sources :

Example 41 with StreamId

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();
        }
    }
}
Also used : StreamSystemMetadataWriter(co.cask.cdap.data2.metadata.system.StreamSystemMetadataWriter) StreamId(co.cask.cdap.proto.id.StreamId) ViewSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ViewSystemMetadataWriter) StreamSpecification(co.cask.cdap.api.data.stream.StreamSpecification) DatasetSystemMetadataWriter(co.cask.cdap.data2.metadata.system.DatasetSystemMetadataWriter) ProgramSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ProgramSystemMetadataWriter) ViewSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ViewSystemMetadataWriter) SystemMetadataWriter(co.cask.cdap.data2.metadata.system.SystemMetadataWriter) AppSystemMetadataWriter(co.cask.cdap.data2.metadata.system.AppSystemMetadataWriter) ArtifactSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ArtifactSystemMetadataWriter) StreamSystemMetadataWriter(co.cask.cdap.data2.metadata.system.StreamSystemMetadataWriter) StreamViewId(co.cask.cdap.proto.id.StreamViewId)

Example 42 with StreamId

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()));
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) Relation(co.cask.cdap.data2.metadata.lineage.Relation) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) ApplicationId(co.cask.cdap.proto.id.ApplicationId) ProgramId(co.cask.cdap.proto.id.ProgramId) RunId(org.apache.twill.api.RunId) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) DatasetId(co.cask.cdap.proto.id.DatasetId) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 43 with StreamId

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());
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) StreamProperties(co.cask.cdap.proto.StreamProperties) Reader(java.io.Reader) File(java.io.File)

Example 44 with StreamId

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);
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId)

Example 45 with StreamId

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());
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId)

Aggregations

StreamId (co.cask.cdap.proto.id.StreamId)166 Test (org.junit.Test)88 DatasetId (co.cask.cdap.proto.id.DatasetId)33 ProgramId (co.cask.cdap.proto.id.ProgramId)30 NamespaceId (co.cask.cdap.proto.id.NamespaceId)27 Path (javax.ws.rs.Path)27 StreamEvent (co.cask.cdap.api.flow.flowlet.StreamEvent)24 ApplicationId (co.cask.cdap.proto.id.ApplicationId)22 IOException (java.io.IOException)20 StreamProperties (co.cask.cdap.proto.StreamProperties)17 FormatSpecification (co.cask.cdap.api.data.format.FormatSpecification)16 StreamViewId (co.cask.cdap.proto.id.StreamViewId)16 Location (org.apache.twill.filesystem.Location)15 StreamConfig (co.cask.cdap.data2.transaction.stream.StreamConfig)12 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)12 StreamAdmin (co.cask.cdap.data2.transaction.stream.StreamAdmin)11 ViewSpecification (co.cask.cdap.proto.ViewSpecification)10 MetadataSearchResultRecord (co.cask.cdap.proto.metadata.MetadataSearchResultRecord)10 Action (co.cask.cdap.proto.security.Action)10 GET (javax.ws.rs.GET)10