foundLock.wait(1000); checkForPrimary();
@Override protected DistributedRegion createAndDefineRegion(boolean isConcurrencyChecksEnabled, RegionAttributes ra, InternalRegionArguments ira, GemFireCacheImpl cache) { BucketRegion br = new BucketRegion("testRegion", ra, null, cache, ira); // it is necessary to set the event tracker to initialized, since initialize() in not being // called on the instantiated region br.getEventTracker().setInitialized(); // since br is a real bucket region object, we need to tell mockito to monitor it br = spy(br); // doNothing().when(dm).addMembershipListener(any()); doNothing().when(br).distributeUpdateOperation(any(), anyLong()); doNothing().when(br).distributeDestroyOperation(any()); doNothing().when(br).distributeInvalidateOperation(any()); doNothing().when(br).distributeUpdateEntryVersionOperation(any()); doNothing().when(br).checkForPrimary(); doNothing().when(br).handleWANEvent(any()); doReturn(false).when(br).needWriteLock(any()); return br; }
/** * lock this bucket and, if present, its colocated "parent" * * @param tryLock - whether to use tryLock (true) or a blocking lock (false) * @return true if locks were obtained and are still held */ public boolean doLockForPrimary(boolean tryLock) { boolean locked = lockPrimaryStateReadLock(tryLock); if (!locked) { return false; } boolean isPrimary = false; try { // Throw a PrimaryBucketException if this VM is assumed to be the // primary but isn't, preventing update and distribution checkForPrimary(); if (cache.isCacheAtShutdownAll()) { throw cache.getCacheClosedException("Cache is shutting down"); } isPrimary = true; } finally { if (!isPrimary) { doUnlockForPrimary(); } } return true; }
if (keyInfo.isCheckPrimary()) { try { br.checkForPrimary(); } catch (PrimaryBucketException pbe) { throw new TransactionDataRebalancedException(