/** * Returns the lockname used by Distributed Lock service to clean the * {@code allPartitionedRegions}. * */ private String getLockNameForBucket2NodeModification(int bucketID) { return (getRegionIdentifier() + ":" + bucketID); }
protected RecoveryLock() { super(PartitionedRegion.this.getRegionIdentifier() + "-RecoveryLock", getCache(), false); }
/** * This method prints the content of the allPartitionedRegion's contents for this * PartitionedRegion. */ public void dumpSelfEntryFromAllPartitionedRegions() { StringBuilder sb = new StringBuilder(this.prRoot.getFullPath()); sb.append("Dumping allPartitionedRegions for "); sb.append(this); sb.append("\n"); sb.append(this.prRoot.get(getRegionIdentifier())); logger.debug(sb.toString()); }
if (pr != null && !pr.isLocallyDestroyed && pr.getRegionIdentifier().equals(regionId)) { return; if (!pr.getRegionIdentifier().equals(regionId)) { logger.warn("{} is using PRID {} for {} but this process maps that PRID to {}", new Object[] {sender.toString(), prId, pr.getRegionIdentifier()}); } else if (pr.getRegionIdentifier().equals(regionId)) { logger.warn("{} is using PRID {} for {} but this process is using PRID {}", new Object[] {sender, prId, pr.getRegionIdentifier(), pr.getPRId()});
public RegionLock getRegionLock() { return getRegionLock(getRegionIdentifier(), getGemFireCache()); }
@Override protected Throwable processCheckForPR(PartitionedRegion pr, DistributionManager distributionManager) { if (pr != null && !pr.getDistributionAdvisor().isInitialized()) { Throwable thr = new ForceReattemptException( String.format("%s : could not find partitioned region with Id %s", distributionManager.getDistributionManagerId(), pr.getRegionIdentifier())); return thr; } return null; }
public void updatePRConfigWithNewGatewaySender(String aeqId) { PartitionRegionHelper.assignBucketsToPartitions(this); PartitionRegionConfig prConfig = this.prRoot.get(getRegionIdentifier()); Set<String> newGateWayIds; if (prConfig.getGatewaySenderIds() != null) { newGateWayIds = new HashSet<>(prConfig.getGatewaySenderIds()); } else { newGateWayIds = new HashSet<>(); } newGateWayIds.add(aeqId); prConfig.setGatewaySenderIds(newGateWayIds); updatePRConfig(prConfig, false); }
String rId = getRegionIdentifier(); try { if (logger.isDebugEnabled()) {
/** * This method checks whether this PartitionedRegion is eligible for the destruction or not. It * first gets the prConfig for this region, and if it NULL, it sends a * destroyPartitionedRegionLocally call as a pure precautionary measure. If it is not null, we * check if this call is intended for this region only and there is no new PartitionedRegion * creation with the same name. This check fixes, bug # 34621. * * @return true, if it is eligible for the region destroy */ private boolean checkIfAlreadyDestroyedOrOldReference() { PartitionRegionConfig prConfig = null; try { prConfig = prRoot.get(this.getRegionIdentifier()); } catch (CancelException ignore) { // ignore, metadata not accessible } boolean isAlreadyDestroyedOrOldReference = false; if (null == prConfig) { isAlreadyDestroyedOrOldReference = true; } else { // If this reference is a destroyed reference and a new PR is created // after destruction of the older one is complete, bail out. if (prConfig.getPRId() != this.partitionedRegionId) { isAlreadyDestroyedOrOldReference = true; } } return isAlreadyDestroyedOrOldReference; }
@Before public void setup() { manager = mock(DistributionManager.class); when(manager.getDistributionManagerId()) .thenReturn(new InternalDistributedMember("localhost", 1)); partitionedRegion = mock(PartitionedRegion.class); advisor = mock(DistributionAdvisor.class); when(partitionedRegion.getDistributionAdvisor()).thenReturn(advisor); when(partitionedRegion.getRegionIdentifier()).thenReturn("testRegion"); }
public void updatePRConfigWithNewSetOfGatewaySenders(Set<String> gatewaySendersToAdd) { PartitionRegionHelper.assignBucketsToPartitions(this); PartitionRegionConfig prConfig = this.prRoot.get(getRegionIdentifier()); prConfig.setGatewaySenderIds(gatewaySendersToAdd); updatePRConfig(prConfig, false); }
/** * 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, 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 } }
Region prRoot = PartitionedRegionHelper.getPRRoot(prRegion.getCache()); PartitionRegionConfig config = (PartitionRegionConfig) prRoot.get(prRegion.getRegionIdentifier()); if (!config.isColocationComplete()) { throw new IllegalStateException("Cannot create buckets, as colocated regions are not "
when(fileAndChunkRegion.getFullPath()).thenReturn("FileRegion"); when(fileAndChunkRegion.getCache()).thenReturn(cache); when(fileAndChunkRegion.getRegionIdentifier()).thenReturn("rid"); indexStats = Mockito.mock(LuceneIndexStats.class); fileSystemStats = Mockito.mock(FileSystemStats.class);
/** * A utility to check to see if a region has been created on all of the VMs that host the regions * this region is colocated with. */ public static boolean isColocationComplete(PartitionedRegion region) { Region prRoot = PartitionedRegionHelper.getPRRoot(region.getCache()); PartitionRegionConfig config = (PartitionRegionConfig) prRoot.get(region.getRegionIdentifier()); // Fix for bug 40075. There is race between this call and the region being concurrently // destroyed. if (config == null) { Assert.assertTrue(region.isDestroyed() || region.isClosed, "Region is not destroyed, but there is no entry in the prRoot for region " + region); return false; } return config.isColocationComplete(); }
prConfig = prRoot.get(this.getRegionIdentifier()); } catch (CancelException ignore) { this.prRoot.put(this.getRegionIdentifier(), prConfig); } catch (CancelException ignore) {
public IndexRepository computeIndexRepository(final Integer bucketId, LuceneSerializer serializer, InternalLuceneIndex index, PartitionedRegion userRegion, final IndexRepository oldRepository, PartitionedRepositoryManager partitionedRepositoryManager) throws IOException { LuceneIndexForPartitionedRegion indexForPR = (LuceneIndexForPartitionedRegion) index; final PartitionedRegion fileRegion = indexForPR.getFileAndChunkRegion(); // We need to ensure that all members have created the fileAndChunk region before continuing Region prRoot = PartitionedRegionHelper.getPRRoot(fileRegion.getCache()); PartitionRegionConfig prConfig = (PartitionRegionConfig) prRoot.get(fileRegion.getRegionIdentifier()); LuceneFileRegionColocationListener luceneFileRegionColocationCompleteListener = new LuceneFileRegionColocationListener(partitionedRepositoryManager, bucketId); fileRegion.addColocationListener(luceneFileRegionColocationCompleteListener); IndexRepository repo = null; if (prConfig.isColocationComplete()) { repo = finishComputingRepository(bucketId, serializer, userRegion, oldRepository, index); } return repo; }
colocatedLockAcquired = true; final PartitionRegionConfig parentConf = this.prRoot.get(colocatedRegion.getRegionIdentifier()); if (parentConf.isColocationComplete() && parentConf.hasSameDataStoreMembers(prConfig)) { colocationComplete = true; this.prRoot.put(getRegionIdentifier(), prConfig);
private PartitionRegionConfig getPRConfigWithLatestExpirationAttributes() { PartitionRegionConfig prConfig = this.prRoot.get(getRegionIdentifier()); return new PartitionRegionConfig(prConfig.getPRId(), prConfig.getFullPath(), prConfig.getPartitionAttrs(), prConfig.getScope(), prConfig.getEvictionAttributes(), this.getRegionIdleTimeout(), this.getRegionTimeToLive(), this.getEntryIdleTimeout(), this.getEntryTimeToLive(), prConfig.getGatewaySenderIds()); }