Skip to content

Commit

Permalink
extract printProcessStatus function as util
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole00 committed Jul 15, 2021
1 parent 54f2739 commit 78d75de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.vesoft.nebula.client.graph.data.HostAddress;
import com.vesoft.nebula.client.graph.data.ResultSet;
import com.vesoft.nebula.client.graph.exception.IOErrorException;
import com.vesoft.nebula.client.util.ProcessUtil;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
Expand All @@ -24,21 +25,6 @@
import org.junit.Test;

public class TestSession {
private static void printProcessStatus(String cmd, Process p) {
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(p.getInputStream()));

String line;
System.out.print(cmd + " output: ");
while ((line = reader.readLine()) != null) {
System.out.print(line);
}
System.out.print("\n");
} catch (Exception e) {
e.printStackTrace();
}
}

@Test
public void testMultiThreadUseTheSameSession() {
Expand Down Expand Up @@ -121,7 +107,7 @@ public void testReconnectWithMultiServices() {
String cmd = "docker restart nebula-docker-compose_graphd2_1";
Process p = runtime.exec(cmd);
p.waitFor(10, TimeUnit.SECONDS);
printProcessStatus(cmd, p);
ProcessUtil.printProcessStatus(cmd, p);

NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig();
nebulaPoolConfig.setMaxConnSize(6);
Expand All @@ -145,11 +131,11 @@ public void testReconnectWithMultiServices() {
cmd = "docker stop nebula-docker-compose_graphd0_1";
p = runtime.exec(cmd);
p.waitFor(5, TimeUnit.SECONDS);
printProcessStatus(cmd, p);
ProcessUtil.printProcessStatus(cmd, p);
cmd = "docker stop nebula-docker-compose_graphd1_1";
p = runtime.exec(cmd);
p.waitFor(5, TimeUnit.SECONDS);
printProcessStatus(cmd, p);
ProcessUtil.printProcessStatus(cmd, p);
}
try {
// the session update later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
* This source code is licensed under Apache 2.0 License,
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

package com.vesoft.nebula.client.util;public class ProcessUtil {

package com.vesoft.nebula.client.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class ProcessUtil {
public static void printProcessStatus(String cmd, Process p) {
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(p.getInputStream()));

String line;
System.out.print(cmd + " output: ");
while ((line = reader.readLine()) != null) {
System.out.print(line);
}
System.out.print("\n");
} catch (Exception e) {
e.printStackTrace();
}
}
}

0 comments on commit 78d75de

Please sign in to comment.