/** * A fake distributed system, which contains a fake distribution manager. */ public static InternalDistributedSystem distributedSystem() { return cache().getInternalDistributedSystem(); }
when(cache.getInternalDistributedSystem()).thenReturn(system); when(cache.getSystem()).thenReturn(system); when(cache.getMyId()).thenReturn(member);
/** * Gets or lazily creates the PartitionedRegion distributed lock service. This call will * synchronize on this GemFireCache. * * @return the PartitionedRegion distributed lock service */ @Override public DistributedLockService getPartitionedRegionLockService() { synchronized (this.prLockServiceLock) { this.stopper.checkCancelInProgress(null); if (this.prLockService == null) { try { this.prLockService = DLockService.create(PartitionedRegionHelper.PARTITION_LOCK_SERVICE_NAME, getInternalDistributedSystem(), true /* distributed */, true /* destroyOnDisconnect */, true /* automateFreeResources */); } catch (IllegalArgumentException e) { this.prLockService = DistributedLockService .getServiceNamed(PartitionedRegionHelper.PARTITION_LOCK_SERVICE_NAME); if (this.prLockService == null) { throw e; // PARTITION_LOCK_SERVICE_NAME must be illegal! } } } return this.prLockService; } }
/** * Gets or lazily creates the GatewaySender distributed lock service. * * @return the GatewaySender distributed lock service */ @Override public DistributedLockService getGatewaySenderLockService() { if (this.gatewayLockService == null) { synchronized (this.gatewayLockServiceLock) { this.stopper.checkCancelInProgress(null); if (this.gatewayLockService == null) { try { this.gatewayLockService = DLockService.create(AbstractGatewaySender.LOCK_SERVICE_NAME, getInternalDistributedSystem(), true /* distributed */, true /* destroyOnDisconnect */, true /* automateFreeResources */); } catch (IllegalArgumentException e) { this.gatewayLockService = DistributedLockService.getServiceNamed(AbstractGatewaySender.LOCK_SERVICE_NAME); if (this.gatewayLockService == null) { throw e; // AbstractGatewaySender.LOCK_SERVICE_NAME must be illegal! } } } } } return this.gatewayLockService; }
when(lr.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(cache.getDistributedSystem()).thenReturn(ds); when(cache.getInternalDistributedSystem()).thenReturn(ds); when(cache.getSearchTimeout()).thenReturn(30); when(attrs.getScope()).thenReturn(Scope.DISTRIBUTED_ACK);
@Test public void testProcessChunk() throws Exception { cache = Fakes.cache(); PartitionedRegion pr = mock(PartitionedRegion.class); InternalDistributedSystem system = cache.getInternalDistributedSystem(); FetchEntriesResponse response = new FetchEntriesResponse(system, pr, null, 0); HeapDataOutputStream chunkStream = createDummyChunk(); FetchEntriesReplyMessage reply = new FetchEntriesReplyMessage(null, 0, 0, chunkStream, 0, 0, 0, false, false); reply.chunk = chunkStream.toByteArray(); response.processChunk(reply); assertNull(response.returnRVV); assertEquals(2, response.returnValue.size()); assertTrue(response.returnValue.get("keyWithOutVersionTag").equals("valueWithOutVersionTag")); assertTrue(response.returnValue.get("keyWithVersionTag").equals("valueWithVersionTag")); assertNull(response.returnVersions.get("keyWithOutVersionTag")); assertNotNull(response.returnVersions.get("keyWithVersionTag")); } }