Streaming state (#7348)

This commit is contained in:
WuTao
2020-04-28 10:36:32 +08:00
committed by GitHub
parent be5235d982
commit 32c2055c99
81 changed files with 5670 additions and 20 deletions
@@ -1,5 +1,14 @@
package io.ray.streaming.api.context;
import io.ray.streaming.state.backend.KeyStateBackend;
import io.ray.streaming.state.keystate.desc.ListStateDescriptor;
import io.ray.streaming.state.keystate.desc.MapStateDescriptor;
import io.ray.streaming.state.keystate.desc.ValueStateDescriptor;
import io.ray.streaming.state.keystate.state.ListState;
import io.ray.streaming.state.keystate.state.MapState;
import io.ray.streaming.state.keystate.state.ValueState;
import java.util.Map;
/**
* Encapsulate the runtime information of a streaming task.
*/
@@ -11,8 +20,23 @@ public interface RuntimeContext {
int getParallelism();
Long getBatchId();
Long getCheckpointId();
void setCheckpointId(long checkpointId);
Long getMaxBatch();
Map<String, String> getConfig();
void setCurrentKey(Object key);
KeyStateBackend getKeyStateBackend();
void setKeyStateBackend(KeyStateBackend keyStateBackend);
<T> ValueState<T> getValueState(ValueStateDescriptor<T> stateDescriptor);
<T> ListState<T> getListState(ListStateDescriptor<T> stateDescriptor);
<S, T> MapState<S, T> getMapState(MapStateDescriptor<S, T> stateDescriptor);
}
@@ -10,7 +10,6 @@ import io.ray.streaming.operator.StreamOperator;
import java.util.List;
public class SourceOperator<T> extends StreamOperator<SourceFunction<T>> {
private SourceContextImpl sourceContext;
public SourceOperator(SourceFunction<T> function) {
@@ -38,6 +37,7 @@ public class SourceOperator<T> extends StreamOperator<SourceFunction<T>> {
}
class SourceContextImpl implements SourceContext<T> {
private List<Collector> collectors;
public SourceContextImpl(List<Collector> collectors) {