use of org.apache.flink.runtime.checkpoint.MasterState in project flink by apache.
the class MetadataV3SerializerTest method testCheckpointWithMasterAndTaskState.
private void testCheckpointWithMasterAndTaskState(String basePath) throws Exception {
final Random rnd = new Random();
final int maxNumMasterStates = 5;
final int maxTaskStates = 20;
final int maxNumSubtasks = 20;
for (int i = 0; i < 100; ++i) {
final long checkpointId = rnd.nextLong() & 0x7fffffffffffffffL;
final int numTasks = rnd.nextInt(maxTaskStates) + 1;
final int numSubtasks = rnd.nextInt(maxNumSubtasks) + 1;
final Collection<OperatorState> taskStates = CheckpointTestUtils.createOperatorStates(rnd, basePath, numTasks, 0, 0, numSubtasks);
final int numMasterStates = rnd.nextInt(maxNumMasterStates) + 1;
final Collection<MasterState> masterStates = CheckpointTestUtils.createRandomMasterStates(rnd, numMasterStates);
testCheckpointSerialization(checkpointId, taskStates, masterStates, basePath);
}
}
use of org.apache.flink.runtime.checkpoint.MasterState in project flink by apache.
the class CheckpointTestUtils method createRandomMasterStates.
/**
* Creates a bunch of random master states.
*/
public static Collection<MasterState> createRandomMasterStates(Random random, int num) {
final ArrayList<MasterState> states = new ArrayList<>(num);
for (int i = 0; i < num; i++) {
int version = random.nextInt(10);
String name = StringUtils.getRandomString(random, 5, 500);
byte[] bytes = new byte[random.nextInt(5000) + 1];
random.nextBytes(bytes);
states.add(new MasterState(name, bytes, version));
}
return states;
}
use of org.apache.flink.runtime.checkpoint.MasterState in project flink by apache.
the class MetadataV3SerializerTest method testCheckpointWithFinishedTasks.
private void testCheckpointWithFinishedTasks(String basePath) throws Exception {
final Random rnd = new Random();
final int maxNumMasterStates = 5;
final int maxNumSubtasks = 20;
final int maxAllRunningTaskStates = 20;
final int maxPartlyFinishedStates = 10;
final int maxFullyFinishedSubtasks = 10;
final long checkpointId = rnd.nextLong() & 0x7fffffffffffffffL;
final int numSubtasks = rnd.nextInt(maxNumSubtasks) + 1;
final int numAllRunningTasks = rnd.nextInt(maxAllRunningTaskStates) + 1;
final int numPartlyFinishedTasks = rnd.nextInt(maxPartlyFinishedStates) + 1;
final int numFullyFinishedTasks = rnd.nextInt(maxFullyFinishedSubtasks) + 1;
final Collection<OperatorState> taskStates = CheckpointTestUtils.createOperatorStates(rnd, basePath, numAllRunningTasks, numPartlyFinishedTasks, numFullyFinishedTasks, numSubtasks);
final int numMasterStates = rnd.nextInt(maxNumMasterStates) + 1;
final Collection<MasterState> masterStates = CheckpointTestUtils.createRandomMasterStates(rnd, numMasterStates);
testCheckpointSerialization(checkpointId, taskStates, masterStates, basePath);
}
Aggregations