static FileStatus setTimes( FSDirectory fsd, FSPermissionChecker pc, String src, long mtime, long atime) throws IOException { INodesInPath iip; fsd.writeLock(); try { iip = fsd.resolvePath(pc, src, DirOp.WRITE); // Write access is required to set access and modification times if (fsd.isPermissionEnabled()) { fsd.checkPathAccess(pc, iip, FsAction.WRITE); } final INode inode = iip.getLastINode(); if (inode == null) { throw new FileNotFoundException("File/Directory " + iip.getPath() + " does not exist."); } boolean changed = unprotectedSetTimes(fsd, iip, mtime, atime, true); if (changed) { fsd.getEditLog().logTimes(iip.getPath(), mtime, atime); } } finally { fsd.writeUnlock(); } return fsd.getAuditFileInfo(iip); }
/** * Sets the access time on the file. Logs it in the transaction log */ void setTimes(String src, INodeFile inode, long mtime, long atime, boolean force) throws IOException { if (unprotectedSetTimes(src, inode, mtime, atime, force)) { fsImage.getEditLog().logTimes(src, mtime, atime); } }
/** * Sets the access time on the file. Logs it in the transaction log */ void setTimes(String src, INodeFile inode, long mtime, long atime, boolean force) throws IOException { if (unprotectedSetTimes(src, inode, mtime, atime, force)) { fsImage.getEditLog().logTimes(src, mtime, atime); } }
boolean changed = FSDirAttrOp.setTimes(dir, iip, -1, now, false); if (changed) { getEditLog().logTimes(src, -1, now);
@Test(timeout = 30000) public void testGetBlockLocationsRacingWithDelete() throws IOException { FSNamesystem fsn = spy(setupFileSystem()); final FSDirectory fsd = fsn.getFSDirectory(); FSEditLog editlog = fsn.getEditLog(); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { INodesInPath iip = fsd.getINodesInPath(FILE_PATH, true); FSDirDeleteOp.delete(fsd, iip, new INode.BlocksMapUpdateInfo(), new ArrayList<INode>(), now()); invocation.callRealMethod(); return null; } }).when(fsn).writeLock(); fsn.getBlockLocations("dummy", RESERVED_PATH, 0, 1024); verify(editlog, never()).logTimes(anyString(), anyLong(), anyLong()); fsn.close(); }
@Test(timeout = 30000) public void testResolveReservedPath() throws IOException { FSNamesystem fsn = setupFileSystem(); FSEditLog editlog = fsn.getEditLog(); fsn.getBlockLocations("dummy", RESERVED_PATH, 0, 1024); verify(editlog).logTimes(eq(FILE_PATH), anyLong(), anyLong()); fsn.close(); }
iip.getLatestSnapshotId()); if (changed) { fsd.getEditLog().logTimes(src, mtime, atime);
@Test(timeout = 30000) public void testGetBlockLocationsRacingWithRename() throws IOException { FSNamesystem fsn = spy(setupFileSystem()); final FSDirectory fsd = fsn.getFSDirectory(); FSEditLog editlog = fsn.getEditLog(); final String DST_PATH = "/bar"; final boolean[] renamed = new boolean[1]; doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { invocation.callRealMethod(); if (!renamed[0]) { FSDirRenameOp.renameTo(fsd, fsd.getPermissionChecker(), FILE_PATH, DST_PATH, new INode.BlocksMapUpdateInfo(), false); renamed[0] = true; } return null; } }).when(fsn).writeLock(); fsn.getBlockLocations("dummy", RESERVED_PATH, 0, 1024); verify(editlog).logTimes(eq(DST_PATH), anyLong(), anyLong()); fsn.close(); }
iip.getLatestSnapshotId()); if (changed) { fsd.getEditLog().logTimes(src, mtime, atime);
inode, -1, now, false, iip.getLatestSnapshotId()); if (changed) { getEditLog().logTimes(src, -1, now);
inode, -1, now, false, iip.getLatestSnapshotId()); if (changed) { getEditLog().logTimes(src, -1, now);