Search in sources :

Example 1 with TopologyEdge

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

the class TopologyEdgeCatalogResource method getTopologyEdgeById.

/**
 * <p>
 * Gets the 'CURRENT' version of specific topology edge by Id. For example,
 * </p>
 * <b>GET /api/v1/catalog/topologies/:TOPOLOGY_ID/edges/:EDGE_ID</b>
 * <pre>
 * {
 *   "responseCode": 1000,
 *   "responseMessage": "Success",
 *   "entity": {
 *     "id": 1,
 *     "topologyId": 1,
 *     "fromId": 1,
 *     "toId": 1,
 *     "streamGroupings": [
 *       {
 *         "streamId": 1,
 *         "grouping": "SHUFFLE"
 *       }
 *     ]
 *   }
 * }
 * </pre>
 */
@GET
@Path("/topologies/{topologyId}/edges/{id}")
@Timed
public Response getTopologyEdgeById(@PathParam("topologyId") Long topologyId, @PathParam("id") Long edgeId, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
    TopologyEdge edge = catalogService.getTopologyEdge(topologyId, edgeId);
    if (edge != null) {
        return WSUtils.respondEntity(edge, OK);
    }
    throw EntityNotFoundException.byId(buildMessageForCompositeId(topologyId, edgeId));
}
Also used : TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 2 with TopologyEdge

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

the class TopologyEdgeCatalogResource method removeTopologyEdge.

/**
 * <p>
 * Removes a topology edge.
 * </p>
 * <b>DELETE /api/v1/catalog/topologies/:TOPOLOGY_ID/edges/:EDGE_ID</b>
 * <pre>
 * {
 *   "responseCode": 1000,
 *   "responseMessage": "Success",
 *   "entity": {
 *     "id": 1,
 *     "topologyId": 1,
 *     "fromId": 1,
 *     "toId": 1,
 *     "streamGroupings": [
 *       {
 *         "streamId": 1,
 *         "grouping": "SHUFFLE"
 *       }
 *     ]
 *   }
 * }
 * </pre>
 */
@DELETE
@Path("/topologies/{topologyId}/edges/{id}")
@Timed
public Response removeTopologyEdge(@PathParam("topologyId") Long topologyId, @PathParam("id") Long edgeId, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
    TopologyEdge removedEdge = catalogService.removeTopologyEdge(topologyId, edgeId);
    if (removedEdge != null) {
        return WSUtils.respondEntity(removedEdge, OK);
    }
    throw EntityNotFoundException.byId(edgeId.toString());
}
Also used : TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with TopologyEdge

use of com.hortonworks.streamline.streams.catalog.TopologyEdge 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 TopologyEdge

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

the class StreamCatalogService method setReconfigureTarget.

private void setReconfigureTarget(TopologyEdge edge, TopologyStream stream) {
    TopologyComponent component = getTo(edge);
    component.setReconfigure(true);
    dao.addOrUpdate(component);
    // if component is a processor, update any rules in that processor that uses any of the streams
    if (component instanceof TopologyProcessor) {
        setReconfigureRules(Collections.singletonList((TopologyProcessor) component), edge.getStreamGroupings().stream().map(StreamGrouping::getStreamId).map(sid -> getStreamInfo(edge.getTopologyId(), sid, edge.getVersionId())).filter(curStream -> stream == null || curStream.getId().equals(stream.getId())).collect(Collectors.toList()));
    }
}
Also used : TopologyComponent(com.hortonworks.streamline.streams.catalog.TopologyComponent) Topology(com.hortonworks.streamline.streams.catalog.Topology) TopologyProcessorStreamMap(com.hortonworks.streamline.streams.catalog.TopologyProcessorStreamMap) Rule(com.hortonworks.streamline.streams.layout.component.rule.Rule) MLModelRegistryClient(com.hortonworks.streamline.registries.model.client.MLModelRegistryClient) UDAF(com.hortonworks.streamline.streams.rule.UDAF) Notifier(com.hortonworks.streamline.streams.catalog.Notifier) StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) Utils(com.hortonworks.streamline.common.util.Utils) QueryParam(com.hortonworks.registries.common.QueryParam) FileStorage(com.hortonworks.registries.common.util.FileStorage) UDAF2(com.hortonworks.streamline.streams.rule.UDAF2) Collections2(com.google.common.collect.Collections2) ComponentUISpecification(com.hortonworks.streamline.common.ComponentUISpecification) TopologyDag(com.hortonworks.streamline.streams.layout.component.TopologyDag) StreamGrouping(com.hortonworks.streamline.streams.catalog.TopologyEdge.StreamGrouping) ComponentConfigException(com.hortonworks.streamline.common.exception.ComponentConfigException) Matcher(java.util.regex.Matcher) TopologyEditorMetadata(com.hortonworks.streamline.streams.catalog.TopologyEditorMetadata) Map(java.util.Map) RuleParser(com.hortonworks.streamline.streams.catalog.rule.RuleParser) TopologyComponentBundle(com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) TopologyData(com.hortonworks.streamline.streams.catalog.topology.TopologyData) Set(java.util.Set) NOTIFICATION(com.hortonworks.streamline.common.ComponentTypes.NOTIFICATION) CURRENT_VERSION(com.hortonworks.streamline.common.util.WSUtils.CURRENT_VERSION) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CustomProcessorInfo(com.hortonworks.streamline.streams.catalog.processor.CustomProcessorInfo) StorableKey(com.hortonworks.registries.storage.StorableKey) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) Joiner(com.google.common.base.Joiner) TopologyState(com.hortonworks.streamline.streams.catalog.topology.state.TopologyState) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) TopologySourceStreamMap(com.hortonworks.streamline.streams.catalog.TopologySourceStreamMap) Projection(com.hortonworks.streamline.streams.catalog.Projection) TopologyOutputComponent(com.hortonworks.streamline.streams.catalog.TopologyOutputComponent) TopologyRule(com.hortonworks.streamline.streams.catalog.TopologyRule) Nullable(javax.annotation.Nullable) TopologyVersion(com.hortonworks.streamline.streams.catalog.TopologyVersion) UDF(com.hortonworks.streamline.streams.catalog.UDF) IOException(java.io.IOException) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) TopologyWindow(com.hortonworks.streamline.streams.catalog.TopologyWindow) TreeMap(java.util.TreeMap) File(com.hortonworks.streamline.streams.catalog.File) DigestInputStream(java.security.DigestInputStream) Preconditions(com.google.common.base.Preconditions) TopologyDagBuilder(com.hortonworks.streamline.streams.catalog.topology.component.TopologyDagBuilder) BiFunction(java.util.function.BiFunction) UDF4(com.hortonworks.streamline.streams.rule.UDF4) LoggerFactory(org.slf4j.LoggerFactory) UDF3(com.hortonworks.streamline.streams.rule.UDF3) UDF2(com.hortonworks.streamline.streams.rule.UDF2) UDF7(com.hortonworks.streamline.streams.rule.UDF7) UDF6(com.hortonworks.streamline.streams.rule.UDF6) RulesProcessor(com.hortonworks.streamline.streams.layout.component.impl.RulesProcessor) UDF5(com.hortonworks.streamline.streams.rule.UDF5) StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) BaseTopologyRule(com.hortonworks.streamline.streams.catalog.BaseTopologyRule) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) WSUtils(com.hortonworks.streamline.common.util.WSUtils) TypeReference(com.fasterxml.jackson.core.type.TypeReference) TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) StorageUtils(com.hortonworks.registries.storage.util.StorageUtils) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) FileUtil(com.hortonworks.streamline.common.util.FileUtil) Collection(java.util.Collection) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) List(java.util.List) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) StorageManager(com.hortonworks.registries.storage.StorageManager) TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) TopologyLayoutConstants(com.hortonworks.streamline.streams.layout.TopologyLayoutConstants) MessageDigest(java.security.MessageDigest) TopologyUIData(com.hortonworks.streamline.streams.catalog.TopologyEditorMetadata.TopologyUIData) TopologyEditorToolbar(com.hortonworks.streamline.streams.catalog.TopologyEditorToolbar) HashMap(java.util.HashMap) Hex(org.apache.commons.codec.binary.Hex) ComponentTypes(com.hortonworks.streamline.common.ComponentTypes) Schema(com.hortonworks.registries.common.Schema) HashSet(java.util.HashSet) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) ImmutableList(com.google.common.collect.ImmutableList) CustomProcessorRuntime(com.hortonworks.streamline.streams.runtime.CustomProcessorRuntime) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam) TopologyExportVisitor(com.hortonworks.streamline.streams.catalog.topology.component.TopologyExportVisitor) Logger(org.slf4j.Logger) Stream(com.hortonworks.streamline.streams.layout.component.Stream) ProxyUtil(com.hortonworks.streamline.common.util.ProxyUtil) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) FileInputStream(java.io.FileInputStream) StorageException(com.hortonworks.registries.storage.exception.StorageException) TopologyBranchRule(com.hortonworks.streamline.streams.catalog.TopologyBranchRule) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) TopologyComponent(com.hortonworks.streamline.streams.catalog.TopologyComponent) FluxComponent(com.hortonworks.streamline.streams.layout.storm.FluxComponent) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) InputStream(java.io.InputStream) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) StreamGrouping(com.hortonworks.streamline.streams.catalog.TopologyEdge.StreamGrouping)

Example 5 with TopologyEdge

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

the class StreamCatalogService method checkDuplicateEdge.

// check if edge already exists for given topology between same source and dest
private void checkDuplicateEdge(TopologyEdge edge) {
    List<QueryParam> queryParams = new ArrayList<>();
    queryParams.add(new QueryParam(TopologyEdge.TOPOLOGYID, edge.getTopologyId().toString()));
    queryParams.add(new QueryParam(TopologyEdge.VERSIONID, edge.getVersionId().toString()));
    queryParams.add(new QueryParam(TopologyEdge.FROMID, edge.getFromId().toString()));
    queryParams.add(new QueryParam(TopologyEdge.TOID, edge.getToId().toString()));
    try {
        Collection<TopologyEdge> existingEdges = listTopologyEdges(queryParams);
        if (existingEdges != null && !existingEdges.isEmpty()) {
            throw new IllegalArgumentException("Edge already exists between source and destination, use update api");
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : 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) ArrayList(java.util.ArrayList) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) ComponentConfigException(com.hortonworks.streamline.common.exception.ComponentConfigException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) StorageException(com.hortonworks.registries.storage.exception.StorageException)

Aggregations

TopologyEdge (com.hortonworks.streamline.streams.catalog.TopologyEdge)15 Timed (com.codahale.metrics.annotation.Timed)5 QueryParam (com.hortonworks.registries.common.QueryParam)5 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)5 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)5 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)5 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)5 Path (javax.ws.rs.Path)5 StorableKey (com.hortonworks.registries.storage.StorableKey)4 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 StorageException (com.hortonworks.registries.storage.exception.StorageException)3 ComponentConfigException (com.hortonworks.streamline.common.exception.ComponentConfigException)3 TopologyBranchRule (com.hortonworks.streamline.streams.catalog.TopologyBranchRule)3 TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)3 TopologyRule (com.hortonworks.streamline.streams.catalog.TopologyRule)3 TopologySink (com.hortonworks.streamline.streams.catalog.TopologySink)3 TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)3 TopologyStream (com.hortonworks.streamline.streams.catalog.TopologyStream)3 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)3