Skip to content

feature-bulk-model-management#82

Merged
davemoore- merged 13 commits intomainfrom
feature-bulk-model-management
Feb 28, 2021
Merged

feature-bulk-model-management#82
davemoore- merged 13 commits intomainfrom
feature-bulk-model-management

Conversation

@davemoore-
Copy link
Copy Markdown
Member

@davemoore- davemoore- commented Feb 27, 2021

This PR introduces the Bulk Models API: POST _zentity/models/_bulk

The API performs a serial execution of multiple model management operations ("create", "update", "delete").

Example:

POST _zentity/models/_bulk
{"create":{"entity_type":"foo"}}
{"attributes":{},"resolvers":{},"matchers":{},"indices":{}}
{"update":{"entity_type":"foo"}}
{"attributes":{"foo":{}},"resolvers":{},"matchers":{},"indices":{}}
{"delete":{"entity_type":"foo"}}
{}

The API optimizes efficiency by only ensuring the existence of the .zentity-models index once at the beginning of the bulk request, and only refreshing the index once at the end of the bulk request.

The API syntax is almost identical to the Elasticsearch Bulk API, with the exception that "delete" operations must be followed by an empty object ({}) instead of skipping the object altogether.

Closes #57

… methods from ModelsAction and ResolutionAction to a new BulkAction class. No new integration tests yet. Existing integration tests are passing, and manual tests show promise.
…arallel), and each operation should neither wait for nor force a refresh.
… methods from ModelsAction and ResolutionAction to a new BulkAction class. No new integration tests yet. Existing integration tests are passing, and manual tests show promise.
…arallel), and each operation should neither wait for nor force a refresh.
@davemoore- davemoore- mentioned this pull request Feb 27, 2021
Copy link
Copy Markdown
Contributor

@austince austince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really great Dave! Nice cleanups + catches in here.

import java.util.List;
import java.util.stream.Collectors;

public class BulkAction {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really nice refactor/ consolidation.

Comment on lines +756 to +762
if (!action.equals("action"))
throw new ValidationException("Each bulk operation must have only one action and payload.");
action = name;
params = Json.ORDERED_MAPPER.writeValueAsString(value);
break;
default:
throw new ValidationException("'" + name + "' is not a recognized action for bulk model management.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, might be nicer to send the error back to the listener here explicitly instead of throwing and then catching below

Consumer<Exception> errorHandler = (e) -> ZentityPlugin.sendResponseError(channel, logger, e);

try {
boolean isBulkRequest = restRequest.path().endsWith("/_bulk");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 nice catch with the /

@davemoore- davemoore- merged commit af7de94 into main Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk Model Management

2 participants