Java Examples for org.sfs.rx.Defer

The following java examples will help you to understand the usage of org.sfs.rx.Defer. These source code samples are taken from different open source projects.

Example 1
Project: sfs-master  File: VolumeV1.java View source code
@Override
public Observable<TransientXVolume> volumeInfo(SfsVertx vertx) {
    Context context = vertx.getOrCreateContext();
    return Defer.aVoid().doOnNext( aVoid -> {
        checkStarted();
    }).flatMap( aVoid -> RxHelper.executeBlocking(context, vertx.getBackgroundPool(), () -> {
        try {
            FileStore fileStore = Files.getFileStore(basePath);
            long usableSpace = fileStore.getUsableSpace();
            long actualUsableSpace;
            try {
                actualUsableSpace = LongMath.checkedAdd(indexFileAllocator.getBytesFree(usableSpace), dataFileAllocator.getBytesFree(usableSpace));
            } catch (ArithmeticException e) {
                actualUsableSpace = usableSpace;
            }
            TransientXAllocatedFile indexFileInfo = new TransientXAllocatedFile().setFile(indexFilePath.toString()).setFileSizeBytes(Files.size(indexFilePath)).setBytesFree(indexFileAllocator.getBytesFree(usableSpace)).setFreeRangeCount(indexFileAllocator.getNumberOfFreeRanges()).setLockCount(indexFile.getLockCount()).setWriteQueueBytesPending(indexFile.getWriteQueueSize()).setWriteQueueBytesFull(indexFile.getWriteQueueMaxWrites()).setWriteQueueBytesDrained(indexFile.getWriteQueueLowWater());
            TransientXAllocatedFile dataFileInfo = new TransientXAllocatedFile().setFile(dataFilePath.toString()).setFileSizeBytes(Files.size(dataFilePath)).setBytesFree(dataFileAllocator.getBytesFree(usableSpace)).setFreeRangeCount(dataFileAllocator.getNumberOfFreeRanges()).setLockCount(blobFile.getLockCount()).setWriteQueueBytesPending(blobFile.getWriteQueueSize()).setWriteQueueBytesFull(blobFile.getWriteQueueMaxWrites()).setWriteQueueBytesDrained(blobFile.getWriteQueueLowWater());
            TransientXFileSystem fileSystemInfo = new TransientXFileSystem().setDevice(fileStore.name()).setPath(basePath.toString()).setTotalSpace(fileStore.getTotalSpace()).setUnallocatedSpace(fileStore.getUnallocatedSpace()).setUsableSpace(usableSpace).setType(fileStore.type()).setPartition(basePath.getRoot().toString());
            TransientXVolume volumeInfo = new TransientXVolume().setId(volumeId).setIndexFile(indexFileInfo).setDataFile(dataFileInfo).setFileSystem(fileSystemInfo).setUsableSpace(actualUsableSpace).setStatus(volumeState.get());
            return volumeInfo;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }));
}