-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add logstash system index APIs #53350
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
Merged
williamrandolph
merged 33 commits into
elastic:master
from
jaymode:logstash_system_index_plugin
Sep 14, 2020
Merged
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
045aaae
Add logstash module with wrapped APIs
jaymode 742c621
remove wrapped APIs and add dedicated logstash APIs
jaymode 5328277
Merge branch 'master' into logstash_system_index_plugin
jaymode dd17265
merge with x-pack plugin
jaymode c94574f
add system index access allowance
jaymode d227480
Merge branch 'master' into logstash_system_index_plugin
jaymode a63f268
formatting
jaymode 922d311
serialization tests and fixes
jaymode 765963d
license
jaymode b82253e
format
jaymode bcfa925
Merge branch 'master' into logstash_system_index_plugin
jaymode 59583e2
Merge branch 'master' into logstash_system_index_plugin
jaymode 7fa4d07
fixes
jaymode c839bf7
aesthetics
jaymode 6a1be8c
constants
jaymode 1cac888
spotless
jaymode 45d0040
Merge branch 'master' into logstash_system_index_plugin
williamrandolph 9f075cb
Merge branch 'master' into logstash_system_index_plugin
williamrandolph 2b3d16e
Break out serialization tests into distinct classes
williamrandolph 0747a10
Merge branch 'master' into logstash_system_index_plugin
williamrandolph 02d1cda
Merge branch 'master' into logstash_system_index_plugin
williamrandolph de40603
Remove test of obsolete setting
williamrandolph 0d11fb3
Merge branch 'master' into logstash_system_index_plugin
williamrandolph 453b2b1
Add test for pipeline multiget logic
williamrandolph bc529ac
Log failures for partial multiget failure
williamrandolph 435df7b
Clean up and add comments
williamrandolph fa51c62
Fix Javadoc
williamrandolph 0e99803
Merge branch 'master' into logstash_system_index_plugin
williamrandolph 505104b
Merge branch 'master' into logstash_system_index_plugin
williamrandolph b734883
Move LogstashSystemIndexIT to javaRestTest task
williamrandolph 551a789
Respond to PR feedback
williamrandolph 5f8a4c3
Remove unused imports, apply spotless
williamrandolph 11c6afb
Merge branch 'master' into logstash_system_index_plugin
williamrandolph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Pipeline.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.logstash; | ||
|
||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType; | ||
|
||
import java.time.Instant; | ||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; | ||
|
||
public class Pipeline { | ||
|
||
@SuppressWarnings("unchecked") | ||
public static final ConstructingObjectParser<Pipeline, String> PARSER = new ConstructingObjectParser<>( | ||
"pipeline", | ||
true, | ||
(objects, id) -> { | ||
Iterator<Object> iterator = Arrays.asList(objects).iterator(); | ||
return new Pipeline( | ||
id, | ||
(Instant) iterator.next(), | ||
(Map<String, Object>) iterator.next(), | ||
(String) iterator.next(), | ||
(String) iterator.next(), | ||
(Map<String, Object>) iterator.next() | ||
); | ||
} | ||
); | ||
|
||
public static final ParseField LAST_MODIFIED = new ParseField("last_modified"); | ||
public static final ParseField PIPELINE_METADATA = new ParseField("pipeline_metadata"); | ||
public static final ParseField USERNAME = new ParseField("username"); | ||
public static final ParseField PIPELINE = new ParseField("pipeline"); | ||
public static final ParseField PIPELINE_SETTINGS = new ParseField("pipeline_settings"); | ||
|
||
static { | ||
PARSER.declareField(constructorArg(), (parser, s) -> { | ||
final String instantISOString = parser.text(); | ||
return Instant.parse(instantISOString); | ||
}, LAST_MODIFIED, ValueType.STRING); | ||
PARSER.declareObject(constructorArg(), (parser, s) -> parser.map(), PIPELINE_METADATA); | ||
PARSER.declareString(constructorArg(), USERNAME); | ||
PARSER.declareString(constructorArg(), PIPELINE); | ||
PARSER.declareObject(constructorArg(), (parser, s) -> parser.map(), PIPELINE_SETTINGS); | ||
} | ||
|
||
private final String id; | ||
private final Instant lastModified; | ||
private final Map<String, Object> pipelineMetadata; | ||
private final String username; | ||
private final String pipeline; | ||
private final Map<String, Object> pipelineSettings; | ||
|
||
public Pipeline( | ||
String id, | ||
Instant lastModified, | ||
Map<String, Object> pipelineMetadata, | ||
String username, | ||
String pipeline, | ||
Map<String, Object> pipelineSettings | ||
) { | ||
this.id = id; | ||
this.lastModified = lastModified; | ||
this.pipelineMetadata = pipelineMetadata; | ||
this.username = username; | ||
this.pipeline = pipeline; | ||
this.pipelineSettings = pipelineSettings; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public Instant getLastModified() { | ||
return lastModified; | ||
} | ||
|
||
public Map<String, Object> getPipelineMetadata() { | ||
return pipelineMetadata; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public String getPipeline() { | ||
return pipeline; | ||
} | ||
|
||
public Map<String, Object> getPipelineSettings() { | ||
return pipelineSettings; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../logstash/src/main/java/org/elasticsearch/xpack/logstash/action/DeletePipelineAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.logstash.action; | ||
|
||
import org.elasticsearch.action.ActionType; | ||
|
||
public class DeletePipelineAction extends ActionType<DeletePipelineResponse> { | ||
|
||
public static final String NAME = "cluster:admin/logstash/pipeline/delete"; | ||
public static final DeletePipelineAction INSTANCE = new DeletePipelineAction(); | ||
|
||
private DeletePipelineAction() { | ||
super(NAME, DeletePipelineResponse::new); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...logstash/src/main/java/org/elasticsearch/xpack/logstash/action/DeletePipelineRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.logstash.action; | ||
|
||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class DeletePipelineRequest extends ActionRequest { | ||
|
||
private final String id; | ||
|
||
public DeletePipelineRequest(String id) { | ||
this.id = Objects.requireNonNull(id); | ||
} | ||
|
||
public DeletePipelineRequest(StreamInput in) throws IOException { | ||
super(in); | ||
this.id = in.readString(); | ||
} | ||
|
||
public String id() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(id); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DeletePipelineRequest that = (DeletePipelineRequest) o; | ||
return Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...ogstash/src/main/java/org/elasticsearch/xpack/logstash/action/DeletePipelineResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.logstash.action; | ||
|
||
import org.elasticsearch.action.ActionResponse; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class DeletePipelineResponse extends ActionResponse { | ||
|
||
private final boolean deleted; | ||
|
||
public DeletePipelineResponse(boolean deleted) { | ||
this.deleted = deleted; | ||
} | ||
|
||
public DeletePipelineResponse(StreamInput in) throws IOException { | ||
super(in); | ||
this.deleted = in.readBoolean(); | ||
} | ||
|
||
public boolean isDeleted() { | ||
return deleted; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeBoolean(deleted); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DeletePipelineResponse that = (DeletePipelineResponse) o; | ||
return deleted == that.deleted; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(deleted); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...gin/logstash/src/main/java/org/elasticsearch/xpack/logstash/action/GetPipelineAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.logstash.action; | ||
|
||
import org.elasticsearch.action.ActionType; | ||
|
||
public class GetPipelineAction extends ActionType<GetPipelineResponse> { | ||
|
||
public static final String NAME = "cluster:admin/logstash/pipeline/get"; | ||
public static final GetPipelineAction INSTANCE = new GetPipelineAction(); | ||
|
||
private GetPipelineAction() { | ||
super(NAME, GetPipelineResponse::new); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...in/logstash/src/main/java/org/elasticsearch/xpack/logstash/action/GetPipelineRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.logstash.action; | ||
|
||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class GetPipelineRequest extends ActionRequest { | ||
|
||
private final List<String> ids; | ||
|
||
public GetPipelineRequest(List<String> ids) { | ||
this.ids = Objects.requireNonNull(ids); | ||
} | ||
|
||
public GetPipelineRequest(StreamInput in) throws IOException { | ||
super(in); | ||
ids = in.readStringList(); | ||
} | ||
|
||
public List<String> ids() { | ||
return ids; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeStringCollection(ids); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
GetPipelineRequest that = (GetPipelineRequest) o; | ||
return Objects.equals(ids, that.ids); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(ids); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.