Skip to content

Commit

Permalink
Removed setters to avoid accessing extension attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Owais Kazi <[email protected]>
  • Loading branch information
owaiskazi19 committed Jul 13, 2022
1 parent 94f720e commit 77f7a50
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 34 deletions.
3 changes: 0 additions & 3 deletions src/main/java/org/opensearch/sdk/ActionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

import java.io.IOException;

/**
* Transport Response Handler class for Cluster Settings API
*/
public class ClusterSettingsResponseHandler implements TransportResponseHandler<ClusterSettingsResponse> {
private static final Logger logger = LogManager.getLogger(ClusterSettingsResponseHandler.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

import java.io.IOException;

/**
* Transport Response Handler class for Cluster State API
*/
public class ClusterStateResponseHandler implements TransportResponseHandler<ClusterStateResponse> {
private static final Logger logger = LogManager.getLogger(ClusterStateResponseHandler.class);

Expand Down
23 changes: 8 additions & 15 deletions src/main/java/org/opensearch/sdk/ExtensionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

package org.opensearch.sdk;

/**
* The class to read extension properties
*/
public class ExtensionSettings {

private String extensionname;
Expand All @@ -22,30 +19,26 @@ public class ExtensionSettings {
// Change the location to extension.yml file of the extension
public static final String EXTENSION_DESCRIPTOR = "src/test/resources/extension.yml";

public String getExtensionname() {
return extensionname;
public ExtensionSettings(String extensionname, String hostaddress, String hostport) {
this.extensionname = extensionname;
this.hostaddress = hostaddress;
this.hostport = hostport;
}

public void setExtensionname(String extensionname) {
this.extensionname = extensionname;
public ExtensionSettings() {}

public String getExtensionname() {
return extensionname;
}

public String getHostaddress() {
return hostaddress;
}

public void setHostaddress(String hostaddress) {
this.hostaddress = hostaddress;
}

public String getHostport() {
return hostport;
}

public void setHostport(String hostport) {
this.hostport = hostport;
}

@Override
public String toString() {
return "\nnodename: " + extensionname + "\nhostaddress: " + hostaddress + "\nhostPort: " + hostport + "\n";
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/opensearch/sdk/ExtensionsRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

import java.io.IOException;

/**
* Transport Response Handler class for Local Node API
*/
public class LocalNodeResponseHandler implements TransportResponseHandler<LocalNodeResponse> {
private static final Logger logger = LogManager.getLogger(LocalNodeResponseHandler.class);

Expand Down
5 changes: 1 addition & 4 deletions src/test/java/org/opensearch/sdk/TestExtensionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@ public class TestExtensionSettings extends OpenSearchTestCase {

@BeforeEach
public void setUp() {
extensionSettings = new ExtensionSettings();
extensionSettings = new ExtensionSettings("test-extension", "127.0.0.1", "1234");
}

@Test
public void testExtensionName() {
extensionSettings.setExtensionname("test-extension");
assertEquals(extensionSettings.getExtensionname(), "test-extension");
}

@Test
public void testHostAddress() {
extensionSettings.setHostaddress("127.0.0.1");
assertEquals(extensionSettings.getHostaddress(), "127.0.0.1");
}

@Test
public void testHostPort() {
extensionSettings.setHostport("1234");
assertEquals(extensionSettings.getHostport(), "1234");
}
}

0 comments on commit 77f7a50

Please sign in to comment.