-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature/extensions] Integrated CreateComponent extensionPoint (#3265)
* Draft createComponent extensionPoint Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Integrated cluster state for createComponent Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Decoupled extension points design Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Changed ClusterServiceRequest to generic ExtensionRequest Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * PR comments Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Using ClusterStateResponse Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> * Rebased Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
- Loading branch information
1 parent
7625fce
commit 76bbc9f
Showing
6 changed files
with
265 additions
and
3 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
60 changes: 60 additions & 0 deletions
60
server/src/main/java/org/opensearch/cluster/ClusterSettingsResponse.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,60 @@ | ||
/* | ||
* 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.cluster; | ||
|
||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.transport.TransportResponse; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
/** | ||
* PluginSettings Response for Extensibility | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ClusterSettingsResponse extends TransportResponse { | ||
private final Settings clusterSettings; | ||
|
||
public ClusterSettingsResponse(ClusterService clusterService) { | ||
this.clusterSettings = clusterService.getSettings(); | ||
} | ||
|
||
public ClusterSettingsResponse(StreamInput in) throws IOException { | ||
super(in); | ||
this.clusterSettings = Settings.readSettingsFromStream(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
Settings.writeSettingsToStream(clusterSettings, out); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ClusterSettingsResponse{" + "clusterSettings=" + clusterSettings + '}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ClusterSettingsResponse that = (ClusterSettingsResponse) o; | ||
return Objects.equals(clusterSettings, that.clusterSettings); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(clusterSettings); | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
server/src/main/java/org/opensearch/cluster/LocalNodeResponse.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,60 @@ | ||
/* | ||
* 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.cluster; | ||
|
||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.transport.TransportResponse; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
/** | ||
* LocalNode Response for Extensibility | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class LocalNodeResponse extends TransportResponse { | ||
private final DiscoveryNode localNode; | ||
|
||
public LocalNodeResponse(ClusterService clusterService) { | ||
this.localNode = clusterService.localNode(); | ||
} | ||
|
||
public LocalNodeResponse(StreamInput in) throws IOException { | ||
super(in); | ||
this.localNode = new DiscoveryNode(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
this.localNode.writeTo(out); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "LocalNodeResponse{" + "localNode=" + localNode + '}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
LocalNodeResponse that = (LocalNodeResponse) o; | ||
return Objects.equals(localNode, that.localNode); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(localNode); | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
server/src/main/java/org/opensearch/extensions/ExtensionRequest.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,66 @@ | ||
/* | ||
* 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.extensions; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.transport.TransportRequest; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
/** | ||
* CLusterService Request for Extensibility | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ExtensionRequest extends TransportRequest { | ||
private static final Logger logger = LogManager.getLogger(ExtensionRequest.class); | ||
private ExtensionsOrchestrator.RequestType requestType; | ||
|
||
public ExtensionRequest(ExtensionsOrchestrator.RequestType requestType) { | ||
this.requestType = requestType; | ||
} | ||
|
||
public ExtensionRequest(StreamInput in) throws IOException { | ||
super(in); | ||
this.requestType = in.readEnum(ExtensionsOrchestrator.RequestType.class); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeEnum(requestType); | ||
} | ||
|
||
public ExtensionsOrchestrator.RequestType getRequestType() { | ||
return this.requestType; | ||
} | ||
|
||
public String toString() { | ||
return "ExtensionRequest{" + "requestType=" + requestType + '}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
|
||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ExtensionRequest that = (ExtensionRequest) o; | ||
return Objects.equals(requestType, that.requestType); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(requestType); | ||
} | ||
|
||
} |
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