@Override public String cancelInProgress() { String reason = getDistributedSystem().getCancelCriterion().cancelInProgress(); if (reason != null) { return reason; } if (GemFireCacheImpl.this.disconnectCause != null) { return GemFireCacheImpl.this.disconnectCause.getMessage(); } if (GemFireCacheImpl.this.isClosing) { return "The cache is closed."; // this + ": closed"; } return null; }
/** * Get cache-wide CacheClientProxy SystemTimer * * @return the timer, lazily created */ @Override public SystemTimer getCCPTimer() { synchronized (this.ccpTimerMutex) { if (this.ccpTimer != null) { return this.ccpTimer; } this.ccpTimer = new SystemTimer(getDistributedSystem(), true); if (this.isClosing) { this.ccpTimer.cancel(); // poison it, don't throw. } return this.ccpTimer; } }
when(config.getDeployWorkingDir()).thenReturn(new File(".")); when(cache.getDistributedSystem()).thenReturn(system); when(cache.getInternalDistributedSystem()).thenReturn(system); when(cache.getSystem()).thenReturn(system);
@Before public void before() throws Exception { System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "statsDisabled", "true"); getRegionsFunction = new GetRegionsFunction(); MockitoAnnotations.initMocks(this); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.cache.getDistributedSystem()).thenReturn(mock(InternalDistributedSystem.class)); when(this.cache.getResourceManager()).thenReturn(this.internalResourceManager); when(functionContext.getResultSender()).thenReturn(testResultSender); when(functionContext.getCache()).thenReturn(cache); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { cache = Fakes.cache(); system = (InternalDistributedSystem) cache.getDistributedSystem(); pr = mock(PartitionedRegion.class); prRoot = mock(DistributedRegion.class); pa = mock(PartitionAttributes.class); prc = mock(PartitionRegionConfig.class); cache = Fakes.cache(); }
public static PartitionedRegion createMockQueueRegion(GemFireCacheImpl cache, String regionName) { // Mock queue region PartitionedRegion queueRegion = mock(PartitionedRegion.class); when(queueRegion.getFullPath()).thenReturn(regionName); when(queueRegion.getPrStats()).thenReturn(mock(PartitionedRegionStats.class)); when(queueRegion.getDataStore()).thenReturn(mock(PartitionedRegionDataStore.class)); when(queueRegion.getCache()).thenReturn(cache); EvictionAttributesImpl ea = (EvictionAttributesImpl) EvictionAttributes .createLRUMemoryAttributes(100, null, EvictionAction.OVERFLOW_TO_DISK); EvictionController eviction = AbstractEvictionController.create(ea, false, cache.getDistributedSystem(), "queueRegion"); when(queueRegion.getEvictionController()).thenReturn(eviction); return queueRegion; }
getDistributedSystem().getCancelCriterion().generateCancelledException(throwable); if (result != null) { return result;
@Before public void setUp() throws Exception { cache = Fakes.cache(); system = (InternalDistributedSystem) cache.getDistributedSystem(); pr1 = mock(PartitionedRegion.class); pr2 = mock(PartitionedRegion.class); prRoot = mock(DistributedRegion.class); pa = mock(PartitionAttributes.class); prc = mock(PartitionRegionConfig.class); cache = Fakes.cache(); resultSender = new TestResultSender(); context = new FunctionContextImpl(cache, "testFunction", null, resultSender); memberManager = mock(PersistentMemberManager.class); smdsFunc = new ShowMissingDiskStoresFunction(); }
@Test public void userRegionShouldNotBeSetBeforeIndexInitialized() throws Exception { TestLuceneServiceImpl testService = new TestLuceneServiceImpl(); Field f = LuceneServiceImpl.class.getDeclaredField("cache"); f.setAccessible(true); f.set(testService, cache); AsyncEventQueueFactoryImpl aeqFactory = mock(AsyncEventQueueFactoryImpl.class); when(cache.createAsyncEventQueueFactory()).thenReturn(aeqFactory); DistributedSystem ds = mock(DistributedSystem.class); Statistics luceneIndexStats = mock(Statistics.class); when(cache.getDistributedSystem()).thenReturn(ds); when(((StatisticsFactory) ds).createAtomicStatistics(any(), anyString())) .thenReturn(luceneIndexStats); when(cache.getRegion(anyString())).thenReturn(region); when(cache.getDistributionManager()).thenReturn(mock(DistributionManager.class)); when(cache.getDistributionManager().getWaitingThreadPool()) .thenReturn(Executors.newSingleThreadExecutor()); RegionAttributes ratts = mock(RegionAttributes.class); when(region.getAttributes()).thenReturn(ratts); when(ratts.getDataPolicy()).thenReturn(DataPolicy.PARTITION); EvictionAttributes evictionAttrs = mock(EvictionAttributes.class); when(ratts.getEvictionAttributes()).thenReturn(evictionAttrs); when(evictionAttrs.getAlgorithm()).thenReturn(EvictionAlgorithm.NONE); Map<String, Analyzer> fieldMap = new HashMap<String, Analyzer>(); fieldMap.put("field1", null); fieldMap.put("field2", null); testService.createIndex("index", "region", fieldMap, null, true); }
@Before public void setup() throws Exception { localNode = new InternalDistributedMember("localhost", 8888); remoteNodeA = new InternalDistributedMember("localhost", 8889); remoteNodeB = new InternalDistributedMember("localhost", 8890); cache = Fakes.cache(); system = (InternalDistributedSystem) cache.getDistributedSystem(); allNodes.add(localNode); allNodes.add(remoteNodeA); allNodes.add(remoteNodeB); pr = mock(PartitionedRegion.class); dataStore = new ExtendedPartitionedRegionDataStore(); CompiledSelect select = mock(CompiledSelect.class); when(select.getType()).thenReturn(CompiledValue.COMPARISON); when(select.getElementTypeForOrderByQueries()).thenReturn(new ObjectTypeImpl(String.class)); query = mock(DefaultQuery.class); when(query.getSimpleSelect()).thenReturn(select); when(query.getLimit(any())).thenReturn(-1); when(pr.getCachePerfStats()).thenReturn(mock(CachePerfStats.class)); when(pr.getMyId()).thenReturn(localNode); when(pr.getDataStore()).thenReturn(dataStore); when(pr.getCache()).thenReturn(cache); }
when(lr.getScope()).thenReturn(Scope.DISTRIBUTED_ACK); when(lr.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(cache.getDistributedSystem()).thenReturn(ds); when(cache.getInternalDistributedSystem()).thenReturn(ds); when(cache.getSearchTimeout()).thenReturn(30);
@Test public void constructCqServerNameShouldReturnSameResultRegardlessOfOptimizedCacheNames() { CqServiceImpl cqService = new CqServiceImpl(Fakes.cache()); ClientProxyMembershipID proxyMembershipID = new ClientProxyMembershipID(Fakes.cache().getDistributedSystem().getDistributedMember()); String name1 = cqService.constructServerCqName("myCq", proxyMembershipID); String name2 = cqService.constructServerCqName("myCq", proxyMembershipID); assertEquals(name1, name2); }
protected RegionMBeanBridge(Region<K, V> region) { this.region = region; this.regAttrs = region.getAttributes(); this.isStatisticsEnabled = regAttrs.getStatisticsEnabled(); if (isStatisticsEnabled) { try { region.getStatistics(); } catch (UnsupportedOperationException e) { this.isStatisticsEnabled = false; } } this.regionAttributesData = RegionMBeanCompositeDataFactory.getRegionAttributesData(regAttrs); this.membershipAttributesData = RegionMBeanCompositeDataFactory.getMembershipAttributesData(regAttrs); this.evictionAttributesData = RegionMBeanCompositeDataFactory.getEvictionAttributesData(regAttrs); this.regionMonitor = new MBeanStatsMonitor("RegionMXBeanMonitor"); configureRegionMetrics(); this.persistentEnabled = region.getAttributes().getDataPolicy().withPersistence(); this.regionStats = ((LocalRegion) region).getRegionPerfStats(); if (regionStats != null) { regionMonitor.addStatisticsToMonitor(regionStats.getStats()); // fixes 46692 } monitorLRUStatistics(); if (regAttrs.getGatewaySenderIds() != null && regAttrs.getGatewaySenderIds().size() > 0) { this.isGatewayEnabled = true; } this.member = GemFireCacheImpl.getInstance().getDistributedSystem().getMemberId(); }
@Test public void constructCqServerNameShouldReturnCorrectResultsEvenAfterCqClosingRemovesValuesFromOptimizedCache() throws Exception { CqServiceImpl cqService = new CqServiceImpl(Fakes.cache()); ClientProxyMembershipID proxyMembershipID = new ClientProxyMembershipID(Fakes.cache().getDistributedSystem().getDistributedMember()); String name1 = cqService.constructServerCqName("myCq", proxyMembershipID); cqService.closeCq("myCq", proxyMembershipID); String name2 = cqService.constructServerCqName("myCq", proxyMembershipID); assertEquals(name1, name2); }