apex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gauravgopi123 <...@git.apache.org>
Subject [GitHub] incubator-apex-core pull request: APEX-103: Add module and dag int...
Date Thu, 03 Dec 2015 08:04:52 GMT
Github user gauravgopi123 commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-core/pull/148#discussion_r46522419
  
    --- Diff: engine/src/main/java/com/datatorrent/stram/codec/LogicalPlanSerializer.java
---
    @@ -116,91 +204,96 @@ public boolean useForType(JavaType t)
         typer = typer.inclusion(JsonTypeInfo.As.PROPERTY);
         propertyObjectMapper.setDefaultTyping(typer);
     
    -    for (OperatorMeta operatorMeta : allOperators) {
    -      HashMap<String, Object> operatorDetailMap = new HashMap<String, Object>();
    -      ArrayList<Map<String, Object>> portList = new ArrayList<Map<String,
Object>>();
    -      Map<String, Object> attributeMap = new HashMap<String, Object>();
    -
    -      String operatorName = operatorMeta.getName();
    -      operatorArray.add(operatorDetailMap);
    -      operatorDetailMap.put("name", operatorName);
    -      operatorDetailMap.put("ports", portList);
    -      operatorDetailMap.put("class", operatorMeta.getOperator().getClass().getName());
    -      operatorDetailMap.put("attributes", attributeMap);
    -      Map<Attribute<Object>, Object> rawAttributes = Attribute.AttributeMap.AttributeInitializer.getAllAttributes(operatorMeta,
Context.OperatorContext.class);
    -      for (Map.Entry<Attribute<Object>, Object> entry : rawAttributes.entrySet())
{
    -        attributeMap.put(entry.getKey().getSimpleName(), entry.getValue());
    -      }
    -
    -      ObjectMapperString str;
    +    try {
    +      str = new ObjectMapperString(propertyObjectMapper.writeValueAsString(operatorMeta.getOperator()));
    +    } catch (Throwable ex) {
    +      LOG.error("Got exception when trying to get properties for operator {}", operatorMeta.getName(),
ex);
    +      str = null;
    +    }
    +    operatorDetailMap.put("properties", str);
     
    -      try {
    -        str = new ObjectMapperString(propertyObjectMapper.writeValueAsString(operatorMeta.getOperator()));
    +    Operators.PortMappingDescriptor pmd = new Operators.PortMappingDescriptor();
    +    Operators.describe(operatorMeta.getOperator(), pmd);
    +    for (Map.Entry<String, PortContextPair<InputPort<?>>> entry : pmd.inputPorts.entrySet())
{
    +      HashMap<String, Object> portDetailMap = new HashMap<String, Object>();
    +      HashMap<String, Object> portAttributeMap = new HashMap<String, Object>();
    +      InputPortMeta portMeta = operatorMeta.getMeta(entry.getValue().component);
    +      String portName = portMeta.getPortName();
    +      portDetailMap.put("name", portName);
    +      portDetailMap.put("type", "input");
    +      portDetailMap.put("attributes", portAttributeMap);
    +      rawAttributes = Attribute.AttributeMap.AttributeInitializer.getAllAttributes(portMeta,
Context.PortContext.class);
    +      for (Map.Entry<Attribute<Object>, Object> attEntry : rawAttributes.entrySet())
{
    +        portAttributeMap.put(attEntry.getKey().getSimpleName(), attEntry.getValue());
           }
    -      catch (Throwable ex) {
    -        LOG.error("Got exception when trying to get properties for operator {}", operatorMeta.getName(),
ex);
    -        str = null;
    -      }
    -      operatorDetailMap.put("properties", str);
    -
    -      Operators.PortMappingDescriptor pmd = new Operators.PortMappingDescriptor();
    -      Operators.describe(operatorMeta.getOperator(), pmd);
    -      for (Map.Entry<String, PortContextPair<InputPort<?>>> entry :
pmd.inputPorts.entrySet()) {
    -        HashMap<String, Object> portDetailMap = new HashMap<String, Object>();
    -        HashMap<String, Object> portAttributeMap = new HashMap<String, Object>();
    -        InputPortMeta portMeta = operatorMeta.getMeta(entry.getValue().component);
    -        String portName = portMeta.getPortName();
    -        portDetailMap.put("name", portName);
    -        portDetailMap.put("type", "input");
    -        portDetailMap.put("attributes", portAttributeMap);
    -        rawAttributes = Attribute.AttributeMap.AttributeInitializer.getAllAttributes(portMeta,
Context.PortContext.class);
    -        for (Map.Entry<Attribute<Object>, Object> attEntry : rawAttributes.entrySet())
{
    -          portAttributeMap.put(attEntry.getKey().getSimpleName(), attEntry.getValue());
    -        }
    -        portList.add(portDetailMap);
    -      }
    -      for (Map.Entry<String, PortContextPair<OutputPort<?>>> entry
: pmd.outputPorts.entrySet()) {
    -        HashMap<String, Object> portDetailMap = new HashMap<String, Object>();
    -        HashMap<String, Object> portAttributeMap = new HashMap<String, Object>();
    -        OutputPortMeta portMeta = operatorMeta.getMeta(entry.getValue().component);
    -        String portName = portMeta.getPortName();
    -        portDetailMap.put("name", portName);
    -        portDetailMap.put("type", "output");
    -        portDetailMap.put("attributes", portAttributeMap);
    -        rawAttributes = Attribute.AttributeMap.AttributeInitializer.getAllAttributes(portMeta,
Context.PortContext.class);
    -        for (Map.Entry<Attribute<Object>, Object> attEntry : rawAttributes.entrySet())
{
    -          portAttributeMap.put(attEntry.getKey().getSimpleName(), attEntry.getValue());
    -        }
    -        portList.add(portDetailMap);
    +      portList.add(portDetailMap);
    +    }
    +    for (Map.Entry<String, PortContextPair<OutputPort<?>>> entry :
pmd.outputPorts.entrySet()) {
    +      HashMap<String, Object> portDetailMap = new HashMap<String, Object>();
    +      HashMap<String, Object> portAttributeMap = new HashMap<String, Object>();
    +      OutputPortMeta portMeta = operatorMeta.getMeta(entry.getValue().component);
    +      String portName = portMeta.getPortName();
    +      portDetailMap.put("name", portName);
    +      portDetailMap.put("type", "output");
    +      portDetailMap.put("attributes", portAttributeMap);
    +      rawAttributes = Attribute.AttributeMap.AttributeInitializer.getAllAttributes(portMeta,
Context.PortContext.class);
    +      for (Map.Entry<Attribute<Object>, Object> attEntry : rawAttributes.entrySet())
{
    +        portAttributeMap.put(attEntry.getKey().getSimpleName(), attEntry.getValue());
           }
    +      portList.add(portDetailMap);
         }
    -    Collection<StreamMeta> allStreams = dag.getAllStreams();
    +    return operatorDetailMap;
    +  }
     
    -    for (StreamMeta streamMeta : allStreams) {
    -      HashMap<String, Object> streamDetailMap = new HashMap<String, Object>();
    -      String streamName = streamMeta.getName();
    -      streamMap.add(streamDetailMap);
    -      String sourcePortName = streamMeta.getSource().getPortName();
    -      OperatorMeta operatorMeta = streamMeta.getSource().getOperatorMeta();
    -      HashMap<String, Object> sourcePortDetailMap = new HashMap<String, Object>();
    -      sourcePortDetailMap.put("operatorName", operatorMeta.getName());
    -      sourcePortDetailMap.put("portName", sourcePortName);
    -      streamDetailMap.put("name", streamName);
    -      streamDetailMap.put("source", sourcePortDetailMap);
    -      List<InputPortMeta> sinks = streamMeta.getSinks();
    -      ArrayList<HashMap<String, Object>> sinkPortList = new ArrayList<HashMap<String,
Object>>();
    -      for (InputPortMeta sinkPort : sinks) {
    -        HashMap<String, Object> sinkPortDetailMap = new HashMap<String, Object>();
    -        sinkPortDetailMap.put("operatorName", sinkPort.getOperatorWrapper().getName());
    -        sinkPortDetailMap.put("portName", sinkPort.getPortName());
    -        sinkPortList.add(sinkPortDetailMap);
    +  private static Object getLogicalStreamDetails(StreamMeta streamMeta)
    +  {
    +
    +    HashMap<String, Object> streamDetailMap = new HashMap<String, Object>();
    +    String streamName = streamMeta.getName();
    +    String sourcePortName = streamMeta.getSource().getPortName();
    +    OperatorMeta operatorMeta = streamMeta.getSource().getOperatorMeta();
    +    HashMap<String, Object> sourcePortDetailMap = new HashMap<String, Object>();
    +    sourcePortDetailMap.put("operatorName", operatorMeta.getName());
    +    sourcePortDetailMap.put("portName", sourcePortName);
    +    streamDetailMap.put("name", streamName);
    +    streamDetailMap.put("source", sourcePortDetailMap);
    +    List<InputPortMeta> sinks = streamMeta.getSinks();
    +    ArrayList<HashMap<String, Object>> sinkPortList = new ArrayList<HashMap<String,
Object>>();
    +    for (InputPortMeta sinkPort : sinks) {
    +      HashMap<String, Object> sinkPortDetailMap = new HashMap<String, Object>();
    +      sinkPortDetailMap.put("operatorName", sinkPort.getOperatorWrapper().getName());
    +      sinkPortDetailMap.put("portName", sinkPort.getPortName());
    +      sinkPortList.add(sinkPortDetailMap);
    +    }
    +    streamDetailMap.put("sinks", sinkPortList);
    +    if (streamMeta.getLocality() != null) {
    +      streamDetailMap.put("locality", streamMeta.getLocality().name());
    +    }
    +    return streamDetailMap;
    +  }
    +
    +  private static Map<String, Object> fillLogicalModuleDetails(ModuleMeta moduleMeta,
LogicalPlan dag, boolean flatten)
    +  {
    +    Map<String, Object> moduleDetailMap = new HashMap<String, Object>();
    +    ArrayList<Object> operatorArray = new ArrayList<Object>();
    +    ArrayList<Object> streamArray = new ArrayList<Object>();
    +    moduleDetailMap.put("name", moduleMeta.getName());
    +    moduleDetailMap.put("className", moduleMeta.getModule().getClass().getName());
    +    moduleDetailMap.put("operators", operatorArray);
    +    moduleDetailMap.put("streams", streamArray);
    +    if (flatten) {
    +      for (OperatorMeta operatorMeta : dag.getAllOperators()) {
    +        if (operatorMeta.getModuleName() != null && operatorMeta.getModuleName()
== moduleMeta.getName()) {
    --- End diff --
    
    Do you need this check if operators belong to module only?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message