-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa74cc0
commit 3978922
Showing
17 changed files
with
313 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
76 changes: 76 additions & 0 deletions
76
...1.15/src/test/java/org/apache/beam/runners/flink/streaming/MemoryStateBackendWrapper.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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.beam.runners.flink.streaming; | ||
|
||
import java.util.Collection; | ||
import org.apache.flink.api.common.JobID; | ||
import org.apache.flink.api.common.typeutils.TypeSerializer; | ||
import org.apache.flink.core.fs.CloseableRegistry; | ||
import org.apache.flink.metrics.MetricGroup; | ||
import org.apache.flink.runtime.execution.Environment; | ||
import org.apache.flink.runtime.query.TaskKvStateRegistry; | ||
import org.apache.flink.runtime.state.AbstractKeyedStateBackend; | ||
import org.apache.flink.runtime.state.BackendBuildingException; | ||
import org.apache.flink.runtime.state.KeyGroupRange; | ||
import org.apache.flink.runtime.state.KeyedStateHandle; | ||
import org.apache.flink.runtime.state.OperatorStateBackend; | ||
import org.apache.flink.runtime.state.OperatorStateHandle; | ||
import org.apache.flink.runtime.state.memory.MemoryStateBackend; | ||
import org.apache.flink.runtime.state.ttl.TtlTimeProvider; | ||
|
||
class MemoryStateBackendWrapper { | ||
static <K> AbstractKeyedStateBackend<K> createKeyedStateBackend( | ||
Environment env, | ||
JobID jobID, | ||
String operatorIdentifier, | ||
TypeSerializer<K> keySerializer, | ||
int numberOfKeyGroups, | ||
KeyGroupRange keyGroupRange, | ||
TaskKvStateRegistry kvStateRegistry, | ||
TtlTimeProvider ttlTimeProvider, | ||
MetricGroup metricGroup, | ||
Collection<KeyedStateHandle> stateHandles, | ||
CloseableRegistry cancelStreamRegistry) | ||
throws BackendBuildingException { | ||
|
||
MemoryStateBackend backend = new MemoryStateBackend(); | ||
return backend.createKeyedStateBackend( | ||
env, | ||
jobID, | ||
operatorIdentifier, | ||
keySerializer, | ||
numberOfKeyGroups, | ||
keyGroupRange, | ||
kvStateRegistry, | ||
ttlTimeProvider, | ||
metricGroup, | ||
stateHandles, | ||
cancelStreamRegistry); | ||
} | ||
|
||
static OperatorStateBackend createOperatorStateBackend( | ||
Environment env, | ||
String operatorIdentifier, | ||
Collection<OperatorStateHandle> stateHandles, | ||
CloseableRegistry cancelStreamRegistry) | ||
throws Exception { | ||
MemoryStateBackend backend = new MemoryStateBackend(); | ||
return backend.createOperatorStateBackend( | ||
env, operatorIdentifier, stateHandles, cancelStreamRegistry); | ||
} | ||
} |
File renamed without changes.
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
project.ext { | ||
flink_major = '1.19' | ||
flink_version = '1.19.0' | ||
} | ||
|
||
// Load the main build script which contains all build logic. | ||
apply from: "../flink_runner.gradle" |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
def basePath = '../../job-server-container' | ||
|
||
project.ext { | ||
resource_path = basePath | ||
} | ||
|
||
// Load the main build script which contains all build logic. | ||
apply from: "$basePath/flink_job_server_container.gradle" |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
def basePath = '../../job-server' | ||
|
||
project.ext { | ||
// Look for the source code in the parent module | ||
main_source_dirs = ["$basePath/src/main/java"] | ||
test_source_dirs = ["$basePath/src/test/java"] | ||
main_resources_dirs = ["$basePath/src/main/resources"] | ||
test_resources_dirs = ["$basePath/src/test/resources"] | ||
archives_base_name = 'beam-runners-flink-1.19-job-server' | ||
} | ||
|
||
// Load the main build script which contains all build logic. | ||
apply from: "$basePath/flink_job_server.gradle" |
80 changes: 80 additions & 0 deletions
80
...1.19/src/test/java/org/apache/beam/runners/flink/streaming/MemoryStateBackendWrapper.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* 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.beam.runners.flink.streaming; | ||
|
||
import java.util.Collection; | ||
import org.apache.flink.api.common.JobID; | ||
import org.apache.flink.api.common.typeutils.TypeSerializer; | ||
import org.apache.flink.core.fs.CloseableRegistry; | ||
import org.apache.flink.metrics.MetricGroup; | ||
import org.apache.flink.runtime.execution.Environment; | ||
import org.apache.flink.runtime.query.TaskKvStateRegistry; | ||
import org.apache.flink.runtime.state.AbstractKeyedStateBackend; | ||
import org.apache.flink.runtime.state.BackendBuildingException; | ||
import org.apache.flink.runtime.state.KeyGroupRange; | ||
import org.apache.flink.runtime.state.KeyedStateBackendParametersImpl; | ||
import org.apache.flink.runtime.state.KeyedStateHandle; | ||
import org.apache.flink.runtime.state.OperatorStateBackend; | ||
import org.apache.flink.runtime.state.OperatorStateBackendParametersImpl; | ||
import org.apache.flink.runtime.state.OperatorStateHandle; | ||
import org.apache.flink.runtime.state.memory.MemoryStateBackend; | ||
import org.apache.flink.runtime.state.ttl.TtlTimeProvider; | ||
|
||
class MemoryStateBackendWrapper { | ||
static <K> AbstractKeyedStateBackend<K> createKeyedStateBackend( | ||
Environment env, | ||
JobID jobID, | ||
String operatorIdentifier, | ||
TypeSerializer<K> keySerializer, | ||
int numberOfKeyGroups, | ||
KeyGroupRange keyGroupRange, | ||
TaskKvStateRegistry kvStateRegistry, | ||
TtlTimeProvider ttlTimeProvider, | ||
MetricGroup metricGroup, | ||
Collection<KeyedStateHandle> stateHandles, | ||
CloseableRegistry cancelStreamRegistry) | ||
throws BackendBuildingException { | ||
|
||
MemoryStateBackend backend = new MemoryStateBackend(); | ||
return backend.createKeyedStateBackend( | ||
new KeyedStateBackendParametersImpl<>( | ||
env, | ||
jobID, | ||
operatorIdentifier, | ||
keySerializer, | ||
numberOfKeyGroups, | ||
keyGroupRange, | ||
kvStateRegistry, | ||
ttlTimeProvider, | ||
metricGroup, | ||
stateHandles, | ||
cancelStreamRegistry)); | ||
} | ||
|
||
static OperatorStateBackend createOperatorStateBackend( | ||
Environment env, | ||
String operatorIdentifier, | ||
Collection<OperatorStateHandle> stateHandles, | ||
CloseableRegistry cancelStreamRegistry) | ||
throws Exception { | ||
MemoryStateBackend backend = new MemoryStateBackend(); | ||
return backend.createOperatorStateBackend( | ||
new OperatorStateBackendParametersImpl( | ||
env, operatorIdentifier, stateHandles, cancelStreamRegistry)); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
runners/flink/1.19/src/test/java/org/apache/beam/runners/flink/streaming/StreamSources.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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.beam.runners.flink.streaming; | ||
|
||
import org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder; | ||
import org.apache.flink.streaming.api.functions.source.SourceFunction; | ||
import org.apache.flink.streaming.api.operators.AbstractStreamOperator; | ||
import org.apache.flink.streaming.api.operators.Output; | ||
import org.apache.flink.streaming.api.operators.StreamSource; | ||
import org.apache.flink.streaming.runtime.streamrecord.RecordAttributes; | ||
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; | ||
import org.apache.flink.streaming.runtime.tasks.OperatorChain; | ||
import org.apache.flink.streaming.runtime.tasks.RegularOperatorChain; | ||
import org.apache.flink.streaming.runtime.tasks.StreamTask; | ||
import org.apache.flink.streaming.runtime.watermarkstatus.WatermarkStatus; | ||
|
||
/** {@link StreamSource} utilities, that bridge incompatibilities between Flink releases. */ | ||
public class StreamSources { | ||
|
||
public static <OutT, SrcT extends SourceFunction<OutT>> void run( | ||
StreamSource<OutT, SrcT> streamSource, | ||
Object lockingObject, | ||
Output<StreamRecord<OutT>> collector) | ||
throws Exception { | ||
streamSource.run(lockingObject, collector, createOperatorChain(streamSource)); | ||
} | ||
|
||
private static OperatorChain<?, ?> createOperatorChain(AbstractStreamOperator<?> operator) { | ||
return new RegularOperatorChain<>( | ||
operator.getContainingTask(), | ||
StreamTask.createRecordWriterDelegate( | ||
operator.getOperatorConfig(), new MockEnvironmentBuilder().build())); | ||
} | ||
|
||
/** The emitWatermarkStatus method was added in Flink 1.14, so we need to wrap Output. */ | ||
public interface OutputWrapper<T> extends Output<T> { | ||
@Override | ||
default void emitWatermarkStatus(WatermarkStatus watermarkStatus) {} | ||
|
||
/** In Flink 1.19 the {@code emitRecordAttributes} method was added. */ | ||
@Override | ||
default void emitRecordAttributes(RecordAttributes recordAttributes) { | ||
throw new UnsupportedOperationException("emitRecordAttributes not implemented"); | ||
} | ||
} | ||
} |
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.