-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
MSQ worker: Support in-memory shuffles. #16790
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
faacd2f
MSQ worker: Support in-memory shuffles.
gianm b6016a2
Updates for static checks, test coverage.
gianm b1445ff
Fixes.
gianm b22b30e
Remove exception.
gianm 4d8d1a0
Changes from review.
gianm aa3d3bf
Address static check.
gianm 11ea1aa
Changes from review.
gianm 61c337b
Improvements to docs and method names.
gianm 112bd71
Update comments, add test.
gianm 193be9e
Additional javadocs.
gianm f9f9321
Fix throws.
gianm ac49b8e
Fix worker stopping in tests.
gianm ff34ede
Fix stuck test.
gianm 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 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 |
---|---|---|
|
@@ -26,17 +26,21 @@ | |
import org.apache.druid.msq.statistics.PartialKeyStatisticsInformation; | ||
|
||
import javax.annotation.Nullable; | ||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* Client for the multi-stage query controller. Used by a Worker task. | ||
* Client for the multi-stage query controller. Used by a {@link Worker}. Each instance is specific to a single query, | ||
* meaning it communicates with a single controller. | ||
*/ | ||
public interface ControllerClient extends AutoCloseable | ||
public interface ControllerClient extends Closeable | ||
{ | ||
/** | ||
* Client side method to update the controller with partial key statistics information for a particular stage and worker. | ||
* Controller's implementation collates all the information for a stage to fetch key statistics from workers. | ||
* Client side method to update the controller with partial key statistics information for a particular stage | ||
* and worker. The controller collates all the information for a stage to fetch key statistics from workers. | ||
* | ||
* Only used when {@link StageDefinition#mustGatherResultKeyStatistics()}. | ||
*/ | ||
void postPartialKeyStatistics( | ||
StageId stageId, | ||
|
@@ -77,20 +81,21 @@ void postResultsComplete( | |
|
||
/** | ||
* Client side method to inform the controller that the error has occured in the given worker. | ||
* | ||
* @param queryId query ID, if this error is associated with a specific query | ||
* @param errorWrapper error details | ||
*/ | ||
void postWorkerError( | ||
String workerId, | ||
@Nullable String queryId, | ||
MSQErrorReport errorWrapper | ||
) throws IOException; | ||
|
||
/** | ||
* Client side method to inform the controller about the warnings generated by the given worker. | ||
*/ | ||
void postWorkerWarning( | ||
List<MSQErrorReport> MSQErrorReports | ||
) throws IOException; | ||
void postWorkerWarning(List<MSQErrorReport> MSQErrorReports) throws IOException; | ||
|
||
List<String> getTaskList() throws IOException; | ||
List<String> getWorkerIds() throws IOException; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: lets add javadoc here, even though it wasn't present in the original code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added javadoc. |
||
|
||
/** | ||
* Close this client. Idempotent. | ||
|
74 changes: 74 additions & 0 deletions
74
...ti-stage-query/src/main/java/org/apache/druid/msq/exec/ListeningOutputChannelFactory.java
This file contains 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,74 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.msq.exec; | ||
|
||
import org.apache.druid.frame.processor.OutputChannel; | ||
import org.apache.druid.frame.processor.OutputChannelFactory; | ||
import org.apache.druid.frame.processor.PartitionedOutputChannel; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Decorator for {@link OutputChannelFactory} that notifies a {@link Listener} whenever a channel is opened. | ||
*/ | ||
public class ListeningOutputChannelFactory implements OutputChannelFactory | ||
{ | ||
private final OutputChannelFactory delegate; | ||
private final Listener listener; | ||
|
||
public ListeningOutputChannelFactory(final OutputChannelFactory delegate, final Listener listener) | ||
{ | ||
this.delegate = delegate; | ||
this.listener = listener; | ||
} | ||
|
||
@Override | ||
public OutputChannel openChannel(final int partitionNumber) throws IOException | ||
{ | ||
return notifyListener(delegate.openChannel(partitionNumber)); | ||
} | ||
|
||
|
||
@Override | ||
public OutputChannel openNilChannel(final int partitionNumber) | ||
{ | ||
return notifyListener(delegate.openNilChannel(partitionNumber)); | ||
} | ||
|
||
@Override | ||
public PartitionedOutputChannel openPartitionedChannel( | ||
final String name, | ||
final boolean deleteAfterRead | ||
) | ||
{ | ||
throw new UnsupportedOperationException("Listening to partitioned channels is not supported"); | ||
} | ||
|
||
private OutputChannel notifyListener(OutputChannel channel) | ||
{ | ||
listener.channelOpened(channel); | ||
return channel; | ||
} | ||
|
||
public interface Listener | ||
{ | ||
void channelOpened(OutputChannel channel); | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the places where this is called, we pass it the worker's task id. Should we keep the parameter name as is? Also, I was taking a look at the controller chat handler and we don't really use the worker's task id afaict. Maybe we can remove the param altogether, though that would introduce backward compatibility issues.
Also, can it be nullable given that we pass this as a URL param?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I don't actually need to change this from
workerId
toqueryId
right now. This was related to some other stuff I was tinkering with, about supporting multiple queries running on the same worker id, but it isn't important for this PR. I'll revert it.Fwiw, the server side (
ControllerResource
) does not read this parameter, so it currently doesn't matter what it is. That's probably why I didn't notice the inconsistency when testing this PR.