Search in sources :

Example 1 with TopologySink

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

the class TopologySinkCatalogResource method addOrUpdateTopologySink.

/**
 * <p>Updates a topology sink.</p>
 * <p>
 * <b>PUT /api/v1/catalog/topologies/:TOPOLOGY_ID/sources/:SINK_ID</b>
 * <pre>
 * {
 *   "name": "hbasesinkTest",
 *   "config": {
 *     "properties": {
 *       "fsUrl": "hdfs://localhost:9000"
 *     }
 *   },
 *   "type": "HBASE"
 * }
 * </pre>
 * <i>Sample success response: </i>
 * <pre>
 * {
 *   "responseCode": 1000,
 *   "responseMessage": "Success",
 *   "entity": {
 *     "id": 1,
 *     "topologyId": 1,
 *     "name": "hbasesinkTest",
 *     "config": {
 *       "properties": {
 *         "fsUrl": "hdfs://localhost:9000"
 *       }
 *     },
 *     "type": "HBASE"
 *   }
 * }
 * </pre>
 */
@PUT
@Path("/topologies/{topologyId}/sinks/{id}")
@Timed
public Response addOrUpdateTopologySink(@PathParam("topologyId") Long topologyId, @PathParam("id") Long sinkId, TopologySink topologySink, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
    TopologySink createdTopologySink = catalogService.addOrUpdateTopologySink(topologyId, sinkId, topologySink);
    return WSUtils.respondEntity(createdTopologySink, CREATED);
}
Also used : TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 2 with TopologySink

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

the class TopologySinkCatalogResource method removeTopologySink.

/**
 * <p>
 * Removes a topology sink.
 * </p>
 * <b>DELETE /api/v1/catalog/topologies/:TOPOLOGY_ID/sources/:SINK_ID</b>
 * <pre>
 * {
 *   "responseCode": 1000,
 *   "responseMessage": "Success",
 *   "entity": {
 *     "id": 1,
 *     "topologyId": 1,
 *     "name": "hbasesink",
 *     "config": {
 *       "properties": {
 *         "fsUrl": "hdfs://localhost:9000"
 *       }
 *     },
 *     "type": "HBASE"
 *   }
 * }
 * </pre>
 */
@DELETE
@Path("/topologies/{topologyId}/sinks/{id}")
@Timed
public Response removeTopologySink(@PathParam("topologyId") Long topologyId, @PathParam("id") Long sinkId, @javax.ws.rs.QueryParam("removeEdges") boolean removeEdges, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
    TopologySink topologySink = catalogService.removeTopologySink(topologyId, sinkId, removeEdges);
    if (topologySink != null) {
        return WSUtils.respondEntity(topologySink, OK);
    }
    throw EntityNotFoundException.byId(buildMessageForCompositeId(topologyId, sinkId));
}
Also used : TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with TopologySink

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

the class StreamCatalogService method copyTopologyDependencies.

private void copyTopologyDependencies(Long topologyId, Long oldVersionId, Long newVersionId) throws Exception {
    List<QueryParam> topologyIdVersionIdQueryParams = WSUtils.buildTopologyIdAndVersionIdAwareQueryParams(topologyId, oldVersionId, null);
    // topology editor metadata
    TopologyEditorMetadata metadata = getTopologyEditorMetadata(topologyId, oldVersionId);
    if (metadata != null) {
        addTopologyEditorMetadata(topologyId, newVersionId, new TopologyEditorMetadata(metadata));
    }
    // sources, output streams
    Collection<TopologySource> sources = listTopologySources(topologyIdVersionIdQueryParams);
    for (TopologySource source : sources) {
        addTopologySource(topologyId, newVersionId, new TopologySource(source));
    }
    // processors, output streams
    Collection<TopologyProcessor> processors = listTopologyProcessors(topologyIdVersionIdQueryParams);
    for (TopologyProcessor processor : processors) {
        addTopologyProcessor(topologyId, newVersionId, new TopologyProcessor(processor));
    }
    // add sinks
    Collection<TopologySink> sinks = listTopologySinks(topologyIdVersionIdQueryParams);
    for (TopologySink sink : sinks) {
        addTopologySink(topologyId, newVersionId, new TopologySink(sink));
    }
    // branch rules
    Collection<TopologyBranchRule> topologyBranchRules = listBranchRules(topologyIdVersionIdQueryParams);
    for (TopologyBranchRule topologyBranchRule : topologyBranchRules) {
        addBranchRule(topologyId, newVersionId, new TopologyBranchRule(topologyBranchRule));
    }
    // windowed rules
    Collection<TopologyWindow> topologyWindows = listWindows(topologyIdVersionIdQueryParams);
    for (TopologyWindow topologyWindow : topologyWindows) {
        addWindow(topologyId, newVersionId, new TopologyWindow(topologyWindow));
    }
    // rules
    Collection<TopologyRule> topologyRules = listRules(topologyIdVersionIdQueryParams);
    for (TopologyRule topologyRule : topologyRules) {
        addRule(topologyId, newVersionId, new TopologyRule(topologyRule));
    }
    // add edges
    Collection<TopologyEdge> edges = listTopologyEdges(topologyIdVersionIdQueryParams);
    for (TopologyEdge edge : edges) {
        addTopologyEdge(topologyId, newVersionId, new TopologyEdge(edge));
    }
    // add topology test run case
    Collection<TopologyTestRunCase> runCases = listTopologyTestRunCase(topologyIdVersionIdQueryParams);
    for (TopologyTestRunCase runCase : runCases) {
        Collection<TopologyTestRunCaseSource> runCaseSources = listTopologyTestRunCaseSource(runCase.getId());
        Collection<TopologyTestRunCaseSink> runCaseSinks = listTopologyTestRunCaseSink(runCase.getId());
        TopologyTestRunCase newCase = addTopologyTestRunCase(topologyId, newVersionId, new TopologyTestRunCase(runCase));
        // add topology test run case source
        for (TopologyTestRunCaseSource runCaseSource : runCaseSources) {
            addTopologyTestRunCaseSource(newCase.getId(), newVersionId, new TopologyTestRunCaseSource(runCaseSource));
        }
        // add topology test run case sink
        for (TopologyTestRunCaseSink runCaseSink : runCaseSinks) {
            addTopologyTestRunCaseSink(newCase.getId(), newVersionId, new TopologyTestRunCaseSink(runCaseSink));
        }
    }
}
Also used : TopologyWindow(com.hortonworks.streamline.streams.catalog.TopologyWindow) TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) TopologyBranchRule(com.hortonworks.streamline.streams.catalog.TopologyBranchRule) TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) TopologyEditorMetadata(com.hortonworks.streamline.streams.catalog.TopologyEditorMetadata) TopologyRule(com.hortonworks.streamline.streams.catalog.TopologyRule) BaseTopologyRule(com.hortonworks.streamline.streams.catalog.BaseTopologyRule) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) QueryParam(com.hortonworks.registries.common.QueryParam) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor)

Example 4 with TopologySink

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

the class StreamCatalogService method getTopologySink.

public TopologySink getTopologySink(Long topologyId, Long sinkId, Long versionId) {
    TopologySink topologySink = new TopologySink();
    topologySink.setId(sinkId);
    topologySink.setVersionId(versionId);
    TopologySink sink = dao.get(new StorableKey(TOPOLOGY_SINK_NAMESPACE, topologySink.getPrimaryKey()));
    if (sink == null || !sink.getTopologyId().equals(topologyId)) {
        return null;
    }
    sink.setVersionTimestamp(getVersionTimestamp(versionId));
    return sink;
}
Also used : TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) StorableKey(com.hortonworks.registries.storage.StorableKey)

Example 5 with TopologySink

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

the class StreamCatalogService method removeTopologyDependencies.

private void removeTopologyDependencies(Long topologyId, Long versionId) throws Exception {
    List<QueryParam> topologyIdVersionIdQueryParams = WSUtils.buildTopologyIdAndVersionIdAwareQueryParams(topologyId, versionId, null);
    // remove topology test histories
    Collection<TopologyTestRunHistory> runHistories = listTopologyTestRunHistory(topologyId, versionId);
    runHistories.forEach(history -> removeTopologyTestRunHistory(history.getId()));
    // remove topology test run case
    Collection<TopologyTestRunCase> runCases = listTopologyTestRunCase(topologyIdVersionIdQueryParams);
    for (TopologyTestRunCase runCase : runCases) {
        Collection<TopologyTestRunCaseSource> runCaseSources = listTopologyTestRunCaseSource(runCase.getId());
        Collection<TopologyTestRunCaseSink> runCaseSinks = listTopologyTestRunCaseSink(runCase.getId());
        // remove topology test run case source
        for (TopologyTestRunCaseSource runCaseSource : runCaseSources) {
            removeTopologyTestRunCaseSource(runCaseSource.getId());
        }
        // remove topology test run case sink
        for (TopologyTestRunCaseSink runCaseSink : runCaseSinks) {
            removeTopologyTestRunCaseSink(runCaseSink.getId());
        }
        removeTestRunCase(topologyId, runCase.getId());
    }
    // remove edges
    Collection<TopologyEdge> edges = listTopologyEdges(topologyIdVersionIdQueryParams);
    for (TopologyEdge edge : edges) {
        removeTopologyEdge(topologyId, edge.getId(), versionId);
    }
    // remove rules
    Collection<TopologyRule> topologyRules = listRules(topologyIdVersionIdQueryParams);
    for (TopologyRule topologyRule : topologyRules) {
        removeRule(topologyId, topologyRule.getId(), versionId);
    }
    // remove windowed rules
    Collection<TopologyWindow> topologyWindows = listWindows(topologyIdVersionIdQueryParams);
    for (TopologyWindow topologyWindow : topologyWindows) {
        removeWindow(topologyId, topologyWindow.getId(), versionId);
    }
    // remove branch rules
    Collection<TopologyBranchRule> topologyBranchRules = listBranchRules(topologyIdVersionIdQueryParams);
    for (TopologyBranchRule topologyBranchRule : topologyBranchRules) {
        removeBranchRule(topologyId, topologyBranchRule.getId(), versionId);
    }
    // remove sinks
    Collection<TopologySink> sinks = listTopologySinks(topologyIdVersionIdQueryParams);
    for (TopologySink sink : sinks) {
        removeTopologySink(topologyId, sink.getId(), versionId, false);
    }
    // remove processors
    Collection<TopologyProcessor> processors = listTopologyProcessors(topologyIdVersionIdQueryParams);
    for (TopologyProcessor processor : processors) {
        removeTopologyProcessor(topologyId, processor.getId(), versionId, false);
    }
    // remove sources
    Collection<TopologySource> sources = listTopologySources(topologyIdVersionIdQueryParams);
    for (TopologySource source : sources) {
        removeTopologySource(topologyId, source.getId(), versionId, false);
    }
    // remove output streams
    Collection<TopologyStream> topologyStreams = listStreamInfos(topologyIdVersionIdQueryParams);
    for (TopologyStream topologyStream : topologyStreams) {
        removeStreamInfo(topologyId, topologyStream.getId(), versionId);
    }
    // remove topology editor metadata
    removeTopologyEditorMetadata(topologyId, versionId);
}
Also used : TopologyBranchRule(com.hortonworks.streamline.streams.catalog.TopologyBranchRule) TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) TopologyRule(com.hortonworks.streamline.streams.catalog.TopologyRule) BaseTopologyRule(com.hortonworks.streamline.streams.catalog.BaseTopologyRule) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) TopologyWindow(com.hortonworks.streamline.streams.catalog.TopologyWindow) TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) QueryParam(com.hortonworks.registries.common.QueryParam) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)

Aggregations

TopologySink (com.hortonworks.streamline.streams.catalog.TopologySink)16 Path (javax.ws.rs.Path)7 Timed (com.codahale.metrics.annotation.Timed)5 TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)5 TopologyTestRunCaseSink (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink)5 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)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 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 TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)2 TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)2 TopologyWindow (com.hortonworks.streamline.streams.catalog.TopologyWindow)2 GET (javax.ws.rs.GET)2