From 703480fd7a4bb84c9ec508b96c35832f8392838d Mon Sep 17 00:00:00 2001 From: "Doroszlai, Attila" Date: Thu, 18 Jan 2024 00:39:10 +0100 Subject: [PATCH] RATIS-2006. Fix DM_EXIT in filestore Client --- ratis-examples/pom.xml | 7 ------- .../org/apache/ratis/examples/filestore/cli/Client.java | 5 +---- .../apache/ratis/examples/filestore/cli/DataStream.java | 5 +++-- .../org/apache/ratis/examples/filestore/cli/LoadGen.java | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/ratis-examples/pom.xml b/ratis-examples/pom.xml index 5e899f8fff..4078f6260f 100644 --- a/ratis-examples/pom.xml +++ b/ratis-examples/pom.xml @@ -122,13 +122,6 @@ junit test - - - com.github.spotbugs - spotbugs-annotations - provided - true - diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Client.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Client.java index 086b791e49..1856fc9b5d 100644 --- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Client.java +++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Client.java @@ -18,7 +18,6 @@ package org.apache.ratis.examples.filestore.cli; import com.beust.jcommander.Parameter; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.ratis.RaftConfigKeys; import org.apache.ratis.client.RaftClient; import org.apache.ratis.client.RaftClientConfigKeys; @@ -143,12 +142,10 @@ public List getClients(RaftProperties raftProperties) { } - @SuppressFBWarnings("DM_EXIT") - protected void stop(List clients) throws IOException { + protected void close(List clients) throws IOException { for (FileStoreClient client : clients) { client.close(); } - System.exit(0); } public String getPath(String fileName) { diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/DataStream.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/DataStream.java index 4e4b4dbc64..b15b860570 100644 --- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/DataStream.java +++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/DataStream.java @@ -116,7 +116,8 @@ private boolean checkParam() { @Override protected void operation(List clients) throws IOException, ExecutionException, InterruptedException { if (!checkParam()) { - stop(clients); + close(clients); + return; } final ExecutorService executor = Executors.newFixedThreadPool(getNumThread()); @@ -136,7 +137,7 @@ protected void operation(List clients) throws IOException, Exec System.out.println("Total data written: " + totalWrittenBytes + " bytes"); System.out.println("Total time taken: " + (endTime - startTime) + " millis"); - stop(clients); + close(clients); } private Map>>> streamWrite( diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/LoadGen.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/LoadGen.java index 8225df9eef..42ffac4e1c 100644 --- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/LoadGen.java +++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/LoadGen.java @@ -64,7 +64,7 @@ protected void operation(List clients) throws IOException, Exec System.out.println("Total data written: " + totalWrittenBytes + " bytes"); System.out.println("Total time taken: " + (endTime - startTime) + " millis"); - stop(clients); + close(clients); } long write(FileChannel in, long offset, FileStoreClient fileStoreClient, String path,