From baede06eb1fd5db82e9a029a6216f4687433aeef Mon Sep 17 00:00:00 2001 From: jeremyhi Date: Mon, 8 Jan 2024 17:49:35 +0800 Subject: [PATCH] chore: shutdown on test --- .../src/main/java/io/greptime/StreamWritePOJOsQuickStart.java | 3 +++ .../src/main/java/io/greptime/StreamWriteQuickStart.java | 3 +++ .../src/main/java/io/greptime/WritePOJOsQuickStart.java | 3 +++ .../src/main/java/io/greptime/WriteQuickStart.java | 3 +++ ingester-protocol/src/main/java/io/greptime/Write.java | 2 +- ingester-protocol/src/main/java/io/greptime/WritePOJO.java | 2 +- .../src/test/java/io/greptime/WriteClientTest.java | 2 +- 7 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ingester-example/src/main/java/io/greptime/StreamWritePOJOsQuickStart.java b/ingester-example/src/main/java/io/greptime/StreamWritePOJOsQuickStart.java index 4412ee6..b0b9c6e 100644 --- a/ingester-example/src/main/java/io/greptime/StreamWritePOJOsQuickStart.java +++ b/ingester-example/src/main/java/io/greptime/StreamWritePOJOsQuickStart.java @@ -77,5 +77,8 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc WriteOk result = future.get(); LOG.info("Write result: {}", result); + + // Shutdown the client when application exits. + greptimeDB.shutdownGracefully(); } } diff --git a/ingester-example/src/main/java/io/greptime/StreamWriteQuickStart.java b/ingester-example/src/main/java/io/greptime/StreamWriteQuickStart.java index dd9b2b3..b7bfe19 100644 --- a/ingester-example/src/main/java/io/greptime/StreamWriteQuickStart.java +++ b/ingester-example/src/main/java/io/greptime/StreamWriteQuickStart.java @@ -98,5 +98,8 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc WriteOk result = future.get(); LOG.info("Write result: {}", result); + + // Shutdown the client when application exits. + greptimeDB.shutdownGracefully(); } } diff --git a/ingester-example/src/main/java/io/greptime/WritePOJOsQuickStart.java b/ingester-example/src/main/java/io/greptime/WritePOJOsQuickStart.java index 1ae200e..6b63e55 100644 --- a/ingester-example/src/main/java/io/greptime/WritePOJOsQuickStart.java +++ b/ingester-example/src/main/java/io/greptime/WritePOJOsQuickStart.java @@ -86,5 +86,8 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc } else { LOG.error("Failed to delete: {}", result.getErr()); } + + // Shutdown the client when application exits. + greptimeDB.shutdownGracefully(); } } diff --git a/ingester-example/src/main/java/io/greptime/WriteQuickStart.java b/ingester-example/src/main/java/io/greptime/WriteQuickStart.java index dc4d56f..e2be6ce 100644 --- a/ingester-example/src/main/java/io/greptime/WriteQuickStart.java +++ b/ingester-example/src/main/java/io/greptime/WriteQuickStart.java @@ -109,5 +109,8 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc } else { LOG.error("Failed to delete: {}", result.getErr()); } + + // Shutdown the client when application exits. + greptimeDB.shutdownGracefully(); } } diff --git a/ingester-protocol/src/main/java/io/greptime/Write.java b/ingester-protocol/src/main/java/io/greptime/Write.java index 3a18eec..bf058a4 100644 --- a/ingester-protocol/src/main/java/io/greptime/Write.java +++ b/ingester-protocol/src/main/java/io/greptime/Write.java @@ -35,7 +35,7 @@ public interface Write { * @see #write(Collection, WriteOp, Context) */ default CompletableFuture> write(Table... tables) { - return write(Arrays.asList(tables), WriteOp.Insert, Context.newDefault()); + return write(Arrays.asList(tables)); } /** diff --git a/ingester-protocol/src/main/java/io/greptime/WritePOJO.java b/ingester-protocol/src/main/java/io/greptime/WritePOJO.java index cf9e263..ef440cc 100644 --- a/ingester-protocol/src/main/java/io/greptime/WritePOJO.java +++ b/ingester-protocol/src/main/java/io/greptime/WritePOJO.java @@ -35,7 +35,7 @@ public interface WritePOJO { * @see #writePOJOs(Collection, WriteOp, Context) */ default CompletableFuture> writePOJOs(List... pojos) { - return writePOJOs(Arrays.asList(pojos), WriteOp.Insert, Context.newDefault()); + return writePOJOs(Arrays.asList(pojos)); } /** * @see #writePOJOs(Collection, WriteOp, Context) diff --git a/ingester-protocol/src/test/java/io/greptime/WriteClientTest.java b/ingester-protocol/src/test/java/io/greptime/WriteClientTest.java index 3f4b3da..09eaa3b 100644 --- a/ingester-protocol/src/test/java/io/greptime/WriteClientTest.java +++ b/ingester-protocol/src/test/java/io/greptime/WriteClientTest.java @@ -105,7 +105,7 @@ public void testWriteSuccess() throws ExecutionException, InterruptedException { Mockito.when(this.routerClient.invoke(Mockito.eq(addr), Mockito.any(), Mockito.any())) // .thenReturn(Util.completedCf(response)); - Result res = this.writeClient.write(Collections.singleton(table)).get(); + Result res = this.writeClient.write(table).get(); Assert.assertTrue(res.isOk()); Assert.assertEquals(3, res.getOk().getSuccess());