XComp commented on a change in pull request #16157: URL: https://github.com/apache/flink/pull/16157#discussion_r655440983
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/Tasks.java ########## @@ -0,0 +1,175 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.runtime.jobmanager; + +import org.apache.flink.runtime.execution.Environment; +import org.apache.flink.runtime.io.network.api.reader.RecordReader; +import org.apache.flink.runtime.io.network.api.writer.RecordWriter; +import org.apache.flink.runtime.io.network.api.writer.RecordWriterBuilder; +import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable; +import org.apache.flink.types.IntValue; + +import java.io.IOException; + +/** Collection of {@link AbstractInvokable}s. */ +public class Tasks { + + /** An {@link AbstractInvokable} that forwards all incoming elements. */ + public static class Forwarder extends AbstractInvokable { + + public Forwarder(Environment environment) { + super(environment); + } + + @Override + public void invoke() throws Exception { + + final RecordReader<IntValue> reader = + new RecordReader<>( + getEnvironment().getInputGate(0), + IntValue.class, + getEnvironment().getTaskManagerInfo().getTmpDirectories()); + + final RecordWriter<IntValue> writer = + new RecordWriterBuilder<IntValue>().build(getEnvironment().getWriter(0)); + + try { + while (true) { + final IntValue record = reader.next(); + + if (record == null) { + return; + } + + writer.emit(record); + } + + // writer.flushAll(); Review comment: ah true, I should have checked the code above... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
