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;
}
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;
}
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));
}
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);
}
Aggregations