public void initBucketPolicy(String[] forests, LinkedHashSet<String> uForests) { policy = new BucketAssignmentPolicy(forests, uForests); }
/** * return the index to the list of updatable forests (all forest - retired - * RO/DO) * * @param uri * @return index in the list of updatable forests */ public int getPlacementForestIndex(DocumentURI uri) { return getBucketPlacementId(uri, buckets, NUM_BUCKET, forests.length, uForests.size()); }
public BucketAssignmentPolicy(String[] forests, LinkedHashSet<String> uForests) { buckets = new int[forests.length][NUM_BUCKET]; initBucketsTable(forests.length); this.forests = forests; this.uForests = uForests; policy = Kind.BUCKET; }
private int getBucketPlacementId(DocumentURI uri, int[][] buckets, int numBuckets, int numForests, int uForests) { String nk = LegacyAssignmentPolicy.normalize(uri.getUri()); BigInteger uriKey=LegacyAssignmentPolicy.getUriKey(nk); long u = uriKey.longValue(); for (int i = 14; i <= 56; i += 14) { u ^= uriKey.shiftRight(i).longValue(); } int bucket = (int) (u&0x3fff); int fIdx = buckets[numForests - 1][bucket]; boolean allUpdatble = numForests == uForests; if (!allUpdatble) { int[] partv = new int[uForests]; int j = 0; for (int i = 0; i < numForests; i++) { if (isUpdatable(i)) { partv[j++] = i; } } fIdx = partv[LegacyAssignmentPolicy.getPlacementId(uri, uForests)]; } return fIdx; }