HDFS-9208. Disabling atime may fail clients like distCp. (Kihwal Lee via yliu)
This commit is contained in:
parent
7e2837f830
commit
9cb5d35353
|
@ -2081,6 +2081,9 @@ Release 2.8.0 - UNRELEASED
|
|||
HDFS-9237. NPE at TestDataNodeVolumeFailureToleration#tearDown.
|
||||
(Brahma Reddy Battula via ozawa)
|
||||
|
||||
HDFS-9208. Disabling atime may fail clients like distCp. (Kihwal Lee via
|
||||
yliu)
|
||||
|
||||
Release 2.7.2 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -42,7 +42,6 @@ import java.util.Arrays;
|
|||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_QUOTA_BY_STORAGETYPE_ENABLED_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_STORAGE_POLICY_ENABLED_KEY;
|
||||
|
||||
|
@ -97,13 +96,6 @@ public class FSDirAttrOp {
|
|||
static HdfsFileStatus setTimes(
|
||||
FSDirectory fsd, String src, long mtime, long atime)
|
||||
throws IOException {
|
||||
if (!fsd.isAccessTimeSupported() && atime != -1) {
|
||||
throw new IOException(
|
||||
"Access time for hdfs is not configured. " +
|
||||
" Please set " + DFS_NAMENODE_ACCESSTIME_PRECISION_KEY
|
||||
+ " configuration parameter.");
|
||||
}
|
||||
|
||||
FSPermissionChecker pc = fsd.getPermissionChecker();
|
||||
byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
|
|||
import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
|
||||
import org.apache.hadoop.test.MockitoUtil;
|
||||
import org.apache.hadoop.util.Time;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
|
@ -309,6 +310,36 @@ public class TestSetTimes {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether atime can be set explicitly even when the atime support is
|
||||
* disabled.
|
||||
*/
|
||||
@Test
|
||||
public void testAtimeUpdate() throws Exception {
|
||||
Configuration conf = new HdfsConfiguration();
|
||||
conf.setInt(DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_KEY, 0);
|
||||
MiniDFSCluster cluster = null;
|
||||
FileSystem fs = null;
|
||||
|
||||
try {
|
||||
cluster = new MiniDFSCluster.Builder(conf)
|
||||
.numDataNodes(0)
|
||||
.build();
|
||||
fs = cluster.getFileSystem();
|
||||
|
||||
// Create an empty file
|
||||
Path p = new Path("/testAtimeUpdate");
|
||||
DFSTestUtil.createFile(cluster.getFileSystem(), p, 0, (short)1, 0L);
|
||||
|
||||
fs.setTimes(p, -1L, 123456L);
|
||||
Assert.assertEquals(123456L, fs.getFileStatus(p).getAccessTime());
|
||||
} finally {
|
||||
if (cluster != null) {
|
||||
cluster.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new TestSetTimes().testTimes();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue