try {
Object o = node.makeRequestSender(key.getNodeCHK(), node.maxHTL(), uid, tag, null, localOnly, ignoreStore, false, true, canWriteClientCache, realTimeFlag);
if(o instanceof CHKBlock)
try {
tag.setServedFromDatastore();
return new ClientCHKBlock((CHKBlock) o, key);
} catch(CHKVerifyException e) {
Logger.error(this, "Does not verify: " + e, e);
throw new LowLevelGetException(LowLevelGetException.DECODE_FAILED);
}
if(o == null)
throw new LowLevelGetException(LowLevelGetException.DATA_NOT_FOUND_IN_STORE);
rs = (RequestSender) o;
boolean rejectedOverload = false;
short waitStatus = 0;
while(true) {
waitStatus = rs.waitUntilStatusChange(waitStatus);
if((!rejectedOverload) && (waitStatus & RequestSender.WAIT_REJECTED_OVERLOAD) != 0) {
// See below; inserts count both
requestStarters.rejectedOverload(false, false, realTimeFlag);
rejectedOverload = true;
}
int status = rs.getStatus();
if(rs.abortedDownstreamTransfers())
status = RequestSender.TRANSFER_FAILED;
if(status == RequestSender.NOT_FINISHED)
continue;
if(status != RequestSender.TIMED_OUT && status != RequestSender.GENERATED_REJECTED_OVERLOAD && status != RequestSender.INTERNAL_ERROR) {
if(logMINOR)
Logger.minor(this, "CHK fetch cost " + rs.getTotalSentBytes() + '/' + rs.getTotalReceivedBytes() + " bytes (" + status + ')');
nodeStats.localChkFetchBytesSentAverage.report(rs.getTotalSentBytes());
nodeStats.localChkFetchBytesReceivedAverage.report(rs.getTotalReceivedBytes());
if(status == RequestSender.SUCCESS)
// See comments above declaration of successful* : We don't report sent bytes here.
//nodeStats.successfulChkFetchBytesSentAverage.report(rs.getTotalSentBytes());
nodeStats.successfulChkFetchBytesReceivedAverage.report(rs.getTotalReceivedBytes());
}
if((status == RequestSender.TIMED_OUT) ||
(status == RequestSender.GENERATED_REJECTED_OVERLOAD)) {
if(!rejectedOverload) {
// See below
requestStarters.rejectedOverload(false, false, realTimeFlag);
rejectedOverload = true;
long rtt = System.currentTimeMillis() - startTime;
double targetLocation=key.getNodeCHK().toNormalizedDouble();
node.nodeStats.reportCHKOutcome(rtt, false, targetLocation, realTimeFlag);
}
} else
if(rs.hasForwarded() &&
((status == RequestSender.DATA_NOT_FOUND) ||
(status == RequestSender.RECENTLY_FAILED) ||
(status == RequestSender.SUCCESS) ||
(status == RequestSender.ROUTE_NOT_FOUND) ||
(status == RequestSender.VERIFY_FAILURE) ||
(status == RequestSender.GET_OFFER_VERIFY_FAILURE))) {
long rtt = System.currentTimeMillis() - startTime;
double targetLocation=key.getNodeCHK().toNormalizedDouble();
if(!rejectedOverload)
requestStarters.requestCompleted(false, false, key.getNodeKey(true), realTimeFlag);
// Count towards RTT even if got a RejectedOverload - but not if timed out.
requestStarters.getThrottle(false, false, realTimeFlag).successfulCompletion(rtt);
node.nodeStats.reportCHKOutcome(rtt, status == RequestSender.SUCCESS, targetLocation, realTimeFlag);
if(status == RequestSender.SUCCESS) {
Logger.minor(this, "Successful CHK fetch took "+rtt);
}
}
if(status == RequestSender.SUCCESS)
try {
return new ClientCHKBlock(rs.getPRB().getBlock(), rs.getHeaders(), key, true);
} catch(CHKVerifyException e) {
Logger.error(this, "Does not verify: " + e, e);
throw new LowLevelGetException(LowLevelGetException.DECODE_FAILED);
} catch(AbortedException e) {
Logger.error(this, "Impossible: " + e, e);