From 20d0d58af884963213e19696eb1708de4eb458ec Mon Sep 17 00:00:00 2001 From: Owais Kazi Date: Tue, 12 Jul 2022 13:10:48 -0700 Subject: [PATCH] Addressed PR Comments Signed-off-by: Owais Kazi --- .../java/org/opensearch/sdk/ActionListener.java | 3 +++ .../sdk/ClusterSettingsResponseHandler.java | 3 +++ .../sdk/ClusterStateResponseHandler.java | 3 +++ .../org/opensearch/sdk/ExtensionSettings.java | 3 +++ .../org/opensearch/sdk/ExtensionsRunner.java | 5 ++++- .../sdk/LocalNodeResponseHandler.java | 3 +++ .../opensearch/sdk/TestExtensionSettings.java | 8 ++++---- .../opensearch/sdk/TestExtensionsRunner.java | 17 +++++++++-------- 8 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/opensearch/sdk/ActionListener.java b/src/main/java/org/opensearch/sdk/ActionListener.java index 993f701ef..cb991543b 100644 --- a/src/main/java/org/opensearch/sdk/ActionListener.java +++ b/src/main/java/org/opensearch/sdk/ActionListener.java @@ -21,6 +21,9 @@ import java.net.Socket; import java.net.UnknownHostException; +/** + * The class for Action Listener to run SDK + */ public class ActionListener { @SuppressForbidden(reason = "need local ephemeral port") diff --git a/src/main/java/org/opensearch/sdk/ClusterSettingsResponseHandler.java b/src/main/java/org/opensearch/sdk/ClusterSettingsResponseHandler.java index 79c0efdb5..be6bf7be3 100644 --- a/src/main/java/org/opensearch/sdk/ClusterSettingsResponseHandler.java +++ b/src/main/java/org/opensearch/sdk/ClusterSettingsResponseHandler.java @@ -10,6 +10,9 @@ import java.io.IOException; +/** + * Transport Response Handler class for Cluster Settings API + */ public class ClusterSettingsResponseHandler implements TransportResponseHandler { private static final Logger logger = LogManager.getLogger(ClusterSettingsResponseHandler.class); diff --git a/src/main/java/org/opensearch/sdk/ClusterStateResponseHandler.java b/src/main/java/org/opensearch/sdk/ClusterStateResponseHandler.java index b6b5e9b30..41af2bd86 100644 --- a/src/main/java/org/opensearch/sdk/ClusterStateResponseHandler.java +++ b/src/main/java/org/opensearch/sdk/ClusterStateResponseHandler.java @@ -10,6 +10,9 @@ import java.io.IOException; +/** + * Transport Response Handler class for Cluster State API + */ public class ClusterStateResponseHandler implements TransportResponseHandler { private static final Logger logger = LogManager.getLogger(ClusterStateResponseHandler.class); diff --git a/src/main/java/org/opensearch/sdk/ExtensionSettings.java b/src/main/java/org/opensearch/sdk/ExtensionSettings.java index 88f5ffe64..56afb979c 100644 --- a/src/main/java/org/opensearch/sdk/ExtensionSettings.java +++ b/src/main/java/org/opensearch/sdk/ExtensionSettings.java @@ -11,6 +11,9 @@ package org.opensearch.sdk; +/** + * The class to read extension properties + */ public class ExtensionSettings { private String extensionname; diff --git a/src/main/java/org/opensearch/sdk/ExtensionsRunner.java b/src/main/java/org/opensearch/sdk/ExtensionsRunner.java index 4fe21f74a..e632b5d54 100644 --- a/src/main/java/org/opensearch/sdk/ExtensionsRunner.java +++ b/src/main/java/org/opensearch/sdk/ExtensionsRunner.java @@ -55,6 +55,9 @@ import static java.util.Collections.emptySet; import static org.opensearch.common.UUIDs.randomBase64UUID; +/** + * The main class for OpenSearch SDK + */ public class ExtensionsRunner { private ExtensionSettings extensionSettings = readExtensionSettings(); private DiscoveryNode opensearchNode; @@ -144,7 +147,7 @@ public Netty4Transport getNetty4Transport(Settings settings, ThreadPool threadPo return transport; } - public TransportService createTransportService(Settings settings) throws IOException { + public TransportService createTransportService(Settings settings){ ThreadPool threadPool = new ThreadPool(settings); diff --git a/src/main/java/org/opensearch/sdk/LocalNodeResponseHandler.java b/src/main/java/org/opensearch/sdk/LocalNodeResponseHandler.java index fad220411..04ee79b3d 100644 --- a/src/main/java/org/opensearch/sdk/LocalNodeResponseHandler.java +++ b/src/main/java/org/opensearch/sdk/LocalNodeResponseHandler.java @@ -10,6 +10,9 @@ import java.io.IOException; +/** + * Transport Response Handler class for Local Node API + */ public class LocalNodeResponseHandler implements TransportResponseHandler { private static final Logger logger = LogManager.getLogger(LocalNodeResponseHandler.class); diff --git a/src/test/java/org/opensearch/sdk/TestExtensionSettings.java b/src/test/java/org/opensearch/sdk/TestExtensionSettings.java index dfb73a86f..a0c4fdf1e 100644 --- a/src/test/java/org/opensearch/sdk/TestExtensionSettings.java +++ b/src/test/java/org/opensearch/sdk/TestExtensionSettings.java @@ -1,15 +1,15 @@ package org.opensearch.sdk; -import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.opensearch.test.OpenSearchTestCase; public class TestExtensionSettings extends OpenSearchTestCase { - private ExtensionSettings extensionSettings; + private static ExtensionSettings extensionSettings; - @BeforeEach - public void setUp() { + @BeforeAll + public static void setup() { extensionSettings = new ExtensionSettings(); } diff --git a/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java b/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java index ac79c9611..e48b578cc 100644 --- a/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java +++ b/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java @@ -22,6 +22,7 @@ import static org.mockito.Mockito.mock; import java.net.InetAddress; +import java.net.UnknownHostException; import java.util.Collections; import org.junit.jupiter.api.BeforeEach; @@ -61,13 +62,13 @@ public void setUp() throws Exception { // test ExtensionsRunner getTransportService return type is transport service @Test - public void testGetTransportService() throws Exception { + public void testGetTransportService() { assert (extensionsRunner.createTransportService(settings) instanceof TransportService); } // test manager method invokes start on transport service @Test - public void testTransportServiceStarted() throws Exception { + public void testTransportServiceStarted() { // verify mocked object interaction in manager method extensionsRunner.startTransportService(transportService); @@ -76,7 +77,7 @@ public void testTransportServiceStarted() throws Exception { // test manager method invokes accept incoming requests on transport service @Test - public void testTransportServiceAcceptedIncomingRequests() throws Exception { + public void testTransportServiceAcceptedIncomingRequests() { // verify mocked object interaction in manager method extensionsRunner.startTransportService(transportService); @@ -84,14 +85,14 @@ public void testTransportServiceAcceptedIncomingRequests() throws Exception { } @Test - public void testRegisterRequestHandler() throws Exception { + public void testRegisterRequestHandler() { extensionsRunner.startTransportService(transportService); verify(transportService, times(3)).registerRequestHandler(anyString(), anyString(), anyBoolean(), anyBoolean(), any(), any()); } @Test - public void testHandlePluginsRequest() throws Exception { + public void testHandlePluginsRequest() throws UnknownHostException { DiscoveryNode sourceNode = new DiscoveryNode( "test_node", new TransportAddress(InetAddress.getByName("localhost"), 9876), @@ -108,7 +109,7 @@ public void testHandlePluginsRequest() throws Exception { } @Test - public void testClusterStateRequest() throws Exception { + public void testClusterStateRequest() { extensionsRunner.sendClusterStateRequest(transportService); @@ -116,7 +117,7 @@ public void testClusterStateRequest() throws Exception { } @Test - public void testClusterSettingRequest() throws Exception { + public void testClusterSettingRequest() { extensionsRunner.sendClusterSettingRequest(transportService); @@ -124,7 +125,7 @@ public void testClusterSettingRequest() throws Exception { } @Test - public void testLocalNodeRequest() throws Exception { + public void testLocalNodeRequest() { extensionsRunner.sendLocalNodeRequest(transportService);