use of org.apache.ratis.util.function.CheckedConsumer in project incubator-ratis by apache.
the class DataStreamClusterTests method transferToWritableByteChannel.
static CheckedConsumer<DataStreamOutputImpl, Exception> transferToWritableByteChannel(File f, int size) {
return new CheckedConsumer<DataStreamOutputImpl, Exception>() {
@Override
public void accept(DataStreamOutputImpl out) throws Exception {
try (FileInputStream in = new FileInputStream(f)) {
final long transferred = in.getChannel().transferTo(0, size, out.getWritableByteChannel());
Assert.assertEquals(size, transferred);
}
}
@Override
public String toString() {
return "transferToWritableByteChannel";
}
};
}
use of org.apache.ratis.util.function.CheckedConsumer in project incubator-ratis by apache.
the class DataStreamClusterTests method writeAsyncDefaultFileRegion.
static CheckedConsumer<DataStreamOutputImpl, Exception> writeAsyncDefaultFileRegion(File f, int size) {
return new CheckedConsumer<DataStreamOutputImpl, Exception>() {
@Override
public void accept(DataStreamOutputImpl out) {
final DataStreamReply dataStreamReply = out.writeAsync(f).join();
DataStreamTestUtils.assertSuccessReply(Type.STREAM_DATA, size, dataStreamReply);
}
@Override
public String toString() {
return "writeAsyncDefaultFileRegion";
}
};
}
Aggregations