boolean ignoreLocalVsRemote = node.nodeStats.ignoreLocalVsRemoteBandwidthLiability();
if(logMINOR) Logger.minor(this, "Maybe waking up slot waiters for "+this+" realtime="+realTime+" for "+PeerNode.this.shortToString());
while(true) {
boolean foundNone = true;
int typeNum;
PeerLoadStats loadStats;
synchronized(routedToLock) {
loadStats = lastIncomingLoadStats;
if(slotWaiters.isEmpty()) {
if(logMINOR) Logger.minor(this, "No slot waiters for "+this);
return;
}
typeNum = slotWaiterTypeCounter;
}
typeNum++;
if(typeNum == RequestType_values.length)
typeNum = 0;
for(int i=0;i<RequestType_values.length;i++) {
SlotWaiterList list;
RequestType type = RequestType_values[typeNum];
if(logMINOR) Logger.minor(this, "Checking slot waiter list for "+type);
SlotWaiter slot;
RequestLikelyAcceptedState acceptState;
PeerNode[] peersForSuccessfulSlot;
synchronized(routedToLock) {
list = slotWaiters.get(type);
if(list == null) {
if(logMINOR) Logger.minor(this, "No list");
typeNum++;
if(typeNum == RequestType_values.length)
typeNum = 0;
continue;
}
if(list.isEmpty()) {
if(logMINOR) Logger.minor(this, "List empty");
typeNum++;
if(typeNum == RequestType_values.length)
typeNum = 0;
continue;
}
if(logMINOR) Logger.minor(this, "Checking slot waiters for "+type);
foundNone = false;
// Requests already running to this node
RunningRequestsSnapshot runningRequests = node.nodeStats.getRunningRequestsTo(PeerNode.this, loadStats.averageTransfersOutPerInsert, realTime);
runningRequests.log(PeerNode.this);
// Requests running from its other peers
RunningRequestsSnapshot otherRunningRequests = loadStats.getOtherRunningRequests();
acceptState = getRequestLikelyAcceptedState(runningRequests, otherRunningRequests, ignoreLocalVsRemote, loadStats);
if(acceptState == null || acceptState == RequestLikelyAcceptedState.UNLIKELY) {
if(logMINOR) Logger.minor(this, "Accept state is "+acceptState+" - not waking up - type is "+type);
return;
}