apex-dev mailing list archives

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

    https://github.com/apache/incubator-apex-core/pull/148#discussion_r46917965
  
    --- Diff: engine/src/main/java/com/datatorrent/stram/codec/LogicalPlanSerializer.java
---
    @@ -116,91 +165,142 @@ 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;
    +      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());
           }
    -      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);
    +      portList.add(portDetailMap);
    +    }
    +    return operatorDetailMap;
    +  }
    +
    +  private static Map<String, 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;
    +  }
    +
    +  /**
    +   * Return list of operators populated by module in the top level dag.
    +   * @param plan  top level dag
    +   * @param moduleMeta module.
    +   * @return
    +   */
    +  private static Collection<OperatorMeta> getTopLevelOperators(LogicalPlan plan,
ModuleMeta moduleMeta) {
    --- End diff --
    
    Changed to List


---
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