use of com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta in project apex-core by apache.
the class StreamingContainerManagerTest method testValidGenericOperatorDeployInfoType.
@Test
public void testValidGenericOperatorDeployInfoType() {
GenericTestOperator o1 = dag.addOperator("o1", GenericTestOperator.class);
TestGeneratorInputOperator.ValidGenericOperator o2 = dag.addOperator("o2", TestGeneratorInputOperator.ValidGenericOperator.class);
dag.addStream("stream1", o1.outport1, o2.input);
dag.setAttribute(OperatorContext.STORAGE_AGENT, new MemoryStorageAgent());
StreamingContainerManager scm = new StreamingContainerManager(dag);
PhysicalPlan physicalPlan = scm.getPhysicalPlan();
List<PTContainer> containers = physicalPlan.getContainers();
for (int i = 0; i < containers.size(); ++i) {
assignContainer(scm, "container" + (i + 1));
}
OperatorMeta o2Meta = dag.getMeta(o2);
PTOperator o2Physical = physicalPlan.getOperators(o2Meta).get(0);
String containerId = o2Physical.getContainer().getExternalId();
OperatorDeployInfo o1DeployInfo = getDeployInfo(scm.getContainerAgent(containerId)).get(0);
Assert.assertEquals("type " + o1DeployInfo, OperatorDeployInfo.OperatorType.GENERIC, o1DeployInfo.type);
}
use of com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta in project apex-core by apache.
the class StramWebServices method getPortAttributes.
@GET
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}/ports/{portName}/attributes")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getPortAttributes(@PathParam("operatorName") String operatorName, @PathParam("portName") String portName, @QueryParam("attributeName") String attributeName) {
init();
OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
if (logicalOperator == null) {
throw new NotFoundException();
}
HashMap<String, String> map = new HashMap<>();
for (Map.Entry<Attribute<?>, Object> entry : dagManager.getPortAttributes(operatorName, portName).entrySet()) {
if (attributeName == null || entry.getKey().getSimpleName().equals(attributeName)) {
Map.Entry<Attribute<Object>, Object> entry1 = (Map.Entry<Attribute<Object>, Object>) (Map.Entry) entry;
map.put(entry1.getKey().getSimpleName(), entry1.getKey().codec.toString(entry1.getValue()));
}
}
return new JSONObject(map);
}
use of com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta in project apex-core by apache.
the class StramWebServices method getOperatorAggregation.
@GET
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}/aggregation")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getOperatorAggregation(@PathParam("operatorName") String operatorName) throws Exception {
init();
OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
if (logicalOperator == null) {
throw new NotFoundException();
}
OperatorAggregationInfo operatorAggregationInfo = dagManager.getOperatorAggregationInfo(operatorName);
return new JSONObject(objectMapper.writeValueAsString(operatorAggregationInfo));
}
use of com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta in project apex-core by apache.
the class StramWebServices method getPort.
@GET
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}/ports/{portName}")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getPort(@PathParam("operatorName") String operatorName, @PathParam("portName") String portName) {
init();
OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
Set<LogicalPlan.InputPortMeta> inputPorts;
Set<LogicalPlan.OutputPortMeta> outputPorts;
if (logicalOperator == null) {
ModuleMeta logicalModule = dagManager.getModuleMeta(operatorName);
if (logicalModule == null) {
throw new NotFoundException();
}
inputPorts = logicalModule.getInputStreams().keySet();
outputPorts = logicalModule.getOutputStreams().keySet();
} else {
inputPorts = logicalOperator.getInputStreams().keySet();
outputPorts = logicalOperator.getOutputStreams().keySet();
}
try {
JSONObject resp = getPortObject(inputPorts, outputPorts, portName);
if (resp != null) {
return resp;
}
} catch (JSONException ex) {
throw new RuntimeException(ex);
}
throw new NotFoundException();
}
use of com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta in project apex-core by apache.
the class StramWebServices method setOperatorProperties.
// not supported by WebAppProxyServlet, can only be called directly
@POST
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}/properties")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public JSONObject setOperatorProperties(JSONObject request, @PathParam("operatorName") String operatorName) {
init();
OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
if (logicalOperator == null) {
throw new NotFoundException();
}
JSONObject response = new JSONObject();
try {
@SuppressWarnings("unchecked") Iterator<String> keys = request.keys();
while (keys.hasNext()) {
String key = keys.next();
String val = request.isNull(key) ? null : request.getString(key);
LOG.debug("Setting property for {}: {}={}", operatorName, key, val);
dagManager.setOperatorProperty(operatorName, key, val);
}
} catch (JSONException ex) {
LOG.warn("Got JSON Exception: ", ex);
} catch (Exception ex) {
LOG.error("Caught exception: ", ex);
throw new RuntimeException(ex);
}
return response;
}
Aggregations