/** * Return the primary for the local bucket. Returns null if no primary can be found within * {@link DistributionConfig#getMemberTimeout}. * * @return the primary bucket member */ public InternalDistributedMember getBucketPrimary(int bucketId) { return getRegionAdvisor().getPrimaryMemberForBucket(bucketId); }
private Set<InternalDistributedMember> getAllRecipients(InternalCache cache, Map map) { Set recipients = new ObjectOpenHashSet(); for (Object pr : map.keySet()) { PartitionedRegion partitionedRegion = (PartitionedRegion) cache.getRegion((String) pr); if (partitionedRegion != null && partitionedRegion.getRegionAdvisor() != null) { recipients.addAll(partitionedRegion.getRegionAdvisor().adviseDataStore()); } } return recipients; }
public static Set<FixedPartitionAttributes> getAllFixedPartitionAttributes( PartitionedRegion region) { Set<FixedPartitionAttributes> fpaSet = new HashSet<FixedPartitionAttributes>(); List<FixedPartitionAttributesImpl> localFPAs = region.getFixedPartitionAttributesImpl(); if (localFPAs != null) { fpaSet.addAll(localFPAs); } List<FixedPartitionAttributesImpl> remoteFPAs = region.getRegionAdvisor().adviseAllFixedPartitionAttributes(); fpaSet.addAll(remoteFPAs); return fpaSet; }
/** * Throw an exception if persistent data recovery from disk is not complete for this region. */ public void checkPROffline() throws PartitionOfflineException { if (getDataPolicy().withPersistence() && !recoveredFromDisk) { Set<PersistentID> persistIds = new HashSet(getRegionAdvisor().advisePersistentMembers().values()); persistIds.removeAll(getRegionAdvisor().adviseInitializedPersistentMembers().values()); throw new PartitionOfflineException(persistIds, String.format("Partitioned Region %s is offline due to unrecovered persistent data, %s", new Object[] {getFullPath(), persistIds})); } }
/** * Clean up locally created bucket and tell other VMs to attempt recovering redundancy * * @param buck the bucket identifier */ private void cleanUpBucket(int buck) { Set dataStores = this.prRegion.getRegionAdvisor().adviseDataStore(); BucketBackupMessage.send(dataStores, this.prRegion, buck); }
@Override public Set<DistributedMember> getMembers(Region region) { if (region instanceof DistributedRegion) { DistributedRegion distributedRegion = (DistributedRegion) region; return (Set<DistributedMember>) distributedRegion.getDistributionAdvisor().adviseCacheOp(); } else if (region instanceof PartitionedRegion) { PartitionedRegion partitionedRegion = (PartitionedRegion) region; return (Set<DistributedMember>) partitionedRegion.getRegionAdvisor().adviseAllPRNodes(); } else { return Collections.emptySet(); } }
/** * Send a message to all PartitionedRegion participants, telling each member of the * PartitionedRegion with a datastore to dump the contents of the allPartitionedRegions for this * PartitionedRegion. */ public void sendDumpAllPartitionedRegions() throws ReplyException { getRegionAdvisor().dumpProfiles("dumpAllPartitionedRegions"); PartitionResponse response = DumpAllPRConfigMessage.send(getRegionAdvisor().adviseAllPRNodes(), this); response.waitForRepliesUninterruptibly(); dumpSelfEntryFromAllPartitionedRegions(); }
/** * Adds a membership listener to watch for member departures, and schedules a task to recover * redundancy of existing buckets */ public void startRedundancyRecovery() { prRegion.getRegionAdvisor().addMembershipListener(new PRMembershipListener()); scheduleRedundancyRecovery(null); }
private static <K, V> Set<? extends DistributedMember> getAllForKey(final Region<K, V> r, final K key) { PartitionedRegion pr = isPartitionedCheck(r); int bucketId = PartitionedRegionHelper.getHashKey(pr, null, key, null, null); return pr.getRegionAdvisor().getBucketOwners(bucketId); }
public RegionStatus(PartitionedRegion region) { this.thisMember = createPersistentMemberID(region); this.region = region.getFullPath(); this.bucketRegions = region.getRegionAdvisor().getProxyBucketArray(); }
private Set<InternalDistributedMember> getAllStores(String partitionName) { if (partitionName != null) { return getFixedPartitionStores(partitionName); } final Set<InternalDistributedMember> allStores = this.prRegion.getRegionAdvisor().adviseDataStore(true); PartitionedRegionDataStore myDS = this.prRegion.getDataStore(); if (myDS != null) { allStores.add(this.prRegion.getDistributionManager().getId()); } return allStores; }
@Override public void checkIfAboveThreshold(EntryEventImpl entryEvent) throws LowMemoryException { getRegionAdvisor().checkIfBucketSick(entryEvent.getKeyInfo().getBucketId(), entryEvent.getKey()); }
private void sendLocalDestroyRegionMessage(RegionEventImpl event) { int serials[] = getRegionAdvisor().getBucketSerials(); RegionEventImpl eventForLocalDestroy = (RegionEventImpl) event.clone(); eventForLocalDestroy.setOperation(Operation.REGION_LOCAL_DESTROY); sendDestroyRegionMessage(event, serials); }
protected synchronized void initRMLWrappers() { if (PartitionedRegion.this.isInitialized() && hasListener()) { initPostCreateRegionMembershipListeners(getRegionAdvisor().adviseAllPRNodes()); } }
@Override protected boolean operateOnPartitionedRegion(ClusterDistributionManager dm, PartitionedRegion pr, long startTime) throws CacheException { PrimaryInfo pinfo = null; if (this.onlyReturnPrimaryInfo) { pinfo = new PrimaryInfo(pr.getRegionAdvisor().getBucket(this.bucketId).isHosting(), pr.getRegionAdvisor().isPrimaryForBucket(this.bucketId), ""); } else { pr.dumpB2NForBucket(this.bucketId); } DumpB2NReplyMessage.send(getSender(), getProcessorId(), dm, pinfo); return false; }
private BucketPersistenceAdvisor getColocatedPersistenceAdvisor() { PartitionedRegion colocatedRegion = ColocationHelper.getColocatedRegion(proxyBucket.getPartitionedRegion()); if (colocatedRegion == null) { return null; } ProxyBucketRegion colocatedProxyBucket = colocatedRegion.getRegionAdvisor().getProxyBucketArray()[proxyBucket.getBucketId()]; return colocatedProxyBucket.getPersistenceAdvisor(); } }
public boolean isRedundancyImpaired() { int numBuckets = this.prRegion.getPartitionAttributes().getTotalNumBuckets(); int targetRedundancy = this.prRegion.getPartitionAttributes().getRedundantCopies(); for (int i = 0; i < numBuckets; i++) { int redundancy = this.prRegion.getRegionAdvisor().getBucketRedundancy(i); if (redundancy < targetRedundancy && redundancy != -1 || redundancy > targetRedundancy) { return true; } } return false; }
public boolean areSecondariesPingable() { Set<InternalDistributedMember> hostingservers = this.partitionedRegion.getRegionAdvisor().getBucketOwners(this.getId()); hostingservers.remove(cache.getDistributedSystem().getDistributedMember()); if (cache.getLogger().fineEnabled()) cache.getLogger() .fine("Pinging secondaries of bucket " + this.getId() + " on servers " + hostingservers); if (hostingservers.size() == 0) return true; return ServerPingMessage.send(cache, hostingservers); }
/** * Returns true if keys needs to be tracked for clients registering interests on PR. */ private boolean hasToTrackKeysForClients(DistributedRegion r) { return r.isUsedForPartitionedRegionBucket() && ((r.getFilterProfile() != null && r.getFilterProfile().hasInterest()) || r.getPartitionedRegion().getRegionAdvisor().hasPRServerWithInterest()); }
@Override protected void setMemoryThresholdFlag(MemoryEvent event) { if (event.getState().isCritical() && !event.getPreviousState().isCritical() && (event.getType() == ResourceType.HEAP_MEMORY || (event.getType() == ResourceType.OFFHEAP_MEMORY && getOffHeap()))) { // update proxy bucket, so that we can reject operations on those buckets. getRegionAdvisor().markBucketsOnMember(event.getMember(), true/* sick */); } else if (!event.getState().isCritical() && event.getPreviousState().isCritical() && (event.getType() == ResourceType.HEAP_MEMORY || (event.getType() == ResourceType.OFFHEAP_MEMORY && getOffHeap()))) { getRegionAdvisor().markBucketsOnMember(event.getMember(), false/* not sick */); } }