Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
masseyke committed Nov 6, 2023
1 parent 39eefd3 commit c960c3c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/reference/ingest/apis/simulate-ingest.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ POST /_ingest/_simulate
==== {api-prereq-title}

* If the {es} {security-features} are enabled, you must have the
`read_pipeline`, `manage_pipeline`, `manage_ingest_pipelines`, or `manage`
<<privileges-list-cluster,cluster privilege>> to use this API.
`index` or `create` <<privileges-list-indices,index privileges>>
to use this API.

[[simulate-ingest-api-desc]]
==== {api-description-title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class SimulateBulkAction extends ActionType<BulkResponse> {

public static final SimulateBulkAction INSTANCE = new SimulateBulkAction();
public static final String NAME = "indices:admin/simulate/bulk";
public static final String NAME = "indices:data/simulate/bulk";

private SimulateBulkAction() {
super(NAME, BulkResponse::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ protected void doInternalExecute(Task task, BulkRequest bulkRequest, String exec
indexData(task, bulkRequest, executorName, listener, autoCreateIndices, indicesThatCannotBeCreated, startTime);
}

/*
* This method is responsible for creating any missing indices and indexing the data in the BulkRequest
*/
protected void indexData(
Task task,
BulkRequest bulkRequest,
Expand Down Expand Up @@ -432,6 +435,10 @@ protected void doRun() {
}
}

/*
* This returns the IngestService to be used for the given request. The default implementation ignores the request and always returns
* the same ingestService, but child classes might use information in the request in creating an IngestService specific to that request.
*/
protected IngestService getIngestService(BulkRequest request) {
return ingestService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public TransportSimulateBulkAction(
);
}

/*
* This overrides indexData in TransportBulkAction in order to _not_ actually create any indices or index any data. Instead, each
* request gets a corresponding CREATE response, using information from the request.
*/
@Override
protected void indexData(
Task task,
Expand Down Expand Up @@ -92,6 +96,10 @@ protected void indexData(
listener.onResponse(new BulkResponse(responses.toArray(new BulkItemResponse[responses.length()]), buildTookInMillis(startTime)));
}

/*
* This overrides TransportSimulateBulkAction's getIngestService to allow us to provide an IngestService that handles pipeline
* substitutions defined in the request.
*/
@Override
protected IngestService getIngestService(BulkRequest request) {
IngestService rawIngestService = super.getIngestService(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ public final class IndexPrivilege extends Privilege {
"indices:data/write/index",
"indices:data/write/index[*",
"indices:data/write/index:op_type/create",
"indices:data/write/bulk*"
"indices:data/write/bulk*",
"indices:data/simulate/bulk*"
);
private static final Automaton INDEX_AUTOMATON = patterns(
"indices:data/write/index*",
"indices:data/write/bulk*",
"indices:data/write/update*"
"indices:data/write/update*",
"indices:data/simulate/bulk*"
);
private static final Automaton DELETE_AUTOMATON = patterns("indices:data/write/delete*", "indices:data/write/bulk*");
private static final Automaton WRITE_AUTOMATON = patterns("indices:data/write/*", AutoPutMappingAction.NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public class Constants {
"cluster:admin/synonym_rules/get",
"cluster:admin/synonym_rules/put",
"cluster:admin/settings/update",
"indices:admin/simulate/bulk",
"cluster:admin/slm/delete",
"cluster:admin/slm/execute",
"cluster:admin/slm/execute/get_expired_snapshots",
Expand Down Expand Up @@ -473,7 +472,6 @@ public class Constants {
"indices:admin/seq_no/remove_retention_lease",
"indices:admin/seq_no/renew_retention_lease",
"indices:admin/settings/update",
"indices:admin/simulate/bulk",
"indices:admin/shards/search_shards",
"indices:admin/search/search_shards",
"indices:admin/template/delete",
Expand Down Expand Up @@ -523,6 +521,7 @@ public class Constants {
"indices:data/read/xpack/rollup/get/index/caps",
"indices:data/read/xpack/rollup/search",
"indices:data/read/xpack/termsenum/list",
"indices:data/simulate/bulk",
"indices:data/write/bulk",
"indices:data/write/bulk[s]",
"indices:data/write/bulk_shard_operations[s]",
Expand Down

0 comments on commit c960c3c

Please sign in to comment.