Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatible Delete and Update rest actions #58246

Merged
merged 64 commits into from
Jul 14, 2020
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
96ebb5c
init work. 221 vs 231 failing
pgomulka Mar 25, 2020
2e922bf
allow registering multiple rest actions under the same path
pgomulka Mar 27, 2020
e7eda97
revert out dirs
pgomulka Mar 27, 2020
5dac4b9
Merge branch 'compat_rest_api' into compat/create_index_include_type
pgomulka Mar 27, 2020
a213e6c
extend restcreateindexaction
pgomulka Mar 27, 2020
f1ad677
code style and discovery nodes in indexaction
pgomulka Mar 27, 2020
8ff3463
fix double registration
pgomulka Mar 30, 2020
9b8a26a
add search action v7
pgomulka Mar 30, 2020
b0a12bd
search & multisearch
pgomulka Mar 31, 2020
b94be5c
types with consumer
pgomulka Apr 1, 2020
f78e021
cleanup type funciton
pgomulka Apr 1, 2020
9eb1c68
packages fixed
pgomulka Apr 1, 2020
a421d56
update by query, delete by query, multi term and term
pgomulka Apr 1, 2020
3364141
package rename
pgomulka Apr 1, 2020
8abcc0a
spotless
pgomulka Apr 1, 2020
6efdb30
checkstyle
pgomulka Apr 1, 2020
90c37e2
fake request build iwth compat
pgomulka Apr 1, 2020
484e4ac
fixing some tests
pgomulka Apr 1, 2020
6184a9d
term vector body not finished
pgomulka Apr 2, 2020
1ee4487
additional testing and using version
pgomulka Apr 2, 2020
abe1d28
unused method
pgomulka Apr 2, 2020
d8fc2e5
method handlers - returning null when no handler under a method was r…
pgomulka Apr 2, 2020
d998555
comments
pgomulka Apr 3, 2020
ec8df43
remove unused constant
pgomulka Apr 3, 2020
8602f65
Merge branch 'compat_rest_api' into compat/create_index_include_type
pgomulka Apr 20, 2020
f3d25e0
fix javadoc
pgomulka Apr 20, 2020
7024913
compile
pgomulka Apr 20, 2020
446c114
Merge branch 'compat/create_index_include_type' into compat/search
pgomulka Apr 20, 2020
cafee2f
spotless
pgomulka Apr 20, 2020
f52dbc1
spotless
pgomulka Apr 20, 2020
0b07539
Merge branch 'compat_rest_api' into compat/create_index_include_type
pgomulka Apr 21, 2020
07a5dbc
Merge branch 'compat/create_index_include_type' into compat/search
pgomulka Apr 21, 2020
8135794
v7 name
pgomulka Apr 22, 2020
2087c6a
Merge branch 'compat/create_index_include_type' into compat/search
pgomulka Apr 22, 2020
7e7ed63
versions and names
pgomulka Apr 22, 2020
81a62fe
spotless
pgomulka Apr 22, 2020
d65a4a2
import fix
pgomulka Apr 22, 2020
adb1a1e
fix tests
pgomulka Apr 22, 2020
f819313
fix test
pgomulka Apr 22, 2020
6e28d24
javadoc
pgomulka Apr 22, 2020
a77716e
Merge branch 'compat_rest_api' into compat/create_index_include_type
pgomulka Apr 23, 2020
dcf588c
Merge branch 'compat/create_index_include_type' into compat/search
pgomulka Apr 23, 2020
da0edd7
Merge branch 'compat_rest_api' into compat/search
pgomulka Apr 28, 2020
42b40ec
fix merge problem
pgomulka Apr 29, 2020
8912c60
Merge branch 'compat_rest_api' into compat/search
pgomulka Apr 29, 2020
6c67db3
Merge branch 'compat_rest_api' into compat/search
pgomulka Apr 29, 2020
5a720c5
Merge branch 'compat_rest_api' into compat/search
pgomulka Jun 17, 2020
5f3158c
compile fix for deprecate method rename
pgomulka Jun 17, 2020
0249a8d
Compatible Delete and Update rest actions
pgomulka Jun 17, 2020
69f408b
checkstyle
pgomulka Jun 17, 2020
2d5274f
validate handlers version
pgomulka Jun 18, 2020
e8b28d6
Merge branch 'compat_rest_api' into compat/search
pgomulka Jul 7, 2020
83afde4
fix after merge master
pgomulka Jul 7, 2020
660f086
spotless
pgomulka Jul 7, 2020
7e1ab7f
Merge branch 'compat_rest_api' into compat/delete_update
pgomulka Jul 7, 2020
9c3031f
Merge branch 'compat/search' into compat/delete_update
pgomulka Jul 7, 2020
188bab2
checkstyle
pgomulka Jul 7, 2020
f070e03
fix tests
pgomulka Jul 7, 2020
7bad475
cleanup
pgomulka Jul 7, 2020
1f04044
Merge branch 'compat_rest_api' into compat/search
pgomulka Jul 8, 2020
8595c33
Merge branch 'compat/search' into compat/delete_update
pgomulka Jul 8, 2020
24a44a8
Merge branch 'compat_rest_api' into compat/search
pgomulka Jul 8, 2020
25788ff
Merge branch 'compat/search' into compat/delete_update
pgomulka Jul 8, 2020
fd4a274
Merge branch 'compat_rest_api' into compat/delete_update
pgomulka Jul 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix double registration
  • Loading branch information
pgomulka committed Mar 30, 2020
commit 8ff3463f7558256da4aba434f14ba8446e1ebce8
29 changes: 12 additions & 17 deletions server/src/main/java/org/elasticsearch/rest/MethodHandlers.java
Original file line number Diff line number Diff line change
@@ -19,13 +19,12 @@

package org.elasticsearch.rest;

import org.elasticsearch.Version;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.collect.Tuple;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
* Encapsulate multiple handlers for the same path, allowing different handlers for different HTTP verbs.
@@ -34,13 +33,14 @@ final class MethodHandlers {

private final String path;
//TODO maybe we should aim for having a type for version instead of string/byte
private final Map<Tuple<RestRequest.Method,String>, RestHandler> methodHandlers;
private final Map<RestRequest.Method, Map<String,RestHandler>> methodHandlers;

MethodHandlers(String path, RestHandler handler, String version, RestRequest.Method... methods) {
this.path = path;
this.methodHandlers = new HashMap<>(methods.length);
for (RestRequest.Method method : methods) {
methodHandlers.put(Tuple.tuple(method, version), handler);
methodHandlers.putIfAbsent(method, new HashMap<>());
methodHandlers.get(method).put(version, handler);
}
}

@@ -50,33 +50,28 @@ final class MethodHandlers {
*/
MethodHandlers addMethods(RestHandler handler, String version, RestRequest.Method... methods) {
for (RestRequest.Method method : methods) {
RestHandler existing = methodHandlers.putIfAbsent(Tuple.tuple(method, version), handler);
methodHandlers.putIfAbsent(method, new HashMap<>());
RestHandler existing = methodHandlers.get(method).put(version, handler);
if (existing != null) {
throw new IllegalArgumentException("Cannot replace existing handler for [" + path + "] for method: " + method);
}
}
return this;
}

/**
* Returns the handler for the given method or {@code null} if none exists.
*/
@Nullable
RestHandler getHandler(RestRequest.Method method) {
return methodHandlers.get(method);
}

@Nullable
RestHandler getHandler(RestRequest.Method method, String version) {
return methodHandlers.get(Tuple.tuple(method,version));
Map<String, RestHandler> versionToHandlers = methodHandlers.get(method);
if (versionToHandlers.containsKey(version)) {
return versionToHandlers.get(version);
}
return versionToHandlers.get(String.valueOf(Version.CURRENT.major));
}

/**
* Return a set of all valid HTTP methods for the particular path
*/
Set<RestRequest.Method> getValidMethods() {
return methodHandlers.keySet().stream()
.map(Tuple::v1)
.collect(Collectors.toSet());
return methodHandlers.keySet();
}
}