Search in sources :

Example 41 with Topology

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

the class TopologyCatalogResource method importTopology.

/**
 * curl -X POST 'http://localhost:8080/api/v1/catalog/topologies/actions/import' -F file=@/tmp/topology.json -F namespaceId=1
 */
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/topologies/actions/import")
@Timed
public Response importTopology(@FormDataParam("file") final InputStream inputStream, @FormDataParam("namespaceId") final Long namespaceId, @FormDataParam("topologyName") final String topologyName, @Context SecurityContext securityContext) throws Exception {
    SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_TOPOLOGY_ADMIN);
    if (namespaceId == null) {
        throw new IllegalArgumentException("Missing namespaceId");
    }
    TopologyData topologyData = new ObjectMapper().readValue(inputStream, TopologyData.class);
    if (topologyName != null && !topologyName.isEmpty()) {
        topologyData.setTopologyName(topologyName);
    }
    Topology importedTopology = catalogService.importTopology(namespaceId, topologyData);
    return WSUtils.respondEntity(importedTopology, OK);
}
Also used : TopologyData(com.hortonworks.streamline.streams.catalog.topology.TopologyData) Topology(com.hortonworks.streamline.streams.catalog.Topology) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Timed(com.codahale.metrics.annotation.Timed)

Example 42 with Topology

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

the class TopologyDashboardResource method getTopologyById.

@GET
@Path("/topologies/{topologyId}/dashboard")
@Timed
public Response getTopologyById(@PathParam("topologyId") Long topologyId, @javax.ws.rs.QueryParam("latencyTopN") Integer latencyTopN, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, NAMESPACE, topologyId, READ);
    String asUser = WSUtils.getUserFromSecurityContext(securityContext);
    Topology result = catalogService.getTopology(topologyId);
    if (result != null) {
        CatalogResourceUtil.TopologyDashboardResponse topologyDetailed = CatalogResourceUtil.enrichTopology(result, asUser, latencyTopN, environmentService, actionsService, metricsService, catalogService);
        return WSUtils.respondEntity(topologyDetailed, OK);
    }
    throw EntityNotFoundException.byId(topologyId.toString());
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 43 with Topology

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

the class TopologyDashboardResource method getTopologyByIdAndVersion.

@GET
@Path("/topologies/{topologyId}/versions/{versionId}/dashboard")
@Timed
public Response getTopologyByIdAndVersion(@PathParam("topologyId") Long topologyId, @PathParam("versionId") Long versionId, @javax.ws.rs.QueryParam("latencyTopN") Integer latencyTopN, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, NAMESPACE, topologyId, READ);
    String asUser = WSUtils.getUserFromSecurityContext(securityContext);
    Topology result = catalogService.getTopology(topologyId, versionId);
    if (result != null) {
        CatalogResourceUtil.TopologyDashboardResponse topologyDetailed = CatalogResourceUtil.enrichTopology(result, asUser, latencyTopN, environmentService, actionsService, metricsService, catalogService);
        return WSUtils.respondEntity(topologyDetailed, OK);
    }
    throw EntityNotFoundException.byId(topologyId.toString());
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 44 with Topology

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

the class TopologyTestHelper method createTopology.

public static Topology createTopology(Long id, Long versionId, Long namespaceId) {
    Topology topology = new Topology();
    topology.setId(id);
    topology.setName("testTopology_" + id);
    topology.setNamespaceId(namespaceId);
    topology.setVersionId(versionId);
    topology.setVersionTimestamp(System.currentTimeMillis());
    return topology;
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology)

Example 45 with Topology

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

the class StreamCatalogServiceTest method createTopology.

private Topology createTopology(String name) {
    Topology topology = new Topology();
    topology.setName(name);
    return topology;
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology)

Aggregations

Topology (com.hortonworks.streamline.streams.catalog.Topology)67 Timed (com.codahale.metrics.annotation.Timed)39 Path (javax.ws.rs.Path)27 GET (javax.ws.rs.GET)17 IOException (java.io.IOException)12 TopologyActions (com.hortonworks.streamline.streams.actions.TopologyActions)9 TopologyTestRunHistory (com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory)9 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)8 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)8 List (java.util.List)8 Map (java.util.Map)8 POST (javax.ws.rs.POST)8 Expectations (mockit.Expectations)8 Test (org.junit.Test)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 TopologyComponent (com.hortonworks.streamline.streams.catalog.TopologyComponent)6 TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)6 ArrayList (java.util.ArrayList)6 StreamCatalogService (com.hortonworks.streamline.streams.catalog.service.StreamCatalogService)5 Collections (java.util.Collections)5