mirror of
https://github.com/wassname/ray.git
synced 2026-07-02 04:42:11 +08:00
[Streaming] fix streaming ci (#9675)
This commit is contained in:
+23
@@ -5,6 +5,8 @@ import io.ray.runtime.util.JniUtils;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -37,4 +39,25 @@ public class EnvUtil {
|
||||
JniUtils.loadLibrary("streaming_java");
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute an external command.
|
||||
*
|
||||
* @return Whether the command succeeded.
|
||||
*/
|
||||
public static boolean executeCommand(List<String> command, int waitTimeoutSeconds) {
|
||||
try {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command)
|
||||
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
||||
.redirectError(ProcessBuilder.Redirect.INHERIT);
|
||||
Process process = processBuilder.start();
|
||||
boolean exit = process.waitFor(waitTimeoutSeconds, TimeUnit.SECONDS);
|
||||
if (!exit) {
|
||||
process.destroyForcibly();
|
||||
}
|
||||
return process.exitValue() == 0;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error executing command " + String.join(" ", command), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
package io.ray.streaming.runtime.util;
|
||||
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import io.ray.api.id.UniqueId;
|
||||
import io.ray.streaming.runtime.core.resource.Container;
|
||||
import io.ray.streaming.runtime.core.resource.ContainerId;
|
||||
import java.io.BufferedInputStream;
|
||||
|
||||
+5
@@ -1,11 +1,14 @@
|
||||
package io.ray.streaming.runtime.demo;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.streaming.api.context.StreamingContext;
|
||||
import io.ray.streaming.api.function.impl.FilterFunction;
|
||||
import io.ray.streaming.api.function.impl.MapFunction;
|
||||
import io.ray.streaming.api.function.impl.SinkFunction;
|
||||
import io.ray.streaming.api.stream.DataStreamSource;
|
||||
import io.ray.streaming.runtime.util.EnvUtil;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
@@ -42,6 +45,8 @@ public class HybridStreamTest {
|
||||
@Test(timeOut = 60000)
|
||||
public void testHybridDataStream() throws Exception {
|
||||
Ray.shutdown();
|
||||
Preconditions.checkArgument(
|
||||
EnvUtil.executeCommand(ImmutableList.of("ray", "stop"), 5));
|
||||
String sinkFileName = "/tmp/testHybridDataStream.txt";
|
||||
Files.deleteIfExists(Paths.get(sinkFileName));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user