/** * This instance method was added so that unit tests could mock it */ int getHashKey(Operation op, Object key, Object value, Object callbackArg) { return PartitionedRegionHelper.getHashKey(this.proxy, op, key, value, callbackArg); }
@Override public String getPrName() { assert isBucket(); String bn = PartitionedRegionHelper.getBucketName(this.name); return PartitionedRegionHelper.getPRPath(bn); }
/** * Return a region that is the root for all Partitioned Region metadata on this node */ public static LocalRegion getPRRoot(final InternalCache cache) { return getPRRoot(cache, true); }
logger.debug("Cleaning PartitionedRegion meta data for memberId={}", failedMemId); Region rootReg = PartitionedRegionHelper.getPRRoot(cache, false); if (rootReg == null) { return; cleanUpMetaDataForRegion(cache, prName, failedMemId, null);
String bucketName = getBucketName(fullPath); if (bucketName == null) { return null; String prid = getPRPath(bucketName); int bid = getBucketId(bucketName); RegionAdvisor ra = (RegionAdvisor) pr.getDistributionAdvisor(); if (postInit) {
PartitionResolver resolver = getResolver(pr, key, callbackArgument); Object resolveKey = null; if (pr.isFixedPartitionedRegion()) { prms)); return assignFixedBucketId(pr, partition, resolveKey); } else { return getHashKey(pr, resolveKey);
public static String getBucketFullPath(String prFullPath, int bucketId) { String name = getBucketName(prFullPath, bucketId); if (name != null) return Region.SEPARATOR + PR_ROOT_REGION_NAME + Region.SEPARATOR + name; return null; }
/** * Utility method to print warning when nodeList in b2n region is found empty. This will signify * potential data loss scenario. * * @param bucketId Id of Bucket whose nodeList in b2n is empty. * @param callingMethod methodName of the calling method. */ public static void logForDataLoss(PartitionedRegion partitionedRegion, int bucketId, String callingMethod) { if (!Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "PRDebug")) { return; } Region root = PartitionedRegionHelper.getPRRoot(partitionedRegion.getCache()); // Region allPartitionedRegions = PartitionedRegionHelper.getPRConfigRegion( // root, partitionedRegion.getCache()); PartitionRegionConfig prConfig = (PartitionRegionConfig) root.get(partitionedRegion.getRegionIdentifier()); if (prConfig == null) return; Set members = partitionedRegion.getDistributionManager().getDistributionManagerIds(); logger.warn( "DATALOSS ( {} ) :: Size of nodeList After verifyBucketNodes for bucket ID, {} is 0", callingMethod, bucketId); logger.warn("DATALOSS ( {} ) :: NodeList from prConfig, {}", callingMethod, printCollection(prConfig.getNodes())); logger.warn("DATALOSS ( {} ) :: Current Membership List, {}", callingMethod, printCollection(members)); }
@Override public void memberDeparted(DistributionManager distributionManager, final InternalDistributedMember id, boolean crashed) { PartitionedRegionHelper.cleanUpMetaDataOnNodeFailure(cache, id); }
public static String getBucketName(String prPath, int bucketId) { return PartitionedRegionHelper.BUCKET_REGION_PREFIX + PartitionedRegionHelper.escapePRPath(prPath) + PartitionedRegion.BUCKET_NAME_SEPARATOR + bucketId; }
@Override public void memberDeparted(DistributionManager distributionManager, final InternalDistributedMember id, final boolean crashed) { try { DistributedMember dmem = prRegion.getSystem().getDistributedMember(); if (logger.isDebugEnabled()) { logger.debug( "MembershipListener invoked on DistributedMember = {} for failed memberId = {}", dmem, id); } if (!prRegion.isCacheClosing() && !prRegion.isDestroyed() && !dmem.equals(id)) { Runnable postRecoveryTask = null; // Only schedule redundancy recovery if this not a fixed PR. if (!PRHARedundancyProvider.this.prRegion.isFixedPartitionedRegion()) { postRecoveryTask = new Runnable() { @Override public void run() { // After the metadata has been cleaned, recover redundancy. scheduleRedundancyRecovery(id); } }; } // Schedule clean up the metadata for the failed member. PartitionedRegionHelper.cleanUpMetaDataForRegion(prRegion.getCache(), prRegion.getRegionIdentifier(), id, postRecoveryTask); } } catch (CancelException e) { // ignore } }
Set<FixedPartitionAttributes> fpaSet = null; if (leaderRegion != null) { fpaSet = PartitionedRegionHelper.getAllFixedPartitionAttributes(leaderRegion); } else { fpaSet = PartitionedRegionHelper.getAllFixedPartitionAttributes(prRgion);
public static boolean isBucketRegion(String fullPath) { return getBucketName(fullPath) != null; }
try { try { PartitionedRegionHelper.cleanUpMetaDataOnNodeFailure(dm.getCache(), getSender()); } catch (VirtualMachineError err) { systemError = true;
/** * Runs hashCode() on given key/routing object producing a long value and then finds absolute * value of the modulus with bucketSize. For better key distribution, possibly use MD5 or SHA or * any unique ID generator for the hash function. * * @param event entry event created for this entry operation * @return the bucket id the key/routing object hashes to */ public static int getHashKey(EntryOperation event) { return getHashKey(event, null, null, null, null, null); }
public String getPrName() { assert isBucket(); String bn = PartitionedRegionHelper.getBucketName(getName()); return PartitionedRegionHelper.getPRPath(bn); }
/** * Initializes the PartitionedRegion - create the Global regions for storing the * PartitiotnedRegion configs. */ private void initializePartitionedRegion() { this.prRoot = PartitionedRegionHelper.getPRRoot(getCache()); }
public String getBucketName(int bucketId) { return PartitionedRegionHelper.getBucketName(getFullPath(), bucketId); }
/** * Test Method: Get the DistributedMember identifier for the vm containing a key * * @param key the key to look for * @return The ID of the DistributedMember holding the key, or null if there is no current mapping * for the key */ public DistributedMember getMemberOwning(Object key) { int bucketId = PartitionedRegionHelper.getHashKey(this, null, key, null, null); return getNodeForBucketRead(bucketId); }
@Test public void testEscapeUnescape() { { String bucketName = PartitionedRegionHelper.getBucketName("/root/region", 5); assertEquals("Name = " + bucketName, -1, bucketName.indexOf('/')); assertEquals("/root/region", PartitionedRegionHelper.getPRPath(bucketName)); } { String bucketName = PartitionedRegionHelper.getBucketName("/root/region_one", 5); assertEquals("Name = " + bucketName, -1, bucketName.indexOf('/')); assertEquals("/root/region_one", PartitionedRegionHelper.getPRPath(bucketName)); } }