forked from apache/hudi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HUDI-3963] Use Lock-Free Message Queue Disruptor Improving Hoodie Wr…
…iting Efficiency (apache#5416) https://issues.apache.org/jira/browse/HUDI-3963 RFC design : apache#5567 Add Lock-Free executor to improve hoodie writing throughput and optimize execution efficiency. Disruptor linked: https://lmax-exchange.github.io/disruptor/user-guide/index.html#_introduction. Existing BoundedInMemory is the default. Users can enable on a need basis. Co-authored-by: yuezhang <yuezhang@freewheel.tv>
- Loading branch information
1 parent
ab1d14a
commit 75de5b8
Showing
34 changed files
with
1,631 additions
and
178 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
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
52 changes: 52 additions & 0 deletions
52
...lient/hudi-spark-client/src/main/java/org/apache/hudi/util/QueueBasedExecutorFactory.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,52 @@ | ||
/* | ||
* 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.hudi.util; | ||
|
||
import org.apache.hudi.common.util.queue.BoundedInMemoryExecutor; | ||
import org.apache.hudi.common.util.queue.DisruptorExecutor; | ||
import org.apache.hudi.common.util.queue.ExecutorType; | ||
import org.apache.hudi.common.util.queue.HoodieExecutor; | ||
import org.apache.hudi.common.util.queue.IteratorBasedQueueConsumer; | ||
import org.apache.hudi.config.HoodieWriteConfig; | ||
import org.apache.hudi.exception.HoodieException; | ||
|
||
import java.util.Iterator; | ||
import java.util.function.Function; | ||
|
||
public class QueueBasedExecutorFactory { | ||
|
||
/** | ||
* Create a new hoodie executor instance on demand. | ||
*/ | ||
public static <I, O, E> HoodieExecutor create(HoodieWriteConfig hoodieConfig, Iterator<I> inputItr, IteratorBasedQueueConsumer<O, E> consumer, | ||
Function<I, O> transformFunction, Runnable preExecuteRunnable) { | ||
ExecutorType executorType = hoodieConfig.getExecutorType(); | ||
|
||
switch (executorType) { | ||
case BOUNDED_IN_MEMORY: | ||
return new BoundedInMemoryExecutor<>(hoodieConfig.getWriteBufferLimitBytes(), inputItr, consumer, | ||
transformFunction, preExecuteRunnable); | ||
case DISRUPTOR: | ||
return new DisruptorExecutor<>(hoodieConfig.getDisruptorWriteBufferSize(), inputItr, consumer, | ||
transformFunction, hoodieConfig.getWriteExecutorWaitStrategy(), preExecuteRunnable); | ||
default: | ||
throw new HoodieException("Unsupported Executor Type " + executorType); | ||
} | ||
} | ||
} |
Oops, something went wrong.