Skip to content

Commit

Permalink
Removed ExtensionActionListener and changed exception types
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
  • Loading branch information
ryanbogan committed Dec 21, 2022
1 parent b349762 commit d80cfd4
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private Setting<?> createSetting(
return Setting.versionSetting(key, (Version) defaultValue, propertyArray);
default:
// This Should Never Happen (TM)
throw new UnsupportedOperationException("A SettingType has been added to the enum and not handled here.");
throw new IllegalArgumentException("A SettingType has been added to the enum and not handled here.");
}
}

Expand Down Expand Up @@ -236,7 +236,7 @@ private void writeDefaultValue(StreamOutput out, Object defaultValue) throws IOE
break;
default:
// This Should Never Happen (TM)
throw new UnsupportedOperationException("A SettingType has been added to the enum and not handled here.");
throw new IllegalArgumentException("A SettingType has been added to the enum and not handled here.");
}
}

Expand Down Expand Up @@ -264,7 +264,7 @@ private Object readDefaultValue(StreamInput in) throws IOException {
return Version.readVersion(in);
default:
// This Should Never Happen (TM)
throw new UnsupportedOperationException("A SettingType has been added to the enum and not handled here.");
throw new IllegalArgumentException("A SettingType has been added to the enum and not handled here.");
}
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public class ExtensionsManager {
public static final String REQUEST_EXTENSION_REGISTER_REST_ACTIONS = "internal:discovery/registerrestactions";
public static final String REQUEST_EXTENSION_REGISTER_TRANSPORT_ACTIONS = "internal:discovery/registertransportactions";
public static final String REQUEST_OPENSEARCH_PARSE_NAMED_WRITEABLE = "internal:discovery/parsenamedwriteable";
public static final String REQUEST_EXTENSION_ACTION_LISTENER_ON_FAILURE = "internal:extensions/actionlisteneronfailure";
public static final String REQUEST_REST_EXECUTE_ON_EXTENSION_ACTION = "internal:extensions/restexecuteonextensiontaction";

private static final Logger logger = LogManager.getLogger(ExtensionsManager.class);
Expand All @@ -94,7 +93,6 @@ public static enum RequestType {
REQUEST_EXTENSION_CLUSTER_STATE,
REQUEST_EXTENSION_LOCAL_NODE,
REQUEST_EXTENSION_CLUSTER_SETTINGS,
REQUEST_EXTENSION_ACTION_LISTENER_ON_FAILURE,
REQUEST_EXTENSION_REGISTER_REST_ACTIONS,
REQUEST_EXTENSION_REGISTER_SETTINGS,
REQUEST_EXTENSION_ENVIRONMENT_SETTINGS,
Expand All @@ -120,8 +118,6 @@ public static enum OpenSearchRequestType {
private CustomSettingsRequestHandler customSettingsRequestHandler;
private TransportService transportService;
private ClusterService clusterService;
private ExtensionActionListener listener;
private ExtensionActionListenerHandler listenerHandler;
private Settings environmentSettings;
private AddSettingsUpdateConsumerRequestHandler addSettingsUpdateConsumerRequestHandler;

Expand All @@ -143,7 +139,6 @@ public ExtensionsManager(Settings settings, Path extensionsPath) throws IOExcept
this.extensions = new ArrayList<DiscoveryExtensionNode>();
this.extensionIdMap = new HashMap<String, DiscoveryExtensionNode>();
this.clusterService = null;
this.listener = new ExtensionActionListener();

/*
* Now Discover extensions
Expand All @@ -170,7 +165,6 @@ public void initializeServicesAndRestHandler(
Settings initialEnvironmentSettings
) {
this.restActionsRequestHandler = new RestActionsRequestHandler(restController, extensionIdMap, transportService);
this.listenerHandler = new ExtensionActionListenerHandler(listener);
this.customSettingsRequestHandler = new CustomSettingsRequestHandler(settingsModule);
this.transportService = transportService;
this.clusterService = clusterService;
Expand Down Expand Up @@ -224,14 +218,6 @@ private void registerRequestHandler() {
ExtensionRequest::new,
((request, channel, task) -> channel.sendResponse(handleExtensionRequest(request)))
);
transportService.registerRequestHandler(
REQUEST_EXTENSION_ACTION_LISTENER_ON_FAILURE,
ThreadPool.Names.GENERIC,
false,
false,
ExtensionActionListenerOnFailureRequest::new,
((request, channel, task) -> channel.sendResponse(listenerHandler.handleExtensionActionListenerOnFailureRequest(request)))
);
transportService.registerRequestHandler(
REQUEST_EXTENSION_ENVIRONMENT_SETTINGS,
ThreadPool.Names.GENERIC,
Expand Down Expand Up @@ -633,14 +619,6 @@ public static String getRequestExtensionRegisterTransportActions() {
return REQUEST_EXTENSION_REGISTER_TRANSPORT_ACTIONS;
}

public static String getRequestExtensionActionListenerOnFailure() {
return REQUEST_EXTENSION_ACTION_LISTENER_ON_FAILURE;
}

public ExtensionActionListener getListener() {
return listener;
}

public static String getRequestExtensionRegisterCustomSettings() {
return REQUEST_EXTENSION_REGISTER_CUSTOM_SETTINGS;
}
Expand Down Expand Up @@ -675,18 +653,6 @@ public void setAddSettingsUpdateConsumerRequestHandler(
this.addSettingsUpdateConsumerRequestHandler = addSettingsUpdateConsumerRequestHandler;
}

public void setListener(ExtensionActionListener listener) {
this.listener = listener;
}

public ExtensionActionListenerHandler getListenerHandler() {
return listenerHandler;
}

public void setListenerHandler(ExtensionActionListenerHandler listenerHandler) {
this.listenerHandler = listenerHandler;
}

public Settings getEnvironmentSettings() {
return environmentSettings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,23 +467,6 @@ public void testHandleExtensionRequest() throws Exception {
assertEquals("Handler not present for the provided request", exception.getMessage());
}

public void testHandleActionListenerOnFailureRequest() throws Exception {

Files.write(extensionDir.resolve("extensions.yml"), extensionsYmlLines, StandardCharsets.UTF_8);

ExtensionsManager extensionsManager = new ExtensionsManager(settings, extensionDir);

extensionsManager.initializeServicesAndRestHandler(restController, settingsModule, transportService, clusterService, settings);

ExtensionActionListenerOnFailureRequest listenerFailureRequest = new ExtensionActionListenerOnFailureRequest("Test failure");

assertEquals(
AcknowledgedResponse.class,
extensionsManager.getListenerHandler().handleExtensionActionListenerOnFailureRequest(listenerFailureRequest).getClass()
);
assertEquals("Test failure", extensionsManager.getListener().getExceptionList().get(0).getMessage());
}

public void testEnvironmentSettingsResponse() throws Exception {

// Test EnvironmentSettingsResponse arg constructor
Expand Down Expand Up @@ -661,7 +644,7 @@ public void testRegisterHandler() throws Exception {
)
);
extensionsManager.initializeServicesAndRestHandler(restController, settingsModule, mockTransportService, clusterService, settings);
verify(mockTransportService, times(9)).registerRequestHandler(anyString(), anyString(), anyBoolean(), anyBoolean(), any(), any());
verify(mockTransportService, times(8)).registerRequestHandler(anyString(), anyString(), anyBoolean(), anyBoolean(), any(), any());

}

Expand Down

0 comments on commit d80cfd4

Please sign in to comment.