use of org.apache.geode.internal.cache.BucketRegion in project geode by apache.
the class PartitionedRepositoryManagerJUnitTest method setUpMockBucket.
protected BucketRegion setUpMockBucket(int id) throws BucketNotFoundException {
BucketRegion mockBucket = Mockito.mock(BucketRegion.class);
BucketRegion fileAndChunkBucket = Mockito.mock(BucketRegion.class);
// Allowing the fileAndChunkBucket to behave like a map so that the IndexWriter operations don't
// fail
Fakes.addMapBehavior(fileAndChunkBucket);
when(fileAndChunkBucket.getFullPath()).thenReturn("File" + id);
when(mockBucket.getId()).thenReturn(id);
when(userRegion.getBucketRegion(eq(id), eq(null))).thenReturn(mockBucket);
when(userDataStore.getLocalBucketById(eq(id))).thenReturn(mockBucket);
when(userRegion.getBucketRegion(eq(id + 113), eq(null))).thenReturn(mockBucket);
when(userDataStore.getLocalBucketById(eq(id + 113))).thenReturn(mockBucket);
when(fileDataStore.getLocalBucketById(eq(id))).thenReturn(fileAndChunkBucket);
fileAndChunkBuckets.put(id, fileAndChunkBucket);
dataBuckets.put(id, mockBucket);
BucketAdvisor mockBucketAdvisor = Mockito.mock(BucketAdvisor.class);
when(fileAndChunkBucket.getBucketAdvisor()).thenReturn(mockBucketAdvisor);
when(mockBucketAdvisor.isPrimary()).thenReturn(true);
return mockBucket;
}
use of org.apache.geode.internal.cache.BucketRegion in project geode by apache.
the class IndexRepositoryImplJUnitTest method setUp.
@Before
public void setUp() throws IOException {
ConcurrentHashMap fileAndChunkRegion = new ConcurrentHashMap();
fileSystemStats = mock(FileSystemStats.class);
RegionDirectory dir = new RegionDirectory(fileAndChunkRegion, fileSystemStats);
IndexWriterConfig config = new IndexWriterConfig(analyzer);
writer = new IndexWriter(dir, config);
String[] indexedFields = new String[] { "s", "i", "l", "d", "f", "s2", "missing" };
mapper = new HeterogeneousLuceneSerializer(indexedFields);
region = Mockito.mock(Region.class);
userRegion = Mockito.mock(BucketRegion.class);
BucketAdvisor bucketAdvisor = Mockito.mock(BucketAdvisor.class);
Mockito.when(bucketAdvisor.isPrimary()).thenReturn(true);
Mockito.when(((BucketRegion) userRegion).getBucketAdvisor()).thenReturn(bucketAdvisor);
Mockito.when(((BucketRegion) userRegion).getBucketAdvisor().isPrimary()).thenReturn(true);
stats = Mockito.mock(LuceneIndexStats.class);
Mockito.when(userRegion.isDestroyed()).thenReturn(false);
repo = new IndexRepositoryImpl(region, writer, mapper, stats, userRegion, mock(DistributedLockService.class), "lockName");
}
use of org.apache.geode.internal.cache.BucketRegion in project geode by apache.
the class WANTestBase method addCacheListenerOnBucketRegion.
private void addCacheListenerOnBucketRegion(String regionName, int numBuckets) {
PartitionedRegion region = (PartitionedRegion) cache.getRegion(regionName);
for (int i = 0; i < numBuckets; i++) {
BucketRegion br = region.getBucketRegion(i);
AttributesMutator mutator = br.getAttributesMutator();
listener1 = new QueueListener();
mutator.addCacheListener(listener1);
}
}
use of org.apache.geode.internal.cache.BucketRegion in project geode by apache.
the class WANTestBase method checkBR.
public static HashMap checkBR(String regionName, int numBuckets) {
PartitionedRegion region = (PartitionedRegion) cache.getRegion(regionName);
HashMap listenerAttrs = new HashMap();
for (int i = 0; i < numBuckets; i++) {
BucketRegion br = region.getBucketRegion(i);
QueueListener listener = (QueueListener) br.getCacheListener();
listenerAttrs.put("Create" + i, listener.createList);
listenerAttrs.put("Update" + i, listener.updateList);
listenerAttrs.put("Destroy" + i, listener.destroyList);
}
return listenerAttrs;
}
use of org.apache.geode.internal.cache.BucketRegion in project geode by apache.
the class MapRangeIndex method saveIndexAddition.
protected void saveIndexAddition(Object mapKey, Object indexKey, Object value, RegionEntry entry) throws IMQException {
boolean isPr = this.region instanceof BucketRegion;
// Get RangeIndex for it or create it if absent
RangeIndex rg = (RangeIndex) this.mapKeyToValueIndex.get(mapKey);
if (rg == null) {
// use previously created MapRangeIndexStatistics
IndexStatistics stats = this.internalIndexStats;
PartitionedIndex prIndex = null;
if (isPr) {
prIndex = (PartitionedIndex) this.getPRIndex();
prIndex.incNumMapKeysStats(mapKey);
}
rg = new RangeIndex(indexName + "-" + mapKey, region, fromClause, indexedExpression, projectionAttributes, this.originalFromClause, this.originalIndexedExpression, this.canonicalizedDefinitions, stats);
rg.evaluator = this.evaluator;
this.mapKeyToValueIndex.put(mapKey, rg);
if (!isPr) {
this.internalIndexStats.incNumMapIndexKeys(1);
}
}
// rg.internalIndexStats.incUpdatesInProgress(1);
long start = System.nanoTime();
rg.saveMapping(indexKey, value, entry);
// This call is skipped when addMapping is called from MapRangeIndex
// rg.internalIndexStats.incNumUpdates();
this.internalIndexStats.incUpdatesInProgress(-1);
long end = System.nanoTime() - start;
this.internalIndexStats.incUpdateTime(end);
this.entryToMapKeysMap.add(entry, mapKey);
}
Aggregations