Search in sources :

Example 16 with TopologySource

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));
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 17 with TopologySource

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);
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

Example 18 with TopologySource

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);
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 19 with TopologySource

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));
    }
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Map(java.util.Map)

Aggregations

TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)19 Path (javax.ws.rs.Path)7 Timed (com.codahale.metrics.annotation.Timed)5 TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)4 TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)4 QueryParam (com.hortonworks.registries.common.QueryParam)3 StorableKey (com.hortonworks.registries.storage.StorableKey)3 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)3 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)3 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)3 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)3 TopologyStream (com.hortonworks.streamline.streams.catalog.TopologyStream)3 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)3 Sets (com.google.common.collect.Sets)2 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)2 TopologyBranchRule (com.hortonworks.streamline.streams.catalog.TopologyBranchRule)2 TopologyEdge (com.hortonworks.streamline.streams.catalog.TopologyEdge)2 TopologyRule (com.hortonworks.streamline.streams.catalog.TopologyRule)2 TopologySink (com.hortonworks.streamline.streams.catalog.TopologySink)2 TopologyTestRunCaseSink (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink)2