@InterfaceAudience.Private @InterfaceStability.Evolving public class DirListingMetadata extends ExpirableMetadata
DirListingMetadata models a directory listing stored in a
MetadataStore. Instances of this class are mutable and thread-safe.| Modifier and Type | Field and Description |
|---|---|
static Collection<PathMetadata> |
EMPTY_DIR
Convenience parameter for passing into constructor.
|
| Constructor and Description |
|---|
DirListingMetadata(DirListingMetadata d)
Copy constructor.
|
DirListingMetadata(org.apache.hadoop.fs.Path path,
Collection<PathMetadata> listing,
boolean isAuthoritative) |
DirListingMetadata(org.apache.hadoop.fs.Path path,
Collection<PathMetadata> listing,
boolean isAuthoritative,
long lastUpdated)
Create a directory listing metadata container.
|
| Modifier and Type | Method and Description |
|---|---|
PathMetadata |
get(org.apache.hadoop.fs.Path childPath)
Lookup entry within this directory listing.
|
Collection<PathMetadata> |
getListing() |
org.apache.hadoop.fs.Path |
getPath() |
boolean |
isAuthoritative() |
Tristate |
isEmpty()
Is the underlying directory known to be empty?
|
Set<org.apache.hadoop.fs.Path> |
listTombstones()
List all tombstones.
|
void |
markDeleted(org.apache.hadoop.fs.Path childPath,
long lastUpdated)
Replace an entry with a tombstone.
|
int |
numEntries() |
String |
prettyPrint() |
void |
prettyPrint(StringBuilder sb)
Log contents to supplied StringBuilder in a pretty fashion.
|
boolean |
put(PathMetadata childPathMetadata)
Add an entry to the directory listing.
|
void |
remove(org.apache.hadoop.fs.Path childPath)
Remove entry from this directory.
|
List<PathMetadata> |
removeExpiredEntriesFromListing(long ttl,
long now)
Remove expired entries from the listing based on TTL.
|
void |
setAuthoritative(boolean authoritative)
Marks this directory listing as full and authoritative.
|
String |
toString() |
DirListingMetadata |
withoutTombstones()
Get the directory listing excluding tombstones.
|
getLastUpdated, isExpired, setLastUpdatedpublic static final Collection<PathMetadata> EMPTY_DIR
public DirListingMetadata(org.apache.hadoop.fs.Path path,
Collection<PathMetadata> listing,
boolean isAuthoritative,
long lastUpdated)
path - Path of the directory. If this path has a host component, then
all paths added later via put(PathMetadata) must also have
the same host.listing - Entries in the directory.isAuthoritative - true iff listing is the full contents of the
directory, and the calling client reports that this may be cached as
the full and authoritative listing of all files in the directory.lastUpdated - last updated time on which expiration is based.public DirListingMetadata(org.apache.hadoop.fs.Path path,
Collection<PathMetadata> listing,
boolean isAuthoritative)
public DirListingMetadata(DirListingMetadata d)
d - the existing DirListingMetadata object.public org.apache.hadoop.fs.Path getPath()
Path of the directory that contains this listing.public Collection<PathMetadata> getListing()
public Set<org.apache.hadoop.fs.Path> listTombstones()
public DirListingMetadata withoutTombstones()
public int numEntries()
isAuthoritative() is
true.
It will also include any tombstones.public boolean isAuthoritative()
MetadataStore that returned it.public Tristate isEmpty()
public void setAuthoritative(boolean authoritative)
authoritative - see isAuthoritative().public PathMetadata get(org.apache.hadoop.fs.Path childPath)
MetadataStore only tracks a partial set of the directory entries.
In the case where isAuthoritative() is true, however, this
function returns null iff the directory is known not to contain the listing
at given path (within the scope of the MetadataStore that returned
it).childPath - path of entry to look for.public void markDeleted(org.apache.hadoop.fs.Path childPath,
long lastUpdated)
childPath - path of entry to replace.public void remove(org.apache.hadoop.fs.Path childPath)
childPath - path of entry to remove.public boolean put(PathMetadata childPathMetadata)
FileStatus with the same path, it will be replaced.childPathMetadata - entry to add to this directory listing.public List<PathMetadata> removeExpiredEntriesFromListing(long ttl, long now)
ttl - the ttl timenow - the current timepublic void prettyPrint(StringBuilder sb)
sb - target StringBuilderpublic String prettyPrint()
Copyright © 2008–2022 Apache Software Foundation. All rights reserved.