Search in sources :

Example 1 with TopologySource

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

the class TopologySourceCatalogResource method getTopologySourceByIdAndVersion.

@GET
@Path("/topologies/{topologyId}/versions/{versionId}/sources/{id}")
@Timed
public Response getTopologySourceByIdAndVersion(@PathParam("topologyId") Long topologyId, @PathParam("id") Long sourceId, @PathParam("versionId") Long versionId, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
    TopologySource source = catalogService.getTopologySource(topologyId, sourceId, versionId);
    if (source != null) {
        return WSUtils.respondEntity(source, OK);
    }
    throw EntityNotFoundException.byVersion(buildMessageForCompositeId(topologyId, sourceId), versionId.toString());
}
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 2 with TopologySource

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

the class TopologySourceCatalogResource method removeTopologySource.

/**
 * <p>
 * Removes a topology source.
 * </p>
 * <b>DELETE /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>
 */
@DELETE
@Path("/topologies/{topologyId}/sources/{id}")
@Timed
public Response removeTopologySource(@PathParam("topologyId") Long topologyId, @PathParam("id") Long sourceId, @javax.ws.rs.QueryParam("removeEdges") boolean removeEdges, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
    TopologySource topologySource = catalogService.removeTopologySource(topologyId, sourceId, removeEdges);
    if (topologySource != null) {
        return WSUtils.respondEntity(topologySource, OK);
    }
    throw EntityNotFoundException.byId(buildMessageForCompositeId(topologyId, sourceId));
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with TopologySource

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

the class TopologyTestRunResource method addOrUpdateTestRunCaseSource.

@PUT
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sources/{id}")
public Response addOrUpdateTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @PathParam("id") Long id, TopologyTestRunCaseSource testRunCaseSource, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE);
    testRunCaseSource.setId(id);
    testRunCaseSource.setTestCaseId(testCaseId);
    TopologySource topologySource = getAssociatedTopologySource(topologyId, testCaseId, testRunCaseSource.getSourceId());
    testRunCaseSource.setVersionId(topologySource.getVersionId());
    TopologyTestRunCaseSource updatedCase = catalogService.addOrUpdateTopologyTestRunCaseSource(testRunCaseSource.getId(), testRunCaseSource);
    return WSUtils.respondEntity(updatedCase, OK);
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 4 with TopologySource

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

the class TopologyTestRunResource method getAssociatedTopologySource.

private TopologySource getAssociatedTopologySource(Long topologyId, Long testCaseId, Long topologySourceId) {
    TopologyTestRunCase testCase = catalogService.getTopologyTestRunCase(topologyId, testCaseId);
    if (testCase == null) {
        throw EntityNotFoundException.byId("Topology test case with topology id " + topologyId + " and test case id " + testCaseId);
    }
    TopologySource topologySource = catalogService.getTopologySource(topologyId, topologySourceId, testCase.getVersionId());
    if (topologySource == null) {
        throw EntityNotFoundException.byId("Topology source with topology id " + topologyId + " and version id " + testCase.getVersionId());
    } else if (!testCase.getVersionId().equals(topologySource.getVersionId())) {
        throw new IllegalStateException("Test case and topology source point to the different version id: " + "version id of test case: " + testCase.getVersionId() + " / " + "version id of topology source: " + topologySource.getVersionId());
    }
    return topologySource;
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)

Example 5 with TopologySource

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

the class TopologyTestRunResource method addTestRunCaseSource.

@POST
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sources")
public Response addTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, TopologyTestRunCaseSource testRunCaseSource, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE);
    TopologySource topologySource = getAssociatedTopologySource(topologyId, testCaseId, testRunCaseSource.getSourceId());
    testRunCaseSource.setVersionId(topologySource.getVersionId());
    TopologyTestRunCaseSource addedCaseSource = catalogService.addTopologyTestRunCaseSource(testRunCaseSource);
    return WSUtils.respondEntity(addedCaseSource, CREATED);
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

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