use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologySourceCatalogResource method getTopologySourceById.
/**
* <p>
* Gets the 'CURRENT' version of specific topology source by Id. For example,
* </p>
* <b>GET /api/v1/catalog/topologies/:TOPOLOGY_ID/sources/:SOURCE_ID</b>
* <pre>
* {
* "responseCode": 1000,
* "responseMessage": "Success",
* "entity": {
* "id": 1,
* "topologyId": 1,
* "name": "kafkaDataSource",
* "config": {
* "properties": {
* "zkUrl": "localhost:2181",
* "zkPath": "/brokers",
* "refreshFreqSecs": 60
* }
* },
* "type": "KAFKA",
* "outputStreams": [{stream1 data..}, {stream2 data..}]
* }
* }
* </pre>
*/
@GET
@Path("/topologies/{topologyId}/sources/{id}")
@Timed
public Response getTopologySourceById(@PathParam("topologyId") Long topologyId, @PathParam("id") Long sourceId, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
TopologySource source = catalogService.getTopologySource(topologyId, sourceId);
if (source != null) {
return WSUtils.respondEntity(source, OK);
}
throw EntityNotFoundException.byId(buildMessageForCompositeId(topologyId, sourceId));
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologySourceCatalogResource method addTopologySource.
/**
* <p>
* Creates a topology source. For example,
* </p>
* <b>POST /api/v1/catalog/topologies/:TOPOLOGY_ID/sources</b>
* <pre>
* {
* "name": "kafkaDataSource",
* "config": {
* "properties": {
* "zkUrl": "localhost:2181",
* "zkPath": "/brokers",
* "refreshFreqSecs": 60
* }
* },
* "type": "KAFKA",
*
* "outputStreamIds": [1]
* OR
* "outputStreams" : [{stream1 data..}, {stream2 data..}]
* }
* </pre>
* <i>Sample success response: </i>
* <pre>
* {
* "responseCode": 1000,
* "responseMessage": "Success",
* "entity": {
* "id": 1,
* "topologyId": 1,
* "name": "kafkaDataSource",
* "config": {
* "properties": {
* "zkUrl": "localhost:2181",
* "zkPath": "/brokers",
* "refreshFreqSecs": 60
* }
* },
* "type": "KAFKA",
* "outputStreamIds": [1] OR "outputStreams" : {..}
* }
* }
* </pre>
*/
@POST
@Path("/topologies/{topologyId}/sources")
@Timed
public Response addTopologySource(@PathParam("topologyId") Long topologyId, TopologySource topologySource, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
TopologySource createdSource = catalogService.addTopologySource(topologyId, topologySource);
return WSUtils.respondEntity(createdSource, CREATED);
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologySourceCatalogResource method addOrUpdateTopologySource.
/**
* <p>Updates a topology source.</p>
* <p>
* <b>PUT /api/v1/catalog/topologies/:TOPOLOGY_ID/sources/:SOURCE_ID</b>
* <pre>
* {
* "name": "kafkaDataSource",
* "config": {
* "properties": {
* "zkUrl": "localhost:2181",
* "zkPath": "/brokers",
* "refreshFreqSecs": 120
* }
* },
* "type": "KAFKA",
* "outputStreamIds": [1]
* }
* </pre>
* <i>Sample success response: </i>
* <pre>
* {
* "responseCode": 1000,
* "responseMessage": "Success",
* "entity": {
* "id": 1,
* "topologyId": 1,
* "name": "kafkaDataSource",
* "config": {
* "properties": {
* "zkUrl": "localhost:2181",
* "zkPath": "/brokers",
* "refreshFreqSecs": 120
* }
* },
* "type": "KAFKA",
* "outputStreamIds": [1]
* }
* }
* </pre>
*/
@PUT
@Path("/topologies/{topologyId}/sources/{id}")
@Timed
public Response addOrUpdateTopologySource(@PathParam("topologyId") Long topologyId, @PathParam("id") Long sourceId, TopologySource topologySource, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
TopologySource createdTopologySource = catalogService.addOrUpdateTopologySource(topologyId, sourceId, topologySource);
return WSUtils.respondEntity(createdTopologySource, CREATED);
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologyTestRunResource method doValidationForTestRunCaseSource.
// this will throw exception if schema validation fails on any records
private void doValidationForTestRunCaseSource(Long topologyId, Long testCaseId, TopologyTestRunCaseSource testRunCaseSource) throws IOException {
TopologySource topologySource = getAssociatedTopologySource(topologyId, testCaseId, testRunCaseSource.getSourceId());
Map<String, String> map = objectMapper.readValue(testRunCaseSource.getRecords(), new TypeReference<Map<String, String>>() {
});
for (Map.Entry<String, String> entry : map.entrySet()) {
List<Map<String, Object>> values = objectMapper.readValue(entry.getValue(), new TypeReference<List<Map<String, Object>>>() {
});
values.forEach(v -> convertValueToConformStream(topologySource.getOutputStreams(), entry.getKey(), v));
}
}
Aggregations