public CHKBlock fetch(NodeCHK key, boolean dontPromote, boolean canReadClientCache, boolean canWriteClientCache, boolean canWriteDatastore, boolean forULPR, BlockMetadata meta) {
double loc=key.toNormalizedDouble();
double dist=Location.distance(lm.getLocation(), loc);
if(canReadClientCache) {
try {
CHKBlock block = chkClientcache.fetch(key, dontPromote || !canWriteClientCache, false, meta);
if(block != null) {
nodeStats.avgClientCacheCHKSuccess.report(loc);
if (dist > nodeStats.furthestClientCacheCHKSuccess)
nodeStats.furthestClientCacheCHKSuccess=dist;
return block;
}
} catch (IOException e) {
Logger.error(this, "Could not read from client cache: "+e, e);
}
}
if(forULPR || useSlashdotCache || canReadClientCache) {
try {
CHKBlock block = chkSlashdotcache.fetch(key, dontPromote, false, meta);
if(block != null) {
nodeStats.avgSlashdotCacheCHKSucess.report(loc);
if (dist > nodeStats.furthestSlashdotCacheCHKSuccess)
nodeStats.furthestSlashdotCacheCHKSuccess=dist;
return block;
}
} catch (IOException e) {
Logger.error(this, "Could not read from slashdot/ULPR cache: "+e, e);
}
}
boolean ignoreOldBlocks = !writeLocalToDatastore;
if(canReadClientCache) ignoreOldBlocks = false;
if(logMINOR) dumpStoreHits();
try {
nodeStats.avgRequestLocation.report(loc);
CHKBlock block = chkDatastore.fetch(key, dontPromote || !canWriteDatastore, ignoreOldBlocks, meta);
if(block == null) {
CHKStore store = oldCHK;
if(store != null)
block = store.fetch(key, dontPromote || !canWriteDatastore, ignoreOldBlocks, meta);
}