Search in sources :

Example 6 with TopologyProcessor

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

the class TopologyComponentFactory method getInputComponent.

private InputComponent getInputComponent(TopologyEdge topologyEdge) {
    TopologySink topologySink;
    TopologyProcessor topologyProcessor;
    if ((topologySink = catalogService.getTopologySink(topologyEdge.getTopologyId(), topologyEdge.getToId(), topologyEdge.getVersionId())) != null) {
        return getStreamlineSink(topologySink);
    } else if ((topologyProcessor = catalogService.getTopologyProcessor(topologyEdge.getTopologyId(), topologyEdge.getToId(), topologyEdge.getVersionId())) != null) {
        return getStreamlineProcessor(topologyProcessor);
    } else {
        throw new IllegalArgumentException("Invalid to id for edge " + topologyEdge);
    }
}
Also used : TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor)

Example 7 with TopologyProcessor

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

the class TopologyExportVisitor method visit.

public void visit(RulesProcessor rulesProcessor) {
    try {
        TopologyComponentBundle componentBundle = streamCatalogService.getTopologyComponentBundle(Long.parseLong(rulesProcessor.getTopologyComponentBundleId()));
        String subType = componentBundle.getSubType();
        RulesHandler rulesHandler = rulesHandlerMap.get(subType);
        for (Rule rule : rulesProcessor.getRules()) {
            rulesHandler.handle(rule);
        }
    } catch (Exception e) {
        throw new RuntimeException(String.format("Unexpected exception thrown while trying to add the rule %s", rulesProcessor.getId()), e);
    }
    TopologyProcessor topologyProcessor = streamCatalogService.getTopologyProcessor(topologyId, Long.parseLong(rulesProcessor.getId()));
    topologyData.addProcessor(topologyProcessor);
    storeBundleIdToType(rulesProcessor);
}
Also used : Rule(com.hortonworks.streamline.streams.layout.component.rule.Rule) TopologyBranchRule(com.hortonworks.streamline.streams.catalog.TopologyBranchRule) TopologyRule(com.hortonworks.streamline.streams.catalog.TopologyRule) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) TopologyComponentBundle(com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle)

Example 8 with TopologyProcessor

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

the class TopologyProcessorCatalogResource method getTopologyProcessorByIdAndVersion.

@GET
@Path("/topologies/{topologyId}/versions/{versionId}/processors/{id}")
@Timed
public Response getTopologyProcessorByIdAndVersion(@PathParam("topologyId") Long topologyId, @PathParam("id") Long processorId, @PathParam("versionId") Long versionId, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
    TopologyProcessor processor = catalogService.getTopologyProcessor(topologyId, processorId, versionId);
    if (processor != null) {
        return WSUtils.respondEntity(processor, OK);
    }
    throw EntityNotFoundException.byVersion(buildMessageForCompositeId(topologyId, processorId), versionId.toString());
}
Also used : TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 9 with TopologyProcessor

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

the class TopologyProcessorCatalogResource method removeTopologyProcessor.

/**
 * <p>
 * Removes a topology processor.
 * </p>
 * <b>DELETE /api/v1/catalog/topologies/:TOPOLOGY_ID/processors/:PROCESSOR_ID</b>
 * <pre>
 * {
 *   "responseCode": 1000,
 *   "responseMessage": "Success",
 *   "entity": {
 *     "id": 1,
 *     "topologyId": 1,
 *     "name": "ParserProcessor",
 *     "config": {
 *       "properties": {
 *         "parallelism": 5
 *       }
 *     },
 *     "type": "PARSER",
 *     "outputStreamIds": [1]
 *   }
 * }
 * </pre>
 */
@DELETE
@Path("/topologies/{topologyId}/processors/{id}")
@Timed
public Response removeTopologyProcessor(@PathParam("topologyId") Long topologyId, @PathParam("id") Long processorId, @javax.ws.rs.QueryParam("removeEdges") boolean removeEdges, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
    TopologyProcessor topologyProcessor = catalogService.removeTopologyProcessor(topologyId, processorId, removeEdges);
    if (topologyProcessor != null) {
        return WSUtils.respondEntity(topologyProcessor, OK);
    }
    throw EntityNotFoundException.byId(processorId.toString());
}
Also used : TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Example 10 with TopologyProcessor

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

the class TopologyProcessorCatalogResource method addOrUpdateTopologyProcessor.

/**
 * <p>Updates a topology processor.</p>
 * <p>
 * <b>PUT /api/v1/catalog/topologies/:TOPOLOGY_ID/processors/:PROCESSOR_ID</b>
 * <pre>
 * {
 *   "name": "ParserProcessor",
 *   "config": {
 *     "properties": {
 *       "parallelism": 5
 *     }
 *   },
 *   "type": "PARSER",
 *   "outputStreamIds": [1]
 * }
 * </pre>
 * <i>Sample success response: </i>
 * <pre>
 * {
 *   "responseCode": 1000,
 *   "responseMessage": "Success",
 *   "entity": {
 *     "id": 1,
 *     "topologyId": 1,
 *     "name": "ParserProcessor",
 *     "config": {
 *       "properties": {
 *         "parallelism": 5
 *       }
 *     },
 *     "type": "PARSER",
 *     "outputStreamIds": [1]
 *   }
 * }
 * </pre>
 */
@PUT
@Path("/topologies/{topologyId}/processors/{id}")
@Timed
public Response addOrUpdateTopologyProcessor(@PathParam("topologyId") Long topologyId, @PathParam("id") Long processorId, TopologyProcessor topologyProcessor, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
    TopologyProcessor createdTopologyProcessor = catalogService.addOrUpdateTopologyProcessor(topologyId, processorId, topologyProcessor);
    return WSUtils.respondEntity(createdTopologyProcessor, CREATED);
}
Also used : TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Aggregations

TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)21 TopologySink (com.hortonworks.streamline.streams.catalog.TopologySink)6 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 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)5 TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)5 TopologyComponentBundle (com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle)5 StorableKey (com.hortonworks.registries.storage.StorableKey)4 TopologyBranchRule (com.hortonworks.streamline.streams.catalog.TopologyBranchRule)4 TopologyRule (com.hortonworks.streamline.streams.catalog.TopologyRule)4 TopologyStream (com.hortonworks.streamline.streams.catalog.TopologyStream)4 Path (javax.ws.rs.Path)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ImmutableList (com.google.common.collect.ImmutableList)3 Sets (com.google.common.collect.Sets)3 TopologyEdge (com.hortonworks.streamline.streams.catalog.TopologyEdge)3