-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP][feature][spark] Support streaming
- Support Spark Continuous Processing
- Loading branch information
Showing
13 changed files
with
652 additions
and
63 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...translation/spark/source/partition/continuous/ContinuousStreamSplitEnumeratorContext.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.seatunnel.translation.spark.source.partition.continuous; | ||
|
||
import org.apache.seatunnel.api.common.metrics.AbstractMetricsContext; | ||
import org.apache.seatunnel.api.common.metrics.MetricsContext; | ||
import org.apache.seatunnel.api.event.EventListener; | ||
import org.apache.seatunnel.api.source.SourceEvent; | ||
import org.apache.seatunnel.api.source.SourceSplit; | ||
import org.apache.seatunnel.api.source.SourceSplitEnumerator; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class ContinuousStreamSplitEnumeratorContext<SplitT extends SourceSplit> | ||
implements SourceSplitEnumerator.Context<SplitT> { | ||
private final int parallelism; | ||
private final EventListener eventListener; | ||
private final Set<Integer> readers = new HashSet<>(); | ||
|
||
public ContinuousStreamSplitEnumeratorContext(int parallelism, EventListener eventListener) { | ||
this.parallelism = parallelism; | ||
this.eventListener = eventListener; | ||
} | ||
|
||
@Override | ||
public int currentParallelism() { | ||
return this.parallelism; | ||
} | ||
|
||
@Override | ||
public Set<Integer> registeredReaders() { | ||
return this.readers; | ||
} | ||
|
||
@Override | ||
public void assignSplit(int subtaskId, List<SplitT> splits) {} | ||
|
||
@Override | ||
public void signalNoMoreSplits(int subtask) {} | ||
|
||
@Override | ||
public void sendEventToSourceReader(int subtaskId, SourceEvent event) { | ||
throw new UnsupportedOperationException( | ||
"Flink ParallelSource don't support sending SourceEvent. " | ||
+ "Please implement the `SupportCoordinate` marker interface on the SeaTunnel source."); | ||
} | ||
|
||
@Override | ||
public MetricsContext getMetricsContext() { | ||
// TODO Waiting for Flink and Spark to implement MetricsContext | ||
// https://github.com/apache/seatunnel/issues/3431 | ||
return new AbstractMetricsContext() {}; | ||
} | ||
|
||
@Override | ||
public EventListener getEventListener() { | ||
return eventListener; | ||
} | ||
} |
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
67 changes: 67 additions & 0 deletions
67
...atunnel/translation/spark/source/partition/continuous/source/endpoint/EndpointSource.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,67 @@ | ||
/* | ||
* 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.seatunnel.translation.spark.source.partition.continuous.source.endpoint; | ||
|
||
import org.apache.seatunnel.api.source.Collector; | ||
import org.apache.seatunnel.api.source.SeaTunnelSource; | ||
import org.apache.seatunnel.api.source.SourceSplit; | ||
import org.apache.seatunnel.api.source.SourceSplitEnumerator; | ||
import org.apache.seatunnel.translation.source.BaseSourceFunction; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class EndpointSource<T, SplitT extends SourceSplit, StateT extends Serializable> | ||
implements BaseSourceFunction<T> { | ||
private final SeaTunnelSource<T, SplitT, StateT> source; | ||
protected final SourceSplitEnumerator<SplitT, StateT> splitEnumerator; | ||
protected final Integer parallelism; | ||
protected final String jobId; | ||
|
||
public EndpointSource( | ||
SeaTunnelSource<T, SplitT, StateT> source, Integer parallelism, String jobId) { | ||
this.source = source; | ||
this.parallelism = parallelism; | ||
this.jobId = jobId; | ||
SourceSplitEnumerator.Context<SplitT> enumeratorContext = | ||
new EndpointSplitEnumeratorContext<>(parallelism, jobId); | ||
try { | ||
splitEnumerator = source.restoreEnumerator(enumeratorContext, null); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void open() throws Exception {} | ||
|
||
@Override | ||
public void run(Collector<T> collector) throws Exception {} | ||
|
||
@Override | ||
public Map<Integer, List<byte[]>> snapshotState(long checkpointId) throws Exception { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void close() throws Exception {} | ||
|
||
@Override | ||
public void notifyCheckpointComplete(long checkpointId) throws Exception {} | ||
} |
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.