Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[streaming] Streaming runtime collector rework for increased flexibil…
…ity with directed outputs and operator chains
- Loading branch information
Showing
9 changed files
with
186 additions
and
86 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...reaming-core/src/main/java/org/apache/flink/streaming/api/collector/CollectorWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,48 @@ | |||
/* | |||
* 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.streaming.api.collector; | |||
|
|||
import java.util.LinkedList; | |||
import java.util.List; | |||
|
|||
import org.apache.flink.util.Collector; | |||
|
|||
public class CollectorWrapper<OUT> implements Collector<OUT> { | |||
|
|||
List<Collector<OUT>> outputs; | |||
|
|||
public CollectorWrapper() { | |||
this.outputs = new LinkedList<Collector<OUT>>(); | |||
} | |||
|
|||
public void addChainedOutput(Collector<OUT> output) { | |||
outputs.add(output); | |||
} | |||
|
|||
@Override | |||
public void collect(OUT record) { | |||
for(Collector<OUT> output: outputs){ | |||
output.collect(record);; | |||
} | |||
} | |||
|
|||
@Override | |||
public void close() { | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...k-streaming-core/src/main/java/org/apache/flink/streaming/api/collector/StreamOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,65 @@ | |||
/* | |||
* 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.streaming.api.collector; | |||
|
|||
import java.util.List; | |||
|
|||
import org.apache.flink.runtime.io.network.api.writer.RecordWriter; | |||
import org.apache.flink.runtime.plugable.SerializationDelegate; | |||
import org.apache.flink.streaming.api.streamrecord.StreamRecord; | |||
import org.apache.flink.util.Collector; | |||
|
|||
public class StreamOutput<OUT> implements Collector<SerializationDelegate<StreamRecord<OUT>>> { | |||
|
|||
private RecordWriter<SerializationDelegate<StreamRecord<OUT>>> output; | |||
|
|||
private List<String> selectedNames; | |||
private boolean selectAll = true; | |||
|
|||
public StreamOutput(RecordWriter<SerializationDelegate<StreamRecord<OUT>>> output, | |||
List<String> selectedNames) { | |||
|
|||
this.output = output; | |||
|
|||
if (selectedNames != null) { | |||
this.selectedNames = selectedNames; | |||
selectAll = false; | |||
} | |||
} | |||
|
|||
public void collect(SerializationDelegate<StreamRecord<OUT>> record) { | |||
try { | |||
output.emit(record); | |||
} catch (Exception e) { | |||
throw new RuntimeException("Could not emit record: " + record.getInstance()); | |||
} | |||
} | |||
|
|||
@Override | |||
public void close() { | |||
} | |||
|
|||
public boolean isSelectAll() { | |||
return selectAll; | |||
} | |||
|
|||
public List<String> getSelectedNames() { | |||
return selectedNames; | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.