-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HUDI-5042]fix clustering schedule problem in flink when enable sched…
…ule clustering and disable async clustering.
- Loading branch information
hbg
committed
Oct 20, 2022
1 parent
779a965
commit 89e7924
Showing
6 changed files
with
227 additions
and
21 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
121 changes: 121 additions & 0 deletions
121
.../src/test/java/org/apache/hudi/table/action/cluster/TestClusteringPlanActionExecutor.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,121 @@ | ||
/* | ||
* 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.table.action.cluster; | ||
|
||
import org.apache.hudi.common.engine.HoodieEngineContext; | ||
import org.apache.hudi.common.engine.HoodieLocalEngineContext; | ||
import org.apache.hudi.common.table.timeline.HoodieActiveTimeline; | ||
import org.apache.hudi.common.table.timeline.HoodieInstant; | ||
import org.apache.hudi.common.testutils.MockHoodieTimeline; | ||
import org.apache.hudi.common.util.Option; | ||
import org.apache.hudi.config.HoodieClusteringConfig; | ||
import org.apache.hudi.config.HoodieWriteConfig; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.apache.hudi.common.model.ActionType.commit; | ||
import static org.apache.hudi.common.model.ActionType.replacecommit; | ||
|
||
class TestClusteringPlanActionExecutor { | ||
@Test | ||
public void testDeltaCommitsClusteringPlanScheduling() { | ||
ClusteringPlanActionExecutor inlineExecutor = getClusteringPlanActionExecutor(true); | ||
ClusteringPlanActionExecutor notInlineExecutor = getClusteringPlanActionExecutor(false); | ||
|
||
List<HoodieInstant> instants = | ||
Arrays.asList( | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "1"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "2") | ||
); | ||
HoodieActiveTimeline activeTimeline = new MockHoodieTimeline(instants); | ||
Assertions.assertFalse(inlineExecutor.isScheduleClustering(activeTimeline), | ||
"Enable inline clustering, 2 delta commits, should not schedule clustering"); | ||
Assertions.assertFalse(notInlineExecutor.isScheduleClustering(activeTimeline), | ||
"Disable inline clustering, 2 delta commits, should not schedule clustering"); | ||
|
||
instants = | ||
Arrays.asList( | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "1"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "2"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "3") | ||
); | ||
activeTimeline = new MockHoodieTimeline(instants); | ||
Assertions.assertFalse(inlineExecutor.isScheduleClustering(activeTimeline), | ||
"Enable inline clustering, 3 delta commits, should not schedule clustering"); | ||
Assertions.assertTrue(notInlineExecutor.isScheduleClustering(activeTimeline), | ||
"Disable inline clustering, 3 delta commits, should schedule clustering"); | ||
|
||
instants = | ||
Arrays.asList( | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "1"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "2"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, replacecommit.name(), "3"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "4"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "5"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "6") | ||
); | ||
activeTimeline = new MockHoodieTimeline(instants); | ||
Assertions.assertFalse(inlineExecutor.isScheduleClustering(activeTimeline), | ||
"Enable inline clustering, 3 delta commits after replacecommit, should not schedule clustering"); | ||
Assertions.assertTrue(notInlineExecutor.isScheduleClustering(activeTimeline), | ||
"Disable inline clustering, 3 delta commits after replacecommit, should schedule clustering"); | ||
|
||
instants = | ||
Arrays.asList( | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "1"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "2"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "3"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "4"), | ||
new HoodieInstant(HoodieInstant.State.COMPLETED, commit.name(), "5") | ||
); | ||
activeTimeline = new MockHoodieTimeline(instants); | ||
Assertions.assertTrue(inlineExecutor.isScheduleClustering(activeTimeline), | ||
"Enable inline clustering, 5 delta commits, should schedule clustering"); | ||
Assertions.assertTrue(notInlineExecutor.isScheduleClustering(activeTimeline), | ||
"Disable inline clustering, 5 delta commits, should schedule clustering"); | ||
} | ||
|
||
private ClusteringPlanActionExecutor getClusteringPlanActionExecutor(boolean isInlineClustering) { | ||
HoodieEngineContext engineContext = new HoodieLocalEngineContext(new Configuration()); | ||
String instantTime = "4"; | ||
HoodieWriteConfig config = | ||
HoodieWriteConfig.newBuilder() | ||
.withPath("/db/tbl") | ||
.withClusteringConfig( | ||
HoodieClusteringConfig.newBuilder() | ||
.withAsyncClustering(false) | ||
.withInlineClustering(isInlineClustering) | ||
.withAsyncClusteringMaxCommits(3) | ||
.withInlineClusteringNumCommits(5) | ||
.build()) | ||
.build(); | ||
|
||
return new ClusteringPlanActionExecutor(engineContext, | ||
config, | ||
null, | ||
instantTime, | ||
Option.empty()); | ||
} | ||
} |
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