Refine search
public FileSystemProps perform() { try { Path target = vertx.resolveFile(path).toPath(); FileStore fs = Files.getFileStore(target); return new FileSystemPropsImpl(fs.getTotalSpace(), fs.getUnallocatedSpace(), fs.getUsableSpace()); } catch (IOException e) { throw new FileSystemException(e); } } };
FileStore fileStore = Files.getFileStore( pathOnDevice ); String name = fileStore.name(); if ( name.equals( "tmpfs" ) || name.equals( "hugetlbfs" ) ) if ( Files.exists( rotational ) ) if ( Files.exists( rotational ) )
/** * Get the file store type of a path. for example, /dev/sdd1(store name) /w2-gst-dev40d(mount * point) ext4(type) * * @return file store type */ public String getFileStoreType(final String path) { File diskFile = new File(path); if (!diskFile.exists()) { diskFile = diskFile.getParentFile(); } Path currentPath = diskFile.toPath(); if (currentPath.isAbsolute() && Files.exists(currentPath)) { try { FileStore store = Files.getFileStore(currentPath); return store.type(); } catch (IOException e) { return null; } } return null; }
private boolean hasEnoughDiskSpace(Path path) { try { FileStore fileStore = getFileStore(path); return fileStore.getUsableSpace() > fileStore.getTotalSpace() * (1.0 - maxUsedSpaceThreshold); } catch (IOException e) { throw new PrestoException(OUT_OF_SPILL_SPACE, "Cannot determine free space for spill", e); } } }
NumberFormat nf = NumberFormat.getNumberInstance(); for (Path root : FileSystems.getDefault().getRootDirectories()) { System.out.print(root + ": "); try { FileStore store = Files.getFileStore(root); System.out.println("available=" + nf.format(store.getUsableSpace()) + ", total=" + nf.format(store.getTotalSpace())); } catch (IOException e) { System.out.println("error querying space: " + e.toString()); } }
if ("tmpfs".equals(store.type())) { return false; String devName = store.name(); Path devsysinfo = null; int matchlen = 0; try (DirectoryStream<Path> stream = Files.newDirectoryStream(sysinfo)) { for (Path device : stream) { String name = device.getFileName().toString(); try (InputStream stream = Files.newInputStream(rotational)) { return stream.read() == '1';
@Test @Category( { FileStores.class, Exclusive.class, Writable.class } ) public void testPathFileStoreGrowingFileLowersUsableSpace() throws IOException { Path file = fileTA(); FileStore store = FS.provider().getFileStore( file ); long before = store.getUnallocatedSpace(); for ( int i = 0; i < 10; i++ ) { Files.write( file, CONTENT_BIG_TXT, StandardOpenOption.APPEND ); } assertThat( store.getUsableSpace()).isLessThanOrEqualTo( before ); }
@Test @Category( { FileStores.class, Exclusive.class, Writable.class } ) public void testPathFileStoreGrowingFileLowersUnallocatedSpace() throws IOException { Path file = fileTA(); FileStore store = FS.provider().getFileStore( file ); long before = store.getUnallocatedSpace(); Files.write( file, CONTENT50 ); assertThat( store.getUnallocatedSpace()).isLessThanOrEqualTo( before ); }
protected Map<String, String> getAttributesFromFile(final Path file) { Map<String, String> attributes = new HashMap<>(); try { FileStore store = Files.getFileStore(file); if (store.supportsFileAttributeView("basic")) { try { final DateFormat formatter = new SimpleDateFormat(FILE_MODIFY_DATE_ATTR_FORMAT, Locale.US); BasicFileAttributeView view = Files.getFileAttributeView(file, BasicFileAttributeView.class); BasicFileAttributes attrs = view.readAttributes(); attributes.put(FILE_LAST_MODIFY_TIME_ATTRIBUTE, formatter.format(new Date(attrs.lastModifiedTime().toMillis()))); if (store.supportsFileAttributeView("owner")) { try { FileOwnerAttributeView view = Files.getFileAttributeView(file, FileOwnerAttributeView.class); attributes.put(FILE_OWNER_ATTRIBUTE, view.getOwner().getName()); } catch (Exception ignore) { if (store.supportsFileAttributeView("posix")) { try { PosixFileAttributeView view = Files.getFileAttributeView(file, PosixFileAttributeView.class);
public static FsInfo.Path getFSInfo(NodePath nodePath) throws IOException { FsInfo.Path fsPath = new FsInfo.Path(); fsPath.path = nodePath.path.toAbsolutePath().toString(); // NOTE: we use already cached (on node startup) FileStore and spins // since recomputing these once per second (default) could be costly, // and they should not change: fsPath.total = adjustForHugeFilesystems(nodePath.fileStore.getTotalSpace()); fsPath.free = adjustForHugeFilesystems(nodePath.fileStore.getUnallocatedSpace()); fsPath.available = adjustForHugeFilesystems(nodePath.fileStore.getUsableSpace()); fsPath.type = nodePath.fileStore.type(); fsPath.mount = nodePath.fileStore.toString(); return fsPath; }
@Override public String getContainerFileStoreName(final String containerName) { final Path path = containers.get(containerName); try { return Files.getFileStore(path).name(); } catch (IOException e) { return null; } }
@Override public long getUsableStorageSpace() throws IOException { long usableSpace = 0L; for (final File file : flowFileRepositoryPaths) { usableSpace += Files.getFileStore(file.toPath()).getUsableSpace(); } return usableSpace; }
public SpaceAvailableExtensionInfo(FileStore store) throws IOException { bytesOnDevice = store.getTotalSpace(); long unallocated = store.getUnallocatedSpace(); long usable = store.getUsableSpace(); unusedBytesOnDevice = Math.max(unallocated, usable); // the rest are intentionally left zero indicating "UNKNOWN" }
@Override public long getStorageCapacity() throws IOException { long capacity = 0L; for (final File file : flowFileRepositoryPaths) { capacity += Files.getFileStore(file.toPath()).getTotalSpace(); } return capacity; }
final Path absolutePath = file1.toPath().toAbsolutePath(); final String absolutePathString = absolutePath.getParent().toString() + File.separator; final FileStore store = Files.getFileStore(file1Path); final DateFormat formatter = new SimpleDateFormat(ListFile.FILE_MODIFY_DATE_ATTR_FORMAT, Locale.US); final String time3Formatted = formatter.format(time3rounded); if (store.supportsFileAttributeView("basic")) { assertEquals(time3Formatted, mock1.getAttribute(ListFile.FILE_LAST_MODIFY_TIME_ATTRIBUTE)); assertNotNull(mock1.getAttribute(ListFile.FILE_CREATION_TIME_ATTRIBUTE)); assertNotNull(mock1.getAttribute(ListFile.FILE_LAST_ACCESS_TIME_ATTRIBUTE)); if (store.supportsFileAttributeView("owner")) { if (store.supportsFileAttributeView("posix")) { assertNotNull("Group name should be set", mock1.getAttribute(ListFile.FILE_GROUP_ATTRIBUTE)); assertNotNull("File permissions should be set", mock1.getAttribute(ListFile.FILE_PERMISSIONS_ATTRIBUTE));
@Override public Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); try { final FileStore store = Files.getFileStore(session.toPath(home)); return new Space(store.getTotalSpace() - store.getUnallocatedSpace(), store.getUnallocatedSpace()); } catch(IOException e) { throw new LocalExceptionMappingService().map("Failure to read attributes of {0}", e, home); } } }
fos = new FileOutputStream(file2); fos.close(); FileStore store = Files.getFileStore(file2.toPath()); if (store.supportsFileAttributeView("dos")) { Files.setAttribute(file2.toPath(), "dos:hidden", true);
protected SpaceAvailableExtensionInfo doSpaceAvailable(int id, String path) throws IOException { Path nrm = resolveNormalizedLocation(path); ServerSession session = getServerSession(); if (log.isDebugEnabled()) { log.debug("doSpaceAvailable({})[id={}] path={}[{}]", session, id, path, nrm); } FileStore store = Files.getFileStore(nrm); if (log.isTraceEnabled()) { log.trace("doSpaceAvailable({})[id={}] path={}[{}] - {}[{}]", session, id, path, nrm, store.name(), store.type()); } return new SpaceAvailableExtensionInfo(store); }
public long getAvailableSizeBytes() throws IOException { return mFileStore.getUsableSpace(); }
@Override public StorageUnits value() { StorageUnits storageUnits = new StorageUnits(); for (FileStore fileStore : FileSystems.getDefault().getFileStores()) { try { StorageInformation storageInformation = new StorageInformation(fileStore.getUsableSpace(), fileStore.getTotalSpace()); storageUnits.put(fileStore.name(), storageInformation); } catch (IOException e) { logger.error("Failed to load file store", e); } } return storageUnits; }