Search in sources :

Example 16 with TopologyStream

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

the class StreamCatalogService method getStreamInfo.

public TopologyStream getStreamInfo(Long topologyId, Long streamId, Long versionId) {
    TopologyStream topologyStream = new TopologyStream();
    topologyStream.setId(streamId);
    topologyStream.setVersionId(versionId);
    TopologyStream result = dao.get(new StorableKey(STREAMINFO_NAMESPACE, topologyStream.getPrimaryKey()));
    if (result == null || !result.getTopologyId().equals(topologyId)) {
        return null;
    }
    result.setVersionTimestamp(getVersionTimestamp(versionId));
    return result;
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream)

Example 17 with TopologyStream

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

the class StreamCatalogService method fillSourceStreams.

private Collection<TopologySource> fillSourceStreams(Collection<TopologySource> sources) {
    if (sources != null) {
        for (TopologySource source : sources) {
            List<TopologyStream> topologyStreams = getOutputStreams(source);
            source.setOutputStreams(topologyStreams);
            source.setOutputStreamIds(new ArrayList<>(Collections2.transform(topologyStreams, new Function<TopologyStream, Long>() {

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

Example 18 with TopologyStream

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

the class TopologyStreamCatalogResource method getStreamInfoById.

/**
 * <p>
 * Gets the 'CURRENT' version of specific stream by Id. For example,
 * </p>
 * <b>GET /api/v1/catalog/topologies/:TOPOLOGY_ID/streams/:STREAM_ID</b>
 * <pre>
 * {
 *   "responseCode": 1000,
 *   "responseMessage": "Success",
 *   "entity": {
 *     "id": 1,
 *     "topologyId": 1,
 *     "streamId": "a",
 *     "fields": [
 *       {"name": "f1", "type": "STRING", "optional": false},
 *       {"name": "f2", "type": "LONG", "optional": false}
 *       ],
 *     "timestamp": 1463238366216
 *   }
 * }
 * </pre>
 *
 * @param streamId the stream id
 * @return the response
 */
@GET
@Path("/topologies/{topologyId}/streams/{id}")
@Timed
public Response getStreamInfoById(@PathParam("topologyId") Long topologyId, @PathParam("id") Long streamId, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
    TopologyStream topologyStream = catalogService.getStreamInfo(topologyId, streamId);
    if (topologyStream != null) {
        return WSUtils.respondEntity(topologyStream, OK);
    }
    throw EntityNotFoundException.byId(buildMessageForCompositeId(topologyId, streamId));
}
Also used : TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 19 with TopologyStream

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

the class TopologyStreamCatalogResource method addStreamInfo.

/**
 * <p>
 * Creates a stream. For example,
 * </p>
 * <b>POST /api/v1/catalog/topologies/:TOPOLOGY_ID/streams</b>
 * <pre>
 * {
 *   "streamId": "default",
 *   "fields": [
 *     {"name": "f1", "type": "STRING"},
 *     {"name": "f2", "type": "LONG"}
 *   ]
 * }
 * </pre>
 * <i>Sample success response: </i>
 * <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": 1463238366216
 *   }
 * }
 * </pre>
 */
@POST
@Path("/topologies/{topologyId}/streams")
@Timed
public Response addStreamInfo(@PathParam("topologyId") Long topologyId, TopologyStream topologyStream, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
    TopologyStream createdStream = catalogService.addStreamInfo(topologyId, topologyStream);
    return WSUtils.respondEntity(createdStream, CREATED);
}
Also used : TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

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