diff --git a/java/test/pom.xml b/java/test/pom.xml index f5c83c558..e2b2aabf4 100644 --- a/java/test/pom.xml +++ b/java/test/pom.xml @@ -41,6 +41,11 @@ guava 27.0.1-jre + + com.google.protobuf + protobuf-java + 3.8.0 + com.sun.xml.bind jaxb-core diff --git a/streaming/java/checkstyle-suppressions.xml b/streaming/java/checkstyle-suppressions.xml index 7bb5e95cb..cb07198ed 100644 --- a/streaming/java/checkstyle-suppressions.xml +++ b/streaming/java/checkstyle-suppressions.xml @@ -1,14 +1,14 @@ + "-//Puppy Crawl//DTD Suppressions 1.1//EN" + "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> - - - + + + - + diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/context/ClusterStarter.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/context/ClusterStarter.java index 7ab72f6b8..89d166af7 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/context/ClusterStarter.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/context/ClusterStarter.java @@ -17,6 +17,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; class ClusterStarter { + private static final Logger LOG = LoggerFactory.getLogger(ClusterStarter.class); private static final String PLASMA_STORE_SOCKET_NAME = "/tmp/ray/plasma_store_socket"; private static final String RAYLET_SOCKET_NAME = "/tmp/ray/raylet_socket"; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/context/StreamingContext.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/context/StreamingContext.java index 63daebb73..1fb30e043 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/context/StreamingContext.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/context/StreamingContext.java @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory; * Encapsulate the context information of a streaming Job. */ public class StreamingContext implements Serializable { + private static final Logger LOG = LoggerFactory.getLogger(StreamingContext.class); private transient AtomicInteger idGenerator; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/RichFunction.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/RichFunction.java index 8ae2d05fa..32a3cff70 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/RichFunction.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/RichFunction.java @@ -3,21 +3,21 @@ package io.ray.streaming.api.function; import io.ray.streaming.api.context.RuntimeContext; /** - * An interface for all user-defined functions to define the life cycle methods of the - * functions, and access the task context where the functions get executed. + * An interface for all user-defined functions to define the life cycle methods of the functions, + * and access the task context where the functions get executed. */ public interface RichFunction extends Function { /** * Initialization method for user function which called before the first call to the user * function. + * * @param runtimeContext runtime context */ void open(RuntimeContext runtimeContext); /** - * Tear-down method for the user function which called after the last call to - * the user function. + * Tear-down method for the user function which called after the last call to the user function. */ void close(); diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/impl/FilterFunction.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/impl/FilterFunction.java index ad8e630ea..d60e335a9 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/impl/FilterFunction.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/impl/FilterFunction.java @@ -3,8 +3,8 @@ package io.ray.streaming.api.function.impl; import io.ray.streaming.api.function.Function; /** - * A filter function is a predicate applied individually to each record. - * The predicate decides whether to keep the element, or to discard it. + * A filter function is a predicate applied individually to each record. The predicate decides + * whether to keep the element, or to discard it. * * @param type of the input data. */ diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/internal/Functions.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/internal/Functions.java index 94441076f..0a8365315 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/internal/Functions.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/function/internal/Functions.java @@ -10,6 +10,7 @@ import io.ray.streaming.api.function.RichFunction; public class Functions { private static class DefaultRichFunction implements RichFunction { + private final Function function; private DefaultRichFunction(Function function) { diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/Partition.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/Partition.java index 5f923769b..8f9393c3a 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/Partition.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/Partition.java @@ -14,7 +14,7 @@ public interface Partition extends Function { * Given a record and downstream partitions, determine which partition(s) should receive the * record. * - * @param record The record. + * @param record The record. * @param numPartition num of partitions * @return IDs of the downstream partitions that should receive the record. */ diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/BroadcastPartition.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/BroadcastPartition.java index 4135c9f5e..dd1b38fb2 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/BroadcastPartition.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/BroadcastPartition.java @@ -7,6 +7,7 @@ import java.util.stream.IntStream; * Broadcast the record to all downstream partitions. */ public class BroadcastPartition implements Partition { + private int[] partitions = new int[0]; public BroadcastPartition() { diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/ForwardPartition.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/ForwardPartition.java index a89bf8f92..9b7473804 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/ForwardPartition.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/ForwardPartition.java @@ -10,6 +10,7 @@ import io.ray.streaming.api.partition.Partition; * @param Type of the input record. */ public class ForwardPartition implements Partition { + private int[] partitions = new int[] {0}; @Override diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/KeyPartition.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/KeyPartition.java index b76b41c3e..1de18168d 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/KeyPartition.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/KeyPartition.java @@ -10,6 +10,7 @@ import io.ray.streaming.message.KeyRecord; * @param Type of the input record. */ public class KeyPartition implements Partition> { + private int[] partitions = new int[1]; @Override diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/RoundRobinPartition.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/RoundRobinPartition.java index 3e5960740..01e624ced 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/RoundRobinPartition.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/partition/impl/RoundRobinPartition.java @@ -8,6 +8,7 @@ import io.ray.streaming.api.partition.Partition; * @param Type of the input record. */ public class RoundRobinPartition implements Partition { + private int seq; private int[] partitions = new int[1]; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/DataStream.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/DataStream.java index bd90b0e25..5ca3c7950 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/DataStream.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/DataStream.java @@ -22,7 +22,6 @@ import java.util.List; /** * Represents a stream of data. - * *

This class defines all the streaming operations. * * @param Type of data in the stream. @@ -33,9 +32,10 @@ public class DataStream extends Stream, T> { super(streamingContext, streamOperator); } - public DataStream(StreamingContext streamingContext, - StreamOperator streamOperator, - Partition partition) { + public DataStream( + StreamingContext streamingContext, + StreamOperator streamOperator, + Partition partition) { super(streamingContext, streamOperator, partition); } @@ -43,15 +43,16 @@ public class DataStream extends Stream, T> { super(input, streamOperator); } - public DataStream(DataStream input, - StreamOperator streamOperator, - Partition partition) { + public DataStream( + DataStream input, + StreamOperator streamOperator, + Partition partition) { super(input, streamOperator, partition); } /** - * Create a java stream that reference passed python stream. - * Changes in new stream will be reflected in referenced stream and vice versa + * Create a java stream that reference passed python stream. Changes in new stream will be + * reflected in referenced stream and vice versa */ public DataStream(PythonDataStream referencedStream) { super(referencedStream); @@ -84,8 +85,8 @@ public class DataStream extends Stream, T> { } /** - * Apply union transformations to this stream by merging {@link DataStream} outputs of - * the same type with each other. + * Apply union transformations to this stream by merging {@link DataStream} outputs of the same + * type with each other. * * @param stream The DataStream to union output with. * @param others The other DataStreams to union output with. @@ -100,8 +101,8 @@ public class DataStream extends Stream, T> { } /** - * Apply union transformations to this stream by merging {@link DataStream} outputs of - * the same type with each other. + * Apply union transformations to this stream by merging {@link DataStream} outputs of the same + * type with each other. * * @param streams The DataStreams to union output with. * @return A new UnionStream. @@ -177,8 +178,8 @@ public class DataStream extends Stream, T> { } /** - * If parent stream is a python stream, we can't call partition related methods - * in the java stream. + * If parent stream is a python stream, we can't call partition related methods in the java + * stream. */ private void checkPartitionCall() { if (getInputStream() != null && getInputStream().getLanguage() == Language.PYTHON) { @@ -188,9 +189,9 @@ public class DataStream extends Stream, T> { } /** - * Convert this stream as a python stream. - * The converted stream and this stream are the same logical stream, which has same stream id. - * Changes in converted stream will be reflected in this stream and vice versa. + * Convert this stream as a python stream. The converted stream and this stream are the same + * logical stream, which has same stream id. Changes in converted stream will be reflected in this + * stream and vice versa. */ public PythonDataStream asPythonStream() { return new PythonDataStream(this); diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/JoinStream.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/JoinStream.java index 1f03e517e..28d17ccc5 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/JoinStream.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/JoinStream.java @@ -13,6 +13,7 @@ import java.io.Serializable; * @param Type of the data in the joined stream. */ public class JoinStream extends DataStream { + private final DataStream rightStream; public JoinStream(DataStream leftStream, DataStream rightStream) { @@ -37,6 +38,7 @@ public class JoinStream extends DataStream { * @param Type of the join key. */ class Where implements Serializable { + private JoinStream joinStream; private KeyFunction leftKeyByFunction; @@ -56,12 +58,14 @@ public class JoinStream extends DataStream { * @param Type of the join key. */ class Equal implements Serializable { + private JoinStream joinStream; private KeyFunction leftKeyByFunction; private KeyFunction rightKeyByFunction; - Equal(JoinStream joinStream, KeyFunction leftKeyByFunction, - KeyFunction rightKeyByFunction) { + Equal( + JoinStream joinStream, KeyFunction leftKeyByFunction, + KeyFunction rightKeyByFunction) { this.joinStream = joinStream; this.leftKeyByFunction = leftKeyByFunction; this.rightKeyByFunction = rightKeyByFunction; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/KeyDataStream.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/KeyDataStream.java index 68708b9e9..cab788ca6 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/KeyDataStream.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/KeyDataStream.java @@ -23,8 +23,8 @@ public class KeyDataStream extends DataStream { } /** - * Create a java stream that reference passed python stream. - * Changes in new stream will be reflected in referenced stream and vice versa + * Create a java stream that reference passed python stream. Changes in new stream will be + * reflected in referenced stream and vice versa */ public KeyDataStream(PythonDataStream referencedStream) { super(referencedStream); @@ -53,9 +53,9 @@ public class KeyDataStream extends DataStream { } /** - * Convert this stream as a python stream. - * The converted stream and this stream are the same logical stream, which has same stream id. - * Changes in converted stream will be reflected in this stream and vice versa. + * Convert this stream as a python stream. The converted stream and this stream are the same + * logical stream, which has same stream id. Changes in converted stream will be reflected in this + * stream and vice versa. */ public PythonKeyDataStream asPythonStream() { return new PythonKeyDataStream(this); diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/Stream.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/Stream.java index 987df79b0..ac750b939 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/Stream.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/Stream.java @@ -21,6 +21,7 @@ import java.util.Map; */ public abstract class Stream, T> implements Serializable { + private final int id; private final StreamingContext streamingContext; private final Stream inputStream; @@ -34,9 +35,10 @@ public abstract class Stream, T> this(streamingContext, null, streamOperator, getForwardPartition(streamOperator)); } - public Stream(StreamingContext streamingContext, - StreamOperator streamOperator, - Partition partition) { + public Stream( + StreamingContext streamingContext, + StreamOperator streamOperator, + Partition partition) { this(streamingContext, null, streamOperator, partition); } @@ -49,10 +51,11 @@ public abstract class Stream, T> this(inputStream.getStreamingContext(), inputStream, streamOperator, partition); } - protected Stream(StreamingContext streamingContext, - Stream inputStream, - StreamOperator streamOperator, - Partition partition) { + protected Stream( + StreamingContext streamingContext, + Stream inputStream, + StreamOperator streamOperator, + Partition partition) { this.streamingContext = streamingContext; this.inputStream = inputStream; this.operator = streamOperator; @@ -64,8 +67,8 @@ public abstract class Stream, T> } /** - * Create a proxy stream of original stream. - * Changes in new stream will be reflected in original stream and vice versa + * Create a proxy stream of original stream. Changes in new stream will be reflected in original + * stream and vice versa */ protected Stream(Stream originalStream) { this.originalStream = originalStream; @@ -183,8 +186,8 @@ public abstract class Stream, T> } /** - * Set the partition function of this {@link Stream} so that output elements are forwarded to - * next operator locally. + * Set the partition function of this {@link Stream} so that output elements are forwarded to next + * operator locally. */ public S forward() { return setPartition(getForwardPartition(operator)); diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/StreamSink.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/StreamSink.java index f03b1baa4..1dd9fcd4f 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/StreamSink.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/StreamSink.java @@ -8,6 +8,7 @@ import io.ray.streaming.operator.StreamOperator; * @param Type of the input data of this sink. */ public abstract class StreamSink extends Stream, T> { + public StreamSink(Stream inputStream, StreamOperator streamOperator) { super(inputStream, streamOperator); } diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/StreamSource.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/StreamSource.java index 0f099be8c..692206695 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/StreamSource.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/StreamSource.java @@ -6,4 +6,5 @@ package io.ray.streaming.api.stream; * @param The type of StreamSource data. */ public interface StreamSource { + } diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/UnionStream.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/UnionStream.java index c3854a6a0..6fd83e29b 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/UnionStream.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/api/stream/UnionStream.java @@ -6,13 +6,13 @@ import java.util.List; /** * Represents a union DataStream. - * *

This stream does not create a physical operation, it only affects how upstream data are - * connected to downstream data. + * connected to downstream data. * * @param The type of union data. */ public class UnionStream extends DataStream { + private List> unionStreams; public UnionStream(DataStream input, List> streams) { diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraph.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraph.java index 8711109a2..cbbf76b75 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraph.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraph.java @@ -30,8 +30,9 @@ public class JobGraph implements Serializable { this.jobEdges = new ArrayList<>(); } - public JobGraph(String jobName, Map jobConfig, - List jobVertices, List jobEdges) { + public JobGraph( + String jobName, Map jobConfig, + List jobVertices, List jobEdges) { this.jobName = jobName; this.jobConfig = jobConfig; this.jobVertices = jobVertices; @@ -40,8 +41,8 @@ public class JobGraph implements Serializable { } /** - * Generate direct-graph(made up of a set of vertices and connected by edges) - * by current job graph for simple log printing. + * Generate direct-graph(made up of a set of vertices and connected by edges) by current job graph + * for simple log printing. * * @return Digraph in string type. */ diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraphBuilder.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraphBuilder.java index 2f6eee6c6..86e7d241d 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraphBuilder.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraphBuilder.java @@ -19,6 +19,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class JobGraphBuilder { + private static final Logger LOG = LoggerFactory.getLogger(JobGraphBuilder.class); private JobGraph jobGraph; @@ -34,8 +35,9 @@ public class JobGraphBuilder { this(streamSinkList, jobName, new HashMap<>()); } - public JobGraphBuilder(List streamSinkList, String jobName, - Map jobConfig) { + public JobGraphBuilder( + List streamSinkList, String jobName, + Map jobConfig) { this.jobGraph = new JobGraph(jobName, jobConfig); this.streamSinkList = streamSinkList; this.edgeIdGenerator = new AtomicInteger(0); @@ -98,7 +100,7 @@ public class JobGraphBuilder { // process join stream if (stream instanceof JoinStream) { - DataStream rightStream = ((JoinStream) stream).getRightStream(); + DataStream rightStream = ((JoinStream) stream).getRightStream(); this.jobGraph.addEdge( new JobEdge(rightStream.getId(), vertexId, rightStream.getPartition())); processStream(rightStream); diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraphOptimizer.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraphOptimizer.java index c44d0be6a..05407722e 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraphOptimizer.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobGraphOptimizer.java @@ -21,10 +21,11 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.Pair; /** - * Optimize job graph by chaining some operators so that some operators can be run in the - * same thread. + * Optimize job graph by chaining some operators so that some operators can be run in the same + * thread. */ public class JobGraphOptimizer { + private final JobGraph jobGraph; private Set visited = new HashSet<>(); // vertex id -> vertex @@ -89,7 +90,8 @@ public class JobGraphOptimizer { mergedVertex = headVertex; } else { List operators = verticesToMerge.stream() - .map(v -> vertexMap.get(v.getVertexId()).getStreamOperator()) + .map(v -> vertexMap.get(v.getVertexId()) + .getStreamOperator()) .collect(Collectors.toList()); List> configs = verticesToMerge.stream() .map(v -> vertexMap.get(v.getVertexId()).getConfig()) @@ -99,7 +101,8 @@ public class JobGraphOptimizer { operator = ChainedOperator.newChainedOperator(operators, configs); } else { List pythonOperators = operators.stream() - .map(o -> (PythonOperator) o).collect(Collectors.toList()); + .map(o -> (PythonOperator) o) + .collect(Collectors.toList()); operator = new ChainedPythonOperator(pythonOperators, configs); } // chained operator config is placed into `ChainedOperator`. @@ -156,9 +159,10 @@ public class JobGraphOptimizer { } } - private boolean canBeChained(JobVertex precedingVertex, - JobVertex succeedingVertex, - JobEdge edge) { + private boolean canBeChained( + JobVertex precedingVertex, + JobVertex succeedingVertex, + JobEdge edge) { if (jobGraph.getVertexOutputEdges(precedingVertex.getVertexId()).size() > 1 || jobGraph.getVertexInputEdges(succeedingVertex.getVertexId()).size() > 1) { return false; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobVertex.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobVertex.java index 7fdb4efdd..dd59ea36d 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobVertex.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/jobgraph/JobVertex.java @@ -18,11 +18,12 @@ public class JobVertex implements Serializable { private StreamOperator streamOperator; private Map config; - public JobVertex(int vertexId, - int parallelism, - VertexType vertexType, - StreamOperator streamOperator, - Map config) { + public JobVertex( + int vertexId, + int parallelism, + VertexType vertexType, + StreamOperator streamOperator, + Map config) { this.vertexId = vertexId; this.parallelism = parallelism; this.vertexType = vertexType; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/message/Record.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/message/Record.java index 777b36dbb..fb1ee2636 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/message/Record.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/message/Record.java @@ -4,6 +4,7 @@ import java.io.Serializable; import java.util.Objects; public class Record implements Serializable { + protected transient String stream; protected T value; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/StreamOperator.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/StreamOperator.java index 4c9239966..67bc77381 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/StreamOperator.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/StreamOperator.java @@ -11,6 +11,7 @@ import io.ray.streaming.message.Record; import java.util.List; public abstract class StreamOperator implements Operator { + protected final String name; protected F function; protected RichFunction richFunction; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/chain/ChainedOperator.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/chain/ChainedOperator.java index ad44d8097..c7c9e7a18 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/chain/ChainedOperator.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/chain/ChainedOperator.java @@ -23,6 +23,7 @@ import java.util.stream.Collectors; * Abstract base class for chained operators. */ public abstract class ChainedOperator extends StreamOperator { + protected final List operators; protected final Operator headOperator; protected final Operator tailOperator; @@ -43,7 +44,8 @@ public abstract class ChainedOperator extends StreamOperator { public void open(List collectorList, RuntimeContext runtimeContext) { // Dont' call super.open() as we `open` every operator separately. List succeedingCollectors = operators.stream().skip(1) - .map(operator -> new ForwardCollector((OneInputOperator) operator)) + .map(operator -> new ForwardCollector( + (OneInputOperator) operator)) .collect(Collectors.toList()); for (int i = 0; i < operators.size() - 1; i++) { StreamOperator operator = operators.get(i); @@ -113,6 +115,7 @@ public abstract class ChainedOperator extends StreamOperator { static class ChainedSourceOperator extends ChainedOperator implements SourceOperator { + private final SourceOperator sourceOperator; @SuppressWarnings("unchecked") @@ -135,6 +138,7 @@ public abstract class ChainedOperator extends StreamOperator { static class ChainedOneInputOperator extends ChainedOperator implements OneInputOperator { + private final OneInputOperator inputOperator; @SuppressWarnings("unchecked") @@ -152,6 +156,7 @@ public abstract class ChainedOperator extends StreamOperator { static class ChainedTwoInputOperator extends ChainedOperator implements TwoInputOperator { + private final TwoInputOperator inputOperator; @SuppressWarnings("unchecked") diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/chain/ForwardCollector.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/chain/ForwardCollector.java index 6d82fbc18..36680dae7 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/chain/ForwardCollector.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/chain/ForwardCollector.java @@ -5,6 +5,7 @@ import io.ray.streaming.message.Record; import io.ray.streaming.operator.OneInputOperator; class ForwardCollector implements Collector { + private final OneInputOperator succeedingOperator; ForwardCollector(OneInputOperator succeedingOperator) { diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/impl/JoinOperator.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/impl/JoinOperator.java index 4050d7879..27f03b523 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/impl/JoinOperator.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/impl/JoinOperator.java @@ -17,6 +17,7 @@ import io.ray.streaming.operator.TwoInputOperator; */ public class JoinOperator extends StreamOperator> implements TwoInputOperator { + public JoinOperator() { } diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/impl/SourceOperatorImpl.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/impl/SourceOperatorImpl.java index 6b59e7779..495604c3a 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/impl/SourceOperatorImpl.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/operator/impl/SourceOperatorImpl.java @@ -13,6 +13,7 @@ import java.util.List; public class SourceOperatorImpl extends StreamOperator> implements SourceOperator { + private SourceContextImpl sourceContext; public SourceOperatorImpl(SourceFunction function) { @@ -47,6 +48,7 @@ public class SourceOperatorImpl extends StreamOperator> } class SourceContextImpl implements SourceContext { + private List collectors; public SourceContextImpl(List collectors) { diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonFunction.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonFunction.java index 5786f0af4..5aed7d4d3 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonFunction.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonFunction.java @@ -7,20 +7,18 @@ import org.apache.commons.lang3.StringUtils; /** * Represents a user defined python function. - * *

Python worker can use information in this class to create a function object.

- * *

If this object is constructed from serialized python function, - * python worker can deserialize it to create python function directly. - * If this object is constructed from moduleName and className/functionName, - * python worker will use `importlib` to load python function.

- * + * python worker can deserialize it to create python function directly. If this object is + * constructed from moduleName and className/functionName, python worker will use `importlib` to + * load python function.

*

If the python data stream api is invoked from python, `function` will be not null.

*

If the python data stream api is invoked from java, `moduleName` and * `functionName` will be not null.

*

*/ public class PythonFunction implements Function { + public enum FunctionInterface { SOURCE_FUNCTION("SourceFunction"), MAP_FUNCTION("MapFunction"), @@ -47,8 +45,8 @@ public class PythonFunction implements Function { // null if this function is constructed from serialized python function. private final String functionName; /** - * FunctionInterface can be used to validate python function, - * and look up operator class from FunctionInterface. + * FunctionInterface can be used to validate python function, and look up operator class from + * FunctionInterface. */ private String functionInterface; @@ -69,10 +67,12 @@ public class PythonFunction implements Function { * * @param moduleName module name of streaming function. * @param functionName function name of streaming function. {@code functionName} is the name - * of a python function, or class name of subclass of `ray.streaming.function.` + * of a + * python function, or class name of subclass of `ray.streaming.function.` */ - public PythonFunction(String moduleName, - String functionName) { + public PythonFunction( + String moduleName, + String functionName) { Preconditions.checkArgument(StringUtils.isNotBlank(moduleName)); Preconditions.checkArgument(StringUtils.isNotBlank(functionName)); this.function = null; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonOperator.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonOperator.java index 81afb497c..185812f99 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonOperator.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonOperator.java @@ -17,6 +17,7 @@ import java.util.stream.Collectors; */ @SuppressWarnings("unchecked") public class PythonOperator extends StreamOperator { + private final String moduleName; private final String className; @@ -80,7 +81,7 @@ public class PythonOperator extends StreamOperator { StringBuilder builder = new StringBuilder(); builder.append(PythonOperator.class.getSimpleName()).append("["); if (function != null) { - builder.append(((PythonFunction)function).toSimpleString()); + builder.append(((PythonFunction) function).toSimpleString()); } else { builder.append(moduleName).append(".").append(className); } @@ -101,6 +102,7 @@ public class PythonOperator extends StreamOperator { } public static class ChainedPythonOperator extends PythonOperator { + private final List operators; private final PythonOperator headOperator; private final PythonOperator tailOperator; diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonPartition.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonPartition.java index ecdbbd49c..1c4970515 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonPartition.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/PythonPartition.java @@ -8,16 +8,15 @@ import org.apache.commons.lang3.StringUtils; /** * Represents a python partition function. *

- * Python worker can create a partition object using information in this - * PythonPartition. + * Python worker can create a partition object using information in this PythonPartition. *

- * If this object is constructed from serialized python partition, - * python worker can deserialize it to create python partition directly. - * If this object is constructed from moduleName and className/functionName, - * python worker will use `importlib` to load python partition function. + * If this object is constructed from serialized python partition, python worker can deserialize it + * to create python partition directly. If this object is constructed from moduleName and + * className/functionName, python worker will use `importlib` to load python partition function. *

*/ public class PythonPartition implements Partition { + public static final PythonPartition BroadcastPartition = new PythonPartition( "ray.streaming.partition", "BroadcastPartition"); public static final PythonPartition KeyPartition = new PythonPartition( diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonDataStream.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonDataStream.java index f7a3e228f..024148c7e 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonDataStream.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonDataStream.java @@ -18,14 +18,16 @@ import java.util.List; */ public class PythonDataStream extends Stream implements PythonStream { - protected PythonDataStream(StreamingContext streamingContext, - PythonOperator pythonOperator) { + protected PythonDataStream( + StreamingContext streamingContext, + PythonOperator pythonOperator) { super(streamingContext, pythonOperator); } - protected PythonDataStream(StreamingContext streamingContext, - PythonOperator pythonOperator, - Partition partition) { + protected PythonDataStream( + StreamingContext streamingContext, + PythonOperator pythonOperator, + Partition partition) { super(streamingContext, pythonOperator, partition); } @@ -33,15 +35,16 @@ public class PythonDataStream extends Stream implement super(input, pythonOperator); } - public PythonDataStream(PythonDataStream input, - PythonOperator pythonOperator, - Partition partition) { + public PythonDataStream( + PythonDataStream input, + PythonOperator pythonOperator, + Partition partition) { super(input, pythonOperator, partition); } /** - * Create a python stream that reference passed java stream. - * Changes in new stream will be reflected in referenced stream and vice versa + * Create a python stream that reference passed java stream. Changes in new stream will be + * reflected in referenced stream and vice versa */ public PythonDataStream(DataStream referencedStream) { super(referencedStream); @@ -85,8 +88,8 @@ public class PythonDataStream extends Stream implement * Apply a filter function to this stream. * * @param func The python FilterFunction. - * @return A new PythonDataStream that contains only the elements satisfying - * the given filter predicate. + * @return A new PythonDataStream that contains only the elements satisfying the given filter + * predicate. */ public PythonDataStream filter(PythonFunction func) { func.setFunctionInterface(FunctionInterface.FILTER_FUNCTION); @@ -94,8 +97,8 @@ public class PythonDataStream extends Stream implement } /** - * Apply union transformations to this stream by merging {@link PythonDataStream} outputs of - * the same type with each other. + * Apply union transformations to this stream by merging {@link PythonDataStream} outputs of the + * same type with each other. * * @param stream The DataStream to union output with. * @param others The other DataStreams to union output with. @@ -109,8 +112,8 @@ public class PythonDataStream extends Stream implement } /** - * Apply union transformations to this stream by merging {@link PythonDataStream} outputs of - * the same type with each other. + * Apply union transformations to this stream by merging {@link PythonDataStream} outputs of the + * same type with each other. * * @param streams The DataStreams to union output with. * @return A new UnionStream. @@ -178,8 +181,8 @@ public class PythonDataStream extends Stream implement } /** - * If parent stream is a python stream, we can't call partition related methods - * in the java stream. + * If parent stream is a python stream, we can't call partition related methods in the java + * stream. */ private void checkPartitionCall() { if (getInputStream() != null && getInputStream().getLanguage() == Language.JAVA) { @@ -189,9 +192,9 @@ public class PythonDataStream extends Stream implement } /** - * Convert this stream as a java stream. - * The converted stream and this stream are the same logical stream, which has same stream id. - * Changes in converted stream will be reflected in this stream and vice versa. + * Convert this stream as a java stream. The converted stream and this stream are the same logical + * stream, which has same stream id. Changes in converted stream will be reflected in this stream + * and vice versa. */ public DataStream asJavaStream() { return new DataStream<>(this); diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonKeyDataStream.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonKeyDataStream.java index 88cb3e391..a75325818 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonKeyDataStream.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonKeyDataStream.java @@ -19,8 +19,8 @@ public class PythonKeyDataStream extends PythonDataStream implements PythonStrea } /** - * Create a python stream that reference passed python stream. - * Changes in new stream will be reflected in referenced stream and vice versa + * Create a python stream that reference passed python stream. Changes in new stream will be + * reflected in referenced stream and vice versa */ public PythonKeyDataStream(DataStream referencedStream) { super(referencedStream); @@ -44,9 +44,9 @@ public class PythonKeyDataStream extends PythonDataStream implements PythonStrea } /** - * Convert this stream as a java stream. - * The converted stream and this stream are the same logical stream, which has same stream id. - * Changes in converted stream will be reflected in this stream and vice versa. + * Convert this stream as a java stream. The converted stream and this stream are the same logical + * stream, which has same stream id. Changes in converted stream will be reflected in this stream + * and vice versa. */ public KeyDataStream asJavaStream() { return new KeyDataStream(this); diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStream.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStream.java index f74f970f6..808516f67 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStream.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStream.java @@ -4,4 +4,5 @@ package io.ray.streaming.python.stream; * A marker interface used to identify all python streams. */ public interface PythonStream { + } diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStreamSink.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStreamSink.java index 5a7dd60ab..05b6cd37c 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStreamSink.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStreamSink.java @@ -8,6 +8,7 @@ import io.ray.streaming.python.PythonOperator; * Represents a sink of the PythonStream. */ public class PythonStreamSink extends StreamSink implements PythonStream { + public PythonStreamSink(PythonDataStream input, PythonOperator sinkOperator) { super(input, sinkOperator); getStreamingContext().addSink(this); diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStreamSource.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStreamSource.java index b33c07ec8..5561e4b05 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStreamSource.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonStreamSource.java @@ -17,8 +17,9 @@ public class PythonStreamSource extends PythonDataStream implements StreamSource withChainStrategy(ChainStrategy.HEAD); } - public static PythonStreamSource from(StreamingContext streamingContext, - PythonFunction sourceFunction) { + public static PythonStreamSource from( + StreamingContext streamingContext, + PythonFunction sourceFunction) { sourceFunction.setFunctionInterface(FunctionInterface.SOURCE_FUNCTION); return new PythonStreamSource(streamingContext, sourceFunction); } diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonUnionStream.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonUnionStream.java index 2e4e4957e..4e115685a 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonUnionStream.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/python/stream/PythonUnionStream.java @@ -6,11 +6,11 @@ import java.util.List; /** * Represents a union DataStream. - * *

This stream does not create a physical operation, it only affects how upstream data are - * connected to downstream data. + * connected to downstream data. */ public class PythonUnionStream extends PythonDataStream { + private List unionStreams; public PythonUnionStream(PythonDataStream input, List others) { diff --git a/streaming/java/streaming-api/src/main/java/io/ray/streaming/util/Config.java b/streaming/java/streaming-api/src/main/java/io/ray/streaming/util/Config.java index b998ddf9f..8d8ae6099 100644 --- a/streaming/java/streaming-api/src/main/java/io/ray/streaming/util/Config.java +++ b/streaming/java/streaming-api/src/main/java/io/ray/streaming/util/Config.java @@ -11,7 +11,7 @@ public class Config { public static final String MEMORY_CHANNEL = "memory_channel"; public static final String NATIVE_CHANNEL = "native_channel"; public static final String CHANNEL_SIZE = "channel_size"; - public static final String CHANNEL_SIZE_DEFAULT = String.valueOf((long)Math.pow(10, 8)); + public static final String CHANNEL_SIZE_DEFAULT = String.valueOf((long) Math.pow(10, 8)); public static final String IS_RECREATE = "streaming.is_recreate"; // return from DataReader.getBundle if only empty message read in this interval. public static final String TIMER_INTERVAL_MS = "timer_interval_ms"; diff --git a/streaming/java/streaming-api/src/test/java/io/ray/streaming/api/stream/StreamTest.java b/streaming/java/streaming-api/src/test/java/io/ray/streaming/api/stream/StreamTest.java index fe05b52d5..dbbfe455c 100644 --- a/streaming/java/streaming-api/src/test/java/io/ray/streaming/api/stream/StreamTest.java +++ b/streaming/java/streaming-api/src/test/java/io/ray/streaming/api/stream/StreamTest.java @@ -2,6 +2,7 @@ package io.ray.streaming.api.stream; import static org.testng.Assert.assertEquals; + import io.ray.streaming.api.context.StreamingContext; import io.ray.streaming.operator.impl.MapOperator; import io.ray.streaming.python.stream.PythonDataStream; diff --git a/streaming/java/streaming-api/src/test/java/io/ray/streaming/jobgraph/JobGraphOptimizerTest.java b/streaming/java/streaming-api/src/test/java/io/ray/streaming/jobgraph/JobGraphOptimizerTest.java index a128d77a8..69d46accd 100644 --- a/streaming/java/streaming-api/src/test/java/io/ray/streaming/jobgraph/JobGraphOptimizerTest.java +++ b/streaming/java/streaming-api/src/test/java/io/ray/streaming/jobgraph/JobGraphOptimizerTest.java @@ -2,6 +2,7 @@ package io.ray.streaming.jobgraph; import static org.testng.Assert.assertEquals; + import com.google.common.collect.Lists; import io.ray.streaming.api.context.StreamingContext; import io.ray.streaming.api.stream.DataStream; @@ -12,13 +13,14 @@ import org.slf4j.LoggerFactory; import org.testng.annotations.Test; public class JobGraphOptimizerTest { - private static final Logger LOG = LoggerFactory.getLogger( JobGraphOptimizerTest.class ); + + private static final Logger LOG = LoggerFactory.getLogger(JobGraphOptimizerTest.class); @Test public void testOptimize() { StreamingContext context = StreamingContext.buildContext(); DataStream source1 = DataStreamSource.fromCollection(context, - Lists.newArrayList(1 ,2 ,3)); + Lists.newArrayList(1, 2, 3)); DataStream source2 = DataStreamSource.fromCollection(context, Lists.newArrayList("1", "2", "3")); DataStream source3 = DataStreamSource.fromCollection(context, @@ -43,7 +45,7 @@ public class JobGraphOptimizerTest { public void testOptimizeHybridStream() { StreamingContext context = StreamingContext.buildContext(); DataStream source1 = DataStreamSource.fromCollection(context, - Lists.newArrayList(1 ,2 ,3)); + Lists.newArrayList(1, 2, 3)); DataStream source2 = DataStreamSource.fromCollection(context, Lists.newArrayList("1", "2", "3")); source1.asPythonStream() diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/config/global/CommonConfig.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/config/global/CommonConfig.java index 7da8db4ac..61daa787a 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/config/global/CommonConfig.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/config/global/CommonConfig.java @@ -12,6 +12,7 @@ public interface CommonConfig extends Config { /** * Ray streaming job id. Non-custom. + * * @return Job id with string type. */ @DefaultValue(value = "default-job-id") @@ -20,6 +21,7 @@ public interface CommonConfig extends Config { /** * Ray streaming job name. Non-custom. + * * @return Job name with string type. */ @DefaultValue(value = "default-job-name") diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/config/master/SchedulerConfig.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/config/master/SchedulerConfig.java index a486f5cc8..3594e3dfc 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/config/master/SchedulerConfig.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/config/master/SchedulerConfig.java @@ -11,8 +11,7 @@ public interface SchedulerConfig extends Config { String WORKER_STARTING_WAIT_TIMEOUT_MS = "streaming.scheduler.worker.starting.timeout.ms"; /** - * The timeout ms of worker initiation. - * Default is: 10000ms(10s). + * The timeout ms of worker initiation. Default is: 10000ms(10s). * * @return timeout ms */ @@ -21,8 +20,7 @@ public interface SchedulerConfig extends Config { int workerInitiationWaitTimeoutMs(); /** - * The timeout ms of worker starting. - * Default is: 10000ms(10s). + * The timeout ms of worker starting. Default is: 10000ms(10s). * * @return timeout ms */ diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/collector/OutputCollector.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/collector/OutputCollector.java index 0ee7e250a..1006165f3 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/collector/OutputCollector.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/collector/OutputCollector.java @@ -17,6 +17,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class OutputCollector implements Collector { + private static final Logger LOGGER = LoggerFactory.getLogger(OutputCollector.class); private final DataWriter writer; @@ -27,15 +28,17 @@ public class OutputCollector implements Collector { private final Serializer javaSerializer = new JavaSerializer(); private final Serializer crossLangSerializer = new CrossLangSerializer(); - public OutputCollector(DataWriter writer, - Collection outputChannelIds, - Collection targetActors, - Partition partition) { + public OutputCollector( + DataWriter writer, + Collection outputChannelIds, + Collection targetActors, + Partition partition) { this.writer = writer; this.outputQueues = outputChannelIds.stream().map(ChannelId::from).toArray(ChannelId[]::new); this.targetActors = targetActors; this.targetLanguages = targetActors.stream() - .map(actor -> actor instanceof PyActorHandle ? Language.PYTHON : Language.JAVA) + .map(actor -> actor instanceof PyActorHandle ? Language.PYTHON : + Language.JAVA) .toArray(Language[]::new); this.partition = partition; LOGGER.debug("OutputCollector constructed, outputChannelIds:{}, partition:{}.", diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/common/AbstractID.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/common/AbstractID.java index db3604f13..c98b7eba7 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/common/AbstractID.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/common/AbstractID.java @@ -6,10 +6,10 @@ import java.io.Serializable; import java.util.UUID; /** - * Streaming system unique identity base class. - * For example, ${@link ContainerID } + * Streaming system unique identity base class. For example, ${@link ContainerID } */ public class AbstractID implements Serializable { + private UUID id; public AbstractID() { @@ -18,7 +18,7 @@ public class AbstractID implements Serializable { @Override public boolean equals(Object obj) { - return id.equals(((AbstractID)obj).getId()); + return id.equals(((AbstractID) obj).getId()); } public UUID getId() { diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionEdge.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionEdge.java index ff6b549cb..b86eafb7e 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionEdge.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionEdge.java @@ -75,10 +75,10 @@ public class ExecutionEdge implements Serializable { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("source", sourceExecutionVertex) - .add("target", targetExecutionVertex) - .add("partition", partition) - .add("index", executionEdgeIndex) - .toString(); + .add("source", sourceExecutionVertex) + .add("target", targetExecutionVertex) + .add("partition", partition) + .add("index", executionEdgeIndex) + .toString(); } } diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionGraph.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionGraph.java index 6a0dc9b58..b9d19bf2d 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionGraph.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionGraph.java @@ -25,9 +25,7 @@ public class ExecutionGraph implements Serializable { private Map jobConfig; /** - * Data map for execution job vertex. - * key: job vertex id. - * value: execution job vertex. + * Data map for execution job vertex. key: job vertex id. value: execution job vertex. */ private Map executionJobVertexMap; @@ -166,8 +164,11 @@ public class ExecutionGraph implements Serializable { */ public List getNonSourceActors() { List executionJobVertices = getExecutionJobVertexList().stream() - .filter(executionJobVertex -> executionJobVertex.isTransformationVertex() - || executionJobVertex.isSinkVertex()) + .filter(executionJobVertex -> + executionJobVertex + .isTransformationVertex() + || executionJobVertex + .isSinkVertex()) .collect(Collectors.toList()); return getActorsFromJobVertices(executionJobVertices); diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionJobVertex.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionJobVertex.java index 380485cd3..f0c87bd0f 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionJobVertex.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionJobVertex.java @@ -17,7 +17,6 @@ import org.aeonbits.owner.ConfigFactory; /** * Physical job vertex. - * *

Execution job vertex is the physical form of {@link JobVertex} and * every execution job vertex is corresponding to a group of {@link ExecutionVertex}. */ @@ -29,8 +28,8 @@ public class ExecutionJobVertex { private final int executionJobVertexId; /** - * Use jobVertex id and operator(use {@link StreamOperator}'s name) as name. - * e.g. 1-SourceOperator + * Use jobVertex id and operator(use {@link StreamOperator}'s name) as name. e.g. + * 1-SourceOperator */ private final String executionJobVertexName; private final StreamOperator streamOperator; diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionVertex.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionVertex.java index a2cc313a6..62421463d 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionVertex.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/graph/executiongraph/ExecutionVertex.java @@ -48,8 +48,8 @@ public class ExecutionVertex implements Serializable { private int parallelism; /** - * Ordered sub index for execution vertex in a execution job vertex. - * Might be changed in dynamic scheduling. + * Ordered sub index for execution vertex in a execution job vertex. Might be changed in dynamic + * scheduling. */ private int executionVertexIndex; @@ -102,8 +102,8 @@ public class ExecutionVertex implements Serializable { } /** - * Unique name generated by execution job vertex name and index of current execution vertex. - * e.g. 1-SourceOperator-3 (vertex index is 3) + * Unique name generated by execution job vertex name and index of current execution vertex. e.g. + * 1-SourceOperator-3 (vertex index is 3) */ public String getExecutionVertexName() { return executionJobVertexName + "-" + executionVertexIndex; @@ -239,7 +239,7 @@ public class ExecutionVertex implements Serializable { @Override public boolean equals(Object obj) { if (obj instanceof ExecutionVertex) { - return this.executionVertexId == ((ExecutionVertex)obj).getExecutionVertexId(); + return this.executionVertexId == ((ExecutionVertex) obj).getExecutionVertexId(); } return false; } diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/processor/TwoInputProcessor.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/processor/TwoInputProcessor.java index 8e5f70d2a..db3222ee8 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/processor/TwoInputProcessor.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/processor/TwoInputProcessor.java @@ -6,6 +6,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TwoInputProcessor extends StreamProcessor> { + private static final Logger LOGGER = LoggerFactory.getLogger(TwoInputProcessor.class); private String leftStream; diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/Container.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/Container.java index d3ba22f70..a132064f4 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/Container.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/Container.java @@ -47,8 +47,7 @@ public class Container implements Serializable { private Map availableResources = new HashMap<>(); /** - * List of {@link ExecutionVertex} ids - * belong to the container. + * List of {@link ExecutionVertex} ids belong to the container. */ private List executionVertexIds = new ArrayList<>(); diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/ContainerID.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/ContainerID.java index 207406299..3f58e8ddd 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/ContainerID.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/ContainerID.java @@ -6,4 +6,5 @@ import io.ray.streaming.runtime.core.common.AbstractID; * Container unique identifier. */ public class ContainerID extends AbstractID { + } diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/ResourceType.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/ResourceType.java index f15c05756..496266cf2 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/ResourceType.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/ResourceType.java @@ -6,12 +6,12 @@ package io.ray.streaming.runtime.core.resource; public enum ResourceType { /** - *Cpu resource key. + * Cpu resource key. */ CPU("CPU"), /** - *Gpu resource key. + * Gpu resource key. */ GPU("GPU"), diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/Resources.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/Resources.java index 763bf8a15..3f7a1b6d7 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/Resources.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/core/resource/Resources.java @@ -28,6 +28,7 @@ public class Resources implements Serializable { /** * Get registered containers, the container list is read-only. + * * @return container list. */ public ImmutableList getRegisteredContainers() { @@ -52,7 +53,8 @@ public class Resources implements Serializable { public ImmutableMap getRegisteredContainerMap() { return ImmutableMap.copyOf(registerContainers.stream() - .collect(java.util.stream.Collectors.toMap(Container::getNodeId, c -> c))); + .collect(java.util.stream.Collectors + .toMap(Container::getNodeId, c -> c))); } @Override diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/JobRuntimeContext.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/JobRuntimeContext.java index 041abb185..ec10c69ae 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/JobRuntimeContext.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/JobRuntimeContext.java @@ -8,7 +8,6 @@ import java.io.Serializable; /** * Runtime context for job master. - * *

Including: graph, resource, checkpoint info, etc. */ public class JobRuntimeContext implements Serializable { diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/graphmanager/GraphManager.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/graphmanager/GraphManager.java index d30bacca6..14598ff45 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/graphmanager/GraphManager.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/graphmanager/GraphManager.java @@ -5,7 +5,6 @@ import io.ray.streaming.runtime.core.graph.executiongraph.ExecutionGraph; /** * Graph manager is one of the important roles of JobMaster. It mainly focuses on graph management. - * *

* Such as: *

    diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/ResourceManagerImpl.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/ResourceManagerImpl.java index b704fbd61..3b7b35ba6 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/ResourceManagerImpl.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/ResourceManagerImpl.java @@ -77,7 +77,7 @@ public class ResourceManagerImpl implements ResourceManager { ResourceAssignStrategyType resourceAssignStrategyType = ResourceAssignStrategyType.PIPELINE_FIRST_STRATEGY; this.resourceAssignStrategy = ResourceAssignStrategyFactory.getStrategy( - resourceAssignStrategyType); + resourceAssignStrategyType); LOG.info("Slot assign strategy: {}.", resourceAssignStrategy.getName()); //Init resource @@ -89,7 +89,8 @@ public class ResourceManagerImpl implements ResourceManager { } @Override - public ResourceAssignmentView assignResource(List containers, + public ResourceAssignmentView assignResource( + List containers, ExecutionGraph executionGraph) { return resourceAssignStrategy.assignResource(containers, executionGraph); } @@ -106,8 +107,8 @@ public class ResourceManagerImpl implements ResourceManager { } /** - * Check the status of ray cluster node and update the internal resource information of - * streaming system. + * Check the status of ray cluster node and update the internal resource information of streaming + * system. */ private void checkAndUpdateResource() { //Get add&del nodes(node -> container) @@ -117,7 +118,8 @@ public class ResourceManagerImpl implements ResourceManager { .filter(this::isAddedNode).collect(Collectors.toList()); List deleteNodes = resources.getRegisteredContainerMap().keySet().stream() - .filter(nodeId -> !latestNodeInfos.containsKey(nodeId)).collect(Collectors.toList()); + .filter(nodeId -> !latestNodeInfos.containsKey(nodeId)) + .collect(Collectors.toList()); LOG.info("Latest node infos: {}, current containers: {}, add nodes: {}, delete nodes: {}.", latestNodeInfos, resources.getRegisteredContainers(), addNodes, deleteNodes); @@ -156,7 +158,6 @@ public class ResourceManagerImpl implements ResourceManager { // failover case: container has already allocated actors double availableCapacity = actorNumPerContainer - container.getAllocatedActorNum(); - //Create ray resource. Ray.setResource(container.getNodeId(), container.getName(), availableCapacity); //Mark container is already registered. @@ -164,7 +165,7 @@ public class ResourceManagerImpl implements ResourceManager { // update container's available dynamic resources container.getAvailableResources() - .put(container.getName(), availableCapacity); + .put(container.getName(), availableCapacity); // update register container list resources.registerContainer(container); diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/ViewBuilder.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/ViewBuilder.java index 16eba4f45..82d6a8517 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/ViewBuilder.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/ViewBuilder.java @@ -15,8 +15,8 @@ public class ViewBuilder { } public static ResourceAssignmentView buildResourceAssignmentView(List containers) { - Map> assignmentView = containers.stream() - .collect(java.util.stream.Collectors.toMap(Container::getId, + Map> assignmentView = + containers.stream().collect(java.util.stream.Collectors.toMap(Container::getId, Container::getExecutionVertexIds)); return ResourceAssignmentView.of(assignmentView); diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/strategy/ResourceAssignStrategy.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/strategy/ResourceAssignStrategy.java index 34eae669f..c4ec37b4a 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/strategy/ResourceAssignStrategy.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/strategy/ResourceAssignStrategy.java @@ -12,8 +12,7 @@ import java.util.List; public interface ResourceAssignStrategy { /** - * Assign {@link Container} for - * {@link ExecutionVertex} + * Assign {@link Container} for {@link ExecutionVertex} * * @param containers registered container * @param executionGraph execution graph diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/strategy/impl/PipelineFirstStrategy.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/strategy/impl/PipelineFirstStrategy.java index 1539922fb..bc65f8d35 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/strategy/impl/PipelineFirstStrategy.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/resourcemanager/strategy/impl/PipelineFirstStrategy.java @@ -17,11 +17,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Based on Ray dynamic resource function, resource details(by ray gcs get) and - * execution logic diagram, PipelineFirstStrategy provides a actor scheduling - * strategies to make the cluster load balanced and controllable scheduling. - * Assume that we have 2 containers and have a DAG graph composed of a source node with parallelism - * of 2 and a sink node with parallelism of 2, the structure will be like: + * Based on Ray dynamic resource function, resource details(by ray gcs get) and execution logic + * diagram, PipelineFirstStrategy provides a actor scheduling strategies to make the cluster load + * balanced and controllable scheduling. Assume that we have 2 containers and have a DAG graph + * composed of a source node with parallelism of 2 and a sink node with parallelism of 2, the + * structure will be like: *
      *   container_0
      *             |- source_1
    @@ -38,7 +38,7 @@ public class PipelineFirstStrategy implements ResourceAssignStrategy {
       private int currentContainerIndex = 0;
     
       /**
    -   *  Assign resource to each execution vertex in the given execution graph.
    +   * Assign resource to each execution vertex in the given execution graph.
        *
        * @param containers registered containers
        * @param executionGraph execution graph
    @@ -125,6 +125,7 @@ public class PipelineFirstStrategy implements ResourceAssignStrategy {
     
       /**
        * Find a container which matches required resource
    +   *
        * @param requiredResource required resource
        * @param containers registered containers
        * @return container that matches the required resource
    @@ -151,6 +152,7 @@ public class PipelineFirstStrategy implements ResourceAssignStrategy {
     
       /**
        * Check if current container has enough resource
    +   *
        * @param requiredResource required resource
        * @param container container
        * @return true if matches, false else
    @@ -198,6 +200,7 @@ public class PipelineFirstStrategy implements ResourceAssignStrategy {
     
       /**
        * Get current container
    +   *
        * @param containers registered container
        * @return current container to allocate actor
        */
    diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/JobScheduler.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/JobScheduler.java
    index 919de1776..3863a1709 100644
    --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/JobScheduler.java
    +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/JobScheduler.java
    @@ -9,6 +9,7 @@ public interface JobScheduler {
     
       /**
        * Schedule streaming job using the physical plan.
    +   *
        * @param executionGraph physical plan
        * @return scheduling result
        */
    diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/ScheduleException.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/ScheduleException.java
    index d26bc16d7..af6b81d4e 100644
    --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/ScheduleException.java
    +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/ScheduleException.java
    @@ -18,7 +18,8 @@ public class ScheduleException extends RuntimeException {
         super(cause);
       }
     
    -  protected ScheduleException(String message, Throwable cause, boolean enableSuppression,
    +  protected ScheduleException(
    +      String message, Throwable cause, boolean enableSuppression,
           boolean writableStackTrace) {
         super(message, cause, enableSuppression, writableStackTrace);
       }
    diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/controller/WorkerLifecycleController.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/controller/WorkerLifecycleController.java
    index 47f20adc6..876e9f924 100644
    --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/controller/WorkerLifecycleController.java
    +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/master/scheduler/controller/WorkerLifecycleController.java
    @@ -171,8 +171,8 @@ public class WorkerLifecycleController {
           List executionVertices) {
         final Object asyncContext = Ray.getAsyncContext();
     
    -    List> futureResults = executionVertices.stream()
    -        .map(vertex -> CompletableFuture.supplyAsync(() -> {
    +    List> futureResults =
    +        executionVertices.stream().map(vertex -> CompletableFuture.supplyAsync(() -> {
               Ray.setAsyncContext(asyncContext);
               return operation.apply(vertex);
             })).collect(Collectors.toList());
    diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/python/GraphPbBuilder.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/python/GraphPbBuilder.java
    index 4f93bc0c2..408397ebb 100644
    --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/python/GraphPbBuilder.java
    +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/python/GraphPbBuilder.java
    @@ -34,8 +34,8 @@ public class GraphPbBuilder {
         List upstreamVertices = executionVertex.getInputVertices();
         List upstreamVertexPbs =
             upstreamVertices.stream()
    -        .map(this::buildVertex)
    -        .collect(Collectors.toList());
    +            .map(this::buildVertex)
    +            .collect(Collectors.toList());
         builder.addAllUpstreamExecutionVertices(upstreamVertexPbs);
     
         // build downstream vertices
    @@ -127,7 +127,8 @@ public class GraphPbBuilder {
     
       private byte[] serializePythonChainedOperator(ChainedPythonOperator operator) {
         List serializedOperators = operator.getOperators().stream()
    -        .map(this::serializeOperator).collect(Collectors.toList());
    +        .map(this::serializeOperator)
    +        .collect(Collectors.toList());
         return serializer.serialize(Arrays.asList(
             serializedOperators,
             operator.getConfigs()
    diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/python/PythonGateway.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/python/PythonGateway.java
    index 2f74587de..e67adb898 100644
    --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/python/PythonGateway.java
    +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/python/PythonGateway.java
    @@ -23,15 +23,13 @@ import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
     
     /**
    - * Gateway for streaming python api.
    - * All calls on DataStream in python will be mapped to DataStream call in java by this
    - * PythonGateway using ray calls.
    - * 

    - * Note: this class needs to be in sync with `GatewayClient` in - * `streaming/python/runtime/gateway_client.py` + * Gateway for streaming python api. All calls on DataStream in python will be mapped to DataStream + * call in java by this PythonGateway using ray calls. this class needs to be in sync with + * GatewayClient in `streaming/python/runtime/gateway_client.py` */ @SuppressWarnings("unchecked") public class PythonGateway { + private static final Logger LOG = LoggerFactory.getLogger(PythonGateway.class); private static final String REFERENCE_ID_PREFIX = "__gateway_reference_id__"; private static MsgPackSerializer serializer = new MsgPackSerializer(); @@ -169,8 +167,9 @@ public class PythonGateway { .toArray(Class[]::new); Optional any = methods.stream() .filter(m -> { - boolean exactMatch = Arrays.equals(m.getParameterTypes(), paramsTypes) || - Arrays.equals(m.getParameterTypes(), unwrappedTypes); + boolean exactMatch = + Arrays.equals(m.getParameterTypes(), paramsTypes) || + Arrays.equals(m.getParameterTypes(), unwrappedTypes); if (exactMatch) { return true; } else if (paramsTypes.length == m.getParameterTypes().length) { diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/rpc/RemoteCallWorker.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/rpc/RemoteCallWorker.java index 9fc425eee..a12dfaea4 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/rpc/RemoteCallWorker.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/rpc/RemoteCallWorker.java @@ -12,8 +12,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Ray call worker. - * It takes the communication job from {@link JobMaster} to {@link JobWorker}. + * Ray call worker. It takes the communication job from {@link JobMaster} to {@link JobWorker}. */ public class RemoteCallWorker { diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/CrossLangSerializer.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/CrossLangSerializer.java index 17557b9ac..56ff42832 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/CrossLangSerializer.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/CrossLangSerializer.java @@ -6,10 +6,11 @@ import java.util.Arrays; import java.util.List; /** - * A serializer for cross-lang serialization between java/python. - * TODO implements a more sophisticated serialization framework + * A serializer for cross-lang serialization between java/python. TODO implements a more + * sophisticated serialization framework */ public class CrossLangSerializer implements Serializer { + private static final byte RECORD_TYPE_ID = 0; private static final byte KEY_RECORD_TYPE_ID = 1; diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/JavaSerializer.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/JavaSerializer.java index d7a1a2649..42072408d 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/JavaSerializer.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/JavaSerializer.java @@ -3,6 +3,7 @@ package io.ray.streaming.runtime.serialization; import io.ray.runtime.serializer.FstSerializer; public class JavaSerializer implements Serializer { + @Override public byte[] serialize(Object object) { return FstSerializer.encode(object); diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/Serializer.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/Serializer.java index b3a3184d7..92449a736 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/Serializer.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/serialization/Serializer.java @@ -1,6 +1,7 @@ package io.ray.streaming.runtime.serialization; public interface Serializer { + byte CROSS_LANG_TYPE_ID = 0; byte JAVA_TYPE_ID = 1; byte PYTHON_TYPE_ID = 2; diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelCreationParametersBuilder.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelCreationParametersBuilder.java index d5a9db374..ff8b92c5d 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelCreationParametersBuilder.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelCreationParametersBuilder.java @@ -42,7 +42,7 @@ public class ChannelCreationParametersBuilder { String language = asyncFunctionDescriptor instanceof JavaFunctionDescriptor ? "Java" : "Python"; return "Language: " + language + " Desc: " + asyncFunctionDescriptor.toList() + " " - + syncFunctionDescriptor.toList(); + + syncFunctionDescriptor.toList(); } // Get actor id in bytes, called from jni. @@ -93,14 +93,16 @@ public class ChannelCreationParametersBuilder { public ChannelCreationParametersBuilder() { } - public static void setJavaReaderFunctionDesc(JavaFunctionDescriptor asyncFunc, - JavaFunctionDescriptor syncFunc) { + public static void setJavaReaderFunctionDesc( + JavaFunctionDescriptor asyncFunc, + JavaFunctionDescriptor syncFunc) { javaReaderAsyncFuncDesc = asyncFunc; javaReaderSyncFuncDesc = syncFunc; } - public static void setJavaWriterFunctionDesc(JavaFunctionDescriptor asyncFunc, - JavaFunctionDescriptor syncFunc) { + public static void setJavaWriterFunctionDesc( + JavaFunctionDescriptor asyncFunc, + JavaFunctionDescriptor syncFunc) { javaWriterAsyncFuncDesc = asyncFunc; javaWriterSyncFuncDesc = syncFunc; } @@ -109,19 +111,23 @@ public class ChannelCreationParametersBuilder { List queues, List actors) { return buildParameters(queues, actors, javaWriterAsyncFuncDesc, javaWriterSyncFuncDesc, - pyWriterAsyncFunctionDesc, pyWriterSyncFunctionDesc); + pyWriterAsyncFunctionDesc, pyWriterSyncFunctionDesc); } - public ChannelCreationParametersBuilder buildOutputQueueParameters(List queues, - List actors) { + public ChannelCreationParametersBuilder buildOutputQueueParameters( + List queues, + List actors) { return buildParameters(queues, actors, javaReaderAsyncFuncDesc, javaReaderSyncFuncDesc, - pyReaderAsyncFunctionDesc, pyReaderSyncFunctionDesc); + pyReaderAsyncFunctionDesc, pyReaderSyncFunctionDesc); } - private ChannelCreationParametersBuilder buildParameters(List queues, + private ChannelCreationParametersBuilder buildParameters( + List queues, List actors, - JavaFunctionDescriptor javaAsyncFunctionDesc, JavaFunctionDescriptor javaSyncFunctionDesc, - PyFunctionDescriptor pyAsyncFunctionDesc, PyFunctionDescriptor pySyncFunctionDesc + JavaFunctionDescriptor javaAsyncFunctionDesc, + JavaFunctionDescriptor javaSyncFunctionDesc, + PyFunctionDescriptor pyAsyncFunctionDesc, + PyFunctionDescriptor pySyncFunctionDesc ) { parameters = new ArrayList<>(queues.size()); diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelId.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelId.java index 4d0c38578..75904e19e 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelId.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelId.java @@ -12,10 +12,11 @@ import java.util.Set; import sun.nio.ch.DirectBuffer; /** - * ChannelID is used to identify a transfer channel between a upstream worker - * and downstream worker. + * ChannelID is used to identify a transfer channel between a upstream worker and downstream + * worker. */ public class ChannelId { + public static final int ID_LENGTH = 20; private static final FinalizableReferenceQueue REFERENCE_QUEUE = new FinalizableReferenceQueue(); // This ensures that the FinalizablePhantomReference itself is not garbage-collected. @@ -132,7 +133,7 @@ public class ChannelId { * Generate channel name, which will be 20 character * * @param fromTaskId upstream task id - * @param toTaskId downstream task id + * @param toTaskId downstream task id * @return channel name */ public static String genIdStr(int fromTaskId, int toTaskId, long ts) { diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelUtils.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelUtils.java index ec6535431..c62b21018 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelUtils.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/ChannelUtils.java @@ -7,6 +7,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ChannelUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(ChannelUtils.class); static byte[] toNativeConf(StreamingWorkerConfig workerConfig) { diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataMessage.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataMessage.java index e6426a549..6c8f08d8e 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataMessage.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataMessage.java @@ -6,6 +6,7 @@ import java.nio.ByteBuffer; * DataMessage represents data between upstream and downstream operator */ public class DataMessage implements Message { + private final ByteBuffer body; private final long msgId; private final long timestamp; diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataReader.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataReader.java index e23dca519..3cdf15a07 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataReader.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataReader.java @@ -14,10 +14,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * DataReader is wrapper of streaming c++ DataReader, which read data - * from channels of upstream workers + * DataReader is wrapper of streaming c++ DataReader, which read data from channels of upstream + * workers */ public class DataReader { + private static final Logger LOG = LoggerFactory.getLogger(DataReader.class); private long nativeReaderPtr; @@ -25,12 +26,13 @@ public class DataReader { /** * @param inputChannels input channels ids - * @param fromActors upstream input actors - * @param workerConfig configuration + * @param fromActors upstream input actors + * @param workerConfig configuration */ - public DataReader(List inputChannels, - List fromActors, - StreamingWorkerConfig workerConfig) { + public DataReader( + List inputChannels, + List fromActors, + StreamingWorkerConfig workerConfig) { Preconditions.checkArgument(inputChannels.size() > 0); Preconditions.checkArgument(inputChannels.size() == fromActors.size()); ChannelCreationParametersBuilder initialParameters = @@ -169,10 +171,11 @@ public class DataReader { byte[] configBytes, boolean isMock); - private native void getBundleNative(long nativeReaderPtr, - long timeoutMillis, - long params, - long metaAddress); + private native void getBundleNative( + long nativeReaderPtr, + long timeoutMillis, + long params, + long metaAddress); private native void stopReaderNative(long nativeReaderPtr); @@ -191,6 +194,7 @@ public class DataReader { } static class BundleMeta { + // kMessageBundleHeaderSize + kUniqueIDSize: // magicNum(4b) + bundleTs(8b) + lastMessageId(8b) + messageListSize(4b) // + bundleType(4b) + rawBundleSize(4b) + channelID(20b) diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataWriter.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataWriter.java index 7fc617cbe..a8cebabb0 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataWriter.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/DataWriter.java @@ -13,10 +13,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * DataWriter is a wrapper of streaming c++ DataWriter, which sends data - * to downstream workers + * DataWriter is a wrapper of streaming c++ DataWriter, which sends data to downstream workers */ public class DataWriter { + private static final Logger LOG = LoggerFactory.getLogger(DataWriter.class); private long nativeWriterPtr; @@ -29,12 +29,13 @@ public class DataWriter { /** * @param outputChannels output channels ids - * @param toActors downstream output actors - * @param workerConfig configuration + * @param toActors downstream output actors + * @param workerConfig configuration */ - public DataWriter(List outputChannels, - List toActors, - StreamingWorkerConfig workerConfig) { + public DataWriter( + List outputChannels, + List toActors, + StreamingWorkerConfig workerConfig) { Preconditions.checkArgument(!outputChannels.isEmpty()); Preconditions.checkArgument(outputChannels.size() == toActors.size()); ChannelCreationParametersBuilder initialParameters = @@ -66,7 +67,7 @@ public class DataWriter { /** * Write msg into the specified channel * - * @param id channel id + * @param id channel id * @param item message item data section is specified by [position, limit). */ public void write(ChannelId id, ByteBuffer item) { @@ -80,9 +81,10 @@ public class DataWriter { /** * Write msg into the specified channels * - * @param ids channel ids - * @param item message item data section is specified by [position, limit). - * item doesn't have to be a direct buffer. + * @param ids channel ids + * @param item message item data section is specified by [position, limit). item doesn't have + * to + * be a direct buffer. */ public void write(Set ids, ByteBuffer item) { int size = item.remaining(); diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/Message.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/Message.java index dd620429c..f48cb6f77 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/Message.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/transfer/Message.java @@ -6,7 +6,7 @@ public interface Message { /** * Message data - * + *

    * Message body is a direct byte buffer, which may be invalid after call next * DataReader#getBundleNative. Please consume this buffer fully * before next call getBundleNative. diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/util/CommonUtils.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/util/CommonUtils.java index 24cd4e204..37940df5d 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/util/CommonUtils.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/util/CommonUtils.java @@ -8,7 +8,7 @@ import java.util.Map; public class CommonUtils { public static Map strMapToObjectMap(Map srcMap) { - Map destMap = (Map) srcMap; + Map destMap = (Map) srcMap; return destMap; } } diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/util/RayUtils.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/util/RayUtils.java index 9f1c3ec1e..8681e3904 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/util/RayUtils.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/util/RayUtils.java @@ -34,8 +34,8 @@ public class RayUtils { */ public static Map getAliveNodeInfoMap() { return getAllNodeInfo().stream() - .filter(nodeInfo -> nodeInfo.isAlive) - .collect(Collectors.toMap(nodeInfo -> nodeInfo.nodeId, nodeInfo -> nodeInfo)); + .filter(nodeInfo -> nodeInfo.isAlive) + .collect(Collectors.toMap(nodeInfo -> nodeInfo.nodeId, nodeInfo -> nodeInfo)); } private static List mockContainerResources() { diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/JobWorker.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/JobWorker.java index e3b364cea..26a71453b 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/JobWorker.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/JobWorker.java @@ -20,8 +20,7 @@ import org.slf4j.LoggerFactory; /** * The streaming worker implementation class, it is ray actor. JobWorker is created by - * {@link JobMaster} through ray api, and JobMaster communicates - * with JobWorker through Ray.call(). + * {@link JobMaster} through ray api, and JobMaster communicates with JobWorker through Ray.call(). * *

    The JobWorker is responsible for creating tasks and defines the methods of communication * between workers. @@ -147,8 +146,7 @@ public class JobWorker implements Serializable { } /** - * Used by upstream streaming queue to send data to this actor - * and receive result from this actor + * Used by upstream streaming queue to send data to this actor and receive result from this actor */ public byte[] onReaderMessageSync(byte[] buffer) { if (transferHandler == null) { @@ -165,8 +163,8 @@ public class JobWorker implements Serializable { } /** - * Used by downstream streaming queue to send data to this actor - * and receive result from this actor + * Used by downstream streaming queue to send data to this actor and receive result from this + * actor */ public byte[] onWriterMessageSync(byte[] buffer) { if (transferHandler == null) { diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/context/JobWorkerContext.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/context/JobWorkerContext.java index 87ece68b6..495a2b187 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/context/JobWorkerContext.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/context/JobWorkerContext.java @@ -56,10 +56,10 @@ public class JobWorkerContext implements Serializable { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("workerId", getWorkerId()) - .add("workerName", getWorkerName()) - .add("config", getConfig()) - .toString(); + .add("workerId", getWorkerId()) + .add("workerName", getWorkerName()) + .add("config", getConfig()) + .toString(); } public byte[] getPythonWorkerContextBytes() { @@ -68,10 +68,11 @@ public class JobWorkerContext implements Serializable { new GraphPbBuilder().buildExecutionVertexContext(executionVertex); byte[] contextBytes = RemoteCall.PythonJobWorkerContext.newBuilder() - .setMasterActor(ByteString.copyFrom((((NativeActorHandle) (master)).toBytes()))) - .setExecutionVertexContext(executionVertexContext) - .build() - .toByteArray(); + .setMasterActor( + ByteString.copyFrom((((NativeActorHandle) (master)).toBytes()))) + .setExecutionVertexContext(executionVertexContext) + .build() + .toByteArray(); return contextBytes; } diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/context/StreamingRuntimeContext.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/context/StreamingRuntimeContext.java index 23b1b924a..6fe22a4ae 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/context/StreamingRuntimeContext.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/context/StreamingRuntimeContext.java @@ -19,6 +19,7 @@ import java.util.Map; * Use Ray to implement RuntimeContext. */ public class StreamingRuntimeContext implements RuntimeContext { + /** * Backend for keyed state. This might be empty if we're not on a keyed stream. */ @@ -33,7 +34,8 @@ public class StreamingRuntimeContext implements RuntimeContext { private Long checkpointId; private Map config; - public StreamingRuntimeContext(ExecutionVertex executionVertex, Map config, + public StreamingRuntimeContext( + ExecutionVertex executionVertex, Map config, int parallelism) { this.taskId = executionVertex.getExecutionVertexId(); this.config = config; @@ -115,8 +117,9 @@ public class StreamingRuntimeContext implements RuntimeContext { return this.keyStateBackend.getMapState(stateDescriptor); } - protected void stateSanityCheck(AbstractStateDescriptor stateDescriptor, - AbstractKeyStateBackend backend) { + protected void stateSanityCheck( + AbstractStateDescriptor stateDescriptor, + AbstractKeyStateBackend backend) { Preconditions.checkNotNull(stateDescriptor, "The state properties must not be null"); Preconditions.checkNotNull(backend, "backend must not be null"); } diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/InputStreamTask.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/InputStreamTask.java index d47815341..9ce0c5fb7 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/InputStreamTask.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/InputStreamTask.java @@ -9,6 +9,7 @@ import io.ray.streaming.runtime.transfer.Message; import io.ray.streaming.runtime.worker.JobWorker; public abstract class InputStreamTask extends StreamTask { + private volatile boolean running = true; private volatile boolean stopped = false; private long readTimeoutMillis; @@ -56,8 +57,8 @@ public abstract class InputStreamTask extends StreamTask { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("taskId", taskId) - .add("processor", processor) - .toString(); + .add("taskId", taskId) + .add("processor", processor) + .toString(); } } diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/SourceStreamTask.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/SourceStreamTask.java index c47fe63ae..3c70ece44 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/SourceStreamTask.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/SourceStreamTask.java @@ -14,8 +14,8 @@ public class SourceStreamTask extends StreamTask { private final SourceProcessor sourceProcessor; /** - * SourceStreamTask for executing a {@link SourceOperator}. - * It is responsible for running the corresponding source operator. + * SourceStreamTask for executing a {@link SourceOperator}. It is responsible for running the + * corresponding source operator. */ public SourceStreamTask(int taskId, Processor sourceProcessor, JobWorker jobWorker) { super(taskId, sourceProcessor, jobWorker); diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/StreamTask.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/StreamTask.java index 00f6bb094..79ad0100d 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/StreamTask.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/StreamTask.java @@ -19,11 +19,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class StreamTask implements Runnable { + private static final Logger LOG = LoggerFactory.getLogger(StreamTask.class); protected int taskId; @@ -44,7 +44,7 @@ public abstract class StreamTask implements Runnable { prepareTask(); this.thread = new Thread(Ray.wrapRunnable(this), - this.getClass().getName() + "-" + System.currentTimeMillis()); + this.getClass().getName() + "-" + System.currentTimeMillis()); this.thread.setDaemon(true); } diff --git a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/TwoInputStreamTask.java b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/TwoInputStreamTask.java index 7126105f6..1bba5b0f5 100644 --- a/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/TwoInputStreamTask.java +++ b/streaming/java/streaming-runtime/src/main/java/io/ray/streaming/runtime/worker/tasks/TwoInputStreamTask.java @@ -16,8 +16,8 @@ public class TwoInputStreamTask extends InputStreamTask { String leftStream, String rightStream) { super(taskId, processor, jobWorker); - ((TwoInputProcessor)(super.processor)).setLeftStream(leftStream); - ((TwoInputProcessor)(super.processor)).setRightStream(rightStream); + ((TwoInputProcessor) (super.processor)).setLeftStream(leftStream); + ((TwoInputProcessor) (super.processor)).setRightStream(rightStream); } } diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/BaseUnitTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/BaseUnitTest.java index 593851a86..569888335 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/BaseUnitTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/BaseUnitTest.java @@ -25,12 +25,12 @@ public abstract class BaseUnitTest { @BeforeMethod public void testBegin(Method method) { LOG.info(">>>>>>>>>>>>>>>>>>>> Test case: {}.{} began >>>>>>>>>>>>>>>>>>>>", - method.getDeclaringClass(), method.getName()); + method.getDeclaringClass(), method.getName()); } @AfterMethod public void testEnd(Method method) { LOG.info(">>>>>>>>>>>>>>>>>>>> Test case: {}.{} end >>>>>>>>>>>>>>>>>>>>", - method.getDeclaringClass(), method.getName()); + method.getDeclaringClass(), method.getName()); } } diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/core/graph/ExecutionGraphTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/core/graph/ExecutionGraphTest.java index 2c49eadaa..05d4f9dc8 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/core/graph/ExecutionGraphTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/core/graph/ExecutionGraphTest.java @@ -50,11 +50,11 @@ public class ExecutionGraphTest extends BaseUnitTest { executionGraph.getExecutionVertexIdGenerator().get()); executionGraph.getAllExecutionVertices().forEach(vertex -> { - Assert.assertNotNull(vertex.getStreamOperator()); - Assert.assertNotNull(vertex.getExecutionJobVertexName()); - Assert.assertNotNull(vertex.getVertexType()); - Assert.assertNotNull(vertex.getLanguage()); - Assert.assertEquals(vertex.getExecutionVertexName(), + Assert.assertNotNull(vertex.getStreamOperator()); + Assert.assertNotNull(vertex.getExecutionJobVertexName()); + Assert.assertNotNull(vertex.getVertexType()); + Assert.assertNotNull(vertex.getLanguage()); + Assert.assertEquals(vertex.getExecutionVertexName(), vertex.getExecutionJobVertexName() + "-" + vertex.getExecutionVertexIndex()); }); @@ -66,10 +66,11 @@ public class ExecutionGraphTest extends BaseUnitTest { List upStreamVertices = upStream.getExecutionVertices(); List downStreamVertices = downStream.getExecutionVertices(); upStreamVertices.forEach(vertex -> { - Assert.assertEquals((double) vertex.getResource().get(ResourceType.CPU.name()), 2.0); - vertex.getOutputEdges().forEach(upStreamOutPutEdge -> { - Assert.assertTrue(downStreamVertices.contains(upStreamOutPutEdge.getTargetExecutionVertex())); - }); + Assert.assertEquals((double) vertex.getResource().get(ResourceType.CPU.name()), 2.0); + vertex.getOutputEdges().forEach(upStreamOutPutEdge -> { + Assert + .assertTrue(downStreamVertices.contains(upStreamOutPutEdge.getTargetExecutionVertex())); + }); }); } diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/HybridStreamTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/HybridStreamTest.java index 81941515e..5fe049aff 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/HybridStreamTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/HybridStreamTest.java @@ -18,6 +18,7 @@ import org.testng.Assert; import org.testng.annotations.Test; public class HybridStreamTest { + private static final Logger LOG = LoggerFactory.getLogger(HybridStreamTest.class); public static class Mapper1 implements MapFunction { diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/UnionStreamTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/UnionStreamTest.java index f3d46d826..8473937a9 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/UnionStreamTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/UnionStreamTest.java @@ -17,7 +17,8 @@ import org.testng.Assert; import org.testng.annotations.Test; public class UnionStreamTest { - private static final Logger LOG = LoggerFactory.getLogger( UnionStreamTest.class ); + + private static final Logger LOG = LoggerFactory.getLogger(UnionStreamTest.class); @Test(timeOut = 60000) public void testUnionStream() throws Exception { diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/WordCountTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/WordCountTest.java index cd811b0af..11234b7d9 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/WordCountTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/demo/WordCountTest.java @@ -46,7 +46,8 @@ public class WordCountTest extends BaseUnitTest implements Serializable { .filter(pair -> !pair.word.contains("world")) .keyBy(pair -> pair.word) .reduce((ReduceFunction) (oldValue, newValue) -> - new WordAndCount(oldValue.word, oldValue.count + newValue.count)) + new WordAndCount(oldValue.word, + oldValue.count + newValue.count)) .sink((SinkFunction) result -> wordCount.put(result.word, result.count)); diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/python/PythonGatewayTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/python/PythonGatewayTest.java index 116ddb801..831e35b92 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/python/PythonGatewayTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/python/PythonGatewayTest.java @@ -2,6 +2,7 @@ package io.ray.streaming.runtime.python; import static org.testng.Assert.assertEquals; + import io.ray.streaming.api.stream.StreamSink; import io.ray.streaming.jobgraph.JobGraph; import io.ray.streaming.jobgraph.JobGraphBuilder; diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/serialization/CrossLangSerializerTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/serialization/CrossLangSerializerTest.java index 0922bc9cd..2c37a0d5f 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/serialization/CrossLangSerializerTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/serialization/CrossLangSerializerTest.java @@ -3,6 +3,7 @@ package io.ray.streaming.runtime.serialization; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; + import io.ray.streaming.message.KeyRecord; import io.ray.streaming.message.Record; import org.apache.commons.lang3.builder.EqualsBuilder; @@ -17,10 +18,10 @@ public class CrossLangSerializerTest { Record record = new Record("value"); record.setStream("stream1"); assertTrue(EqualsBuilder.reflectionEquals(record, - serializer.deserialize(serializer.serialize(record)))); + serializer.deserialize(serializer.serialize(record)))); KeyRecord keyRecord = new KeyRecord("key", "value"); keyRecord.setStream("stream2"); assertEquals(keyRecord, - serializer.deserialize(serializer.serialize(keyRecord))); + serializer.deserialize(serializer.serialize(keyRecord))); } } \ No newline at end of file diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/serialization/MsgPackSerializerTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/serialization/MsgPackSerializerTest.java index 44568df8d..9c140c9cc 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/serialization/MsgPackSerializerTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/serialization/MsgPackSerializerTest.java @@ -3,6 +3,7 @@ package io.ray.streaming.runtime.serialization; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -18,7 +19,7 @@ public class MsgPackSerializerTest { MsgPackSerializer serializer = new MsgPackSerializer(); assertEquals(serializer.deserialize( - serializer.serialize((byte)1)), (byte)1); + serializer.serialize((byte) 1)), (byte) 1); } @Test diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/streamingqueue/Worker.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/streamingqueue/Worker.java index 314dcf181..4e94d5167 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/streamingqueue/Worker.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/streamingqueue/Worker.java @@ -1,12 +1,12 @@ package io.ray.streaming.runtime.streamingqueue; +import io.ray.api.ActorHandle; import io.ray.api.BaseActorHandle; import io.ray.api.Ray; -import io.ray.api.ActorHandle; import io.ray.runtime.functionmanager.JavaFunctionDescriptor; import io.ray.streaming.runtime.config.StreamingWorkerConfig; -import io.ray.streaming.runtime.transfer.ChannelId; import io.ray.streaming.runtime.transfer.ChannelCreationParametersBuilder; +import io.ray.streaming.runtime.transfer.ChannelId; import io.ray.streaming.runtime.transfer.DataMessage; import io.ray.streaming.runtime.transfer.DataReader; import io.ray.streaming.runtime.transfer.DataWriter; @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; import org.testng.Assert; public class Worker { + private static final Logger LOGGER = LoggerFactory.getLogger(Worker.class); protected TransferHandler transferHandler = null; @@ -50,6 +51,7 @@ public class Worker { } class ReaderWorker extends Worker { + private static final Logger LOGGER = LoggerFactory.getLogger(ReaderWorker.class); private String name = null; @@ -170,6 +172,7 @@ class ReaderWorker extends Worker { } class WriterWorker extends Worker { + private static final Logger LOGGER = LoggerFactory.getLogger(WriterWorker.class); private String name = null; diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/transfer/ChannelIdTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/transfer/ChannelIdTest.java index fe841844c..11dcddeda 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/transfer/ChannelIdTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/transfer/ChannelIdTest.java @@ -2,6 +2,7 @@ package io.ray.streaming.runtime.transfer; import static org.testng.Assert.assertEquals; + import io.ray.streaming.runtime.BaseUnitTest; import io.ray.streaming.runtime.util.EnvUtil; import org.testng.annotations.Test; diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/util/Mockitools.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/util/Mockitools.java index 9a2f27589..4dc305d71 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/util/Mockitools.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/util/Mockitools.java @@ -21,12 +21,11 @@ public class Mockitools { public static void mockGscApi() { PowerMockito.mockStatic(RayUtils.class); PowerMockito.when(RayUtils.getAliveNodeInfoMap()) - .thenReturn(mockGetNodeInfoMap(mockGetAllNodeInfo())); + .thenReturn(mockGetNodeInfoMap(mockGetAllNodeInfo())); } /** * Mock get all node info from GCS - * @return */ public static List mockGetAllNodeInfo() { List nodeInfos = new LinkedList<>(); @@ -55,21 +54,22 @@ public class Mockitools { /** * Mock get node info map + * * @param nodeInfos all node infos fetched from GCS * @return node info map, key is node unique id, value is node info */ public static Map mockGetNodeInfoMap(List nodeInfos) { return nodeInfos.stream().filter(nodeInfo -> nodeInfo.isAlive).collect( - Collectors.toMap(nodeInfo -> nodeInfo.nodeId, nodeInfo -> nodeInfo)); + Collectors.toMap(nodeInfo -> nodeInfo.nodeId, nodeInfo -> nodeInfo)); } private static NodeInfo mockNodeInfo(int i, Map resources) { return new NodeInfo( - createNodeId(i), - "localhost" + i, - "localhost" + i, - true, - resources); + createNodeId(i), + "localhost" + i, + "localhost" + i, + true, + resources); } private static UniqueId createNodeId(int id) { diff --git a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/util/ReflectionUtilsTest.java b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/util/ReflectionUtilsTest.java index d483cd427..d263ead06 100644 --- a/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/util/ReflectionUtilsTest.java +++ b/streaming/java/streaming-runtime/src/test/java/io/ray/streaming/runtime/util/ReflectionUtilsTest.java @@ -2,6 +2,7 @@ package io.ray.streaming.runtime.util; import static org.testng.Assert.assertEquals; + import java.io.Serializable; import java.util.Collections; import org.testng.annotations.Test; @@ -9,6 +10,7 @@ import org.testng.annotations.Test; public class ReflectionUtilsTest { static class Foo implements Serializable { + public void f1() { } diff --git a/streaming/java/streaming-state/pom.xml b/streaming/java/streaming-state/pom.xml index 63620d3ba..0820e92b0 100644 --- a/streaming/java/streaming-state/pom.xml +++ b/streaming/java/streaming-state/pom.xml @@ -2,95 +2,95 @@ - - ray-streaming - io.ray - 0.9.0-SNAPSHOT - - 4.0.0 + + ray-streaming + io.ray + 0.9.0-SNAPSHOT + + 4.0.0 - streaming-state - ray streaming state - ray streaming state - - - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-log4j12 - ${slf4j.version} - - - log4j - log4j - ${log4j.version} - - - org.testng - testng - ${testng.version} - test - - - org.mockito - mockito-all - ${mockito.version} - test - - - - com.google.guava - guava - ${guava.version} - - - + streaming-state + ray streaming state + ray streaming state + - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - org.testng - testng - - - org.mockito - mockito-all - - - de.ruedigermoeller - fst - ${fst.version} - - - com.google.guava - guava - - - org.apache.commons - commons-lang3 - 3.3.2 - - - com.beust - jcommander - 1.27 - + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + + + log4j + log4j + ${log4j.version} + + + org.testng + testng + ${testng.version} + test + + + org.mockito + mockito-all + ${mockito.version} + test + + + + com.google.guava + guava + ${guava.version} + + + + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + org.testng + testng + + + org.mockito + mockito-all + + + de.ruedigermoeller + fst + ${fst.version} + + + com.google.guava + guava + + + org.apache.commons + commons-lang3 + 3.3.2 + + + com.beust + jcommander + 1.27 + + \ No newline at end of file diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/StateStoreManager.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/StateStoreManager.java index 5d55273a8..d5d568a7c 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/StateStoreManager.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/StateStoreManager.java @@ -21,21 +21,20 @@ package io.ray.streaming.state; /** * TransactionState interface. *

    - * Streaming State should implement transaction in case of failure, - * which in our case is four default method, finish, commit, ackCommit, rollback. + * Streaming State should implement transaction in case of failure, which in our case is four + * default method, finish, commit, ackCommit, rollback. */ public interface StateStoreManager { /** - * The finish method is used when the batched data is all saved in state. - * Normally, serialization job is done here. + * The finish method is used when the batched data is all saved in state. Normally, serialization + * job is done here. */ void finish(long checkpointId); /** * The commit method is used for persistent, and can be used in another thread to reach async - * state commit. - * Normally, data persistent is done here. + * state commit. Normally, data persistent is done here. */ void commit(long checkpointId); diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/AbstractStateBackend.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/AbstractStateBackend.java index d01d7a6b1..3392f32df 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/AbstractStateBackend.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/AbstractStateBackend.java @@ -20,6 +20,7 @@ package io.ray.streaming.state.backend; import static io.ray.streaming.state.config.ConfigKey.DELIMITER; + import io.ray.streaming.state.config.ConfigKey; import io.ray.streaming.state.keystate.desc.AbstractStateDescriptor; import io.ray.streaming.state.serialization.KeyMapStoreSerializer; diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/KeyStateBackend.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/KeyStateBackend.java index 9e73295ec..4dea4511c 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/KeyStateBackend.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/KeyStateBackend.java @@ -31,16 +31,17 @@ import io.ray.streaming.state.keystate.state.proxy.MapStateStoreManagerProxy; import io.ray.streaming.state.keystate.state.proxy.ValueStateStoreManagerProxy; /** - * key state backend manager, managing different kinds of states in different thread. - * This class is not thread safe. + * key state backend manager, managing different kinds of states in different thread. This class is + * not thread safe. */ public class KeyStateBackend extends AbstractKeyStateBackend { protected final int numberOfKeyGroups; protected final KeyGroup keyGroup; - public KeyStateBackend(int numberOfKeyGroups, KeyGroup keyGroup, - AbstractStateBackend abstractStateBackend) { + public KeyStateBackend( + int numberOfKeyGroups, KeyGroup keyGroup, + AbstractStateBackend abstractStateBackend) { super(abstractStateBackend); this.numberOfKeyGroups = numberOfKeyGroups; this.keyGroup = keyGroup; diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/StateBackendBuilder.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/StateBackendBuilder.java index 27e849a96..0921c5a26 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/StateBackendBuilder.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/backend/StateBackendBuilder.java @@ -27,8 +27,9 @@ import java.util.Map; */ public class StateBackendBuilder { - private static AbstractStateBackend getStateBackend(Map config, - BackendType type) { + private static AbstractStateBackend getStateBackend( + Map config, + BackendType type) { switch (type) { case MEMORY: return new MemoryStateBackend(config); diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/config/ConfigHelper.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/config/ConfigHelper.java index 0fbf88f3e..cc5ad02cc 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/config/ConfigHelper.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/config/ConfigHelper.java @@ -21,8 +21,7 @@ package io.ray.streaming.state.config; import java.util.Map; /** - * Config Helper figure out the config info. - * Todo replace this to config module. + * Config Helper figure out the config info. Todo replace this to config module. */ public class ConfigHelper { diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/config/ConfigKey.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/config/ConfigKey.java index f7d8a42a0..4ce263856 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/config/ConfigKey.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/config/ConfigKey.java @@ -21,8 +21,7 @@ package io.ray.streaming.state.config; import java.util.Map; /** - * state config keys. - * Todo replace this to config module. + * state config keys. Todo replace this to config module. */ public final class ConfigKey { diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/KeyGroup.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/KeyGroup.java index fb24c72d1..c3d6ad6ef 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/KeyGroup.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/KeyGroup.java @@ -22,9 +22,8 @@ import com.google.common.base.Preconditions; import java.io.Serializable; /** - * This class defines key-groups. Key-groups is - * the key space in a job, which is partitioned for keyed state processing in state backend. - * The boundaries of the key-group are inclusive. + * This class defines key-groups. Key-groups is the key space in a job, which is partitioned for + * keyed state processing in state backend. The boundaries of the key-group are inclusive. */ public class KeyGroup implements Serializable { diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/KeyGroupAssignment.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/KeyGroupAssignment.java index 77b465f74..5e49259e2 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/KeyGroupAssignment.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/KeyGroupAssignment.java @@ -57,8 +57,9 @@ public final class KeyGroupAssignment { return Math.abs(key.hashCode() % maxParallelism); } - public static Map> computeKeyGroupToTask(int maxParallelism, - List targetTasks) { + public static Map> computeKeyGroupToTask( + int maxParallelism, + List targetTasks) { Map> keyGroupToTask = new ConcurrentHashMap<>(); for (int index = 0; index < targetTasks.size(); index++) { KeyGroup taskKeyGroup = getKeyGroup(maxParallelism, targetTasks.size(), index); diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/desc/ListStateDescriptor.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/desc/ListStateDescriptor.java index c6a7af6b6..aa2100350 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/desc/ListStateDescriptor.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/desc/ListStateDescriptor.java @@ -21,6 +21,7 @@ package io.ray.streaming.state.keystate.desc; import static io.ray.streaming.state.config.ConfigKey.DELIMITER; + import io.ray.streaming.state.keystate.state.ListState; /** @@ -41,8 +42,9 @@ public class ListStateDescriptor extends AbstractStateDescriptor return build(name, type, false); } - public static ListStateDescriptor build(String name, Class type, - boolean isOperatorList) { + public static ListStateDescriptor build( + String name, Class type, + boolean isOperatorList) { return new ListStateDescriptor<>(name, type, isOperatorList); } @@ -75,7 +77,8 @@ public class ListStateDescriptor extends AbstractStateDescriptor public String getIdentify() { if (isOperatorList) { return String - .format("%s%s%d%s%d", super.getIdentify(), DELIMITER, partitionNum, DELIMITER, index); + .format("%s%s%d%s%d", super.getIdentify(), DELIMITER, partitionNum, DELIMITER, + index); } else { return super.getIdentify(); } diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/desc/MapStateDescriptor.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/desc/MapStateDescriptor.java index 15373265e..f1803b03e 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/desc/MapStateDescriptor.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/desc/MapStateDescriptor.java @@ -31,8 +31,9 @@ public class MapStateDescriptor extends AbstractStateDescriptor MapStateDescriptor build(String name, Class keyType, - Class valueType) { + public static MapStateDescriptor build( + String name, Class keyType, + Class valueType) { return new MapStateDescriptor<>(name, keyType, valueType); } diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/impl/OperatorStateImpl.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/impl/OperatorStateImpl.java index e1b8defd3..b5a50415b 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/impl/OperatorStateImpl.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/impl/OperatorStateImpl.java @@ -20,6 +20,7 @@ package io.ray.streaming.state.keystate.state.impl; import static io.ray.streaming.state.config.ConfigKey.DELIMITER; + import com.google.common.base.Preconditions; import io.ray.streaming.state.PartitionRecord; import io.ray.streaming.state.backend.AbstractKeyStateBackend; @@ -30,9 +31,8 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; /** - * This class defines the implementation of operator state. - * When the state is initialized, we must scan the whole table. - * And if the state type is splitList, all the records must be spitted. + * This class defines the implementation of operator state. When the state is initialized, we must + * scan the whole table. And if the state type is splitList, all the records must be spitted. */ public class OperatorStateImpl implements ListState { diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/ListStateStoreManagerProxy.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/ListStateStoreManagerProxy.java index 9f25ec4f4..82136da27 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/ListStateStoreManagerProxy.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/ListStateStoreManagerProxy.java @@ -35,8 +35,9 @@ public class ListStateStoreManagerProxy extends StateStoreManagerProxy listState; - public ListStateStoreManagerProxy(AbstractKeyStateBackend keyStateBackend, - ListStateDescriptor stateDescriptor) { + public ListStateStoreManagerProxy( + AbstractKeyStateBackend keyStateBackend, + ListStateDescriptor stateDescriptor) { super(keyStateBackend, stateDescriptor); if (stateDescriptor.isOperatorList()) { this.listState = new OperatorStateImpl<>(stateDescriptor, keyStateBackend); diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/MapStateStoreManagerProxy.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/MapStateStoreManagerProxy.java index a30e5084a..7542a5bf3 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/MapStateStoreManagerProxy.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/MapStateStoreManagerProxy.java @@ -34,8 +34,9 @@ public class MapStateStoreManagerProxy extends StateStoreManagerProxy mapState; - public MapStateStoreManagerProxy(KeyStateBackend keyStateBackend, - MapStateDescriptor stateDescriptor) { + public MapStateStoreManagerProxy( + KeyStateBackend keyStateBackend, + MapStateDescriptor stateDescriptor) { super(keyStateBackend, stateDescriptor); this.mapState = new MapStateImpl<>(stateDescriptor, keyStateBackend); } diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/ValueStateStoreManagerProxy.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/ValueStateStoreManagerProxy.java index 3ab4bd2a1..13e68c8dc 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/ValueStateStoreManagerProxy.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/keystate/state/proxy/ValueStateStoreManagerProxy.java @@ -33,8 +33,9 @@ public class ValueStateStoreManagerProxy extends StateStoreManagerProxy im private final ValueStateImpl valueState; - public ValueStateStoreManagerProxy(KeyStateBackend keyStateBackend, - ValueStateDescriptor stateDescriptor) { + public ValueStateStoreManagerProxy( + KeyStateBackend keyStateBackend, + ValueStateDescriptor stateDescriptor) { super(keyStateBackend, stateDescriptor); this.valueState = new ValueStateImpl<>(stateDescriptor, keyStateBackend); } diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/serialization/Serializer.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/serialization/Serializer.java index 6db0c589f..ec66ede98 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/serialization/Serializer.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/serialization/Serializer.java @@ -25,8 +25,8 @@ import org.nustaq.serialization.FSTConfiguration; */ public class Serializer { - private static final ThreadLocal conf = ThreadLocal - .withInitial(FSTConfiguration::createDefaultConfiguration); + private static final ThreadLocal conf = + ThreadLocal.withInitial(FSTConfiguration::createDefaultConfiguration); public static byte[] object2Bytes(Object value) { return conf.get().asByteArray(value); diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/strategy/AbstractStateStoreManager.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/strategy/AbstractStateStoreManager.java index 0d4e179fe..41873966b 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/strategy/AbstractStateStoreManager.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/strategy/AbstractStateStoreManager.java @@ -28,8 +28,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** - * This class defines the StoreManager Abstract class. - * We use three layer to store the state, frontStore, middleStore and keyValueStore(remote). + * This class defines the StoreManager Abstract class. We use three layer to store the state, + * frontStore, middleStore and keyValueStore(remote). */ public abstract class AbstractStateStoreManager implements StateStoreManager { diff --git a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/strategy/StateStoreManagerProxy.java b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/strategy/StateStoreManagerProxy.java index d74982c5a..268af0b0d 100644 --- a/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/strategy/StateStoreManagerProxy.java +++ b/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/strategy/StateStoreManagerProxy.java @@ -37,8 +37,9 @@ public abstract class StateStoreManagerProxy implements StateStoreManager { protected final AbstractStateStoreManager stateStrategy; private final AbstractKeyStateBackend keyStateBackend; - public StateStoreManagerProxy(AbstractKeyStateBackend keyStateBackend, - AbstractStateDescriptor stateDescriptor) { + public StateStoreManagerProxy( + AbstractKeyStateBackend keyStateBackend, + AbstractStateDescriptor stateDescriptor) { this.keyStateBackend = keyStateBackend; KeyValueStore> backStorage = keyStateBackend .getBackStorage(stateDescriptor); diff --git a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/backend/KeyStateBackendTest.java b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/backend/KeyStateBackendTest.java index 91b375c5f..514b120e7 100644 --- a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/backend/KeyStateBackendTest.java +++ b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/backend/KeyStateBackendTest.java @@ -38,7 +38,7 @@ public class KeyStateBackendTest { public void testGetValueState() { keyStateBackend.setCheckpointId(1L); ValueStateDescriptor valueStateDescriptor = ValueStateDescriptor - .build("value", String.class, null); + .build("value", String.class, null); valueStateDescriptor.setTableName("kepler_hlg_ut"); ValueState valueState = keyStateBackend.getValueState(valueStateDescriptor); @@ -120,7 +120,7 @@ public class KeyStateBackendTest { public void testGetListState() { keyStateBackend.setCheckpointId(1l); ListStateDescriptor listStateDescriptor = ListStateDescriptor - .build("list", String.class); + .build("list", String.class); listStateDescriptor.setTableName("kepler_hlg_ut"); ListState listState = keyStateBackend.getListState(listStateDescriptor); @@ -208,7 +208,8 @@ public class KeyStateBackendTest { public void testGetMapState() { keyStateBackend.setCheckpointId(1l); MapStateDescriptor mapStateDescriptor = MapStateDescriptor - .build("map", String.class, String.class); + .build("map", String.class, + String.class); mapStateDescriptor.setTableName("kepler_hlg_ut"); MapState mapState = keyStateBackend.getMapState(mapStateDescriptor); diff --git a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/impl/DefaultKeyValueStoreSerializationTest.java b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/impl/DefaultKeyValueStoreSerializationTest.java index 2bf546481..332aa8299 100644 --- a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/impl/DefaultKeyValueStoreSerializationTest.java +++ b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/impl/DefaultKeyValueStoreSerializationTest.java @@ -24,7 +24,8 @@ import org.testng.annotations.Test; public class DefaultKeyValueStoreSerializationTest { - DefaultKeyValueStoreSerialization serDe = new DefaultKeyValueStoreSerialization<>(); + DefaultKeyValueStoreSerialization serDe = + new DefaultKeyValueStoreSerialization<>(); byte[] ret; @Test diff --git a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/KeyGroupAssignmentTest.java b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/KeyGroupAssignmentTest.java index eeb560d09..31aa81004 100644 --- a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/KeyGroupAssignmentTest.java +++ b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/KeyGroupAssignmentTest.java @@ -20,6 +20,7 @@ package io.ray.streaming.state.keystate; import static org.testng.Assert.assertEquals; + import org.testng.annotations.Test; public class KeyGroupAssignmentTest { diff --git a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/desc/MapStateDescriptorTest.java b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/desc/MapStateDescriptorTest.java index 8c62888c5..1c6de6a67 100644 --- a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/desc/MapStateDescriptorTest.java +++ b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/desc/MapStateDescriptorTest.java @@ -26,7 +26,8 @@ public class MapStateDescriptorTest { @Test public void test() { MapStateDescriptor descriptor = MapStateDescriptor - .build("msdTest", String.class, Integer.class); + .build("msdTest", String.class, + Integer.class); descriptor.setTableName("table"); Assert.assertEquals(descriptor.getTableName(), "table"); diff --git a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/MapStateImplTest.java b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/MapStateImplTest.java index 5dd7ad566..5b86ad4a5 100644 --- a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/MapStateImplTest.java +++ b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/MapStateImplTest.java @@ -39,7 +39,8 @@ public class MapStateImplTest { keyStateBackend = new KeyStateBackend(1, new KeyGroup(1, 2), new MemoryStateBackend(new HashMap<>())); MapStateDescriptor descriptor = MapStateDescriptor - .build("MapStateImplTest", Integer.class, String.class); + .build("MapStateImplTest", Integer.class, + String.class); descriptor.setTableName("table"); mapState = (MapStateImpl) keyStateBackend.getMapState(descriptor); } diff --git a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/OperatorStateImplTest.java b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/OperatorStateImplTest.java index 843a0d0dd..d3d3297b4 100644 --- a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/OperatorStateImplTest.java +++ b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/OperatorStateImplTest.java @@ -42,7 +42,8 @@ public class OperatorStateImplTest { operatorStateBackend = new OperatorStateBackend(new MemoryStateBackend(config)); descriptor = ListStateDescriptor - .build("OperatorStateImplTest" + System.currentTimeMillis(), Integer.class, true); + .build("OperatorStateImplTest" + System.currentTimeMillis(), Integer.class, + true); descriptor.setPartitionNumber(1); descriptor.setIndex(0); descriptor.setTableName(table_name); diff --git a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/ValueStateImplTest.java b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/ValueStateImplTest.java index bbda18e87..3a45dd014 100644 --- a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/ValueStateImplTest.java +++ b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/keystate/state/impl/ValueStateImplTest.java @@ -37,7 +37,8 @@ public class ValueStateImplTest { keyStateBackend = new KeyStateBackend(1, new KeyGroup(1, 2), new MemoryStateBackend(new HashMap<>())); ValueStateDescriptor descriptor = ValueStateDescriptor - .build("ValueStateImplTest", String.class, "hello"); + .build("ValueStateImplTest", String.class, + "hello"); descriptor.setTableName("table"); valueState = (ValueStateImpl) keyStateBackend.getValueState(descriptor); diff --git a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/strategy/DualStateStrategyTest.java b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/strategy/DualStateStrategyTest.java index 16fa4d29d..2d0c8173f 100644 --- a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/strategy/DualStateStrategyTest.java +++ b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/strategy/DualStateStrategyTest.java @@ -55,7 +55,8 @@ public class DualStateStrategyTest { public void caseKV() { ValueStateDescriptor valueStateDescriptor = ValueStateDescriptor - .build("VALUE-" + currentTime, String.class, defaultValue); + .build("VALUE-" + currentTime, + String.class, defaultValue); valueStateDescriptor.setTableName(table); ValueState state = this.keyStateBackend.getValueState(valueStateDescriptor); @@ -159,7 +160,8 @@ public class DualStateStrategyTest { public void caseKVGap() { ValueStateDescriptor valueStateDescriptor = ValueStateDescriptor - .build("value2-" + currentTime, String.class, defaultValue); + .build("value2-" + currentTime, + String.class, defaultValue); valueStateDescriptor.setTableName(table); ValueState state = this.keyStateBackend.getValueState(valueStateDescriptor); @@ -208,7 +210,8 @@ public class DualStateStrategyTest { public void caseKList() { ListStateDescriptor listStateDescriptor = ListStateDescriptor - .build("LIST-" + currentTime, Integer.class); + .build("LIST-" + currentTime, + Integer.class); listStateDescriptor.setTableName(table); ListState state = this.keyStateBackend.getListState(listStateDescriptor); @@ -310,7 +313,8 @@ public class DualStateStrategyTest { public void caseKMap() { MapStateDescriptor mapStateDescriptor = MapStateDescriptor - .build("MAP-" + currentTime, Integer.class, Integer.class); + .build("MAP-" + currentTime, + Integer.class, Integer.class); mapStateDescriptor.setTableName(table); MapState state = this.keyStateBackend.getMapState(mapStateDescriptor); diff --git a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/strategy/MVStateStrategyTest.java b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/strategy/MVStateStrategyTest.java index 4580e3890..6b7316595 100644 --- a/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/strategy/MVStateStrategyTest.java +++ b/streaming/java/streaming-state/src/test/java/io/ray/streaming/state/strategy/MVStateStrategyTest.java @@ -53,7 +53,8 @@ public class MVStateStrategyTest { public void caseKV() { ValueStateDescriptor valueStateDescriptor = ValueStateDescriptor - .build("mvint-" + currentTime, String.class, ""); + .build("mvint-" + currentTime, + String.class, ""); valueStateDescriptor.setTableName(table); ValueState state = this.keyStateBackend.getValueState(valueStateDescriptor); @@ -170,7 +171,8 @@ public class MVStateStrategyTest { public void caseKList() { ListStateDescriptor listStateDescriptor = ListStateDescriptor - .build("mvlist-" + currentTime, Integer.class); + .build("mvlist-" + currentTime, + Integer.class); listStateDescriptor.setTableName(table); ListState state = this.keyStateBackend.getListState(listStateDescriptor); @@ -274,7 +276,8 @@ public class MVStateStrategyTest { public void caseKMap() { MapStateDescriptor mapStateDescriptor = MapStateDescriptor - .build("mvmap-" + currentTime, Integer.class, Integer.class); + .build("mvmap-" + currentTime, + Integer.class, Integer.class); mapStateDescriptor.setTableName(table); MapState state = this.keyStateBackend.getMapState(mapStateDescriptor); diff --git a/streaming/java/testng.xml b/streaming/java/testng.xml index 69e4af5af..62c72a40f 100644 --- a/streaming/java/testng.xml +++ b/streaming/java/testng.xml @@ -1,9 +1,9 @@ - + - + - +