Search in sources :

Example 1 with StreamSpecification

use of co.cask.cdap.api.data.stream.StreamSpecification in project cdap by caskdata.

the class DefaultDatasetConfigurer method addStream.

@Override
public void addStream(Stream stream) {
    checkArgument(stream != null, "Stream cannot be null.");
    StreamSpecification spec = stream.configure();
    StreamSpecification existingSpec = streams.get(spec.getName());
    if (existingSpec != null && !existingSpec.equals(spec)) {
        throw new IllegalArgumentException(String.format("Stream '%s' was added multiple times with different specs. " + "Please resolve the conflict so that there is only one spec for the stream.", spec.getName()));
    }
    streams.put(spec.getName(), spec);
}
Also used : StreamSpecification(co.cask.cdap.api.data.stream.StreamSpecification)

Example 2 with StreamSpecification

use of co.cask.cdap.api.data.stream.StreamSpecification in project cdap by caskdata.

the class FileStreamAdmin method getProperties.

@Override
public StreamProperties getProperties(StreamId streamId) throws Exception {
    // User should have any access on the stream to read its properties
    ensureAccess(streamId);
    // get the principal which will be used for impersonation to display as owner
    String ownerPrincipal = ownerAdmin.getOwnerPrincipal(streamId);
    StreamConfig config = getConfig(streamId);
    StreamSpecification spec = streamMetaStore.getStream(streamId);
    return new StreamProperties(config.getTTL(), config.getFormat(), config.getNotificationThresholdMB(), spec.getDescription(), ownerPrincipal);
}
Also used : StreamSpecification(co.cask.cdap.api.data.stream.StreamSpecification) StreamProperties(co.cask.cdap.proto.StreamProperties) CoordinatorStreamProperties(co.cask.cdap.data.stream.CoordinatorStreamProperties)

Example 3 with StreamSpecification

use of co.cask.cdap.api.data.stream.StreamSpecification in project cdap by caskdata.

the class InMemoryStreamAdmin method dropAllInNamespace.

@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);
        streamMetaStore.removeStream(stream);
    }
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) StreamSpecification(co.cask.cdap.api.data.stream.StreamSpecification)

Example 4 with StreamSpecification

use of co.cask.cdap.api.data.stream.StreamSpecification 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 5 with StreamSpecification

use of co.cask.cdap.api.data.stream.StreamSpecification in project cdap by caskdata.

the class LocalStreamService method initialize.

@Override
protected void initialize() throws Exception {
    for (Map.Entry<NamespaceId, StreamSpecification> streamSpecEntry : streamMetaStore.listStreams().entries()) {
        StreamId streamId = streamSpecEntry.getKey().stream(streamSpecEntry.getValue().getName());
        StreamConfig config;
        try {
            config = streamAdmin.getConfig(streamId);
        } catch (FileNotFoundException e) {
            // TODO: this kind of inconsistency should not happen. [CDAP-5722]
            LOG.warn("Inconsistent stream state: Stream '{}' exists in meta store " + "but its configuration file does not exist", streamId);
            continue;
        } catch (Exception e) {
            LOG.warn("Inconsistent stream state: Stream '{}' exists in meta store " + "but its configuration cannot be read:", streamId, e);
            continue;
        }
        long eventsSizes = getStreamEventsSize(streamId);
        createSizeAggregator(streamId, eventsSizes, config.getNotificationThresholdMB());
    }
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) StreamSpecification(co.cask.cdap.api.data.stream.StreamSpecification) FileNotFoundException(java.io.FileNotFoundException) StreamConfig(co.cask.cdap.data2.transaction.stream.StreamConfig) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) NotificationFeedException(co.cask.cdap.notifications.feeds.NotificationFeedException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

StreamSpecification (co.cask.cdap.api.data.stream.StreamSpecification)14 StreamId (co.cask.cdap.proto.id.StreamId)7 NamespaceId (co.cask.cdap.proto.id.NamespaceId)6 Map (java.util.Map)4 DatasetCreationSpec (co.cask.cdap.internal.dataset.DatasetCreationSpec)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 Plugin (co.cask.cdap.api.plugin.Plugin)2 StreamConfig (co.cask.cdap.data2.transaction.stream.StreamConfig)2 NotificationFeedException (co.cask.cdap.notifications.feeds.NotificationFeedException)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 ProgramSpecification (co.cask.cdap.api.ProgramSpecification)1 ArtifactId (co.cask.cdap.api.artifact.ArtifactId)1 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)1 DataSetException (co.cask.cdap.api.dataset.DataSetException)1 DatasetSpecification (co.cask.cdap.api.dataset.DatasetSpecification)1 FlowSpecification (co.cask.cdap.api.flow.FlowSpecification)1 MapReduceSpecification (co.cask.cdap.api.mapreduce.MapReduceSpecification)1 ScheduleSpecification (co.cask.cdap.api.schedule.ScheduleSpecification)1 ServiceSpecification (co.cask.cdap.api.service.ServiceSpecification)1