-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/2.x' into 2.x
Signed-off-by: Marc Handalian <marc.handalian@gmail.com>
- Loading branch information
Showing
29 changed files
with
1,326 additions
and
216 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
51 changes: 51 additions & 0 deletions
51
...ement/src/main/java/org/opensearch/plugin/wlm/action/TransportUpdateQueryGroupAction.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,51 @@ | ||
/* | ||
* 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.support.ActionFilters; | ||
import org.opensearch.action.support.HandledTransportAction; | ||
import org.opensearch.common.inject.Inject; | ||
import org.opensearch.core.action.ActionListener; | ||
import org.opensearch.plugin.wlm.service.QueryGroupPersistenceService; | ||
import org.opensearch.tasks.Task; | ||
import org.opensearch.transport.TransportService; | ||
|
||
/** | ||
* Transport action to update QueryGroup | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class TransportUpdateQueryGroupAction extends HandledTransportAction<UpdateQueryGroupRequest, UpdateQueryGroupResponse> { | ||
|
||
private final QueryGroupPersistenceService queryGroupPersistenceService; | ||
|
||
/** | ||
* Constructor for TransportUpdateQueryGroupAction | ||
* | ||
* @param actionName - action name | ||
* @param transportService - a {@link TransportService} object | ||
* @param actionFilters - a {@link ActionFilters} object | ||
* @param queryGroupPersistenceService - a {@link QueryGroupPersistenceService} object | ||
*/ | ||
@Inject | ||
public TransportUpdateQueryGroupAction( | ||
String actionName, | ||
TransportService transportService, | ||
ActionFilters actionFilters, | ||
QueryGroupPersistenceService queryGroupPersistenceService | ||
) { | ||
super(UpdateQueryGroupAction.NAME, transportService, actionFilters, UpdateQueryGroupRequest::new); | ||
this.queryGroupPersistenceService = queryGroupPersistenceService; | ||
} | ||
|
||
@Override | ||
protected void doExecute(Task task, UpdateQueryGroupRequest request, ActionListener<UpdateQueryGroupResponse> listener) { | ||
queryGroupPersistenceService.updateInClusterStateMetadata(request, listener); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...oad-management/src/main/java/org/opensearch/plugin/wlm/action/UpdateQueryGroupAction.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 update QueryGroup | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class UpdateQueryGroupAction extends ActionType<UpdateQueryGroupResponse> { | ||
|
||
/** | ||
* An instance of UpdateQueryGroupAction | ||
*/ | ||
public static final UpdateQueryGroupAction INSTANCE = new UpdateQueryGroupAction(); | ||
|
||
/** | ||
* Name for UpdateQueryGroupAction | ||
*/ | ||
public static final String NAME = "cluster:admin/opensearch/wlm/query_group/_update"; | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
private UpdateQueryGroupAction() { | ||
super(NAME, UpdateQueryGroupResponse::new); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...ad-management/src/main/java/org/opensearch/plugin/wlm/action/UpdateQueryGroupRequest.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,83 @@ | ||
/* | ||
* 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.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.XContentParser; | ||
import org.opensearch.wlm.MutableQueryGroupFragment; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A request for update QueryGroup | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class UpdateQueryGroupRequest extends ActionRequest { | ||
private final String name; | ||
private final MutableQueryGroupFragment mutableQueryGroupFragment; | ||
|
||
/** | ||
* Constructor for UpdateQueryGroupRequest | ||
* @param name - QueryGroup name for UpdateQueryGroupRequest | ||
* @param mutableQueryGroupFragment - MutableQueryGroupFragment for UpdateQueryGroupRequest | ||
*/ | ||
UpdateQueryGroupRequest(String name, MutableQueryGroupFragment mutableQueryGroupFragment) { | ||
this.name = name; | ||
this.mutableQueryGroupFragment = mutableQueryGroupFragment; | ||
} | ||
|
||
/** | ||
* Constructor for UpdateQueryGroupRequest | ||
* @param in - A {@link StreamInput} object | ||
*/ | ||
UpdateQueryGroupRequest(StreamInput in) throws IOException { | ||
this(in.readString(), new MutableQueryGroupFragment(in)); | ||
} | ||
|
||
/** | ||
* Generate a UpdateQueryGroupRequest from XContent | ||
* @param parser - A {@link XContentParser} object | ||
* @param name - name of the QueryGroup to be updated | ||
*/ | ||
public static UpdateQueryGroupRequest fromXContent(XContentParser parser, String name) throws IOException { | ||
QueryGroup.Builder builder = QueryGroup.Builder.fromXContent(parser); | ||
return new UpdateQueryGroupRequest(name, builder.getMutableQueryGroupFragment()); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
QueryGroup.validateName(name); | ||
return null; | ||
} | ||
|
||
/** | ||
* name getter | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* mutableQueryGroupFragment getter | ||
*/ | ||
public MutableQueryGroupFragment getmMutableQueryGroupFragment() { | ||
return mutableQueryGroupFragment; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(name); | ||
mutableQueryGroupFragment.writeTo(out); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...d-management/src/main/java/org/opensearch/plugin/wlm/action/UpdateQueryGroupResponse.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,74 @@ | ||
/* | ||
* 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.cluster.metadata.QueryGroup; | ||
import org.opensearch.core.action.ActionResponse; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.rest.RestStatus; | ||
import org.opensearch.core.xcontent.ToXContent; | ||
import org.opensearch.core.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Response for the update API for QueryGroup | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class UpdateQueryGroupResponse extends ActionResponse implements ToXContent, ToXContentObject { | ||
private final QueryGroup queryGroup; | ||
private final RestStatus restStatus; | ||
|
||
/** | ||
* Constructor for UpdateQueryGroupResponse | ||
* @param queryGroup - the QueryGroup to be updated | ||
* @param restStatus - the rest status for the response | ||
*/ | ||
public UpdateQueryGroupResponse(final QueryGroup queryGroup, RestStatus restStatus) { | ||
this.queryGroup = queryGroup; | ||
this.restStatus = restStatus; | ||
} | ||
|
||
/** | ||
* Constructor for UpdateQueryGroupResponse | ||
* @param in - a {@link StreamInput} object | ||
*/ | ||
public UpdateQueryGroupResponse(StreamInput in) throws IOException { | ||
queryGroup = new QueryGroup(in); | ||
restStatus = RestStatus.readFrom(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
queryGroup.writeTo(out); | ||
RestStatus.writeTo(out, restStatus); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
return queryGroup.toXContent(builder, params); | ||
} | ||
|
||
/** | ||
* queryGroup getter | ||
*/ | ||
public QueryGroup getQueryGroup() { | ||
return queryGroup; | ||
} | ||
|
||
/** | ||
* restStatus getter | ||
*/ | ||
public RestStatus getRestStatus() { | ||
return restStatus; | ||
} | ||
} |
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
Oops, something went wrong.