Esempio n. 1
0
 /** Use the command chmod to set permission. */
 @Override
 public void setPermission(Path p, FsPermission permission) throws IOException {
   if (NativeIO.isAvailable()) {
     NativeIO.POSIX.chmod(pathToFile(p).getCanonicalPath(), permission.toShort());
   } else {
     String perm = String.format("%04o", permission.toShort());
     Shell.execCommand(
         Shell.getSetPermissionCommand(perm, false, FileUtil.makeShellPath(pathToFile(p), true)));
   }
 }
  public static class PageRounder {
    private final long osPageSize =
        NativeIO.POSIX.getCacheManipulator().getOperatingSystemPageSize();

    /** Round up a number to the operating system page size. */
    public long round(long count) {
      long newCount = (count + (osPageSize - 1)) / osPageSize;
      return newCount * osPageSize;
    }
  }
Esempio n. 3
0
  @BeforeClass
  public static void setupTest() {
    EditLogFileOutputStream.setShouldSkipFsyncForTesting(true);

    // Track calls to posix_fadvise.
    NativeIO.POSIX.setCacheManipulator(tracker);

    // Normally, we wait for a few megabytes of data to be read or written
    // before dropping the cache.  This is to avoid an excessive number of
    // JNI calls to the posix_fadvise function.  However, for the purpose
    // of this test, we want to use small files and see all fadvise calls
    // happen.
    BlockSender.CACHE_DROP_INTERVAL_BYTES = 4096;
    BlockReceiver.CACHE_DROP_LAG_BYTES = 4096;
  }