FSDirAttrOp { static boolean unprotectedSetTimes( FSDirectory fsd, INodesInPath iip, long mtime, long atime, boolean force) throws QuotaExceededException { assert fsd.hasWriteLock(); boolean status = false; INode inode = iip.getLastINode(); int latest = iip.getLatestSnapshotId(); if (mtime >= 0) { inode = inode.setModificationTime(mtime, latest); status = true; } if (atime >= 0 && (status || force || atime > inode.getAccessTime() + fsd.getAccessTimePrecision())) { inode.setAccessTime(atime, latest, fsd.getFSNamesystem().getSnapshotManager(). getSkipCaptureAccessTimeOnlyChange()); status = true; } return status; }    }
@Test public void testUnprotectedSetTimes() throws Exception { assertFalse("SetTimes should not update access time " + "because it's within the last precision interval", unprotectedSetTimes(100, 0, 1000, -1, false)); assertFalse("SetTimes should not update access time " + "because it's within the last precision interval", unprotectedSetTimes(1000, 0, 1000, -1, false)); assertTrue("SetTimes should update access time", unprotectedSetTimes(1011, 10, 1000, -1, false)); assertTrue("SetTimes should update access time", unprotectedSetTimes(100, 0, 1000, -1, true)); assertTrue("SetTimes should update access time", unprotectedSetTimes(100, 0, 1000, 1, false)); }