Java Code Examples for com.datatorrent.stram.plan.logical.LogicalPlan.StreamMeta#getName()
The following examples show how to use
com.datatorrent.stram.plan.logical.LogicalPlan.StreamMeta#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 | 4 votes |
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 2
Source File: LogicalPlanSerializer.java From attic-apex-core with Apache License 2.0 | 4 votes |
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; }