|
@@ -23,13 +23,10 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
-import org.apache.hadoop.hdfs.server.datanode.DatanodeUtil;
|
|
|
|
-import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi;
|
|
|
|
import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.junit.Assert;
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.concurrent.CountDownLatch;
|
|
import java.util.concurrent.CountDownLatch;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
@@ -37,9 +34,6 @@ import java.util.concurrent.Executors;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
-import java.util.HashSet;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.*;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.*;
|
|
import static org.apache.hadoop.hdfs.StorageType.DEFAULT;
|
|
import static org.apache.hadoop.hdfs.StorageType.DEFAULT;
|
|
@@ -247,6 +241,26 @@ public class TestLazyPersistFiles extends LazyPersistTestCase {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Truncate to lazy persist file is denied.
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ @Test
|
|
|
|
+ public void testTruncateIsDenied() throws IOException {
|
|
|
|
+ startUpCluster(true, -1);
|
|
|
|
+ final String METHOD_NAME = GenericTestUtils.getMethodName();
|
|
|
|
+ Path path = new Path("/" + METHOD_NAME + ".dat");
|
|
|
|
+
|
|
|
|
+ makeTestFile(path, BLOCK_SIZE, true);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ client.truncate(path.toString(), BLOCK_SIZE/2);
|
|
|
|
+ fail("Truncate to LazyPersist file did not fail as expected");
|
|
|
|
+ } catch (Throwable t) {
|
|
|
|
+ LOG.info("Got expected exception ", t);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* If one or more replicas of a lazyPersist file are lost, then the file
|
|
* If one or more replicas of a lazyPersist file are lost, then the file
|
|
* must be discarded by the NN, instead of being kept around as a
|
|
* must be discarded by the NN, instead of being kept around as a
|