forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into plugin-aware-thread-context
- Loading branch information
Showing
141 changed files
with
4,626 additions
and
1,720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8218a00c07f9f66d5dc7ae2ba613da6890867497 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3eb54effe40946dfb06dc5cd6c7ce4116cd51ea4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
apply plugin: 'opensearch.yaml-rest-test' | ||
apply plugin: 'opensearch.internal-cluster-test' | ||
|
||
opensearchplugin { | ||
description 'OpenSearch Workload Management Plugin.' | ||
classname 'org.opensearch.plugin.wlm.WorkloadManagementPlugin' | ||
} | ||
|
||
dependencies { | ||
} |
64 changes: 64 additions & 0 deletions
64
...workload-management/src/main/java/org/opensearch/plugin/wlm/WorkloadManagementPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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 org.opensearch.plugin.wlm; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.opensearch.cluster.node.DiscoveryNodes; | ||
import org.opensearch.common.settings.ClusterSettings; | ||
import org.opensearch.common.settings.IndexScopedSettings; | ||
import org.opensearch.common.settings.Setting; | ||
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.TransportCreateQueryGroupAction; | ||
import org.opensearch.plugin.wlm.rest.RestCreateQueryGroupAction; | ||
import org.opensearch.plugin.wlm.service.QueryGroupPersistenceService; | ||
import org.opensearch.plugins.ActionPlugin; | ||
import org.opensearch.plugins.Plugin; | ||
import org.opensearch.rest.RestController; | ||
import org.opensearch.rest.RestHandler; | ||
|
||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Plugin class for WorkloadManagement | ||
*/ | ||
public class WorkloadManagementPlugin extends Plugin implements ActionPlugin { | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
public WorkloadManagementPlugin() {} | ||
|
||
@Override | ||
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() { | ||
return List.of(new ActionPlugin.ActionHandler<>(CreateQueryGroupAction.INSTANCE, TransportCreateQueryGroupAction.class)); | ||
} | ||
|
||
@Override | ||
public List<RestHandler> getRestHandlers( | ||
Settings settings, | ||
RestController restController, | ||
ClusterSettings clusterSettings, | ||
IndexScopedSettings indexScopedSettings, | ||
SettingsFilter settingsFilter, | ||
IndexNameExpressionResolver indexNameExpressionResolver, | ||
Supplier<DiscoveryNodes> nodesInCluster | ||
) { | ||
return List.of(new RestCreateQueryGroupAction()); | ||
} | ||
|
||
@Override | ||
public List<Setting<?>> getSettings() { | ||
return List.of(QueryGroupPersistenceService.MAX_QUERY_GROUP_COUNT); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...oad-management/src/main/java/org/opensearch/plugin/wlm/action/CreateQueryGroupAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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 org.opensearch.plugin.wlm.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
/** | ||
* Transport action to create QueryGroup | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class CreateQueryGroupAction extends ActionType<CreateQueryGroupResponse> { | ||
|
||
/** | ||
* An instance of CreateQueryGroupAction | ||
*/ | ||
public static final CreateQueryGroupAction INSTANCE = new CreateQueryGroupAction(); | ||
|
||
/** | ||
* Name for CreateQueryGroupAction | ||
*/ | ||
public static final String NAME = "cluster:admin/opensearch/wlm/query_group/_create"; | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
private CreateQueryGroupAction() { | ||
super(NAME, CreateQueryGroupResponse::new); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...ad-management/src/main/java/org/opensearch/plugin/wlm/action/CreateQueryGroupRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* 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 org.opensearch.plugin.wlm.action; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.cluster.metadata.QueryGroup; | ||
import org.opensearch.common.UUIDs; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.XContentParser; | ||
import org.joda.time.Instant; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A request for create QueryGroup | ||
* User input schema: | ||
* { | ||
* "name": "analytics", | ||
* "resiliency_mode": "enforced", | ||
* "resource_limits": { | ||
* "cpu" : 0.4, | ||
* "memory" : 0.2 | ||
* } | ||
* } | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class CreateQueryGroupRequest extends ActionRequest { | ||
private final QueryGroup queryGroup; | ||
|
||
/** | ||
* Constructor for CreateQueryGroupRequest | ||
* @param queryGroup - A {@link QueryGroup} object | ||
*/ | ||
public CreateQueryGroupRequest(QueryGroup queryGroup) { | ||
this.queryGroup = queryGroup; | ||
} | ||
|
||
/** | ||
* Constructor for CreateQueryGroupRequest | ||
* @param in - A {@link StreamInput} object | ||
*/ | ||
public CreateQueryGroupRequest(StreamInput in) throws IOException { | ||
super(in); | ||
queryGroup = new QueryGroup(in); | ||
} | ||
|
||
/** | ||
* Generate a CreateQueryGroupRequest from XContent | ||
* @param parser - A {@link XContentParser} object | ||
*/ | ||
public static CreateQueryGroupRequest fromXContent(XContentParser parser) throws IOException { | ||
QueryGroup.Builder builder = QueryGroup.Builder.fromXContent(parser); | ||
return new CreateQueryGroupRequest(builder._id(UUIDs.randomBase64UUID()).updatedAt(Instant.now().getMillis()).build()); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
queryGroup.writeTo(out); | ||
} | ||
|
||
/** | ||
* QueryGroup getter | ||
*/ | ||
public QueryGroup getQueryGroup() { | ||
return queryGroup; | ||
} | ||
} |
Oops, something went wrong.