Search in sources :

Example 11 with TopologyStream

use of com.hortonworks.streamline.streams.catalog.TopologyStream in project streamline by hortonworks.

the class TopologyStreamCatalogResource method removeStreamInfo.

/**
 * <p>
 * Removes a stream resource.
 * </p>
 * <b>DELETE /api/v1/catalog/topologies/:TOPOLOGY_ID/streams/:STREAM_ID</b>
 * <pre>
 * {
 *   "responseCode": 1000,
 *   "responseMessage": "Success",
 *   "entity": {
 *     "id": 1,
 *     "streamId": "default",
 *     "topologyId": 1,
 *     "fields": [
 *       {
 *         "name": "f1",
 *         "type": "STRING",
 *         "optional": false
 *       },
 *       {
 *         "name": "f2",
 *         "type": "LONG",
 *         "optional": false
 *       }
 *     ],
 *     "timestamp": 1463238609751
 *   }
 * }
 * </pre>
 */
@DELETE
@Path("/topologies/{topologyId}/streams/{id}")
@Timed
public Response removeStreamInfo(@PathParam("topologyId") Long topologyId, @PathParam("id") Long id, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
    TopologyStream removedStream = catalogService.removeStreamInfo(topologyId, id);
    if (removedStream != null) {
        return WSUtils.respondEntity(removedStream, OK);
    }
    throw EntityNotFoundException.byId(buildMessageForCompositeId(topologyId, id));
}
Also used : TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Example 12 with TopologyStream

use of com.hortonworks.streamline.streams.catalog.TopologyStream in project streamline by hortonworks.

the class TopologyComponentFactory method updateWithSchemas.

private void updateWithSchemas(Long topologyId, Long versionId, Map<String, NormalizationConfig> normalizationConfigRead) {
    for (Map.Entry<String, NormalizationConfig> entry : normalizationConfigRead.entrySet()) {
        NormalizationConfig normalizationConfig = entry.getValue();
        TopologyStream topologyStream = catalogService.getStreamInfoByName(topologyId, entry.getKey(), versionId);
        if (topologyStream != null) {
            normalizationConfig.setInputSchema(topologyStream.getSchema());
        }
    }
}
Also used : NormalizationConfig(com.hortonworks.streamline.streams.layout.component.impl.normalization.NormalizationConfig) TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 13 with TopologyStream

use of com.hortonworks.streamline.streams.catalog.TopologyStream in project streamline by hortonworks.

the class StreamCatalogService method createProcessorStreamMapping.

private void createProcessorStreamMapping(TopologyProcessor topologyProcessor, List<TopologyStream> streams) {
    for (TopologyStream outputStream : streams) {
        TopologyStream addedStream = addStreamInfo(topologyProcessor.getTopologyId(), outputStream);
        dao.<TopologyProcessorStreamMap>add(new TopologyProcessorStreamMap(topologyProcessor.getId(), topologyProcessor.getVersionId(), addedStream.getId()));
    }
}
Also used : TopologyProcessorStreamMap(com.hortonworks.streamline.streams.catalog.TopologyProcessorStreamMap) TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream)

Example 14 with TopologyStream

use of com.hortonworks.streamline.streams.catalog.TopologyStream in project streamline by hortonworks.

the class StreamCatalogService method fillProcessorStreams.

private Collection<TopologyProcessor> fillProcessorStreams(Collection<TopologyProcessor> processors) {
    if (processors != null) {
        for (TopologyProcessor processor : processors) {
            List<TopologyStream> topologyStreams = getOutputStreams(processor);
            processor.setOutputStreams(topologyStreams);
            processor.setOutputStreamIds(new ArrayList<>(Collections2.transform(topologyStreams, new Function<TopologyStream, Long>() {

                @Nullable
                @Override
                public Long apply(@Nullable TopologyStream input) {
                    return input.getId();
                }
            })));
        }
    }
    return processors;
}
Also used : TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) Nullable(javax.annotation.Nullable)

Example 15 with TopologyStream

use of com.hortonworks.streamline.streams.catalog.TopologyStream in project streamline by hortonworks.

the class StreamCatalogService method addOrUpdateStreamInfo.

public TopologyStream addOrUpdateStreamInfo(Long topologyId, Long id, TopologyStream stream) {
    stream.setId(id);
    Long currentVersionId = getCurrentVersionId(topologyId);
    stream.setVersionId(currentVersionId);
    stream.setTopologyId(topologyId);
    long timestamp = System.currentTimeMillis();
    stream.setVersionTimestamp(timestamp);
    validateStreamInfo(stream);
    TopologyStream curStream = getStreamInfo(topologyId, stream.getId());
    if (!curStream.getFields().equals(stream.getFields())) {
        setReconfigureTarget(stream);
    }
    dao.addOrUpdate(stream);
    updateVersionTimestamp(currentVersionId, timestamp);
    return stream;
}
Also used : TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream)

Aggregations

TopologyStream (com.hortonworks.streamline.streams.catalog.TopologyStream)19 ArrayList (java.util.ArrayList)6 Timed (com.codahale.metrics.annotation.Timed)4 QueryParam (com.hortonworks.registries.common.QueryParam)4 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)4 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)4 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)4 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)4 Path (javax.ws.rs.Path)4 StorableKey (com.hortonworks.registries.storage.StorableKey)3 TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)3 TopologyProcessorStreamMap (com.hortonworks.streamline.streams.catalog.TopologyProcessorStreamMap)3 TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)3 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)2 TopologyBranchRule (com.hortonworks.streamline.streams.catalog.TopologyBranchRule)2 TopologyComponent (com.hortonworks.streamline.streams.catalog.TopologyComponent)2 TopologyEdge (com.hortonworks.streamline.streams.catalog.TopologyEdge)2 StreamGrouping (com.hortonworks.streamline.streams.catalog.TopologyEdge.StreamGrouping)2 TopologyOutputComponent (com.hortonworks.streamline.streams.catalog.TopologyOutputComponent)2 TopologyRule (com.hortonworks.streamline.streams.catalog.TopologyRule)2