@Override public String toString() { if (this.partitionedRegion != null) { String rName = this.partitionedRegion.getFullPath(); return this.partitionedRegion.getMyId() + "@" + getClass().getName() + "@" + System.identityHashCode(this) + " name: " + rName + " bucket count: " + this.localBucket2RegionMap.size(); } return null; }
@Override public String toString() { return new StringBuffer().append("Partitioned Region ").append("@") .append(Integer.toHexString(hashCode())).append(" [").append("path='").append(getFullPath()) .append("'; dataPolicy=").append(this.getDataPolicy()).append("; prId=") .append(this.partitionedRegionId).append("; isDestroyed=").append(this.isDestroyed) .append("; isClosed=").append(this.isClosed).append("; retryTimeout=") .append(this.retryTimeout).append("; serialNumber=").append(getSerialNumber()) .append("; partition attributes=").append(getPartitionAttributes().toString()) .append("; on VM ").append(getMyId()).append("]").toString(); }
public boolean isPersistentRecoveryComplete() { if (!ColocationHelper.checkMembersColocation(this.prRegion, this.prRegion.getMyId())) { return false; } if (allBucketsRecoveredFromDisk != null && allBucketsRecoveredFromDisk.getCount() > 0) { return false; } Map<String, PartitionedRegion> colocatedRegions = ColocationHelper.getAllColocationRegions(this.prRegion); for (PartitionedRegion region : colocatedRegions.values()) { PRHARedundancyProvider redundancyProvider = region.getRedundancyProvider(); if (redundancyProvider.allBucketsRecoveredFromDisk != null && redundancyProvider.allBucketsRecoveredFromDisk.getCount() > 0) { return false; } } return true; }
/** * This is for FPR, for given partition, we have to return the set of datastores on which the * given partition is defined * * @param partitionName name of the partition for which datastores need to be found out */ private Set<InternalDistributedMember> getFixedPartitionStores(String partitionName) { Set<InternalDistributedMember> members = this.prRegion.getRegionAdvisor().adviseFixedPartitionDataStores(partitionName); List<FixedPartitionAttributesImpl> FPAs = this.prRegion.getFixedPartitionAttributesImpl(); if (FPAs != null) { for (FixedPartitionAttributesImpl fpa : FPAs) { if (fpa.getPartitionName().equals(partitionName)) { members.add((InternalDistributedMember) this.prRegion.getMyId()); } } } return members; }
recips.remove(getMyId()); if (!recips.isEmpty()) { Map<Integer, SizeEntry> remoteSizes = getSizeRemotely(recips, false);
/** * If a bucket is local, try to fetch the value from it */ public Object getFromLocalBucket(int bucketId, final Object key, final Object aCallbackArgument, boolean disableCopyOnRead, boolean preferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent, boolean returnTombstones) throws ForceReattemptException, PRLocallyDestroyedException { Object obj; // try reading locally. InternalDistributedMember readNode = getNodeForBucketRead(bucketId); if (readNode == null) { return null; // fixes 51657 } if (readNode.equals(getMyId()) && null != (obj = this.dataStore.getLocally(bucketId, key, aCallbackArgument, disableCopyOnRead, preferCD, requestingClient, clientEvent, returnTombstones, true))) { if (logger.isTraceEnabled()) { logger.trace("getFromBucket: Getting key {} ({}) locally - success", key, key.hashCode()); } return obj; } return null; }
/** * Fetch a BucketRegion, but do not return until it is initialized * * @param key optional for error reporting; if none, no key available. * @param bucketId the bucket to fetch * @return the region */ public BucketRegion getInitializedBucketForId(Object key, Integer bucketId) throws ForceReattemptException { final BucketRegion bucketRegion = this.localBucket2RegionMap.get(bucketId); if (null == bucketRegion) { this.partitionedRegion.checkReadiness(); if (logger.isDebugEnabled()) { logger.debug("Got null bucket region for bucketId={}{}{} for PartitionedRegion = {}", this.partitionedRegion.getPRId(), PartitionedRegion.BUCKET_ID_SEPARATOR, bucketId, this.partitionedRegion); } ForceReattemptException fre = new BucketNotFoundException( String.format("Bucket id %s not found on VM %s", new Object[] {this.partitionedRegion.bucketStringForLogs(bucketId.intValue()), this.partitionedRegion.getMyId()})); if (key != null) { fre.setHash(key.hashCode()); } throw fre; } bucketRegion.waitForData(); return bucketRegion; }
@Override public void localDestroyRegion(Object aCallbackArgument) { getDataView().checkSupportsRegionDestroy(); String prName = this.getColocatedWith(); List<PartitionedRegion> listOfChildRegions = ColocationHelper.getColocatedChildRegions(this); List<String> childRegionsWithoutSendersList = new ArrayList<String>(); if (listOfChildRegions.size() != 0) { for (PartitionedRegion childRegion : listOfChildRegions) { if (!childRegion.getName().contains(ParallelGatewaySenderQueue.QSTRING)) { childRegionsWithoutSendersList.add(childRegion.getFullPath()); } } } if ((prName != null) || (!childRegionsWithoutSendersList.isEmpty())) { throw new UnsupportedOperationException( "Any Region in colocation chain cannot be destroyed locally."); } RegionEventImpl event = new RegionEventImpl(this, Operation.REGION_LOCAL_DESTROY, aCallbackArgument, false, getMyId(), generateEventID()/* generate EventID */); try { basicDestroyRegion(event, false); } catch (CacheWriterException e) { // not possible with local operation, CacheWriter not called throw new Error("CacheWriterException should not be thrown in localDestroyRegion", e); } catch (TimeoutException e) { // not possible with local operation, no distributed locks possible throw new Error("TimeoutException should not be thrown in localDestroyRegion", e); } }
public void initialize(GemFireCacheImpl cache, PartitionedRegion queueRegion) { InternalDistributedMember member = cache.getMyId(); when(queueRegion.getMyId()).thenReturn(member); when(cache.getRegionByPath(this.bucketRegionQueue.getFullPath())) .thenReturn(this.bucketRegionQueue); } }
while (itr.hasNext()) { InternalDistributedMember idm = ((Node) itr.next()).getMemberId(); if (!idm.equals(getMyId())) { configRecipients.add(idm);
final InternalDistributedMember creationRequestor, final boolean isDiskRecovery) { CreateBucketResult grab; DistributedMember dm = pr.getMyId(); List<PartitionedRegion> colocatedWithList = ColocationHelper.getColocatedChildRegions(pr);
@Before public void setup() throws Exception { localNode = new InternalDistributedMember("localhost", 8888); remoteNodeA = new InternalDistributedMember("localhost", 8889); remoteNodeB = new InternalDistributedMember("localhost", 8890); cache = Fakes.cache(); system = (InternalDistributedSystem) cache.getDistributedSystem(); allNodes.add(localNode); allNodes.add(remoteNodeA); allNodes.add(remoteNodeB); pr = mock(PartitionedRegion.class); dataStore = new ExtendedPartitionedRegionDataStore(); CompiledSelect select = mock(CompiledSelect.class); when(select.getType()).thenReturn(CompiledValue.COMPARISON); when(select.getElementTypeForOrderByQueries()).thenReturn(new ObjectTypeImpl(String.class)); query = mock(DefaultQuery.class); when(query.getSimpleSelect()).thenReturn(select); when(query.getLimit(any())).thenReturn(-1); when(pr.getCachePerfStats()).thenReturn(mock(CachePerfStats.class)); when(pr.getMyId()).thenReturn(localNode); when(pr.getDataStore()).thenReturn(dataStore); when(pr.getCache()).thenReturn(cache); }
InternalDistributedMember localMember = (InternalDistributedMember) pr.getMyId();
private void setNetworkHopType(final Integer bucketId, final InternalDistributedMember targetNode) { if (this.isDataStore() && !getMyId().equals(targetNode)) { Set<ServerBucketProfile> profiles = this.getRegionAdvisor().getClientBucketProfiles(bucketId); if (profiles != null) { for (ServerBucketProfile profile : profiles) { if (profile.getDistributedMember().equals(targetNode)) { if (isProfileFromSameGroup(profile)) { if (this.getNetworkHopType() != NETWORK_HOP_TO_SAME_GROUP && logger.isDebugEnabled()) { logger.debug( "one-hop: cache op meta data staleness observed. Message is in same server group (byte 1)"); } this.setNetworkHopType((byte) NETWORK_HOP_TO_SAME_GROUP); } else { if (this.getNetworkHopType() != NETWORK_HOP_TO_DIFFERENT_GROUP && logger.isDebugEnabled()) { logger.debug( "one-hop: cache op meta data staleness observed. Message is to different server group (byte 2)"); } this.setNetworkHopType((byte) NETWORK_HOP_TO_DIFFERENT_GROUP); } this.setMetadataVersion((byte) profile.getVersion()); break; } } } } }
@Override public void destroyRegion(Object aCallbackArgument) throws CacheWriterException, TimeoutException { this.cache.invokeBeforeDestroyed(this); checkForColocatedChildren(); getDataView().checkSupportsRegionDestroy(); checkForLimitedOrNoAccess(); RegionEventImpl event = new RegionEventImpl(this, Operation.REGION_DESTROY, aCallbackArgument, false, getMyId(), generateEventID()); basicDestroyRegion(event, true); }
if (txState != null) { if (txState.isRealDealLocal()) { targetNode = getMyId(); } else { targetNode = (InternalDistributedMember) txState.getTarget();
@Override protected RegionEntry basicGetTXEntry(KeyInfo keyInfo) { int bucketId = keyInfo.getBucketId(); if (bucketId == KeyInfo.UNKNOWN_BUCKET) { bucketId = PartitionedRegionHelper.getHashKey(this, null, keyInfo.getKey(), keyInfo.getValue(), keyInfo.getCallbackArg()); keyInfo.setBucketId(bucketId); } if (keyInfo.isCheckPrimary()) { DistributedMember primary = getRegionAdvisor().getPrimaryMemberForBucket(bucketId); if (!primary.equals(getMyId())) { throw new PrimaryBucketException( "Bucket " + bucketId + " is not primary. Current primary holder is " + primary); } } BucketRegion br = this.dataStore.getLocalBucketById(bucketId); RegionEntry re = br.basicGetEntry(keyInfo.getKey()); if (re != null && re.isRemoved()) { re = null; } return re; }
boolean putResult = false; VersionedObjectList versions = null; final boolean isLocal = (this.localMaxMemory > 0) && currentTarget.equals(getMyId()); if (isLocal) { // local
boolean putResult = false; VersionedObjectList versions = null; final boolean isLocal = (this.localMaxMemory > 0) && currentTarget.equals(getMyId()); if (isLocal) { // local
if (!getMyId().equals(member) && keyInfo.isCheckPrimary()) { throw new PrimaryBucketException( "Bucket " + bucketId + " is not primary. Current primary holder is " + member);