本文整理汇总了Java中org.apache.flink.api.common.restartstrategy.RestartStrategies.RestartStrategyConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java RestartStrategies.RestartStrategyConfiguration方法的具体用法?Java RestartStrategies.RestartStrategyConfiguration怎么用?Java RestartStrategies.RestartStrategyConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.common.restartstrategy.RestartStrategies
的用法示例。
在下文中一共展示了RestartStrategies.RestartStrategyConfiguration方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRestartStrategy
import org.apache.flink.api.common.restartstrategy.RestartStrategies; //导入方法依赖的package包/类
/**
* Returns the restart strategy which has been set for the current job.
*
* @return The specified restart configuration
*/
@PublicEvolving
@SuppressWarnings("deprecation")
public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() {
if (restartStrategyConfiguration == null) {
// support the old API calls by creating a restart strategy from them
if (getNumberOfExecutionRetries() > 0 && getExecutionRetryDelay() >= 0) {
return RestartStrategies.fixedDelayRestart(getNumberOfExecutionRetries(), getExecutionRetryDelay());
} else if (getNumberOfExecutionRetries() == 0) {
return RestartStrategies.noRestart();
} else {
return null;
}
} else {
return restartStrategyConfiguration;
}
}
示例2: createRestartStrategy
import org.apache.flink.api.common.restartstrategy.RestartStrategies; //导入方法依赖的package包/类
/**
* Creates a {@link RestartStrategy} instance from the given {@link org.apache.flink.api.common.restartstrategy.RestartStrategies.RestartStrategyConfiguration}.
*
* @param restartStrategyConfiguration Restart strategy configuration which specifies which
* restart strategy to instantiate
* @return RestartStrategy instance
*/
public static RestartStrategy createRestartStrategy(RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration) {
if (restartStrategyConfiguration instanceof RestartStrategies.NoRestartStrategyConfiguration) {
return new NoRestartStrategy();
} else if (restartStrategyConfiguration instanceof RestartStrategies.FixedDelayRestartStrategyConfiguration) {
RestartStrategies.FixedDelayRestartStrategyConfiguration fixedDelayConfig =
(RestartStrategies.FixedDelayRestartStrategyConfiguration) restartStrategyConfiguration;
return new FixedDelayRestartStrategy(
fixedDelayConfig.getRestartAttempts(),
fixedDelayConfig.getDelayBetweenAttemptsInterval().toMilliseconds());
} else if (restartStrategyConfiguration instanceof RestartStrategies.FailureRateRestartStrategyConfiguration) {
RestartStrategies.FailureRateRestartStrategyConfiguration config =
(RestartStrategies.FailureRateRestartStrategyConfiguration) restartStrategyConfiguration;
return new FailureRateRestartStrategy(
config.getMaxFailureRate(),
config.getFailureInterval(),
config.getDelayBetweenAttemptsInterval()
);
} else if (restartStrategyConfiguration instanceof RestartStrategies.FallbackRestartStrategyConfiguration) {
return null;
} else {
throw new IllegalArgumentException("Unknown restart strategy configuration " +
restartStrategyConfiguration + ".");
}
}
示例3: testAutomaticRestartingWhenCheckpointing
import org.apache.flink.api.common.restartstrategy.RestartStrategies; //导入方法依赖的package包/类
/**
* Tests that in a streaming use case where checkpointing is enabled, a
* fixed delay with Integer.MAX_VALUE retries is instantiated if no other restart
* strategy has been specified.
*/
@Test
public void testAutomaticRestartingWhenCheckpointing() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.enableCheckpointing(500);
env.fromElements(1).print();
StreamGraph graph = env.getStreamGraph();
JobGraph jobGraph = graph.getJobGraph();
RestartStrategies.RestartStrategyConfiguration restartStrategy =
jobGraph.getSerializedExecutionConfig().deserializeValue(getClass().getClassLoader()).getRestartStrategy();
Assert.assertNotNull(restartStrategy);
Assert.assertTrue(restartStrategy instanceof RestartStrategies.FixedDelayRestartStrategyConfiguration);
Assert.assertEquals(Integer.MAX_VALUE, ((RestartStrategies.FixedDelayRestartStrategyConfiguration) restartStrategy).getRestartAttempts());
}
示例4: testNoRestartingWhenCheckpointingAndExplicitExecutionRetriesZero
import org.apache.flink.api.common.restartstrategy.RestartStrategies; //导入方法依赖的package包/类
/**
* Checks that in a streaming use case where checkpointing is enabled and the number
* of execution retries is set to 0, restarting is deactivated.
*/
@Test
public void testNoRestartingWhenCheckpointingAndExplicitExecutionRetriesZero() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.enableCheckpointing(500);
env.setNumberOfExecutionRetries(0);
env.fromElements(1).print();
StreamGraph graph = env.getStreamGraph();
JobGraph jobGraph = graph.getJobGraph();
RestartStrategies.RestartStrategyConfiguration restartStrategy =
jobGraph.getSerializedExecutionConfig().deserializeValue(getClass().getClassLoader()).getRestartStrategy();
Assert.assertNotNull(restartStrategy);
Assert.assertTrue(restartStrategy instanceof RestartStrategies.NoRestartStrategyConfiguration);
}
示例5: testFixedRestartingWhenCheckpointingAndExplicitExecutionRetriesNonZero
import org.apache.flink.api.common.restartstrategy.RestartStrategies; //导入方法依赖的package包/类
/**
* Checks that in a streaming use case where checkpointing is enabled and the number
* of execution retries is set to 42 and the delay to 1337, fixed delay restarting is used.
*/
@Test
public void testFixedRestartingWhenCheckpointingAndExplicitExecutionRetriesNonZero() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.enableCheckpointing(500);
env.setNumberOfExecutionRetries(42);
env.getConfig().setExecutionRetryDelay(1337);
env.fromElements(1).print();
StreamGraph graph = env.getStreamGraph();
JobGraph jobGraph = graph.getJobGraph();
RestartStrategies.RestartStrategyConfiguration restartStrategy =
jobGraph.getSerializedExecutionConfig().deserializeValue(getClass().getClassLoader()).getRestartStrategy();
Assert.assertNotNull(restartStrategy);
Assert.assertTrue(restartStrategy instanceof RestartStrategies.FixedDelayRestartStrategyConfiguration);
Assert.assertEquals(42, ((RestartStrategies.FixedDelayRestartStrategyConfiguration) restartStrategy).getRestartAttempts());
Assert.assertEquals(1337, ((RestartStrategies.FixedDelayRestartStrategyConfiguration) restartStrategy).getDelayBetweenAttemptsInterval().toMilliseconds());
}
示例6: setRestartStrategy
import org.apache.flink.api.common.restartstrategy.RestartStrategies; //导入方法依赖的package包/类
/**
* Sets the restart strategy configuration. The configuration specifies which restart strategy
* will be used for the execution graph in case of a restart.
*
* @param restartStrategyConfiguration Restart strategy configuration to be set
*/
@PublicEvolving
public void setRestartStrategy(RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration) {
config.setRestartStrategy(restartStrategyConfiguration);
}
示例7: getRestartStrategy
import org.apache.flink.api.common.restartstrategy.RestartStrategies; //导入方法依赖的package包/类
/**
* Returns the specified restart strategy configuration.
*
* @return The restart strategy configuration to be used
*/
@PublicEvolving
public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() {
return config.getRestartStrategy();
}
示例8: setRestartStrategy
import org.apache.flink.api.common.restartstrategy.RestartStrategies; //导入方法依赖的package包/类
/**
* Sets the restart strategy to be used for recovery.
*
* <pre>{@code
* ExecutionConfig config = env.getConfig();
*
* config.setRestartStrategy(RestartStrategies.fixedDelayRestart(
* 10, // number of retries
* 1000 // delay between retries));
* }</pre>
*
* @param restartStrategyConfiguration Configuration defining the restart strategy to use
*/
@PublicEvolving
public void setRestartStrategy(RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration) {
this.restartStrategyConfiguration = restartStrategyConfiguration;
}