Search in sources :

Example 1 with Builder

use of org.apache.tez.test.service.rpc.TezTestServiceProtocolProtos.TaskSpecProto.Builder in project tez by apache.

the class ProtoConverters method convertTaskSpecToProto.

public static TaskSpecProto convertTaskSpecToProto(TaskSpec taskSpec) {
    Builder builder = TaskSpecProto.newBuilder();
    builder.setTaskAttemptIdString(taskSpec.getTaskAttemptID().toString());
    builder.setDagName(taskSpec.getDAGName());
    builder.setVertexName(taskSpec.getVertexName());
    builder.setVertexParallelism(taskSpec.getVertexParallelism());
    if (taskSpec.getProcessorDescriptor() != null) {
        builder.setProcessorDescriptor(DagTypeConverters.convertToDAGPlan(taskSpec.getProcessorDescriptor()));
    }
    if (taskSpec.getInputs() != null && !taskSpec.getInputs().isEmpty()) {
        for (InputSpec inputSpec : taskSpec.getInputs()) {
            builder.addInputSpecs(convertInputSpecToProto(inputSpec));
        }
    }
    if (taskSpec.getOutputs() != null && !taskSpec.getOutputs().isEmpty()) {
        for (OutputSpec outputSpec : taskSpec.getOutputs()) {
            builder.addOutputSpecs(convertOutputSpecToProto(outputSpec));
        }
    }
    if (taskSpec.getGroupInputs() != null && !taskSpec.getGroupInputs().isEmpty()) {
        for (GroupInputSpec groupInputSpec : taskSpec.getGroupInputs()) {
            builder.addGroupedInputSpecs(convertGroupInputSpecToProto(groupInputSpec));
        }
    }
    if (taskSpec.getTaskConf() != null) {
        ConfigurationProto.Builder confBuilder = ConfigurationProto.newBuilder();
        Iterator<Entry<String, String>> iter = taskSpec.getTaskConf().iterator();
        while (iter.hasNext()) {
            Entry<String, String> entry = iter.next();
            confBuilder.addConfKeyValues(PlanKeyValuePair.newBuilder().setKey(entry.getKey()).setValue(entry.getValue()).build());
        }
        builder.setTaskConf(confBuilder.build());
    }
    return builder.build();
}
Also used : Entry(java.util.Map.Entry) Builder(org.apache.tez.test.service.rpc.TezTestServiceProtocolProtos.TaskSpecProto.Builder) GroupInputSpec(org.apache.tez.runtime.api.impl.GroupInputSpec) InputSpec(org.apache.tez.runtime.api.impl.InputSpec) OutputSpec(org.apache.tez.runtime.api.impl.OutputSpec) GroupInputSpec(org.apache.tez.runtime.api.impl.GroupInputSpec) ConfigurationProto(org.apache.tez.dag.api.records.DAGProtos.ConfigurationProto)

Aggregations

Entry (java.util.Map.Entry)1 ConfigurationProto (org.apache.tez.dag.api.records.DAGProtos.ConfigurationProto)1 GroupInputSpec (org.apache.tez.runtime.api.impl.GroupInputSpec)1 InputSpec (org.apache.tez.runtime.api.impl.InputSpec)1 OutputSpec (org.apache.tez.runtime.api.impl.OutputSpec)1 Builder (org.apache.tez.test.service.rpc.TezTestServiceProtocolProtos.TaskSpecProto.Builder)1