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

Add start rollup job support to HL REST Client #34623

Merged
merged 11 commits into from
Oct 29, 2018

Conversation

cbuescher
Copy link
Member

This change adds support for starting a rollup job to High Level REST Client.

Relates to #29827

This change adds support for starting a rollup job to High Level REST Client.

Relates to elastic#29827
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@cbuescher
Copy link
Member Author

@elasticmachine test this please

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

One nit and one larger comment that I think is worth discussing.

@@ -48,6 +50,18 @@ static Request putJob(final PutRollupJobRequest putRollupJobRequest) throws IOEx
return request;
}

static Request startJob(final StartRollupJobRequest startRollupJobRequest) throws IOException {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_xpack")
Copy link
Contributor

Choose a reason for hiding this comment

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

this is now a variadic, so u can .addPathPartAsIs("_xpack", "rollup", "job")....

@@ -58,7 +60,7 @@ public int hashCode() {
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
builder.startObject();
{
builder.field("acknowledged", isAcknowledged());
builder.field(field, isAcknowledged());
Copy link
Contributor

Choose a reason for hiding this comment

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

Im not sure i like changing this, because it would be nice if we had a more generic AcknowledgedResponse. I understand that yall need to override the "acknowledged" field, but maybe its best to have builder.field(getField(), isAcknowledged()); and override that in the child classes that are in this review. I wonder if the ConstructingObjectParser can also be put in here with the same abstraction.

Copy link
Member Author

Choose a reason for hiding this comment

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

np, will update

@cbuescher
Copy link
Member Author

@hub-cap thanks for the review, I updated the PR. Can you take a second look?

@colings86 colings86 added v6.6.0 and removed v6.5.0 labels Oct 25, 2018
Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

Hey, awesome work. The only thing change is to remove the abstract from getFieldName, and just have the default AcknowledgeResponse impl of this method be "acknowledged", since thats the generic case that other APIs can and will use as well.

I think it might be worth also moving the parser in. You can feel free to shoot this down, but i basically did the following to a sample response i had sitting in my current branch. Mind you, the tests started failing cuz i changed the parse field name, just to make sure it was working :)

public class DeleteRollupJobResponse extends AcknowledgedResponse {
    private static final String PARSE_FIELD_NAME = "some_other_ack";

    private static final ConstructingObjectParser<DeleteRollupJobResponse, Void> PARSER =
        AcknowledgedResponse.generateParser("delete_rollup_job_response", DeleteRollupJobResponse::new, PARSE_FIELD_NAME);

    public DeleteRollupJobResponse(boolean acknowledged) {
        super(acknowledged);
    }

    public static DeleteRollupJobResponse fromXContent(final XContentParser parser) throws IOException {
        return PARSER.parse(parser, null);
    }

    @Override
    String getFieldName() {
        return PARSE_FIELD_NAME;
    }
}

and added the following to AcknowledgedResponse

public static <T> ConstructingObjectParser generateParser(String name, Function<Boolean, T> ctor, String parseField) {
        ConstructingObjectParser p = new ConstructingObjectParser<>(name, true, args -> ctor.apply((boolean) args[0]));
        p.declareBoolean(constructorArg(), new ParseField(parseField));
        return p;
    }

@cbuescher
Copy link
Member Author

@hub-cap I think I got what you mean. Please take a look at the last commit if thats the change you intended.

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

yea this is real nice now.

public DeleteRollupJobResponse(boolean acknowledged) {
super(acknowledged);
}

private static final ConstructingObjectParser<DeleteRollupJobResponse, Void> PARSER = AcknowledgedResponse
Copy link
Contributor

Choose a reason for hiding this comment

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

super bueno!

@cbuescher cbuescher merged commit 3a464bd into elastic:master Oct 29, 2018
cbuescher pushed a commit that referenced this pull request Oct 29, 2018
This change adds support for starting a rollup job to High Level REST Client.

Relates to #29827
kcm pushed a commit that referenced this pull request Oct 30, 2018
This change adds support for starting a rollup job to High Level REST Client.

Relates to #29827
@jpountz jpountz removed the :StorageEngine/Rollup Turn fine-grained time-based data into coarser-grained data label Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants