Search in sources :

Example 1 with OutputStreamInternal

use of org.apache.samza.operators.stream.OutputStreamInternal in project samza by apache.

the class OperatorJsonUtils method operatorToMap.

/**
   * Format the operator properties into a map
   * @param spec a {@link OperatorSpec} instance
   * @return map of the operator properties
   */
public static Map<String, Object> operatorToMap(OperatorSpec spec) {
    Map<String, Object> map = new HashMap<>();
    map.put(OP_CODE, spec.getOpCode().name());
    map.put(OP_ID, spec.getOpId());
    map.put(SOURCE_LOCATION, spec.getSourceLocation());
    if (spec.getNextStream() != null) {
        Collection<OperatorSpec> nextOperators = spec.getNextStream().getRegisteredOperatorSpecs();
        map.put(NEXT_OPERATOR_IDS, nextOperators.stream().map(OperatorSpec::getOpId).collect(Collectors.toSet()));
    } else {
        map.put(NEXT_OPERATOR_IDS, Collections.emptySet());
    }
    if (spec instanceof SinkOperatorSpec) {
        OutputStreamInternal outputStream = ((SinkOperatorSpec) spec).getOutputStream();
        if (outputStream != null) {
            map.put(OUTPUT_STREAM_ID, outputStream.getStreamSpec().getId());
        }
    }
    if (spec instanceof PartialJoinOperatorSpec) {
        map.put(TTL_MS, ((PartialJoinOperatorSpec) spec).getTtlMs());
    }
    return map;
}
Also used : OperatorSpec(org.apache.samza.operators.spec.OperatorSpec) PartialJoinOperatorSpec(org.apache.samza.operators.spec.PartialJoinOperatorSpec) SinkOperatorSpec(org.apache.samza.operators.spec.SinkOperatorSpec) HashMap(java.util.HashMap) PartialJoinOperatorSpec(org.apache.samza.operators.spec.PartialJoinOperatorSpec) SinkOperatorSpec(org.apache.samza.operators.spec.SinkOperatorSpec) OutputStreamInternal(org.apache.samza.operators.stream.OutputStreamInternal)

Aggregations

HashMap (java.util.HashMap)1 OperatorSpec (org.apache.samza.operators.spec.OperatorSpec)1 PartialJoinOperatorSpec (org.apache.samza.operators.spec.PartialJoinOperatorSpec)1 SinkOperatorSpec (org.apache.samza.operators.spec.SinkOperatorSpec)1 OutputStreamInternal (org.apache.samza.operators.stream.OutputStreamInternal)1