forked from apache/seatunnel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Improve][Zeta] when job finished, the checkpoint won't write to file (…
- Loading branch information
Showing
7 changed files
with
211 additions
and
60 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
118 changes: 118 additions & 0 deletions
118
...er/src/test/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointStorageTest.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,118 @@ | ||
/* | ||
* 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.seatunnel.engine.server.checkpoint; | ||
|
||
import org.apache.seatunnel.engine.checkpoint.storage.PipelineState; | ||
import org.apache.seatunnel.engine.checkpoint.storage.api.CheckpointStorage; | ||
import org.apache.seatunnel.engine.checkpoint.storage.api.CheckpointStorageFactory; | ||
import org.apache.seatunnel.engine.checkpoint.storage.exception.CheckpointStorageException; | ||
import org.apache.seatunnel.engine.common.config.SeaTunnelConfig; | ||
import org.apache.seatunnel.engine.common.config.server.CheckpointConfig; | ||
import org.apache.seatunnel.engine.common.utils.FactoryUtil; | ||
import org.apache.seatunnel.engine.core.job.JobStatus; | ||
import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.awaitility.Awaitility.await; | ||
|
||
@DisabledOnOs(OS.WINDOWS) | ||
public class CheckpointStorageTest extends AbstractSeaTunnelServerTest { | ||
|
||
public static String STREAM_CONF_PATH = "stream_fake_to_console_biginterval.conf"; | ||
public static String BATCH_CONF_PATH = "batch_fakesource_to_file.conf"; | ||
|
||
@Override | ||
public SeaTunnelConfig loadSeaTunnelConfig() { | ||
SeaTunnelConfig seaTunnelConfig = super.loadSeaTunnelConfig(); | ||
CheckpointConfig checkpointConfig = seaTunnelConfig.getEngineConfig().getCheckpointConfig(); | ||
// set a bigger interval in here and config file to avoid auto trigger checkpoint affect | ||
// test result | ||
checkpointConfig.setCheckpointInterval(Integer.MAX_VALUE); | ||
seaTunnelConfig.getEngineConfig().setCheckpointConfig(checkpointConfig); | ||
return seaTunnelConfig; | ||
} | ||
|
||
@Test | ||
public void testGenerateFileWhenSavepoint() | ||
throws CheckpointStorageException, InterruptedException { | ||
long jobId = System.currentTimeMillis(); | ||
CheckpointConfig checkpointConfig = | ||
server.getSeaTunnelConfig().getEngineConfig().getCheckpointConfig(); | ||
server.getSeaTunnelConfig().getEngineConfig().setCheckpointConfig(checkpointConfig); | ||
|
||
CheckpointStorage checkpointStorage = | ||
FactoryUtil.discoverFactory( | ||
Thread.currentThread().getContextClassLoader(), | ||
CheckpointStorageFactory.class, | ||
checkpointConfig.getStorage().getStorage()) | ||
.create(checkpointConfig.getStorage().getStoragePluginConfig()); | ||
startJob(jobId, STREAM_CONF_PATH, false); | ||
await().atMost(120000, TimeUnit.MILLISECONDS) | ||
.untilAsserted( | ||
() -> | ||
Assertions.assertTrue( | ||
server.getCoordinatorService() | ||
.getJobStatus(jobId) | ||
.equals(JobStatus.RUNNING))); | ||
Thread.sleep(1000); | ||
CompletableFuture<Void> future1 = | ||
server.getCoordinatorService().getJobMaster(jobId).savePoint(); | ||
future1.join(); | ||
await().atMost(120000, TimeUnit.MILLISECONDS) | ||
.untilAsserted( | ||
() -> | ||
Assertions.assertEquals( | ||
server.getCoordinatorService().getJobStatus(jobId), | ||
JobStatus.SAVEPOINT_DONE)); | ||
List<PipelineState> savepoint1 = checkpointStorage.getAllCheckpoints(String.valueOf(jobId)); | ||
Assertions.assertEquals(1, savepoint1.size()); | ||
} | ||
|
||
@Test | ||
public void testBatchJob() throws CheckpointStorageException { | ||
long jobId = System.currentTimeMillis(); | ||
CheckpointConfig checkpointConfig = | ||
server.getSeaTunnelConfig().getEngineConfig().getCheckpointConfig(); | ||
server.getSeaTunnelConfig().getEngineConfig().setCheckpointConfig(checkpointConfig); | ||
|
||
CheckpointStorage checkpointStorage = | ||
FactoryUtil.discoverFactory( | ||
Thread.currentThread().getContextClassLoader(), | ||
CheckpointStorageFactory.class, | ||
checkpointConfig.getStorage().getStorage()) | ||
.create(checkpointConfig.getStorage().getStoragePluginConfig()); | ||
startJob(jobId, BATCH_CONF_PATH, false); | ||
await().atMost(120000, TimeUnit.MILLISECONDS) | ||
.untilAsserted( | ||
() -> | ||
Assertions.assertEquals( | ||
server.getCoordinatorService().getJobStatus(jobId), | ||
JobStatus.FINISHED)); | ||
List<PipelineState> allCheckpoints = | ||
checkpointStorage.getAllCheckpoints(String.valueOf(jobId)); | ||
Assertions.assertEquals(0, allCheckpoints.size()); | ||
} | ||
} |
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
...engine/seatunnel-engine-server/src/test/resources/stream_fake_to_console_biginterval.conf
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. | ||
# | ||
###### | ||
###### This config file is a demonstration of streaming processing in SeaTunnel config | ||
###### | ||
|
||
env { | ||
# You can set SeaTunnel environment configuration here | ||
parallelism = 2 | ||
job.mode = "STREAMING" | ||
checkpoint.interval = 2147483640 | ||
} | ||
|
||
source { | ||
# This is a example source plugin **only for test and demonstrate the feature source plugin** | ||
FakeSource { | ||
parallelism = 2 | ||
result_table_name = "fake" | ||
row.num = 16 | ||
schema = { | ||
fields { | ||
name = "string" | ||
age = "int" | ||
} | ||
} | ||
} | ||
|
||
# If you would like to get more information about how to configure SeaTunnel and see full list of source plugins, | ||
# please go to https://seatunnel.apache.org/docs/category/source-v2 | ||
} | ||
|
||
sink { | ||
Console { | ||
} | ||
|
||
# If you would like to get more information about how to configure SeaTunnel and see full list of sink plugins, | ||
# please go to https://seatunnel.apache.org/docs/category/sink-v2 | ||
} |