Make supervisor API similar to submit task API#8810
Make supervisor API similar to submit task API#8810jihoonson merged 22 commits intoapache:masterfrom
Conversation
|
This pull request introduces 3 alerts when merging c34c5cf into 3b602da - view on LGTM.com new alerts:
|
|
This pull request introduces 1 alert when merging 8d0c0a6 into 6f7fbeb - view on LGTM.com new alerts:
|
|
Please fix LGTM alert. |
|
I am a strong 👍 on the design (I am biased since I filed the original issue). |
jihoonson
left a comment
There was a problem hiding this comment.
Yeah, i looked at that, it thinks
dataSchemacan be null here because of test cases, where null is passed fordataSchema, though those tests pass a validingestionSchema, and it's already checked in here. Not sure how to make lgtm ignore that or fix otherwise.
You can fix it by making a non-null IndexIngestionSpec first and then using it in the constructor.
Also, this PR changes only IndexTask. Are you going to change ParallelIndexSupervisorTask in a follow-up pr?
| { | ||
| "type" : "index", | ||
| "spec" : { | ||
| "type" : "index", |
There was a problem hiding this comment.
Wrong indentation. Should be 2 spaces.
| ) | ||
| { | ||
| return makeGroupId(ingestionSchema.ioConfig.appendToExisting, ingestionSchema.dataSchema.getDataSource()); | ||
| final boolean isValid = (ingestionSchema != null) ^ (dataSchema != null |
There was a problem hiding this comment.
This check should be in the constructor rather than here since it's a method to make a groupId.
There was a problem hiding this comment.
makeGroupId is called from the constructor inside this, so can't add another check before calling this
| && ioConfig != null | ||
| && tuningConfig != null); | ||
| if (!isValid) { | ||
| throw new ISE("invalid spec input"); |
There was a problem hiding this comment.
Please make the error message more user friendly. It should say what's missing or what's duplicate.
| } | ||
| if (ingestionSchema == null) { | ||
| assert (ioConfig != null); | ||
| assert (dataSchema != null); |
There was a problem hiding this comment.
Why these asserts? Seems duplicate.
There was a problem hiding this comment.
these were added because of lgtm warnings
| @@ -174,6 +191,9 @@ public IndexTask( | |||
| @JsonProperty("id") final String id, | |||
| @JsonProperty("resource") final TaskResource taskResource, | |||
| @JsonProperty("spec") final IndexIngestionSpec ingestionSchema, | |||
| false | ||
| ), | ||
| null, | ||
| null, |
There was a problem hiding this comment.
Please add another constructor to IndexTask which is compatible to the old constructor so that you can minimize the change of this PR. The constructor should be @VisibleForTesting and @Deprecated.
There was a problem hiding this comment.
added the original constructor back
|
|
||
| final String json = jsonMapper.writeValueAsString(task); | ||
|
|
||
| Thread.sleep(100); // Just want to run the clock a bit to make sure the task id doesn't change |
There was a problem hiding this comment.
I don't understand this comment. What does it do?
There was a problem hiding this comment.
copy-paste of another test case :). Tried removing the sleep, test case still passes.
| @Test(expected = ISE.class) | ||
| public void testIndexTaskInvalidSpecSerde() | ||
| { | ||
| new IndexTask( |
There was a problem hiding this comment.
This is not a serde test. The test should deserialize from a json string.
There was a problem hiding this comment.
moved this to IndexTaskTest
Yes, want to change |
|
Thanks @jihoonson for review and suggestion, I have updated this PR to allow supervisor schema to take in |
|
@surekhasaharan thanks for updating the PR. Would you please merge master so that LGTM can be passed? |
…to submit-task-api
…to submit-task-api
|
|
||
| private static KafkaSupervisorTuningConfig getTuningConfig( | ||
| KafkaSupervisorIngestionSpec ingestionSchema, | ||
| KafkaSupervisorTuningConfig tuningConfig |
There was a problem hiding this comment.
Please annotate both @Nullable.
|
|
||
| @JsonCreator | ||
| public KafkaSupervisorSpec( | ||
| @JsonProperty("spec") KafkaSupervisorIngestionSpec ingestionSchema, |
There was a problem hiding this comment.
Please annotate ingestionSchema, dataSchema, tuningConfig, and ioConfig with @Nullable.
| @JsonProperty | ||
| public DataSchema getDataSchema() | ||
| { | ||
| return super.getDataSchema(); |
There was a problem hiding this comment.
And getDataSchema() should be deprecated.
There was a problem hiding this comment.
removed from subclass and deprecated in base class
|
|
||
| @Override | ||
| @JsonProperty | ||
| public KafkaSupervisorTuningConfig getTuningConfig() |
There was a problem hiding this comment.
This and getIoConfig() should be deprecated now.
| @JsonProperty | ||
| public KafkaSupervisorIngestionSpec getSpec() | ||
| { | ||
| return (KafkaSupervisorIngestionSpec) super.getSpec(); |
There was a problem hiding this comment.
Hmm sorry now it's not nullable.
| protected final ObjectMapper mapper; | ||
| protected final RowIngestionMetersFactory rowIngestionMetersFactory; | ||
| private final SeekableStreamSupervisorIngestionSpec ingestionSchema; | ||
| private final DataSchema dataSchema; |
There was a problem hiding this comment.
This class now has duplicate information between ingestionSchema and dataSchema, ioConfig, and tuningConfig. I suggest to remove dataSchema, ioConfig, and tuningConfig and keep only ingestionSchema.
There was a problem hiding this comment.
These will still be required in subclasses KafkaSupervisorSpec and KinesisSupervisorSpec for backwards compatibility, so there will be some duplication.
There was a problem hiding this comment.
It doesn't have to be duplicate. You can always create ingestionSchema and get things from it.
There was a problem hiding this comment.
ok right, removed the extra configs from this class.
| @JsonProperty | ||
| public KafkaSupervisorIngestionSpec getSpec() | ||
| { | ||
| return (KafkaSupervisorIngestionSpec) super.getSpec(); |
There was a problem hiding this comment.
Hmm sorry now it's not nullable.
| } | ||
|
|
||
| @Override | ||
| @Nullable |
There was a problem hiding this comment.
Same here. It's not nullable now.
|
Thanks. I left a couple of trivial comments. LGTM after removing wrong nullable annotations. |
* accept spec or dataSchema, tuningConfig, ioConfig while submitting task json * fix test * update docs * lgtm warning * Add original constructor back to IndexTask to minimize changes * fix indentation in docs * Allow spec to be specified in supervisor schema * undo IndexTask spec changes * update docs * Add Nullable and deprecated annotations * remove deprecated configs from SeekableStreamSupervisorSpec * remove nullable annotation
Fixes #8662
Description
Make submit task and supervisor API's similar in structure. supervisor API accepts both forms.
New form:
and old form:
The supervisor spec would allow both formats, but the serialization is done to the old format to allow for backwards compatibility.
This PR has: