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;
}
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;
}
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;
}
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;
}
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());
}
Aggregations