Revert "[Streaming] Fault Tolerance Implementation (#10008)" (#10582)

This reverts commit 1b1466748f.
This commit is contained in:
SangBin Cho
2020-09-04 13:21:18 -07:00
committed by GitHub
parent da83bbd764
commit cb919c5e5c
158 changed files with 1227 additions and 7040 deletions
@@ -7,26 +7,4 @@ import java.io.Serializable;
*/
public interface Function extends Serializable {
/**
* This method will be called periodically by framework, you should return a a serializable
* object which represents function state, framework will help you to serialize this object, save
* it to storage, and load it back when in fail-over through.
* {@link Function#loadCheckpoint(Serializable)}.
*
* @return A serializable object which represents function state.
*/
default Serializable saveCheckpoint() {
return null;
}
/**
* This method will be called by framework when a worker died and been restarted.
* We will pass the last object you returned in {@link Function#saveCheckpoint()} when
* doing checkpoint, you are responsible to load this object back to you function.
*
* @param checkpointObject the last object you returned in {@link Function#saveCheckpoint()}
*/
default void loadCheckpoint(Serializable checkpointObject) {
}
}
@@ -9,9 +9,9 @@ import io.ray.streaming.api.function.Function;
*/
public interface SourceFunction<T> extends Function {
void init(int parallelism, int index);
void init(int parallel, int index);
void fetch(SourceContext<T> ctx) throws Exception;
void run(SourceContext<T> ctx) throws Exception;
void close();
@@ -1,6 +1,7 @@
package io.ray.streaming.api.function.internal;
import io.ray.streaming.api.function.impl.SourceFunction;
import java.util.ArrayList;
import java.util.Collection;
/**
@@ -11,25 +12,22 @@ import java.util.Collection;
public class CollectionSourceFunction<T> implements SourceFunction<T> {
private Collection<T> values;
private boolean finished = false;
public CollectionSourceFunction(Collection<T> values) {
this.values = values;
}
@Override
public void init(int totalParallel, int currentIndex) {
public void init(int parallel, int index) {
}
@Override
public void fetch(SourceContext<T> ctx) throws Exception {
if (finished) {
return;
}
public void run(SourceContext<T> ctx) throws Exception {
for (T value : values) {
ctx.collect(value);
}
finished = true;
// empty collection
values = new ArrayList<>();
}
@Override
@@ -1,5 +1,6 @@
package io.ray.streaming.message;
import java.util.Objects;
public class KeyRecord<K, T> extends Record<T> {
@@ -25,13 +25,4 @@ public interface Operator extends Serializable {
ChainStrategy getChainStrategy();
/**
* See {@link Function#saveCheckpoint()}.
*/
Serializable saveCheckpoint();
/**
* See {@link Function#loadCheckpoint(Serializable)}.
*/
void loadCheckpoint(Serializable checkpointObject);
}
@@ -4,7 +4,7 @@ import io.ray.streaming.api.function.impl.SourceFunction.SourceContext;
public interface SourceOperator<T> extends Operator {
void fetch();
void run();
SourceContext<T> getSourceContext();
@@ -8,7 +8,6 @@ import io.ray.streaming.api.function.RichFunction;
import io.ray.streaming.api.function.internal.Functions;
import io.ray.streaming.message.KeyRecord;
import io.ray.streaming.message.Record;
import java.io.Serializable;
import java.util.List;
public abstract class StreamOperator<F extends Function> implements Operator {
@@ -73,16 +72,6 @@ public abstract class StreamOperator<F extends Function> implements Operator {
}
}
@Override
public Serializable saveCheckpoint() {
return function.saveCheckpoint();
}
@Override
public void loadCheckpoint(Serializable checkpointObject) {
function.loadCheckpoint(checkpointObject);
}
@Override
public String getName() {
return name;
@@ -13,7 +13,6 @@ import io.ray.streaming.operator.OperatorType;
import io.ray.streaming.operator.SourceOperator;
import io.ray.streaming.operator.StreamOperator;
import io.ray.streaming.operator.TwoInputOperator;
import java.io.Serializable;
import java.lang.reflect.Proxy;
import java.util.Collections;
import java.util.List;
@@ -86,23 +85,6 @@ public abstract class ChainedOperator extends StreamOperator<Function> {
return tailOperator;
}
@Override
public Serializable saveCheckpoint() {
Object[] checkpoints = new Object[operators.size()];
for (int i = 0; i < operators.size(); ++i) {
checkpoints[i] = operators.get(i).saveCheckpoint();
}
return checkpoints;
}
@Override
public void loadCheckpoint(Serializable checkpointObject) {
Serializable[] checkpoints = (Serializable[]) checkpointObject;
for (int i = 0; i < operators.size(); ++i) {
operators.get(i).loadCheckpoint(checkpoints[i]);
}
}
private RuntimeContext createRuntimeContext(RuntimeContext runtimeContext, int index) {
return (RuntimeContext) Proxy.newProxyInstance(runtimeContext.getClass().getClassLoader(),
new Class[] {RuntimeContext.class},
@@ -143,8 +125,8 @@ public abstract class ChainedOperator extends StreamOperator<Function> {
}
@Override
public void fetch() {
sourceOperator.fetch();
public void run() {
sourceOperator.run();
}
@Override
@@ -29,9 +29,9 @@ public class SourceOperatorImpl<T> extends StreamOperator<SourceFunction<T>>
}
@Override
public void fetch() {
public void run() {
try {
this.function.fetch(this.sourceContext);
this.function.run(this.sourceContext);
} catch (Exception e) {
throw new RuntimeException(e);
}