You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Chesnay Schepler (Jira)" <ji...@apache.org> on 2020/01/29 10:35:00 UTC
[jira] [Comment Edited] (FLINK-15787) Upgrade REST API response to
remove '-' from key names.
[ https://issues.apache.org/jira/browse/FLINK-15787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17025797#comment-17025797 ]
Chesnay Schepler edited comment on FLINK-15787 at 1/29/20 10:34 AM:
--------------------------------------------------------------------
I think I have found a fairly lightweight way of doing this:
As an example, this is the current {{TriggerResponse}}:
{code}
public class TriggerResponse implements ResponseBody {
private static final String FIELD_NAME_REQUEST_ID = "request-id";
@JsonProperty(FIELD_NAME_REQUEST_ID)
private final TriggerId triggerId;
...
public TriggerId getTriggerId() {
return triggerId;
}
}
{code}
This is a modified version that
a) accepts both naming schemes during deserialization, with a single field
b) writes the same field using both naming schemes during serialization
{code}
public class TriggerResponse implements ResponseBody {
private static final String FIELD_NAME_REQUEST_ID = "requestId";
private static final String LEGACY_FIELD_NAME_REQUEST_ID = "request-id";
@JsonProperty(FIELD_NAME_REQUEST_ID)
@JsonAlias(LEGACY_FIELD_NAME_REQUEST_ID)
private final TriggerId triggerId;
...
@JsonProperty(LEGACY_FIELD_NAME_REQUEST_ID)
public TriggerId getTriggerId() {
return triggerId;
}
}
{code}
This should be a fairly mechanical change, without requiring any modifications to handlers.
The REST API docs generator will spit out both fields in the schema, but I don't see a way around that.
was (Author: zentol):
I think I have found a fairly lightweight way of doing this:
As an example, this is the current {{TriggerResponse}}:
{code}
public class TriggerResponse implements ResponseBody {
private static final String FIELD_NAME_REQUEST_ID = "request-id";
@JsonProperty(FIELD_NAME_REQUEST_ID)
private final TriggerId triggerId;
...
public TriggerId getTriggerId() {
return triggerId;
}
}
{code}
This is a modified version that
a) accepts both naming schemes during deserialization, with a single field
b) writes the same field using both naming schemes during serialization
{code}
public class TriggerResponse implements ResponseBody {
private static final String FIELD_NAME_REQUEST_ID = "requestId";
private static final String LEGACY_FIELD_NAME_REQUEST_ID = "request-id";
@JsonProperty(FIELD_NAME_REQUEST_ID)
@JsonAlias(LEGACY_FIELD_NAME_REQUEST_ID)
private final TriggerId triggerId;
...
@JsonProperty(LEGACY_FIELD_NAME_REQUEST_ID)
public TriggerId getTriggerId() {
return triggerId;
}
}
{code}
This should be a fairly mechanical change, without requiring any modifications to handlers.
The REST API docs generator will spit out both fields for responses, but I don't see a way around that.
> Upgrade REST API response to remove '-' from key names.
> -------------------------------------------------------
>
> Key: FLINK-15787
> URL: https://issues.apache.org/jira/browse/FLINK-15787
> Project: Flink
> Issue Type: Improvement
> Components: Runtime / REST
> Affects Versions: 1.10.0
> Reporter: Daryl Roberts
> Assignee: Chesnay Schepler
> Priority: Major
> Fix For: 1.11.0
>
>
> There are some REST API responses that include keys with hyphens in them. This results in the frontend having to use string-lookups to access those values and we lose the type information when doing that.
> Example from {{/jobs/<jobid>/vertices/<vertex>/backpressure}}
> {{export interface JobBackpressureInterface {}}
> {{ status: string;}}
> {{ 'backpressure-level': string;}}
> {{ 'end-timestamp': number;}}
> {{ subtasks: JobBackpressureSubtaskInterface[];}}
> {{}}}
> I would like to update all of these to use {{_}} instead so we can maintain the type information we have in the web-runtime.
> My suggestion to do this with out a version bump to the API is to just make an addition to all the enpoints that include the _ versions as well. Then after the web-runtime has completely switched over to using the new keys, you can deprecate and remove the old hypenated keys at your own pace.
> [~chesnay] [~trohrmann]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)