From 12296ce066e05004a9510bb437c401613a0574cf Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Mon, 5 Feb 2024 09:31:44 -0600 Subject: [PATCH] Clean up license headers --- .../admin/indices/view/CreateViewAction.java | 8 + .../admin/indices/view/SearchViewAction.java | 8 + .../admin/indices/view/ViewService.java | 8 + .../opensearch/index/view/package-info.java | 10 -- .../org/opensearch/index/view/views-design.md | 168 ------------------ .../action/admin/indices/RestViewAction.java | 2 + .../admin/indices/view/CreateViewTests.java | 4 - .../admin/indices/view/SearchViewTests.java | 4 - .../cluster/metadata/ViewTests.java | 5 - 9 files changed, 26 insertions(+), 191 deletions(-) delete mode 100644 server/src/main/java/org/opensearch/index/view/package-info.java delete mode 100644 server/src/main/java/org/opensearch/index/view/views-design.md diff --git a/server/src/main/java/org/opensearch/action/admin/indices/view/CreateViewAction.java b/server/src/main/java/org/opensearch/action/admin/indices/view/CreateViewAction.java index c47eb9ea5432d..ea563986d154e 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/view/CreateViewAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/view/CreateViewAction.java @@ -1,3 +1,11 @@ +/* + * 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.action.admin.indices.view; import org.opensearch.action.ActionRequestValidationException; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/view/SearchViewAction.java b/server/src/main/java/org/opensearch/action/admin/indices/view/SearchViewAction.java index b089d04751a63..2e475eaecd5d2 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/view/SearchViewAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/view/SearchViewAction.java @@ -1,3 +1,11 @@ +/* + * 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.action.admin.indices.view; import org.opensearch.action.ActionRequestValidationException; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/view/ViewService.java b/server/src/main/java/org/opensearch/action/admin/indices/view/ViewService.java index 29ec6b3ba29aa..9b7a3a38e061e 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/view/ViewService.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/view/ViewService.java @@ -1,3 +1,11 @@ +/* + * 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.action.admin.indices.view; import org.apache.logging.log4j.LogManager; diff --git a/server/src/main/java/org/opensearch/index/view/package-info.java b/server/src/main/java/org/opensearch/index/view/package-info.java deleted file mode 100644 index bb65723bdd5cd..0000000000000 --- a/server/src/main/java/org/opensearch/index/view/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * 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. - */ - -/** Core classes responsible for handling all view operations */ -package org.opensearch.index.view; diff --git a/server/src/main/java/org/opensearch/index/view/views-design.md b/server/src/main/java/org/opensearch/index/view/views-design.md deleted file mode 100644 index 4bd5d9585c5c2..0000000000000 --- a/server/src/main/java/org/opensearch/index/view/views-design.md +++ /dev/null @@ -1,168 +0,0 @@ -# Views - -Views define how searches are performed against indices on a cluster, uniform data access that is configured separately from the queries. - -## Design - -### View data - -Views create a mapping to the resources that hold information to be searched over in a consistent manner. This abstraction allows for indirection with the backing indices, so they might be changed without callers being impacted. This can also be used to simplify the security model - searches over views do not require permissions to the backing indices only permissions to the view itself. - -```mermaid -classDiagram - class View { - +String name - +String description - +long createdAt - +long modifiedAt - +List targets - +toXContent(XContentBuilder, Params) XContentBuilder - +writeTo(StreamOutput) void - } - class Target { - +String indexPattern - +toXContent(XContentBuilder, Params) XContentBuilder - +writeTo(StreamOutput) void - } - class StreamOutput - class XContentBuilder - - View -- Target : contains - View -- StreamOutput : writes to - View -- XContentBuilder : outputs to - Target -- StreamOutput : writes to - Target -- XContentBuilder : outputs to -``` - -### View persistence - -Views are long lived objects in OpenSearch, all operations on them should be fully committed before responding to the caller. Views are intentionally created for user scenarios following a similar creation cadence to indices. - -Committed implies that the updates are synchronized across all nodes in a cluster. The Cluster Metadata Store is already available and allows for acknowledging that changes have been applied to all nodes. While this data could be stored in a new purpose built index, index data replication has delays and ensuring synchronization is non-trivial to implement as is seen in the Security plugins [1]. - -- [1] https://github.com/opensearch-project/security/issues/3275 - -```mermaid -sequenceDiagram - participant Client - participant HTTP_Request as ActionHandler - participant Cluster_Metadata as Cluster Metadata Store - participant Data_Store as Indices - - Client->>HTTP_Request: View List/Get/Update/Create/Delete
/views or /views/{view_id} - HTTP_Request->>Cluster_Metadata: Query Views - alt Update/Create/Delete - Cluster_Metadata->>Cluster_Metadata: Refresh Cluster - end - Cluster_Metadata-->>HTTP_Request: Return - HTTP_Request-->>Client: Return - - Client->>HTTP_Request: Search View
/views/{view_id}/search - HTTP_Request->>Cluster_Metadata: Query Views - Cluster_Metadata-->>HTTP_Request: Return - HTTP_Request->>HTTP_Request: Rewrite Search Request - HTTP_Request->>HTTP_Request: Validate Search Request - HTTP_Request->>Data_Store: Search indices - Data_Store-->>HTTP_Request: Return - HTTP_Request-->>Client: Return -``` -## Appendix - -### Local Testing - -``` -curl localhost:9200/abc/_doc \ - -XPOST \ - --header "Content-Type: application/json" \ - --data '{"foo":"bar"}' \ - -curl localhost:9200/views \ - -XPOST \ - --header "Content-Type: application/json" \ - --data '{"name":"hi", "createdAt": -1, "modifiedAt": -1, "targets":[]}' \ - -v - -curl localhost:9200/views \ - -XPOST \ - --header "Content-Type: application/json" \ - --data '{"name":"hi", "createdAt": -1, "modifiedAt": -1, "targets":[{"indexPattern":"abc"}]}' \ - -v - - -curl localhost:9200/views/hi/_search -``` - -### v0 View Data Model - -``` -VIEW MODEL -{ - name: STRING, // [Optional] Friendly name resolves to ID - id: STRING, // Non-mutatable identifier - description: STRING, // [Optional] Description of the view - created: DATE, // Creation time of the view - modified: DATE // Last modified time of the view - query: QUERY, // enforced query - filter: QUERY, // P2 enforced query after transformations - targets: [ - { - indexPattern: STRING, // No wildcard/aliases! - // P2 Allow wildcard/aliases query parameter - query: QUERY, // enforced query specific for this target - filter: QUERY, // P2 enforced query specific after transformations - documentTransformer: SCRIPT // P2 Convert the results in some way - } - ], - documentTransformer: SCRIPT // P2 Convert the results in some way -} -``` - -#### View Operations - -| Method | Path | -| - | - | -| POST | /views | -| GET | /views/{view_id} | -| PUT | /views/{view_id} | -| PATCH | /views/{view_id} | -| DELETE | /views/{view_id} | - -#### Enumerate Views - -| Method | Path | -| - | - | -| GET | /views | - -#### Perform a Search on a view -| Method | Path | -| - | - | -| GET | /views/{view_id}/_search | -| POST | /views/{view_id}/_search | - -#### Search Views // P2? -| Method | Path | -| - | - | -| GET | /views/_search | -| POST | /views/_search | - -#### Mapping // P2? Need to understand the utility / impact of not having this -| Method | Path | -| - | - | -| GET | /views/{view_id}/_mappings | -| PUT | /views/{view_id}/_mappings | -| PATCH | /views/{view_id}/_mappings | - - -*Results do not include any fields '_', how to protect leaking data?* - -#### Response on Create/Enumerate/Search - -views: [ - { - name: STRING, - id: STRING, - description: STRING, - created: DATE, - modified: DATE - } -] diff --git a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestViewAction.java b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestViewAction.java index 126348e71c971..486a7e9da9706 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestViewAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestViewAction.java @@ -110,6 +110,8 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC } } + // TODO: Replace and reorganize this layout + // public List routes() { // return List.of( diff --git a/server/src/test/java/org/opensearch/action/admin/indices/view/CreateViewTests.java b/server/src/test/java/org/opensearch/action/admin/indices/view/CreateViewTests.java index 3879da72243af..49d13a260ad3e 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/view/CreateViewTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/view/CreateViewTests.java @@ -5,10 +5,6 @@ * 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. - */ package org.opensearch.action.admin.indices.view; diff --git a/server/src/test/java/org/opensearch/action/admin/indices/view/SearchViewTests.java b/server/src/test/java/org/opensearch/action/admin/indices/view/SearchViewTests.java index 1e56676a10e29..e07104cbb6ad6 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/view/SearchViewTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/view/SearchViewTests.java @@ -5,10 +5,6 @@ * 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. - */ package org.opensearch.action.admin.indices.view; diff --git a/server/src/test/java/org/opensearch/cluster/metadata/ViewTests.java b/server/src/test/java/org/opensearch/cluster/metadata/ViewTests.java index e417dbd1b33a2..145d3277bbf14 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/ViewTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/ViewTests.java @@ -6,11 +6,6 @@ * compatible open source license. */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - package org.opensearch.cluster.metadata; import org.opensearch.cluster.metadata.View.Target;