@Override public AttributesMutator getAttributesMutator() { checkReadiness(); return this; }
@Override public boolean hasNext() { PartitionedRegion.this.checkReadiness(); if (this.currentBucketI.hasNext()) { return true; } else { while (!this.currentBucketI.hasNext() && this.bucketSetI.hasNext()) { PartitionedRegion.this.checkReadiness(); this.currentBucketI = getNextBucketIter(false); } return this.currentBucketI.hasNext(); } }
@Override public Set keySet(boolean allowTombstones) { checkReadiness(); return Collections.unmodifiableSet(new KeysSet(allowTombstones)); }
public Set keysWithoutCreatesForTests() { checkReadiness(); Set<Integer> availableBuckets = new HashSet<Integer>(); for (int i = 0; i < getTotalNumberOfBuckets(); i++) { if (distAdvisor.isStorageAssignedForBucket(i)) { availableBuckets.add(i); } } return Collections.unmodifiableSet(new KeysSet(availableBuckets)); }
/** * This method returns collection of all the values of this PartitionedRegion(locally or * remotely). * * @return collection of all the values of this PartitionedRegion */ @Override public Collection values() { checkReadiness(); if (!restoreSetOperationTransactionBehavior) { discoverJTA(); } return Collections.unmodifiableSet(new ValuesSet()); }
/** * This method returns set of all the keys of this PartitionedRegion(locally or remotely). * * @return set of all the keys of this PartitionedRegion * * OVERRIDES */ @Override public Set keys() { checkReadiness(); if (!restoreSetOperationTransactionBehavior) { discoverJTA(); } return Collections.unmodifiableSet(new KeysSet()); }
@Override public Collection values() { this.proxy.checkReadiness(); return this.proxy.new ValuesSet(getBucketSet()); }
/** * Throw a ForceReattemptException if bucket has been moved out of this data store. */ private void checkIfBucketMoved(BucketRegion br) throws ForceReattemptException { if (br.isBucketDestroyed()) { this.partitionedRegion.checkReadiness(); throw new ForceReattemptException("bucket moved to other member during read op"); } }
/** * Check for region closure, region destruction, cache closure as well as distributed system * disconnect. As of 6/21/2007, there were at least four volatile variables reads and one * synchonrization performed upon completion of this method. */ private void checkShutdown() { checkReadiness(); this.cache.getCancelCriterion().checkCancelInProgress(null); }
public KeysSetIterator(Set<Integer> bucketSet, boolean allowTombstones) { PartitionedRegion.this.checkReadiness(); this.bucketSet = bucketSet; this.allowTombstones = allowTombstones; this.bucketSetI = createBucketSetI(); this.currentBucketI = getNextBucketIter(false /* no throw */); }
void doPostRemoveAll(PartitionedRegion r, DistributedRemoveAllOperation op, BucketRegion bucketRegion, boolean lockedForPrimary) { try { // Only RemoveAllPRMessage knows if the thread id is fake. Event has no idea. // So we have to manually set useFakeEventId for this op op.setUseFakeEventId(true); r.checkReadiness(); bucketRegion.getDataView().postRemoveAll(op, this.versions, bucketRegion); r.checkReadiness(); } finally { if (lockedForPrimary) { bucketRegion.doUnlockForPrimary(); } } }
void doPostPutAll(PartitionedRegion r, DistributedPutAllOperation dpao, BucketRegion bucketRegion, boolean lockedForPrimary) { try { // Only PutAllPRMessage knows if the thread id is fake. Event has no idea. // So we have to manually set useFakeEventId for this DPAO dpao.setUseFakeEventId(true); r.checkReadiness(); bucketRegion.getDataView().postPutAll(dpao, this.versions, bucketRegion); r.checkReadiness(); } finally { if (lockedForPrimary) { bucketRegion.doUnlockForPrimary(); } } }
@Test public void doPostPutAllCallsCheckReadinessBeforeAndAfter() throws Exception { DistributedPutAllOperation distributedPutAllOperation = mock(DistributedPutAllOperation.class); InternalDataView internalDataView = mock(InternalDataView.class); when(bucketRegion.getDataView()).thenReturn(internalDataView); PutAllPRMessage putAllPRMessage = new PutAllPRMessage(); putAllPRMessage.doPostPutAll(partitionedRegion, distributedPutAllOperation, bucketRegion, true); InOrder inOrder = inOrder(partitionedRegion, internalDataView); inOrder.verify(partitionedRegion).checkReadiness(); inOrder.verify(internalDataView).postPutAll(any(), any(), any()); inOrder.verify(partitionedRegion).checkReadiness(); }
@Override public boolean containsKey(Object key) { checkReadiness(); validateKey(key); return getDataView().containsKey(getKeyInfo(key), this); }
@Test public void doPostRemoveAllCallsCheckReadinessBeforeAndAfter() throws Exception { DistributedRemoveAllOperation distributedRemoveAllOperation = mock(DistributedRemoveAllOperation.class); InternalDataView internalDataView = mock(InternalDataView.class); when(bucketRegion.getDataView()).thenReturn(internalDataView); RemoveAllPRMessage removeAllPRMessage = new RemoveAllPRMessage(); removeAllPRMessage.doPostRemoveAll(partitionedRegion, distributedRemoveAllOperation, bucketRegion, true); InOrder inOrder = inOrder(partitionedRegion, internalDataView); inOrder.verify(partitionedRegion).checkReadiness(); inOrder.verify(internalDataView).postRemoveAll(any(), any(), any()); inOrder.verify(partitionedRegion).checkReadiness(); }
@Test(expected = RegionDestroyedException.class) public void waitUntilLockedThrowsIfFoundLockAndPartitionedRegionIsClosing() { BucketRegion bucketRegion = spy(new BucketRegion(regionName, regionAttributes, partitionedRegion, cache, internalRegionArgs)); Integer[] keys = {1}; doReturn(mock(LockObject.class)).when(bucketRegion).searchAndLock(keys); doThrow(regionDestroyedException).when(partitionedRegion) .checkReadiness(); bucketRegion.waitUntilLocked(keys); }
@Override public void checkInterruptedByShutdownAll() { // when ShutdownAll is on-going, break all the GII for BR if (proxyBucket.getCache().isCacheAtShutdownAll()) { throw proxyBucket.getCache().getCacheClosedException("Cache is being closed by ShutdownAll"); } proxyBucket.getPartitionedRegion().checkReadiness(); }
@Override protected boolean operateOnPartitionedRegion(ClusterDistributionManager dm, PartitionedRegion pr, long startTime) throws CacheException, ForceReattemptException { if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) { logger.trace(LogMarker.DM_VERBOSE, "PrimaryRequestMessage operateOnRegion: {}", pr.getFullPath()); } pr.checkReadiness(); final boolean isPrimary; // TODO, I am sure if this is the method to call to elect the primary -- mthomas 4/19/2007 if (dm.getId().equals(pr.getBucketPrimary(this.bucketId))) { isPrimary = true; } else { isPrimary = false; } PrimaryRequestReplyMessage.sendReply(getSender(), getProcessorId(), isPrimary, dm); return false; }
public InternalDistributedMember getOrCreateNodeForBucketRead(int bucketId) { InternalDistributedMember targetNode = getNodeForBucketRead(bucketId); if (targetNode != null) { return targetNode; } try { return createBucket(bucketId, 0, null); } catch (PartitionedRegionStorageException e) { // try not to throw a PRSE if the cache is closing or this region was // destroyed during createBucket() (bug 36574) this.checkReadiness(); if (this.cache.isClosed()) { throw new RegionDestroyedException(toString(), getFullPath()); } throw e; } }
public void checkForPrimary() { final boolean isp = getBucketAdvisor().isPrimary(); if (!isp) { this.partitionedRegion.checkReadiness(); checkReadiness(); InternalDistributedMember primaryHolder = getBucketAdvisor().basicGetPrimaryMember(); throw new PrimaryBucketException( "Bucket " + getName() + " is not primary. Current primary holder is " + primaryHolder); } }