org.apache.flink.runtime.state.RetrievableStreamStateHandle Java Examples

The following examples show how to use org.apache.flink.runtime.state.RetrievableStreamStateHandle. 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: FileSystemStateStorageHelper.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public RetrievableStateHandle<T> store(T state) throws Exception {
	Exception latestException = null;

	for (int attempt = 0; attempt < 10; attempt++) {
		Path filePath = getNewFilePath();

		try (FSDataOutputStream outStream = fs.create(filePath, FileSystem.WriteMode.NO_OVERWRITE)) {
			InstantiationUtil.serializeObject(outStream, state);
			return new RetrievableStreamStateHandle<T>(filePath, outStream.getPos());
		}
		catch (Exception e) {
			latestException = e;
		}
	}

	throw new Exception("Could not open output stream for state backend", latestException);
}
 
Example #2
Source File: FileSystemStateStorageHelper.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public RetrievableStateHandle<T> store(T state) throws Exception {
	Exception latestException = null;

	for (int attempt = 0; attempt < 10; attempt++) {
		Path filePath = getNewFilePath();

		try (FSDataOutputStream outStream = fs.create(filePath, FileSystem.WriteMode.NO_OVERWRITE)) {
			InstantiationUtil.serializeObject(outStream, state);
			return new RetrievableStreamStateHandle<T>(filePath, outStream.getPos());
		}
		catch (Exception e) {
			latestException = e;
		}
	}

	throw new Exception("Could not open output stream for state backend", latestException);
}
 
Example #3
Source File: FileSystemStateStorageHelper.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public RetrievableStateHandle<T> store(T state) throws Exception {
	Exception latestException = null;

	for (int attempt = 0; attempt < 10; attempt++) {
		Path filePath = getNewFilePath();

		try (FSDataOutputStream outStream = fs.create(filePath, FileSystem.WriteMode.NO_OVERWRITE)) {
			InstantiationUtil.serializeObject(outStream, state);
			return new RetrievableStreamStateHandle<T>(filePath, outStream.getPos());
		}
		catch (Exception e) {
			latestException = e;
		}
	}

	throw new Exception("Could not open output stream for state backend", latestException);
}
 
Example #4
Source File: ZooKeeperSubmittedJobGraphsStoreITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public RetrievableStateHandle<SubmittedJobGraph> store(SubmittedJobGraph state) throws IOException {
	ByteStreamStateHandle byteStreamStateHandle = new ByteStreamStateHandle(
			String.valueOf(UUID.randomUUID()),
			InstantiationUtil.serializeObject(state));
	return new RetrievableStreamStateHandle<>(byteStreamStateHandle);
}
 
Example #5
Source File: ZooKeeperSubmittedJobGraphsStoreITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public RetrievableStateHandle<SubmittedJobGraph> store(SubmittedJobGraph state) throws IOException {
	ByteStreamStateHandle byteStreamStateHandle = new ByteStreamStateHandle(
			String.valueOf(UUID.randomUUID()),
			InstantiationUtil.serializeObject(state));
	return new RetrievableStreamStateHandle<>(byteStreamStateHandle);
}