@Override public Object getSerializedValue(LocalRegion localRegion, KeyInfo keyInfo, boolean doNotLockEntry, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent, boolean returnTombstones) throws DataLocationException { PartitionedRegion pr = (PartitionedRegion) localRegion; return pr.getDataStore().getSerializedLocally(keyInfo, doNotLockEntry, requestingClient, clientEvent, returnTombstones); }
protected boolean areLocalBucketQueueRegionsPresent() { boolean bucketsAvailable = false; for (PartitionedRegion prQ : this.userRegionNameToshadowPRMap.values()) { if (prQ.getDataStore().getAllLocalBucketRegions().size() > 0) return true; } return false; }
@Override public CachePerfStats getRegionPerfStats() { PartitionedRegionDataStore ds = getDataStore(); CachePerfStats result = null; if (ds != null) { // If we don't have a data store (we are an accessor) // then we do not have per region stats. // This is not good. We should still have stats even for accessors. result = ds.getCachePerfStats(); // fixes 46692 } return result; }
protected Set<BucketRegion> getLocalBucketRegions(PartitionedRegion pr) { Set<BucketRegion> localBucketRegions = new HashSet<BucketRegion>(); if (pr.isDataStore()) { localBucketRegions = pr.getDataStore().getAllLocalBucketRegions(); } return localBucketRegions; }
private StoppableReadLock getParentBucketCreationLock() { PartitionedRegion colocatedRegion = ColocationHelper.getColocatedRegion(this.partitionedRegion); StoppableReadLock parentLock = null; if (colocatedRegion != null) { parentLock = colocatedRegion.getDataStore().bucketCreationLock.readLock(); return parentLock; } return null; }
/** * Find the bucket in region2 that matches the bucket id from region1. */ protected BucketRegion getMatchingBucket(PartitionedRegion region, Integer bucketId) { // Force the bucket to be created if it is not already region.getOrCreateNodeForBucketWrite(bucketId, null); return region.getDataStore().getLocalBucketById(bucketId); } }
@Override public int size() { int size = 0; for (Integer bId : buckets) { BucketRegion br = proxy.getDataStore().getLocalBucketById(bId); size += br.size(); } return size; }
@Override public EntryExpiryTask getEntryExpiryTask(Object key) { BucketRegion br = this.getDataStore().getLocalBucketByKey(key); if (br == null) { throw new EntryNotFoundException("Bucket for key " + key + " does not exist."); } return br.getEntryExpiryTask(key); }
private void checkForBucketMovement(Object oneResult) { if (!(forwardExceptions && oneResult instanceof Throwable) && !pr.getDataStore().areAllBucketsHosted(bucketSet)) { // making sure that we send all the local results first // before sending this exception to client bme = new BucketMovedException( "Bucket migrated to another node. Please retry."); if (function.isHA()) { throw bme; } } }
@Before public void setup() throws Exception { partitionedRegion = mock(PartitionedRegion.class, RETURNS_DEEP_STUBS); dataStore = mock(PartitionedRegionDataStore.class); bucketRegion = mock(BucketRegion.class, RETURNS_DEEP_STUBS); keys = new Object[] {1}; entryData = mock(DistributedPutAllOperation.PutAllEntryData.class); when(partitionedRegion.getDataStore()).thenReturn(dataStore); when(dataStore.getInitializedBucketForId(null, bucketId)).thenReturn(bucketRegion); when(entryData.getEventID()).thenReturn(mock(EventID.class)); }
@Before public void setup() throws Exception { partitionedRegion = mock(PartitionedRegion.class, RETURNS_DEEP_STUBS); dataStore = mock(PartitionedRegionDataStore.class); bucketRegion = mock(BucketRegion.class, RETURNS_DEEP_STUBS); keys = new Object[] {1}; entryData = mock(DistributedRemoveAllOperation.RemoveAllEntryData.class); when(partitionedRegion.getDataStore()).thenReturn(dataStore); when(dataStore.getInitializedBucketForId(null, bucketId)).thenReturn(bucketRegion); when(entryData.getEventID()).thenReturn(mock(EventID.class)); }
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 invalidateOnRemote(EntryEventImpl event, boolean invokeCallbacks, boolean forceNewEntry) throws DataLocationException { PartitionedRegion pr = (PartitionedRegion) event.getRegion(); pr.getDataStore().invalidateLocally(event.getKeyInfo().getBucketId(), event); }
@Override public boolean putEntryOnRemote(EntryEventImpl event, boolean ifNew, boolean ifOld, Object expectedOldValue, boolean requireOldValue, long lastModified, boolean overwriteDestroyed) throws DataLocationException { PartitionedRegion pr = (PartitionedRegion) event.getRegion(); return pr.getDataStore().putLocally(event.getKeyInfo().getBucketId(), event, ifNew, ifOld, expectedOldValue, requireOldValue, lastModified); }
@Override public void destroyOnRemote(EntryEventImpl event, boolean cacheWrite, Object expectedOldValue) throws DataLocationException { PartitionedRegion pr = (PartitionedRegion) event.getRegion(); pr.getDataStore().destroyLocally(event.getKeyInfo().getBucketId(), event, expectedOldValue); return; }
private boolean isColocatedPartitionedRegionInitialized(PartitionedRegion partitionedRegion, final int bucketId) { if (!partitionedRegion.isInitialized()) { return false; } if (!partitionedRegion.getDataStore().isColocationComplete(bucketId)) { return false; } List<PartitionedRegion> colocatedWithList = getColocatedChildRegions(partitionedRegion); return areAllColocatedPartitionedRegionsReady(bucketId, colocatedWithList); }
@Test public void createLuceneIndexOnExistingRegionShouldNotThrowNPEIfBucketMovedDuringReindexing() { LuceneIndexImpl index = mock(LuceneIndexImpl.class); PartitionedRegionDataStore dataStore = mock(PartitionedRegionDataStore.class); when(region.getDataStore()).thenReturn(dataStore); Integer bucketIds[] = {1, 2, 3, 4, 5}; Set<Integer> primaryBucketIds = new HashSet(Arrays.asList(bucketIds)); when(dataStore.getAllLocalPrimaryBucketIds()).thenReturn(primaryBucketIds); when(dataStore.getLocalBucketById(3)).thenReturn(null); boolean result = service.createLuceneIndexOnDataRegion(region, index); assertTrue(result); }
@Override protected boolean includePartitionedRegion(PartitionedRegion region) { return region.getEvictionAttributes().getAlgorithm().isLRUHeap() && region.getDataStore() != null && region.getAttributes().getOffHeap(); }
@Override @Before public void setUp() { cache = Fakes.cache(); userRegion = Mockito.mock(PartitionedRegion.class); userDataStore = Mockito.mock(PartitionedRegionDataStore.class); when(userRegion.getDataStore()).thenReturn(userDataStore); when(cache.getRegion("/testRegion")).thenReturn(userRegion); serializer = new HeterogeneousLuceneSerializer(); createIndexAndRepoManager(); }
@Override protected boolean operateOnPartitionedRegion(ClusterDistributionManager dm, PartitionedRegion region, long startTime) throws ForceReattemptException { PartitionedRegionDataStore dataStore = region.getDataStore(); boolean moved = dataStore.moveBucket(this.bucketId, this.source, true); region.getPrStats().endPartitionMessagesProcessing(startTime); MoveBucketReplyMessage.send(getSender(), getProcessorId(), dm, null, moved); return false; }