Java Code Examples for com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta#getName()

The following examples show how to use com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogicalPlanSerializer.java    From Bats with Apache License 2.0 6 votes vote down vote up
/**
 * Return information about operators and inner modules of a module.
 *
 * @param dag        top level DAG
 * @param moduleMeta module information. DAG within module is used for constructing response.
 * @return
 */
private static Map<String, Object> getLogicalModuleDetails(LogicalPlan dag, LogicalPlan.ModuleMeta moduleMeta)
{
  Map<String, Object> moduleDetailMap = new HashMap<>();
  ArrayList<String> operatorArray = new ArrayList<>();
  moduleDetailMap.put("name", moduleMeta.getName());
  moduleDetailMap.put("className", moduleMeta.getGenericOperator().getClass().getName());

  moduleDetailMap.put("operators", operatorArray);
  for (OperatorMeta operatorMeta : moduleMeta.getDag().getAllOperators()) {
    if (operatorMeta.getModuleName() == null) {
      String fullName = moduleMeta.getFullName() + LogicalPlan.MODULE_NAMESPACE_SEPARATOR + operatorMeta.getName();
      operatorArray.add(fullName);
    }
  }
  ArrayList<Map<String, Object>> modulesArray = new ArrayList<>();
  moduleDetailMap.put("modules", modulesArray);
  for (LogicalPlan.ModuleMeta meta : moduleMeta.getDag().getAllModules()) {
    modulesArray.add(getLogicalModuleDetails(dag, meta));
  }
  return moduleDetailMap;
}
 
Example 2
Source File: LogicalPlanSerializer.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
/**
 * Return information about operators and inner modules of a module.
 *
 * @param dag        top level DAG
 * @param moduleMeta module information. DAG within module is used for constructing response.
 * @return
 */
private static Map<String, Object> getLogicalModuleDetails(LogicalPlan dag, LogicalPlan.ModuleMeta moduleMeta)
{
  Map<String, Object> moduleDetailMap = new HashMap<>();
  ArrayList<String> operatorArray = new ArrayList<>();
  moduleDetailMap.put("name", moduleMeta.getName());
  moduleDetailMap.put("className", moduleMeta.getGenericOperator().getClass().getName());

  moduleDetailMap.put("operators", operatorArray);
  for (OperatorMeta operatorMeta : moduleMeta.getDag().getAllOperators()) {
    if (operatorMeta.getModuleName() == null) {
      String fullName = moduleMeta.getFullName() + LogicalPlan.MODULE_NAMESPACE_SEPARATOR + operatorMeta.getName();
      operatorArray.add(fullName);
    }
  }
  ArrayList<Map<String, Object>> modulesArray = new ArrayList<>();
  moduleDetailMap.put("modules", modulesArray);
  for (LogicalPlan.ModuleMeta meta : moduleMeta.getDag().getAllModules()) {
    modulesArray.add(getLogicalModuleDetails(dag, meta));
  }
  return moduleDetailMap;
}
 
Example 3
Source File: StreamingContainerManager.java    From Bats with Apache License 2.0 5 votes vote down vote up
private OperatorAggregationInfo fillOperatorAggregationInfo(OperatorMeta operator)
{
  OperatorAggregationInfo oai = new OperatorAggregationInfo();

  Collection<PTOperator> physicalOperators = getPhysicalPlan().getAllOperators(operator);
  if (physicalOperators.isEmpty()) {
    return null;
  }
  oai.name = operator.getName();

  for (PTOperator physicalOperator : physicalOperators) {
    if (!physicalOperator.isUnifier()) {
      OperatorStatus os = physicalOperator.stats;
      oai.latencyMA.addNumber(os.latencyMA.getAvg());
      oai.cpuPercentageMA.addNumber(os.cpuNanosPMSMA.getAvg() / 10000);
      oai.tuplesEmittedPSMA.addNumber(os.tuplesEmittedPSMA.get());
      oai.tuplesProcessedPSMA.addNumber(os.tuplesProcessedPSMA.get());
      oai.currentWindowId.addNumber(os.currentWindowId.get());
      oai.recoveryWindowId.addNumber(toWsWindowId(physicalOperator.getRecoveryCheckpoint().windowId));
      if (os.lastHeartbeat != null) {
        oai.lastHeartbeat.addNumber(os.lastHeartbeat.getGeneratedTms());
      }
      oai.checkpointTime.addNumber(os.checkpointTimeMA.getAvg());
    }
  }
  return oai;
}
 
Example 4
Source File: StreamingContainerManager.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
private OperatorAggregationInfo fillOperatorAggregationInfo(OperatorMeta operator)
{
  OperatorAggregationInfo oai = new OperatorAggregationInfo();

  Collection<PTOperator> physicalOperators = getPhysicalPlan().getAllOperators(operator);
  if (physicalOperators.isEmpty()) {
    return null;
  }
  oai.name = operator.getName();

  for (PTOperator physicalOperator : physicalOperators) {
    if (!physicalOperator.isUnifier()) {
      OperatorStatus os = physicalOperator.stats;
      oai.latencyMA.addNumber(os.latencyMA.getAvg());
      oai.cpuPercentageMA.addNumber(os.cpuNanosPMSMA.getAvg() / 10000);
      oai.tuplesEmittedPSMA.addNumber(os.tuplesEmittedPSMA.get());
      oai.tuplesProcessedPSMA.addNumber(os.tuplesProcessedPSMA.get());
      oai.currentWindowId.addNumber(os.currentWindowId.get());
      oai.recoveryWindowId.addNumber(toWsWindowId(physicalOperator.getRecoveryCheckpoint().windowId));
      if (os.lastHeartbeat != null) {
        oai.lastHeartbeat.addNumber(os.lastHeartbeat.getGeneratedTms());
      }
      oai.checkpointTime.addNumber(os.checkpointTimeMA.getAvg());
    }
  }
  return oai;
}
 
Example 5
Source File: LogicalPlanSerializer.java    From Bats with Apache License 2.0 4 votes vote down vote up
public static PropertiesConfiguration convertToProperties(LogicalPlan dag)
{
  PropertiesConfiguration props = new PropertiesConfiguration();
  Collection<OperatorMeta> allOperators = dag.getAllOperators();

  for (OperatorMeta operatorMeta : allOperators) {
    String operatorKey = LogicalPlanConfiguration.OPERATOR_PREFIX + operatorMeta.getName();
    Operator operator = operatorMeta.getOperator();
    props.setProperty(operatorKey + "." + LogicalPlanConfiguration.OPERATOR_CLASSNAME, operator.getClass().getName());
    BeanMap operatorProperties = LogicalPlanConfiguration.getObjectProperties(operator);
    @SuppressWarnings("rawtypes")
    Iterator entryIterator = operatorProperties.entryIterator();
    while (entryIterator.hasNext()) {
      try {
        @SuppressWarnings("unchecked")
        Map.Entry<String, Object> entry = (Map.Entry<String, Object>)entryIterator.next();
        if (!entry.getKey().equals("class") && !entry.getKey().equals("name") && entry.getValue() != null) {
          props.setProperty(operatorKey + "." + entry.getKey(), entry.getValue());
        }
      } catch (Exception ex) {
        LOG.warn("Error trying to get a property of operator {}", operatorMeta.getName(), ex);
      }
    }
  }
  Collection<StreamMeta> allStreams = dag.getAllStreams();

  for (StreamMeta streamMeta : allStreams) {
    String streamKey = LogicalPlanConfiguration.STREAM_PREFIX + streamMeta.getName();
    OutputPortMeta source = streamMeta.getSource();
    Collection<InputPortMeta> sinks = streamMeta.getSinks();
    props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_SOURCE, source.getOperatorMeta().getName() + "." + source.getPortName());
    String sinksValue = "";
    for (InputPortMeta sink : sinks) {
      if (!sinksValue.isEmpty()) {
        sinksValue += ",";
      }
      sinksValue += sink.getOperatorMeta().getName() + "." + sink.getPortName();
    }
    props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_SINKS, sinksValue);
    if (streamMeta.getLocality() != null) {
      props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_LOCALITY, streamMeta.getLocality().name());
    }
  }

  // TBD: Attributes

  return props;
}
 
Example 6
Source File: LogicalPlanConfiguration.java    From Bats with Apache License 2.0 4 votes vote down vote up
private PropertyArgs getPropertyArgs(OperatorMeta om)
{
  return new PropertyArgs(om.getName(), om.getGenericOperator().getClass().getName());
}
 
Example 7
Source File: LogicalPlanSerializer.java    From attic-apex-core with Apache License 2.0 4 votes vote down vote up
public static PropertiesConfiguration convertToProperties(LogicalPlan dag)
{
  PropertiesConfiguration props = new PropertiesConfiguration();
  Collection<OperatorMeta> allOperators = dag.getAllOperators();

  for (OperatorMeta operatorMeta : allOperators) {
    String operatorKey = LogicalPlanConfiguration.OPERATOR_PREFIX + operatorMeta.getName();
    Operator operator = operatorMeta.getOperator();
    props.setProperty(operatorKey + "." + LogicalPlanConfiguration.OPERATOR_CLASSNAME, operator.getClass().getName());
    BeanMap operatorProperties = LogicalPlanConfiguration.getObjectProperties(operator);
    @SuppressWarnings("rawtypes")
    Iterator entryIterator = operatorProperties.entryIterator();
    while (entryIterator.hasNext()) {
      try {
        @SuppressWarnings("unchecked")
        Map.Entry<String, Object> entry = (Map.Entry<String, Object>)entryIterator.next();
        if (!entry.getKey().equals("class") && !entry.getKey().equals("name") && entry.getValue() != null) {
          props.setProperty(operatorKey + "." + entry.getKey(), entry.getValue());
        }
      } catch (Exception ex) {
        LOG.warn("Error trying to get a property of operator {}", operatorMeta.getName(), ex);
      }
    }
  }
  Collection<StreamMeta> allStreams = dag.getAllStreams();

  for (StreamMeta streamMeta : allStreams) {
    String streamKey = LogicalPlanConfiguration.STREAM_PREFIX + streamMeta.getName();
    OutputPortMeta source = streamMeta.getSource();
    Collection<InputPortMeta> sinks = streamMeta.getSinks();
    props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_SOURCE, source.getOperatorMeta().getName() + "." + source.getPortName());
    String sinksValue = "";
    for (InputPortMeta sink : sinks) {
      if (!sinksValue.isEmpty()) {
        sinksValue += ",";
      }
      sinksValue += sink.getOperatorMeta().getName() + "." + sink.getPortName();
    }
    props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_SINKS, sinksValue);
    if (streamMeta.getLocality() != null) {
      props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_LOCALITY, streamMeta.getLocality().name());
    }
  }

  // TBD: Attributes

  return props;
}
 
Example 8
Source File: LogicalPlanConfiguration.java    From attic-apex-core with Apache License 2.0 4 votes vote down vote up
private PropertyArgs getPropertyArgs(OperatorMeta om)
{
  return new PropertyArgs(om.getName(), om.getGenericOperator().getClass().getName());
}