|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * |
| 4 | + * The OpenSearch Contributors require contributions made to |
| 5 | + * this file be licensed under the Apache-2.0 license or a |
| 6 | + * compatible open source license. |
| 7 | + */ |
| 8 | + |
| 9 | +package org.opensearch.plugin.wlm; |
| 10 | + |
| 11 | +import org.opensearch.action.ActionRequest; |
| 12 | +import org.opensearch.cluster.metadata.IndexNameExpressionResolver; |
| 13 | +import org.opensearch.cluster.node.DiscoveryNodes; |
| 14 | +import org.opensearch.common.inject.Module; |
| 15 | +import org.opensearch.common.settings.ClusterSettings; |
| 16 | +import org.opensearch.common.settings.IndexScopedSettings; |
| 17 | +import org.opensearch.common.settings.Setting; |
| 18 | +import org.opensearch.common.settings.Settings; |
| 19 | +import org.opensearch.common.settings.SettingsFilter; |
| 20 | +import org.opensearch.core.action.ActionResponse; |
| 21 | +import org.opensearch.plugin.wlm.action.CreateQueryGroupAction; |
| 22 | +import org.opensearch.plugin.wlm.action.DeleteQueryGroupAction; |
| 23 | +import org.opensearch.plugin.wlm.action.GetQueryGroupAction; |
| 24 | +import org.opensearch.plugin.wlm.action.TransportCreateQueryGroupAction; |
| 25 | +import org.opensearch.plugin.wlm.action.TransportDeleteQueryGroupAction; |
| 26 | +import org.opensearch.plugin.wlm.action.TransportGetQueryGroupAction; |
| 27 | +import org.opensearch.plugin.wlm.action.TransportUpdateQueryGroupAction; |
| 28 | +import org.opensearch.plugin.wlm.action.UpdateQueryGroupAction; |
| 29 | +import org.opensearch.plugin.wlm.rest.RestCreateQueryGroupAction; |
| 30 | +import org.opensearch.plugin.wlm.rest.RestDeleteQueryGroupAction; |
| 31 | +import org.opensearch.plugin.wlm.rest.RestGetQueryGroupAction; |
| 32 | +import org.opensearch.plugin.wlm.rest.RestUpdateQueryGroupAction; |
| 33 | +import org.opensearch.plugin.wlm.service.QueryGroupPersistenceService; |
| 34 | +import org.opensearch.plugins.ActionPlugin; |
| 35 | +import org.opensearch.plugins.Plugin; |
| 36 | +import org.opensearch.rest.RestController; |
| 37 | +import org.opensearch.rest.RestHandler; |
| 38 | + |
| 39 | +import java.util.Collection; |
| 40 | +import java.util.List; |
| 41 | +import java.util.function.Supplier; |
| 42 | + |
| 43 | +/** |
| 44 | + * Plugin class for WorkloadManagement |
| 45 | + */ |
| 46 | +public class WorkloadManagementPlugin extends Plugin implements ActionPlugin { |
| 47 | + |
| 48 | + /** |
| 49 | + * Default constructor |
| 50 | + */ |
| 51 | + public WorkloadManagementPlugin() {} |
| 52 | + |
| 53 | + @Override |
| 54 | + public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() { |
| 55 | + return List.of( |
| 56 | + new ActionPlugin.ActionHandler<>(CreateQueryGroupAction.INSTANCE, TransportCreateQueryGroupAction.class), |
| 57 | + new ActionPlugin.ActionHandler<>(GetQueryGroupAction.INSTANCE, TransportGetQueryGroupAction.class), |
| 58 | + new ActionPlugin.ActionHandler<>(DeleteQueryGroupAction.INSTANCE, TransportDeleteQueryGroupAction.class), |
| 59 | + new ActionPlugin.ActionHandler<>(UpdateQueryGroupAction.INSTANCE, TransportUpdateQueryGroupAction.class) |
| 60 | + ); |
| 61 | + } |
| 62 | + |
| 63 | + @Override |
| 64 | + public List<RestHandler> getRestHandlers( |
| 65 | + Settings settings, |
| 66 | + RestController restController, |
| 67 | + ClusterSettings clusterSettings, |
| 68 | + IndexScopedSettings indexScopedSettings, |
| 69 | + SettingsFilter settingsFilter, |
| 70 | + IndexNameExpressionResolver indexNameExpressionResolver, |
| 71 | + Supplier<DiscoveryNodes> nodesInCluster |
| 72 | + ) { |
| 73 | + return List.of( |
| 74 | + new RestCreateQueryGroupAction(), |
| 75 | + new RestGetQueryGroupAction(), |
| 76 | + new RestDeleteQueryGroupAction(), |
| 77 | + new RestUpdateQueryGroupAction() |
| 78 | + ); |
| 79 | + } |
| 80 | + |
| 81 | + @Override |
| 82 | + public List<Setting<?>> getSettings() { |
| 83 | + return List.of(QueryGroupPersistenceService.MAX_QUERY_GROUP_COUNT); |
| 84 | + } |
| 85 | + |
| 86 | + @Override |
| 87 | + public Collection<Module> createGuiceModules() { |
| 88 | + return List.of(new WorkloadManagementPluginModule()); |
| 89 | + } |
| 90 | +} |
0 commit comments