HADOOP-13756 LocalMetadataStore#put(DirListingMetadata) should also put file metadata into fileHash. (Gabor Bota)

This commit is contained in:
Aaron Fabbri 2018-04-26 20:40:30 -07:00
parent 0a293de00d
commit 7d8bcf534a
No known key found for this signature in database
GPG Key ID: B2EEFA9E78118A29
2 changed files with 28 additions and 0 deletions

View File

@ -281,6 +281,7 @@ public class LocalMetadataStore implements MetadataStore {
LOG.debug("put dirMeta {}", meta.prettyPrint());
}
dirHash.put(standardize(meta.getPath()), meta);
put(meta.getListing());
}
public synchronized void put(Collection<PathMetadata> metas) throws

View File

@ -738,6 +738,33 @@ public abstract class MetadataStoreTestBase extends Assert {
}
}
@Test
public void testPutDirListingMetadataPutsFileMetadata()
throws IOException {
boolean authoritative = true;
String[] filenames = {"/dir1/file1", "/dir1/file2", "/dir1/file3"};
String dirPath = "/dir1";
ArrayList<PathMetadata> metas = new ArrayList<>(filenames.length);
for (String filename : filenames) {
metas.add(new PathMetadata(makeFileStatus(filename, 100)));
}
DirListingMetadata dirMeta =
new DirListingMetadata(strToPath(dirPath), metas, authoritative);
ms.put(dirMeta);
if (!allowMissing()) {
assertDirectorySize(dirPath, filenames.length);
PathMetadata metadata;
for(String fileName : filenames){
metadata = ms.get(strToPath(fileName));
assertNotNull(String.format(
"PathMetadata for file %s should not be null.", fileName),
metadata);
}
}
}
/*
* Helper functions.
*/