-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MSQ worker: Support in-memory shuffles. (#16790)
* MSQ worker: Support in-memory shuffles. This patch is a follow-up to #16168, adding worker-side support for in-memory shuffles. Changes include: 1) Worker-side code now respects the same context parameter "maxConcurrentStages" that was added to the controller in #16168. The parameter remains undocumented for now, to give us a chance to more fully develop and test this functionality. 1) WorkerImpl is broken up into WorkerImpl, RunWorkOrder, and RunWorkOrderListener to improve readability. 2) WorkerImpl has a new StageOutputHolder + StageOutputReader concept, which abstract over memory-based or file-based stage results. 3) RunWorkOrder is updated to create in-memory stage output channels when instructed to. 4) ControllerResource is updated to add /doneReadingInput/, so the controller can tell when workers that sort, but do not gather statistics, are done reading their inputs. 5) WorkerMemoryParameters is updated to consider maxConcurrentStages. Additionally, WorkerChatHandler is split into WorkerResource, so as to match ControllerChatHandler and ControllerResource. * Updates for static checks, test coverage. * Fixes. * Remove exception. * Changes from review. * Address static check. * Changes from review. * Improvements to docs and method names. * Update comments, add test. * Additional javadocs. * Fix throws. * Fix worker stopping in tests. * Fix stuck test.
- Loading branch information
Showing
60 changed files
with
4,650 additions
and
2,131 deletions.
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
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
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
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
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); | ||
} | ||
} |
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
Oops, something went wrong.