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