private void checkEnoughMemSpace(StorageDir storageDir) {
    if (!OSUtils.isLinux()) {
      return;
    }
    List<UnixMountInfo> info;
    try {
      info = ShellUtils.getUnixMountInfo();
    } catch (IOException e) {
      LOG.warn("Failed to get mount information for verifying memory capacity: {}",
          e.getMessage());
      return;
    }
    boolean foundMountInfo = false;
    for (UnixMountInfo mountInfo : info) {
      Optional<String> mountPointOption = mountInfo.getMountPoint();
      Optional<String> fsTypeOption = mountInfo.getFsType();
      Optional<Long> sizeOption = mountInfo.getOptions().getSize();
      if (!mountPointOption.isPresent() || !fsTypeOption.isPresent() || !sizeOption.isPresent()) {
        continue;
      }
      String mountPoint = mountPointOption.get();
      String fsType = fsTypeOption.get();
      long size = sizeOption.get();
      try {
        // getDirPath gives something like "/mnt/tmpfs/alluxioworker".
        String rootStoragePath = PathUtils.getParent(storageDir.getDirPath());
        if (!PathUtils.cleanPath(mountPoint).equals(rootStoragePath)) {
          continue;
        }
      } catch (InvalidPathException e) {
        continue;
      }
      foundMountInfo = true;
      if ((fsType.equalsIgnoreCase("tmpfs") || fsType.equalsIgnoreCase("ramfs"))
          && size < storageDir.getCapacityBytes()) {
        throw new IllegalStateException(String.format(
            "%s is smaller than the configured size: %s size: %s, configured size: %s", fsType,
            fsType, FormatUtils.getSizeFromBytes(size),
            FormatUtils.getSizeFromBytes(storageDir.getCapacityBytes())));
      }
      break;
    }
    if (!foundMountInfo) {
      LOG.warn("Failed to verify memory capacity");
    }
  }
private void checkEnoughMemSpace ( StorageDir storageDir ) { if ( ! OSUtils . isLinux ( ) ) { return ; } List < UnixMountInfo > info ; try { info = ShellUtils . getUnixMountInfo ( ) ; } catch ( IOException e ) { LOG . warn ( "Failed to get mount information for verifying memory capacity: {}" , e . getMessage ( ) ) ; return ; } boolean foundMountInfo = false ; for ( UnixMountInfo mountInfo : info ) { Optional < String > mountPointOption = mountInfo . getMountPoint ( ) ; Optional < String > fsTypeOption = mountInfo . getFsType ( ) ; Optional < Long > sizeOption = mountInfo . getOptions ( ) . getSize ( ) ; if ( ! mountPointOption . isPresent ( ) || ! fsTypeOption . isPresent ( ) || ! sizeOption . isPresent ( ) ) { continue ; } String mountPoint = mountPointOption . get ( ) ; String fsType = fsTypeOption . get ( ) ; long size = sizeOption . get ( ) ; try { String rootStoragePath = PathUtils . getParent ( storageDir . getDirPath ( ) ) ; if ( ! PathUtils . cleanPath ( mountPoint ) . equals ( rootStoragePath ) ) { continue ; } } catch ( InvalidPathException e ) { continue ; } foundMountInfo = true ; if ( ( fsType . equalsIgnoreCase ( "tmpfs" ) || fsType . equalsIgnoreCase ( "ramfs" ) ) && size < storageDir . getCapacityBytes ( ) ) { throw new IllegalStateException ( String . format ( "%s is smaller than the configured size: %s size: %s, configured size: %s" , fsType , fsType , FormatUtils . getSizeFromBytes ( size ) , FormatUtils . getSizeFromBytes ( storageDir . getCapacityBytes ( ) ) ) ) ; } break ; } if ( ! foundMountInfo ) { LOG . warn ( "Failed to verify memory capacity" ) ; } }
Checks that a tmpfs/ramfs backing the storage directory has enough capacity. If the storage
directory is not backed by tmpfs/ramfs or the size of the tmpfs/ramfs cannot be determined, a
warning is logged but no exception is thrown.

@param storageDir the storage dir to check
@throws IllegalStateException if the tmpfs/ramfs is smaller than the configured memory size