Java Code Examples for org.apache.flink.runtime.state.CheckpointStorageLocationReference#getDefault()

The following examples show how to use org.apache.flink.runtime.state.CheckpointStorageLocationReference#getDefault() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FsCheckpointStorage.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public CheckpointStorageLocation initializeLocationForCheckpoint(long checkpointId) throws IOException {
	checkArgument(checkpointId >= 0);

	// prepare all the paths needed for the checkpoints
	final Path checkpointDir = createCheckpointDirectory(checkpointsDirectory, checkpointId);

	// create the checkpoint exclusive directory
	fileSystem.mkdirs(checkpointDir);

	return new FsCheckpointStorageLocation(
			fileSystem,
			checkpointDir,
			sharedStateDirectory,
			taskOwnedStateDirectory,
			CheckpointStorageLocationReference.getDefault(),
			fileSizeThreshold);
}
 
Example 2
Source File: SubtaskCheckpointCoordinatorTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private boolean initCheckpoint(boolean unalignedCheckpointEnabled, CheckpointType checkpointType) throws IOException {
	class MockWriter extends ChannelStateWriterImpl.NoOpChannelStateWriter {
		private boolean started;
		@Override
		public void start(long checkpointId, CheckpointOptions checkpointOptions) {
			started = true;
		}
	}

	MockWriter writer = new MockWriter();
	SubtaskCheckpointCoordinator coordinator = coordinator(unalignedCheckpointEnabled, writer);
	CheckpointStorageLocationReference locationReference = CheckpointStorageLocationReference.getDefault();
	CheckpointOptions options = new CheckpointOptions(checkpointType, locationReference, true, unalignedCheckpointEnabled);
	coordinator.initCheckpoint(1L, options);
	return writer.started;
}
 
Example 3
Source File: PendingCheckpointTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private PendingCheckpoint createPendingCheckpoint(CheckpointProperties props, Executor executor) throws IOException {

		final Path checkpointDir = new Path(tmpFolder.newFolder().toURI());
		final FsCheckpointStorageLocation location = new FsCheckpointStorageLocation(
				LocalFileSystem.getSharedInstance(),
				checkpointDir, checkpointDir, checkpointDir,
				CheckpointStorageLocationReference.getDefault(),
				1024);

		final Map<ExecutionAttemptID, ExecutionVertex> ackTasks = new HashMap<>(ACK_TASKS);

		return new PendingCheckpoint(
			new JobID(),
			0,
			1,
			ackTasks,
			props,
			location,
			executor);
	}
 
Example 4
Source File: FsCheckpointStorage.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CheckpointStorageLocation initializeLocationForCheckpoint(long checkpointId) throws IOException {
	checkArgument(checkpointId >= 0);

	// prepare all the paths needed for the checkpoints
	final Path checkpointDir = createCheckpointDirectory(checkpointsDirectory, checkpointId);

	// create the checkpoint exclusive directory
	fileSystem.mkdirs(checkpointDir);

	return new FsCheckpointStorageLocation(
			fileSystem,
			checkpointDir,
			sharedStateDirectory,
			taskOwnedStateDirectory,
			CheckpointStorageLocationReference.getDefault(),
			fileSizeThreshold,
			writeBufferSize);
}
 
Example 5
Source File: PendingCheckpointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private PendingCheckpoint createPendingCheckpoint(CheckpointProperties props, Executor executor) throws IOException {

		final Path checkpointDir = new Path(tmpFolder.newFolder().toURI());
		final FsCheckpointStorageLocation location = new FsCheckpointStorageLocation(
				LocalFileSystem.getSharedInstance(),
				checkpointDir, checkpointDir, checkpointDir,
				CheckpointStorageLocationReference.getDefault(),
				1024,
				4096);

		final Map<ExecutionAttemptID, ExecutionVertex> ackTasks = new HashMap<>(ACK_TASKS);

		return new PendingCheckpoint(
			new JobID(),
			0,
			1,
			ackTasks,
			props,
			location,
			executor);
	}
 
Example 6
Source File: FsCheckpointStorage.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CheckpointStorageLocation initializeLocationForCheckpoint(long checkpointId) throws IOException {
	checkArgument(checkpointId >= 0, "Illegal negative checkpoint id: %d.", checkpointId);
	checkArgument(baseLocationsInitialized, "The base checkpoint location has not been initialized.");

	// prepare all the paths needed for the checkpoints
	final Path checkpointDir = createCheckpointDirectory(checkpointsDirectory, checkpointId);

	// create the checkpoint exclusive directory
	fileSystem.mkdirs(checkpointDir);

	return new FsCheckpointStorageLocation(
			fileSystem,
			checkpointDir,
			sharedStateDirectory,
			taskOwnedStateDirectory,
			CheckpointStorageLocationReference.getDefault(),
			fileSizeThreshold,
			writeBufferSize);
}
 
Example 7
Source File: SylphFsCheckpointStorage.java    From sylph with Apache License 2.0 6 votes vote down vote up
@Override
public CheckpointStorageLocation initializeLocationForCheckpoint(long checkpointId)
        throws IOException
{
    checkArgument(checkpointId >= 0);

    // prepare all the paths needed for the checkpoints
    final Path checkpointDir = createCheckpointDirectory(checkpointsDirectory, checkpointId);

    // create the checkpoint exclusive directory
    fileSystem.mkdirs(checkpointDir);

    return new FsCheckpointStorageLocation(
            fileSystem,
            checkpointDir,
            sharedStateDirectory,
            taskOwnedStateDirectory,
            CheckpointStorageLocationReference.getDefault(),
            fileSizeThreshold,
            writeBufferSize);
}
 
Example 8
Source File: LocalInputChannelTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoNotifyOnSavepoint() throws IOException {
	TestBufferReceivedListener listener = new TestBufferReceivedListener();
	SingleInputGate inputGate = new SingleInputGateBuilder().build();
	inputGate.registerBufferReceivedListener(listener);
	LocalInputChannel channel = InputChannelBuilder.newBuilder().buildLocalChannel(inputGate);
	CheckpointBarrier barrier = new CheckpointBarrier(123L, 123L, new CheckpointOptions(SAVEPOINT, CheckpointStorageLocationReference.getDefault()));
	channel.notifyPriorityEvent(new BufferConsumer(toBuffer(barrier).getMemorySegment(), FreeingBufferRecycler.INSTANCE, getDataType(barrier)));
	channel.checkError();
	assertTrue(listener.notifiedOnBarriers.isEmpty());
}
 
Example 9
Source File: CheckpointOptionsTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckpointNeedsAlignment() {
	CheckpointStorageLocationReference location = CheckpointStorageLocationReference.getDefault();
	assertFalse(new CheckpointOptions(CHECKPOINT, location, true, true).needsAlignment());
	assertTrue(new CheckpointOptions(CHECKPOINT, location, true, false).needsAlignment());
	assertFalse(new CheckpointOptions(CHECKPOINT, location, false, true).needsAlignment());
	assertFalse(new CheckpointOptions(CHECKPOINT, location, false, false).needsAlignment());
}
 
Example 10
Source File: CheckpointOptionsTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testSavepointNeedsAlignment() {
	CheckpointStorageLocationReference location = CheckpointStorageLocationReference.getDefault();
	assertTrue(new CheckpointOptions(SAVEPOINT, location, true, true).needsAlignment());
	assertFalse(new CheckpointOptions(SAVEPOINT, location, false, true).needsAlignment());
	assertTrue(new CheckpointOptions(SAVEPOINT, location, true, false).needsAlignment());
	assertFalse(new CheckpointOptions(SAVEPOINT, location, false, false).needsAlignment());
}
 
Example 11
Source File: PendingCheckpointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private PendingCheckpoint createPendingCheckpoint(
		CheckpointProperties props,
		Collection<OperatorID> operatorCoordinators,
		Collection<String> masterStateIdentifiers,
		Executor executor) throws IOException {

	final Path checkpointDir = new Path(tmpFolder.newFolder().toURI());
	final FsCheckpointStorageLocation location = new FsCheckpointStorageLocation(
			LocalFileSystem.getSharedInstance(),
			checkpointDir, checkpointDir, checkpointDir,
			CheckpointStorageLocationReference.getDefault(),
			1024,
			4096);

	final Map<ExecutionAttemptID, ExecutionVertex> ackTasks = new HashMap<>(ACK_TASKS);

	return new PendingCheckpoint(
		new JobID(),
		0,
		1,
		ackTasks,
		operatorCoordinators,
		masterStateIdentifiers,
		props,
		location,
		executor,
		new CompletableFuture<>());
}
 
Example 12
Source File: CheckpointOptions.java    From flink with Apache License 2.0 5 votes vote down vote up
public static CheckpointOptions forCheckpointWithDefaultLocation(
		boolean isExactlyOnceMode,
		boolean isUnalignedCheckpoint) {
	return new CheckpointOptions(
		CheckpointType.CHECKPOINT,
		CheckpointStorageLocationReference.getDefault(),
		isExactlyOnceMode,
		isUnalignedCheckpoint);
}
 
Example 13
Source File: FsCheckpointStorageTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testDirectoriesForExclusiveAndSharedState() throws Exception {
	final FileSystem fs = LocalFileSystem.getSharedInstance();
	final Path checkpointDir = randomTempPath();
	final Path sharedStateDir = randomTempPath();

	FsCheckpointStorageLocation storageLocation = new FsCheckpointStorageLocation(
			fs,
			checkpointDir,
			sharedStateDir,
			randomTempPath(),
			CheckpointStorageLocationReference.getDefault(),
			FILE_SIZE_THRESHOLD,
			WRITE_BUFFER_SIZE);

	assertNotEquals(storageLocation.getCheckpointDirectory(), storageLocation.getSharedStateDirectory());

	assertEquals(0, fs.listStatus(storageLocation.getCheckpointDirectory()).length);
	assertEquals(0, fs.listStatus(storageLocation.getSharedStateDirectory()).length);

	// create exclusive state

	CheckpointStateOutputStream exclusiveStream =
			storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.EXCLUSIVE);

	exclusiveStream.write(42);
	exclusiveStream.flush();
	StreamStateHandle exclusiveHandle = exclusiveStream.closeAndGetHandle();

	assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length);
	assertEquals(0, fs.listStatus(storageLocation.getSharedStateDirectory()).length);

	// create shared state

	CheckpointStateOutputStream sharedStream =
			storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.SHARED);

	sharedStream.write(42);
	sharedStream.flush();
	StreamStateHandle sharedHandle = sharedStream.closeAndGetHandle();

	assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length);
	assertEquals(1, fs.listStatus(storageLocation.getSharedStateDirectory()).length);

	// drop state

	exclusiveHandle.discardState();
	sharedHandle.discardState();
}
 
Example 14
Source File: PersistentMetadataCheckpointStorageLocation.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public CheckpointStorageLocationReference getLocationReference() {
	return CheckpointStorageLocationReference.getDefault();
}
 
Example 15
Source File: NonPersistentMetadataCheckpointStorageLocation.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public CheckpointStorageLocationReference getLocationReference() {
	return CheckpointStorageLocationReference.getDefault();
}
 
Example 16
Source File: NonPersistentMetadataCheckpointStorageLocation.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public CheckpointStorageLocationReference getLocationReference() {
	return CheckpointStorageLocationReference.getDefault();
}
 
Example 17
Source File: PersistentMetadataCheckpointStorageLocation.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public CheckpointStorageLocationReference getLocationReference() {
	return CheckpointStorageLocationReference.getDefault();
}
 
Example 18
Source File: FsCheckpointStorageTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testDirectoriesForExclusiveAndSharedState() throws Exception {
	final FileSystem fs = LocalFileSystem.getSharedInstance();
	final Path checkpointDir = randomTempPath();
	final Path sharedStateDir = randomTempPath();

	FsCheckpointStorageLocation storageLocation = new FsCheckpointStorageLocation(
			fs,
			checkpointDir,
			sharedStateDir,
			randomTempPath(),
			CheckpointStorageLocationReference.getDefault(),
			FILE_SIZE_THRESHOLD);

	assertNotEquals(storageLocation.getCheckpointDirectory(), storageLocation.getSharedStateDirectory());

	assertEquals(0, fs.listStatus(storageLocation.getCheckpointDirectory()).length);
	assertEquals(0, fs.listStatus(storageLocation.getSharedStateDirectory()).length);

	// create exclusive state

	CheckpointStateOutputStream exclusiveStream =
			storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.EXCLUSIVE);

	exclusiveStream.write(42);
	exclusiveStream.flush();
	StreamStateHandle exclusiveHandle = exclusiveStream.closeAndGetHandle();

	assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length);
	assertEquals(0, fs.listStatus(storageLocation.getSharedStateDirectory()).length);

	// create shared state

	CheckpointStateOutputStream sharedStream =
			storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.SHARED);

	sharedStream.write(42);
	sharedStream.flush();
	StreamStateHandle sharedHandle = sharedStream.closeAndGetHandle();

	assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length);
	assertEquals(1, fs.listStatus(storageLocation.getSharedStateDirectory()).length);

	// drop state

	exclusiveHandle.discardState();
	sharedHandle.discardState();
}
 
Example 19
Source File: FsCheckpointStorageTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testDirectoriesForExclusiveAndSharedState() throws Exception {
	final FileSystem fs = LocalFileSystem.getSharedInstance();
	final Path checkpointDir = randomTempPath();
	final Path sharedStateDir = randomTempPath();

	FsCheckpointStorageLocation storageLocation = new FsCheckpointStorageLocation(
			fs,
			checkpointDir,
			sharedStateDir,
			randomTempPath(),
			CheckpointStorageLocationReference.getDefault(),
			FILE_SIZE_THRESHOLD,
			WRITE_BUFFER_SIZE);

	assertNotEquals(storageLocation.getCheckpointDirectory(), storageLocation.getSharedStateDirectory());

	assertEquals(0, fs.listStatus(storageLocation.getCheckpointDirectory()).length);
	assertEquals(0, fs.listStatus(storageLocation.getSharedStateDirectory()).length);

	// create exclusive state

	FsCheckpointStateOutputStream exclusiveStream =
			storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.EXCLUSIVE);

	exclusiveStream.write(42);
	exclusiveStream.flushToFile();
	StreamStateHandle exclusiveHandle = exclusiveStream.closeAndGetHandle();

	assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length);
	assertEquals(0, fs.listStatus(storageLocation.getSharedStateDirectory()).length);

	// create shared state

	FsCheckpointStateOutputStream sharedStream =
			storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.SHARED);

	sharedStream.write(42);
	sharedStream.flushToFile();
	StreamStateHandle sharedHandle = sharedStream.closeAndGetHandle();

	assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length);
	assertEquals(1, fs.listStatus(storageLocation.getSharedStateDirectory()).length);

	// drop state

	exclusiveHandle.discardState();
	sharedHandle.discardState();
}
 
Example 20
Source File: PersistentMetadataCheckpointStorageLocation.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public CheckpointStorageLocationReference getLocationReference() {
	return CheckpointStorageLocationReference.getDefault();
}