|
@@ -111,18 +111,21 @@ public class TestHDFSConcat {
|
|
|
long trgBlocks = nn.getBlockLocations(trg, 0, trgLen).locatedBlockCount();
|
|
|
|
|
|
Path [] files = new Path[numFiles];
|
|
|
- byte [] [] bytes = new byte [numFiles][(int)fileLen];
|
|
|
+ byte[][] bytes = new byte[numFiles + 1][(int) fileLen];
|
|
|
LocatedBlocks [] lblocks = new LocatedBlocks[numFiles];
|
|
|
long [] lens = new long [numFiles];
|
|
|
|
|
|
-
|
|
|
+ stm = dfs.open(trgPath);
|
|
|
+ stm.readFully(0, bytes[0]);
|
|
|
+ stm.close();
|
|
|
int i;
|
|
|
for(i=0; i<files.length; i++) {
|
|
|
files[i] = new Path("/file"+i);
|
|
|
Path path = files[i];
|
|
|
System.out.println("Creating file " + path);
|
|
|
- DFSTestUtil.createFile(dfs, path, fileLen, REPL_FACTOR, 1);
|
|
|
-
|
|
|
+
|
|
|
+ // make files with different content
|
|
|
+ DFSTestUtil.createFile(dfs, path, fileLen, REPL_FACTOR, i);
|
|
|
fStatus = nn.getFileInfo(path.toUri().getPath());
|
|
|
lens[i] = fStatus.getLen();
|
|
|
assertEquals(trgLen, lens[i]); // file of the same length.
|
|
@@ -131,7 +134,7 @@ public class TestHDFSConcat {
|
|
|
|
|
|
//read the file
|
|
|
stm = dfs.open(path);
|
|
|
- stm.readFully(0, bytes[i]);
|
|
|
+ stm.readFully(0, bytes[i + 1]);
|
|
|
//bytes[i][10] = 10;
|
|
|
stm.close();
|
|
|
}
|
|
@@ -153,6 +156,17 @@ public class TestHDFSConcat {
|
|
|
// check count update
|
|
|
ContentSummary cBefore = dfs.getContentSummary(trgPath.getParent());
|
|
|
|
|
|
+ // resort file array, make INode id not sorted.
|
|
|
+ for (int j = 0; j < files.length / 2; j++) {
|
|
|
+ Path tempPath = files[j];
|
|
|
+ files[j] = files[files.length - 1 - j];
|
|
|
+ files[files.length - 1 - j] = tempPath;
|
|
|
+
|
|
|
+ byte[] tempBytes = bytes[1 + j];
|
|
|
+ bytes[1 + j] = bytes[files.length - 1 - j + 1];
|
|
|
+ bytes[files.length - 1 - j + 1] = tempBytes;
|
|
|
+ }
|
|
|
+
|
|
|
// now concatenate
|
|
|
dfs.concat(trgPath, files);
|
|
|
|