-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Remove tricky switch in bulk #80624
Remove tricky switch in bulk #80624
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.ActionRunnable; | ||
import org.elasticsearch.action.DocWriteRequest; | ||
import org.elasticsearch.action.DocWriteRequest.OpType; | ||
import org.elasticsearch.action.DocWriteResponse; | ||
import org.elasticsearch.action.RoutingMissingException; | ||
import org.elasticsearch.action.admin.indices.create.AutoCreateAction; | ||
|
@@ -523,26 +524,14 @@ protected void doRun() { | |
throw new IllegalArgumentException("only write ops with an op_type of create are allowed in data streams"); | ||
} | ||
|
||
IndexRouting indexRouting = concreteIndices.routing(concreteIndex); | ||
|
||
switch (docWriteRequest.opType()) { | ||
case CREATE: | ||
case INDEX: | ||
prohibitAppendWritesInBackingIndices(docWriteRequest, metadata); | ||
prohibitCustomRoutingOnDataStream(docWriteRequest, metadata); | ||
IndexRequest indexRequest = (IndexRequest) docWriteRequest; | ||
indexRequest.resolveRouting(metadata); | ||
indexRequest.process(); | ||
break; | ||
case UPDATE: | ||
docWriteRequest.routing(metadata.resolveWriteIndexRouting(docWriteRequest.routing(), docWriteRequest.index())); | ||
break; | ||
case DELETE: | ||
docWriteRequest.routing(metadata.resolveWriteIndexRouting(docWriteRequest.routing(), docWriteRequest.index())); | ||
break; | ||
default: | ||
throw new AssertionError("request type not supported: [" + docWriteRequest.opType() + "]"); | ||
if (docWriteRequest.opType() == OpType.CREATE || docWriteRequest.opType() == OpType.INDEX) { | ||
prohibitAppendWritesInBackingIndices(docWriteRequest, metadata); | ||
prohibitCustomRoutingOnDataStream(docWriteRequest, metadata); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @martijnvg I wonder if it is not a bug that we do not check this for all request types, including update/delete? Maybe better handled in a follow-up, but would be nice to move out of this "if". And perhaps then let There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat! I was hoping writing it like this would make stuff like this more obvious. I'll leave this to @martijnvg's follow up though. |
||
} | ||
docWriteRequest.routing(metadata.resolveWriteIndexRouting(docWriteRequest.routing(), docWriteRequest.index())); | ||
docWriteRequest.process(); | ||
|
||
IndexRouting indexRouting = concreteIndices.routing(concreteIndex); | ||
int shardId = docWriteRequest.route(indexRouting); | ||
List<BulkItemRequest> shardRequests = requestsByShard.computeIfAbsent( | ||
new ShardId(concreteIndex, shardId), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
resolveRouting(...)
method can now also be removed fromIndexRequest
class? (looks this was the only usage).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh! I had done that when I was working on it and had lost it in the shuffle. I'll add it back