use of com.hortonworks.streamline.streams.catalog.TopologyRule in project streamline by hortonworks.
the class StreamCatalogService method getRule.
public TopologyRule getRule(Long topologyId, Long ruleId, Long versionId) {
TopologyRule topologyTopologyRule = new TopologyRule();
topologyTopologyRule.setId(ruleId);
topologyTopologyRule.setVersionId(versionId);
TopologyRule ruleInfo = dao.get(new StorableKey(TOPOLOGY_RULEINFO_NAMESPACE, topologyTopologyRule.getPrimaryKey()));
if (ruleInfo == null || !ruleInfo.getTopologyId().equals(topologyId)) {
return null;
}
ruleInfo.setVersionTimestamp(getVersionTimestamp(versionId));
return ruleInfo;
}
use of com.hortonworks.streamline.streams.catalog.TopologyRule in project streamline by hortonworks.
the class StreamCatalogService method removeRule.
public TopologyRule removeRule(Long topologyId, Long ruleId, Long versionId) throws Exception {
TopologyRule topologyRule = getRule(topologyId, ruleId, versionId);
if (topologyRule != null) {
topologyRule = dao.remove(new StorableKey(TOPOLOGY_RULEINFO_NAMESPACE, topologyRule.getPrimaryKey()));
topologyRule.setVersionTimestamp(updateVersionTimestamp(versionId).getTimestamp());
}
return topologyRule;
}
use of com.hortonworks.streamline.streams.catalog.TopologyRule in project streamline by hortonworks.
the class RuleCatalogResource method addTopologyRule.
/**
* <p>
* Creates a topology rule. For example,
* </p>
* <b>POST /api/v1/catalog/topologies/:TOPOLOGY_ID/rules</b>
* <pre>
* {
* "name": "rule1",
* "description": "rule test",
* "sql": "select temperature, humidity from nest where humidity > 90 AND celciusToFarenheit(temperature) > 80",
* "actions": ...
* }
* </pre>
* <i>Sample success response: </i>
* <pre>
* {
* "responseCode": 1000,
* "responseMessage": "Success",
* "entity": {
* "id": 1,
* "topologyId": 1,
* "name": "rule1",
* "description": "rule test",
* "sql": "select temperature, humidity from nest where humidity > 90 AND celciusToFarenheit(temperature) > 80",
* "window": null,
* "actions": ...
* }
* }
* </pre>
*
* <i>
* Note:
* </i>
* <ol>
* <li>'celciusToFarenheit' is a user defined function defined via UDFCatalogResource (/api/v1/catalog/udfs) api.</li>
* <li>'temperature' and 'humidity' are the fields of the 'nest' output stream which should have been defined via
* the TopologyStreamCatalogResource (/api/v1/catalog/topologies/{topologyId}/streams) api.</li>
*/
@POST
@Path("/topologies/{topologyId}/rules")
@Timed
public Response addTopologyRule(@PathParam("topologyId") Long topologyId, TopologyRule topologyRule, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
TopologyRule createdTopologyRule = catalogService.addRule(topologyId, topologyRule);
return WSUtils.respondEntity(createdTopologyRule, CREATED);
}
Aggregations