org.apache.flink.util.ResourceGuard.Lease Java Examples

The following examples show how to use org.apache.flink.util.ResourceGuard.Lease. 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: Loggers.java    From stateful-functions with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("resource")
public Closeable acquireLease(OutputStream stream) {
  Preconditions.checkState(stream instanceof KeyedStateCheckpointOutputStream);
  try {
    Lease lease = cast(stream).acquireLease();
    return lease::close;
  } catch (IOException e) {
    throw new IllegalStateException("Unable to obtain a lease for the input stream.", e);
  }
}
 
Example #2
Source File: Loggers.java    From flink-statefun with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("resource")
public Closeable acquireLease(OutputStream stream) {
  Preconditions.checkState(stream instanceof KeyedStateCheckpointOutputStream);
  try {
    Lease lease = cast(stream).acquireLease();
    return lease::close;
  } catch (IOException e) {
    throw new IllegalStateException("Unable to obtain a lease for the input stream.", e);
  }
}
 
Example #3
Source File: NonClosingCheckpointOutputStream.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a {@link org.apache.flink.util.ResourceGuard.Lease} that prevents closing this stream. To allow the system
 * to close this stream, each of the acquired leases need to call {@link Lease#close()}, on their acquired leases.
 */
public final ResourceGuard.Lease acquireLease() throws IOException {
	return resourceGuard.acquireResource();
}
 
Example #4
Source File: NonClosingCheckpointOutputStream.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a {@link org.apache.flink.util.ResourceGuard.Lease} that prevents closing this stream. To allow the system
 * to close this stream, each of the acquired leases need to call {@link Lease#close()}, on their acquired leases.
 */
public final ResourceGuard.Lease acquireLease() throws IOException {
	return resourceGuard.acquireResource();
}