mirror of
https://github.com/wassname/ray.git
synced 2026-07-15 11:25:40 +08:00
[Streaming] Supports multiple downstream collector (#9240)
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@ import io.ray.streaming.api.function.impl.FlatMapFunction;
|
||||
import io.ray.streaming.api.function.impl.ReduceFunction;
|
||||
import io.ray.streaming.api.stream.DataStreamSource;
|
||||
import io.ray.streaming.runtime.BaseUnitTest;
|
||||
import io.ray.streaming.runtime.transfer.ChannelID;
|
||||
import io.ray.streaming.runtime.transfer.ChannelId;
|
||||
import io.ray.streaming.runtime.util.EnvUtil;
|
||||
import io.ray.streaming.util.Config;
|
||||
import java.io.File;
|
||||
@@ -99,7 +99,7 @@ public class StreamingQueueTest extends BaseUnitTest implements Serializable {
|
||||
List<String> inputQueueList = new ArrayList<>();
|
||||
int queueNum = 2;
|
||||
for (int i = 0; i < queueNum; ++i) {
|
||||
String qid = ChannelID.genRandomIdStr();
|
||||
String qid = ChannelId.genRandomIdStr();
|
||||
LOGGER.info("getRandomQueueId: {}", qid);
|
||||
inputQueueList.add(qid);
|
||||
outputQueueList.add(qid);
|
||||
|
||||
+7
-6
@@ -5,7 +5,7 @@ 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.ChannelId;
|
||||
import io.ray.streaming.runtime.transfer.ChannelCreationParametersBuilder;
|
||||
import io.ray.streaming.runtime.transfer.DataMessage;
|
||||
import io.ray.streaming.runtime.transfer.DataReader;
|
||||
@@ -14,6 +14,7 @@ import io.ray.streaming.runtime.transfer.TransferHandler;
|
||||
import io.ray.streaming.util.Config;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -53,7 +54,7 @@ class ReaderWorker extends Worker {
|
||||
|
||||
private String name = null;
|
||||
private List<String> inputQueueList = null;
|
||||
Map<String, BaseActorHandle> inputActors = new HashMap<>();
|
||||
List<BaseActorHandle> inputActors = new ArrayList<>();
|
||||
private DataReader dataReader = null;
|
||||
private long handler = 0;
|
||||
private ActorHandle<WriterWorker> peerActor = null;
|
||||
@@ -88,7 +89,7 @@ class ReaderWorker extends Worker {
|
||||
LOGGER.info("java.library.path = {}", System.getProperty("java.library.path"));
|
||||
|
||||
for (String queue : this.inputQueueList) {
|
||||
inputActors.put(queue, this.peerActor);
|
||||
inputActors.add(this.peerActor);
|
||||
LOGGER.info("ReaderWorker actorId: {}", this.peerActor.getId());
|
||||
}
|
||||
|
||||
@@ -173,7 +174,7 @@ class WriterWorker extends Worker {
|
||||
|
||||
private String name = null;
|
||||
private List<String> outputQueueList = null;
|
||||
Map<String, BaseActorHandle> outputActors = new HashMap<>();
|
||||
List<BaseActorHandle> outputActors = new ArrayList<>();
|
||||
DataWriter dataWriter = null;
|
||||
ActorHandle<ReaderWorker> peerActor = null;
|
||||
int msgCount = 0;
|
||||
@@ -205,7 +206,7 @@ class WriterWorker extends Worker {
|
||||
LOGGER.info("WriterWorker init:");
|
||||
|
||||
for (String queue : this.outputQueueList) {
|
||||
outputActors.put(queue, this.peerActor);
|
||||
outputActors.add(this.peerActor);
|
||||
LOGGER.info("WriterWorker actorId: {}", this.peerActor.getId());
|
||||
}
|
||||
|
||||
@@ -260,7 +261,7 @@ class WriterWorker extends Worker {
|
||||
}
|
||||
|
||||
bb.clear();
|
||||
ChannelID qid = ChannelID.from(outputQueueList.get(j));
|
||||
ChannelId qid = ChannelId.from(outputQueueList.get(j));
|
||||
dataWriter.write(qid, bb);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@ import io.ray.streaming.runtime.BaseUnitTest;
|
||||
import io.ray.streaming.runtime.util.EnvUtil;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class ChannelIDTest extends BaseUnitTest {
|
||||
public class ChannelIdTest extends BaseUnitTest {
|
||||
|
||||
static {
|
||||
EnvUtil.loadNativeLibraries();
|
||||
@@ -14,9 +14,9 @@ public class ChannelIDTest extends BaseUnitTest {
|
||||
|
||||
@Test
|
||||
public void testIdStrToBytes() {
|
||||
String idStr = ChannelID.genRandomIdStr();
|
||||
assertEquals(idStr.length(), ChannelID.ID_LENGTH * 2);
|
||||
assertEquals(ChannelID.idStrToBytes(idStr).length, ChannelID.ID_LENGTH);
|
||||
String idStr = ChannelId.genRandomIdStr();
|
||||
assertEquals(idStr.length(), ChannelId.ID_LENGTH * 2);
|
||||
assertEquals(ChannelId.idStrToBytes(idStr).length, ChannelId.ID_LENGTH);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user