Search in sources :

Example 16 with TopologyComponentBundle

use of com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle in project streamline by hortonworks.

the class StreamCatalogService method listCustomProcessorBundlesWithFilter.

private Collection<TopologyComponentBundle> listCustomProcessorBundlesWithFilter(List<QueryParam> params) throws IOException {
    List<QueryParam> queryParamsForTopologyComponent = new ArrayList<>();
    queryParamsForTopologyComponent.add(new QueryParam(TopologyComponentBundle.SUB_TYPE, TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_SUB_TYPE));
    for (QueryParam qp : params) {
        if (qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE)) {
            queryParamsForTopologyComponent.add(qp);
        }
    }
    Collection<TopologyComponentBundle> customProcessors = this.listTopologyComponentBundlesForTypeWithFilter(TopologyComponentBundle.TopologyComponentType.PROCESSOR, queryParamsForTopologyComponent);
    Collection<TopologyComponentBundle> result = new ArrayList<>();
    for (TopologyComponentBundle cp : customProcessors) {
        Map<String, Object> config = new HashMap<>();
        for (ComponentUISpecification.UIField uiField : cp.getTopologyComponentUISpecification().getFields()) {
            config.put(uiField.getFieldName(), uiField.getDefaultValue());
        }
        boolean matches = true;
        for (QueryParam qp : params) {
            if (!qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE) && !qp.getValue().equals(config.get(qp.getName()))) {
                matches = false;
                break;
            }
        }
        if (matches) {
            result.add(cp);
        }
    }
    return result;
}
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) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ComponentUISpecification(com.hortonworks.streamline.common.ComponentUISpecification) TopologyComponentBundle(com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle)

Example 17 with TopologyComponentBundle

use of com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle in project streamline by hortonworks.

the class StreamCatalogService method listCustomProcessorsFromBundleWithFilter.

public Collection<CustomProcessorInfo> listCustomProcessorsFromBundleWithFilter(List<QueryParam> params) throws IOException {
    Collection<TopologyComponentBundle> customProcessors = this.listCustomProcessorBundlesWithFilter(params);
    Collection<CustomProcessorInfo> result = new ArrayList<>();
    for (TopologyComponentBundle cp : customProcessors) {
        result.add(CustomProcessorInfo.fromTopologyComponentBundle(cp));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) CustomProcessorInfo(com.hortonworks.streamline.streams.catalog.processor.CustomProcessorInfo) TopologyComponentBundle(com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle)

Example 18 with TopologyComponentBundle

use of com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle in project streamline by hortonworks.

the class StreamCatalogService method updateCustomProcessorInfoAsBundle.

public CustomProcessorInfo updateCustomProcessorInfoAsBundle(CustomProcessorInfo customProcessorInfo, InputStream jarFile, boolean verify) throws IOException, ComponentConfigException, NoSuchAlgorithmException {
    List<QueryParam> queryParams = new ArrayList<>();
    queryParams.add(new QueryParam(CustomProcessorInfo.NAME, customProcessorInfo.getName()));
    Collection<TopologyComponentBundle> result = this.listCustomProcessorBundlesWithFilter(queryParams);
    if (result.isEmpty() || result.size() != 1) {
        throw new IOException("Failed to update custom processor with name:" + customProcessorInfo.getName());
    }
    this.handleCustomProcessorJar(jarFile, customProcessorInfo, verify);
    TopologyComponentBundle newCustomProcessorBundle = customProcessorInfo.toTopologyComponentBundle();
    this.addOrUpdateTopologyComponentBundle(result.iterator().next().getId(), newCustomProcessorBundle, null);
    return customProcessorInfo;
}
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) IOException(java.io.IOException) TopologyComponentBundle(com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle)

Example 19 with TopologyComponentBundle

use of com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle in project streamline by hortonworks.

the class RestIntegrationTest method createTopologyComponent.

private TopologyComponentBundle createTopologyComponent(Long id, String name, TopologyComponentBundle.TopologyComponentType topologyComponentType, String subType) {
    TopologyComponentBundle topologyComponentBundle = new TopologyComponentBundle();
    topologyComponentBundle.setId(id);
    topologyComponentBundle.setName(name);
    topologyComponentBundle.setType(topologyComponentType);
    topologyComponentBundle.setStreamingEngine("STORM");
    topologyComponentBundle.setSubType(subType);
    topologyComponentBundle.setTimestamp(System.currentTimeMillis());
    topologyComponentBundle.setTransformationClass("com.hortonworks.iotas.streams.layout.storm.KafkaSpoutFluxComponent");
    topologyComponentBundle.setBuiltin(true);
    return topologyComponentBundle;
}
Also used : TopologyComponentBundle(com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle)

Example 20 with TopologyComponentBundle

use of com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle in project streamline by hortonworks.

the class TopologyComponentBundleResource method removeTopologyComponentBundle.

/**
 * Delete a topology component bundle.
 * <p>
 * curl -sS -X DELETE -i   http://localhost:8080/api/v1/catalog/streams/componentbundles/SOURCE/3
 * </p>
 */
@DELETE
@Path("/componentbundles/{component}/{id}")
@Timed
public Response removeTopologyComponentBundle(@PathParam("component") TopologyComponentBundle.TopologyComponentType componentType, @PathParam("id") Long id, @Context SecurityContext securityContext) throws IOException {
    SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_TOPOLOGY_COMPONENT_BUNDLE_ADMIN);
    TopologyComponentBundle removedTopologyComponentBundle = catalogService.removeTopologyComponentBundle(id);
    if (removedTopologyComponentBundle != null) {
        return WSUtils.respondEntity(removedTopologyComponentBundle, OK);
    }
    throw EntityNotFoundException.byId(id.toString());
}
Also used : TopologyComponentBundle(com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

TopologyComponentBundle (com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle)23 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)8 QueryParam (com.hortonworks.registries.common.QueryParam)7 Timed (com.codahale.metrics.annotation.Timed)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Path (javax.ws.rs.Path)6 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 InputStream (java.io.InputStream)5 TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)4 ComponentUISpecification (com.hortonworks.streamline.common.ComponentUISpecification)3 File (java.io.File)3 HashMap (java.util.HashMap)3 ImmutableList (com.google.common.collect.ImmutableList)2 StorageException (com.hortonworks.registries.storage.exception.StorageException)2 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)2 CustomProcessorInfo (com.hortonworks.streamline.streams.catalog.processor.CustomProcessorInfo)2