/** calculates the object request list to request to each member */ public final synchronized void calculateAccesses() { if (hasAccessesCalculated) { return; } hasAccessesCalculated = true; if (log.isTraceEnabled()) { log.trace("Calculating accessed keys for data placement optimization"); } RemoteTopKeyRequest request = new RemoteTopKeyRequest(streamLibContainer.getCapacity() * 2); request.merge(streamLibContainer.getTopKFrom(REMOTE_PUT, maxNumberOfKeysToRequest), 2); request.merge(streamLibContainer.getTopKFrom(REMOTE_GET, maxNumberOfKeysToRequest), 1); sortObjectsByPrimaryOwner(request.toRequestMap(maxNumberOfKeysToRequest), true); request.clear(); LocalTopKeyRequest localTopKeyRequest = new LocalTopKeyRequest(); localTopKeyRequest.merge(streamLibContainer.getTopKFrom(LOCAL_PUT), 2); localTopKeyRequest.merge(streamLibContainer.getTopKFrom(LOCAL_GET), 1); sortObjectsByPrimaryOwner(localTopKeyRequest.toRequestMap(), false); request.clear(); if (log.isTraceEnabled()) { StringBuilder stringBuilder = new StringBuilder("Accesses:\n"); for (int i = 0; i < accessesByPrimaryOwner.length; ++i) { stringBuilder .append(clusterSnapshot.get(i)) .append(" ==> ") .append(accessesByPrimaryOwner[i]) .append("\n"); } log.debug(stringBuilder); } streamLibContainer.resetStat(REMOTE_GET); streamLibContainer.resetStat(LOCAL_GET); streamLibContainer.resetStat(REMOTE_PUT); streamLibContainer.resetStat(LOCAL_PUT); }
public AccessesManager(DistributionManager distributionManager, int maxNumberOfKeysToRequest) { this.distributionManager = distributionManager; this.maxNumberOfKeysToRequest = maxNumberOfKeysToRequest; streamLibContainer = StreamLibContainer.getInstance(); }