metaWriter_ = metaWriter;
}
@Override
public void onRemoval(final RemovalNotification<HavaloUUID,Repository> removed) {
Repository repo = null;
try {
// The repo that was "evicted" could be null if it was
// garbage collected between the time it was evicted
// and this listener was called. This should _not_
// happen given that we've asked the Cache to maintain
// _STRONG_ references to the keys and values in the
// cache, but we should check just in case.
if((repo = removed.getValue()) != null) {
// If the repository directory has been deleted (invalidated),
// we should not attempt to flush the meta data for it
// to disk -- the underlying repository has been deleted.
if(repo.getFile().exists()) {
// Queue the repository to be flushed to disk.
metaWriter_.queue(repo);
} else {
logger__.debug("Not flushing repo meta " +
"data, underlying repo directory is " +
"missing (id=" + repo.getKey() + ", " +
"file=" + repo.getFile().getCanonicalPath() +
") -- was probably for a deleted repository.");
}
} else {
// Should really _not_ happen based on the notes
// provided above.
throw new RepositoryFlushException("Could not " +
"flush NULL repository -- was perhaps " +
"already GC'ed?");
}
} catch (Exception e) {
logger__.error("Failed miserably to flush repository " +
"(id=" + ((repo != null) ? repo.getRepoId() : "NULL") +
") -- could be trouble!", e);
}
}