flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Connolly <stephen.alan.conno...@gmail.com>
Subject REST API question GET /jars/:jarid/plan
Date Thu, 07 Mar 2019 10:25:12 GMT
In the documentation for the /jars/:jarid/plan endpoint
https://ci.apache.org/projects/flink/flink-docs-stable/monitoring/rest_api.html#jars-jarid-plan

It says:

> Program arguments can be passed both via the JSON request (recommended)
or query parameters.

Has anyone got sample code that sends the JSON request?

I have got the end-point working with query parameters, but I need to
support more than 2083 GET URL length limit.

When I have my code like this:

        UriTemplate template = UriTemplate.fromTemplate(apiUrl)
                .literal("/v1/jars")
                .path("jarId")
                .literal("/plan")
                .query("entryClass", "programArg*", "parallelism")
                .build()
                .set("jarId", jarId);
        if (requestBody.getEntryClass() != null) {
            // TODO find a way to have this as entry-class even if the spec
says no
            template.set("entryClass", requestBody.getEntryClass());
        }
        if (!requestBody.getProgramArgs().isEmpty()) {
            template.set("programArg",
requestBody.getProgramArgs().toArray(new String[0]));
        }
        if (requestBody.getParallelism() > 0) {
            template.set("parallelism", requestBody.getParallelism());
        }
        return get(
                template,
                null,
                null,
                JsonNode.class,
                MEDIA_TYPE_JSON
        );

Then I get the plan returned.

When I change to this

        UriTemplate template = UriTemplate.fromTemplate(apiUrl)
                .literal("/v1/jars")
                .path("jarId")
                .literal("/plan")
                .build()
                .set("jarId", jarId);
        return get(
                template,
                requestBody,
                MEDIA_TYPE_JSON,
                JsonNode.class,
                MEDIA_TYPE_JSON
        );

I get a 404.

Basically, adding the request body makes the URL go 404... For fun I tried
having both query parameters and request body and that gets a 404 also.

So does anyone have a working example using the JSON request body (and
let's not get started on how a request body is a really bad idea for GET
requests)

Mime
View raw message