Skip to content

Commit

Permalink
Add create rule api
Browse files Browse the repository at this point in the history
Signed-off-by: Ruirui Zhang <[email protected]>
  • Loading branch information
ruai0511 committed Feb 12, 2025
1 parent 34ef146 commit bab1e6e
Show file tree
Hide file tree
Showing 54 changed files with 1,405 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,39 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.settings.SettingsFilter;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.plugin.wlm.action.CreateQueryGroupAction;
import org.opensearch.plugin.wlm.action.DeleteQueryGroupAction;
import org.opensearch.plugin.wlm.action.GetQueryGroupAction;
import org.opensearch.plugin.wlm.action.TransportCreateQueryGroupAction;
import org.opensearch.plugin.wlm.action.TransportDeleteQueryGroupAction;
import org.opensearch.plugin.wlm.action.TransportGetQueryGroupAction;
import org.opensearch.plugin.wlm.action.TransportUpdateQueryGroupAction;
import org.opensearch.plugin.wlm.action.UpdateQueryGroupAction;
import org.opensearch.plugin.wlm.rest.RestCreateQueryGroupAction;
import org.opensearch.plugin.wlm.rest.RestDeleteQueryGroupAction;
import org.opensearch.plugin.wlm.rest.RestGetQueryGroupAction;
import org.opensearch.plugin.wlm.rest.RestUpdateQueryGroupAction;
import org.opensearch.plugin.wlm.service.QueryGroupPersistenceService;
import org.opensearch.indices.SystemIndexDescriptor;
import org.opensearch.plugin.wlm.querygroup.action.CreateQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.DeleteQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.GetQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.TransportCreateQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.TransportDeleteQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.TransportGetQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.TransportUpdateQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.UpdateQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.rest.RestCreateQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.rest.RestDeleteQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.rest.RestGetQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.rest.RestUpdateQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.service.QueryGroupPersistenceService;
import org.opensearch.plugin.wlm.rule.action.CreateRuleAction;
import org.opensearch.plugin.wlm.rule.action.TransportCreateRuleAction;
import org.opensearch.plugin.wlm.rule.rest.RestCreateRuleAction;
import org.opensearch.plugins.ActionPlugin;
import org.opensearch.plugins.Plugin;
import org.opensearch.plugins.SystemIndexPlugin;
import org.opensearch.rest.RestController;
import org.opensearch.rest.RestHandler;

import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;

import static org.opensearch.plugin.wlm.rule.service.RulePersistenceService.RULE_INDEX;

/**
* Plugin class for WorkloadManagement
*/
public class WorkloadManagementPlugin extends Plugin implements ActionPlugin {
public class WorkloadManagementPlugin extends Plugin implements ActionPlugin, SystemIndexPlugin {

/**
* Default constructor
Expand All @@ -56,10 +63,17 @@ public WorkloadManagementPlugin() {}
new ActionPlugin.ActionHandler<>(CreateQueryGroupAction.INSTANCE, TransportCreateQueryGroupAction.class),
new ActionPlugin.ActionHandler<>(GetQueryGroupAction.INSTANCE, TransportGetQueryGroupAction.class),
new ActionPlugin.ActionHandler<>(DeleteQueryGroupAction.INSTANCE, TransportDeleteQueryGroupAction.class),
new ActionPlugin.ActionHandler<>(UpdateQueryGroupAction.INSTANCE, TransportUpdateQueryGroupAction.class)
new ActionPlugin.ActionHandler<>(UpdateQueryGroupAction.INSTANCE, TransportUpdateQueryGroupAction.class),
new ActionPlugin.ActionHandler<>(CreateRuleAction.INSTANCE, TransportCreateRuleAction.class)
);
}

@Override
public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
List<SystemIndexDescriptor> descriptors = List.of(new SystemIndexDescriptor(RULE_INDEX, "System index used for storing rules"));
return descriptors;
}

@Override
public List<RestHandler> getRestHandlers(
Settings settings,
Expand All @@ -74,7 +88,8 @@ public List<RestHandler> getRestHandlers(
new RestCreateQueryGroupAction(),
new RestGetQueryGroupAction(),
new RestDeleteQueryGroupAction(),
new RestUpdateQueryGroupAction()
new RestUpdateQueryGroupAction(),
new RestCreateRuleAction()
);
}

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

import org.opensearch.common.inject.AbstractModule;
import org.opensearch.common.inject.Singleton;
import org.opensearch.plugin.wlm.service.QueryGroupPersistenceService;
import org.opensearch.plugin.wlm.querygroup.service.QueryGroupPersistenceService;

/**
* Guice Module to manage WorkloadManagement related objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.ActionType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.cluster.metadata.QueryGroup;
import org.opensearch.core.action.ActionResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.ActionType;
import org.opensearch.action.support.master.AcknowledgedResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.master.AcknowledgedRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.ActionType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.clustermanager.ClusterManagerNodeReadRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.cluster.metadata.QueryGroup;
import org.opensearch.core.action.ActionResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction;
Expand All @@ -17,7 +17,7 @@
import org.opensearch.common.inject.Inject;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.plugin.wlm.service.QueryGroupPersistenceService;
import org.opensearch.plugin.wlm.querygroup.service.QueryGroupPersistenceService;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction;
Expand All @@ -19,7 +19,7 @@
import org.opensearch.common.inject.Inject;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.plugin.wlm.service.QueryGroupPersistenceService;
import org.opensearch.plugin.wlm.querygroup.service.QueryGroupPersistenceService;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -23,7 +23,7 @@
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.plugin.wlm.service.QueryGroupPersistenceService;
import org.opensearch.plugin.wlm.querygroup.service.QueryGroupPersistenceService;
import org.opensearch.search.pipeline.SearchPipelineService;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction;
Expand All @@ -17,7 +17,7 @@
import org.opensearch.common.inject.Inject;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.plugin.wlm.service.QueryGroupPersistenceService;
import org.opensearch.plugin.wlm.querygroup.service.QueryGroupPersistenceService;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.ActionType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.action;
package org.opensearch.plugin.wlm.querygroup.action;

import org.opensearch.cluster.metadata.QueryGroup;
import org.opensearch.core.action.ActionResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/**
* Package for the action classes related to query groups in WorkloadManagementPlugin
*/
package org.opensearch.plugin.wlm.querygroup.action;
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.rest;
package org.opensearch.plugin.wlm.querygroup.rest;

import org.opensearch.client.node.NodeClient;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.plugin.wlm.action.CreateQueryGroupAction;
import org.opensearch.plugin.wlm.action.CreateQueryGroupRequest;
import org.opensearch.plugin.wlm.action.CreateQueryGroupResponse;
import org.opensearch.plugin.wlm.querygroup.action.CreateQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.CreateQueryGroupRequest;
import org.opensearch.plugin.wlm.querygroup.action.CreateQueryGroupResponse;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.BytesRestResponse;
import org.opensearch.rest.RestChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.rest;
package org.opensearch.plugin.wlm.querygroup.rest;

import org.opensearch.client.node.NodeClient;
import org.opensearch.plugin.wlm.action.DeleteQueryGroupAction;
import org.opensearch.plugin.wlm.action.DeleteQueryGroupRequest;
import org.opensearch.plugin.wlm.querygroup.action.DeleteQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.DeleteQueryGroupRequest;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.rest;
package org.opensearch.plugin.wlm.querygroup.rest;

import org.opensearch.client.node.NodeClient;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.plugin.wlm.action.GetQueryGroupAction;
import org.opensearch.plugin.wlm.action.GetQueryGroupRequest;
import org.opensearch.plugin.wlm.action.GetQueryGroupResponse;
import org.opensearch.plugin.wlm.querygroup.action.GetQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.GetQueryGroupRequest;
import org.opensearch.plugin.wlm.querygroup.action.GetQueryGroupResponse;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.BytesRestResponse;
import org.opensearch.rest.RestChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.rest;
package org.opensearch.plugin.wlm.querygroup.rest;

import org.opensearch.client.node.NodeClient;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.plugin.wlm.action.UpdateQueryGroupAction;
import org.opensearch.plugin.wlm.action.UpdateQueryGroupRequest;
import org.opensearch.plugin.wlm.action.UpdateQueryGroupResponse;
import org.opensearch.plugin.wlm.querygroup.action.UpdateQueryGroupAction;
import org.opensearch.plugin.wlm.querygroup.action.UpdateQueryGroupRequest;
import org.opensearch.plugin.wlm.querygroup.action.UpdateQueryGroupResponse;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.BytesRestResponse;
import org.opensearch.rest.RestChannel;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/**
* Package for the rest classes related to query groups in WorkloadManagementPlugin
*/
package org.opensearch.plugin.wlm.querygroup.rest;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.plugin.wlm.service;
package org.opensearch.plugin.wlm.querygroup.service;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -27,10 +27,10 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.plugin.wlm.action.CreateQueryGroupResponse;
import org.opensearch.plugin.wlm.action.DeleteQueryGroupRequest;
import org.opensearch.plugin.wlm.action.UpdateQueryGroupRequest;
import org.opensearch.plugin.wlm.action.UpdateQueryGroupResponse;
import org.opensearch.plugin.wlm.querygroup.action.CreateQueryGroupResponse;
import org.opensearch.plugin.wlm.querygroup.action.DeleteQueryGroupRequest;
import org.opensearch.plugin.wlm.querygroup.action.UpdateQueryGroupRequest;
import org.opensearch.plugin.wlm.querygroup.action.UpdateQueryGroupResponse;
import org.opensearch.wlm.MutableQueryGroupFragment;
import org.opensearch.wlm.ResourceType;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/**
* Package for the service classes related to query groups in WorkloadManagementPlugin
*/
package org.opensearch.plugin.wlm.querygroup.service;
Loading

0 comments on commit bab1e6e

Please sign in to comment.