void calculate(PeerNode[] peers) { double[] allPeers = new double[peers.length]; int x = 0; for(PeerNode peer : peers) { PeerLoadStats stats = peer.outputLoadTracker(isRealtime).getLastIncomingLoadStats(); if(stats == null) continue; allPeers[x++] = stats.peerLimit(isInput); } if(x != peers.length) { allPeers = Arrays.copyOf(allPeers, x); } Arrays.sort(allPeers); if(x == 0) return; synchronized(this) { min = allPeers[0]; median = allPeers[x / 2]; firstQuartile = allPeers[x / 4]; lastQuartile = allPeers[(x * 3) / 4]; max = allPeers[x - 1]; if(logMINOR) Logger.minor(this, "Quartiles for peer capacities: "+(isInput?"input ":"output ")+(isRealtime?"realtime: ":"bulk: ")+Arrays.toString(getQuartiles())); } }
private double getLoad(HashSet<PeerNode> waitedFor) { double total = 0; for(PeerNode pn : waitedFor) { total += pn.outputLoadTracker(realTimeFlag).proportionTimingOutFatallyInWait(); } return total / waitedFor.size(); }
tag.setWaitingForSlot(); if(!peer.outputLoadTracker(realTime).queueSlotWaiter(this)) { synchronized(this) { waitingFor.remove(peer);
continue; if(newLoadManagement && p.outputLoadTracker(realTime).getLastIncomingLoadStats() == null) { if(logMINOR) Logger.minor(this, "Skipping (no load stats): "+p.getPeer());
if(i > 3) { Logger.error(this, "Rejected repeatedly ("+i+") by "+next+" : "+this); next.outputLoadTracker(realTimeFlag).setDontSendUnlessGuaranteed(); next.outputLoadTracker(realTimeFlag).clearDontSendUnlessGuaranteed(); return DO.FINISHED;
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); peersForSuccessfulSlot = slot.innerOnWaited(PeerNode.this, acceptState); if(peersForSuccessfulSlot == null) continue; reportAllocated(slot.isLocal()); slotWaiterTypeCounter = typeNum;
noLoadStats = (this.lastIncomingLoadStats == null); if(!noLoadStats) { SlotWaiterList list = makeSlotWaiters(waiter.requestType); list.put(waiter); if(logMINOR) Logger.minor(this, "Queued slot "+waiter+" waiter for "+waiter.requestType+" on "+list+" on "+this+" for "+PeerNode.this); reportAllocated(waiter.isLocal()); waiter.unregister(null, all); } else if(queued) {
RequestLikelyAcceptedState acceptState = getRequestLikelyAcceptedState(runningRequests, otherRunningRequests, ignoreLocalVsRemote, loadStats); if(logMINOR) Logger.minor(this, "Predicted acceptance state for request: "+acceptState+" must beat "+worstAcceptable); if(acceptState.ordinal() > worstAcceptable.ordinal()) return null;
/** @return True if either bulk or realtime has not yet received a valid peer load * stats message. If so, we will not be able to route requests to the node under new * load management. */ private boolean noLoadStats() { if(node.enableNewLoadManagement(false) || node.enableNewLoadManagement(true)) { if(outputLoadTrackerRealTime.getLastIncomingLoadStats() == null) { if(isRoutable()) Logger.normal(this, "No realtime load stats on "+this); return true; } if(outputLoadTrackerBulk.getLastIncomingLoadStats() == null) { if(isRoutable()) Logger.normal(this, "No bulk load stats on "+this); return true; } } return false; }
/** LOCKING: Call inside routedToLock * @param otherRunningRequests * @param runningRequests * @param byteCountersInput * @param byteCountersOutput */ private RequestLikelyAcceptedState getRequestLikelyAcceptedState(RunningRequestsSnapshot runningRequests, RunningRequestsSnapshot otherRunningRequests, boolean ignoreLocalVsRemote, PeerLoadStats stats) { RequestLikelyAcceptedState outputState = getRequestLikelyAcceptedStateBandwidth(false, runningRequests, otherRunningRequests, ignoreLocalVsRemote, stats); RequestLikelyAcceptedState inputState = getRequestLikelyAcceptedStateBandwidth(true, runningRequests, otherRunningRequests, ignoreLocalVsRemote, stats); RequestLikelyAcceptedState transfersState = getRequestLikelyAcceptedStateTransfers(runningRequests, otherRunningRequests, ignoreLocalVsRemote, stats); RequestLikelyAcceptedState ret = inputState; if(outputState.ordinal() > ret.ordinal()) ret = outputState; if(transfersState.ordinal() > ret.ordinal()) ret = transfersState; return ret; }
public IncomingLoadSummaryStats getIncomingLoadStats(boolean realTime) { return outputLoadTracker(realTime).getIncomingLoadStats(); }
public void reportLoadStatus(PeerLoadStats stat) { if(logMINOR) Logger.minor(this, "Got load status : "+stat); synchronized(routedToLock) { lastIncomingLoadStats = stat; } maybeNotifySlotWaiter(); }
public boolean isLowCapacity(boolean isRealtime) { PeerLoadStats stats = outputLoadTracker(isRealtime).getLastIncomingLoadStats(); if(stats == null) return false; NodePinger pinger = node.nodeStats.nodePinger; if(pinger == null) return false; // FIXME possible? if(pinger.capacityThreshold(isRealtime, true) > stats.peerLimit(true)) return true; if(pinger.capacityThreshold(isRealtime, false) > stats.peerLimit(false)) return true; return false; }