QueryService doLookupQueryService() { return Optional.ofNullable(this.queryService).orElseGet(() -> (this.cache instanceof ClientCache ? ((ClientCache) this.cache).getLocalQueryService() : this.cache.getQueryService())); }
private static <T extends RegionService> T mockRegionServiceApi(T mockRegionService) { AtomicBoolean closed = new AtomicBoolean(false); doAnswer(newSetter(closed, true, null)).when(mockRegionService).close(); when(mockRegionService.isClosed()).thenAnswer(newGetter(closed)); when(mockRegionService.getCancelCriterion()).thenThrow(newUnsupportedOperationException(NOT_SUPPORTED)); when(mockRegionService.getRegion(anyString())).thenAnswer(invocation -> { String regionPath = invocation.getArgument(0); String resolvedRegionPath = Optional.ofNullable(regionPath) .map(String::trim) .filter(it -> !it.isEmpty()) .map(GemFireMockObjectsSupport::toRegionPath) .orElseThrow(() -> newIllegalArgumentException("Region path [%s] is not valid", regionPath)); return regions.get(resolvedRegionPath); }); when(mockRegionService.createPdxEnum(anyString(), anyString(), anyInt())) .thenThrow(newUnsupportedOperationException(NOT_SUPPORTED)); when(mockRegionService.createPdxInstanceFactory(anyString())) .thenThrow(newUnsupportedOperationException(NOT_SUPPORTED)); when(mockRegionService.rootRegions()).thenAnswer(invocation -> regions.values().stream().filter(GemFireMockObjectsSupport::isRootRegion).collect(Collectors.toSet())); return mockRegionService; }
/** * Closes and destroys the {@link Region}. * * @throws Exception if {@code destroy()} fails. * @see org.springframework.beans.factory.DisposableBean * @see org.apache.geode.cache.Region#close() * @see org.apache.geode.cache.Region#destroyRegion() */ @Override public void destroy() throws Exception { Optional.ofNullable(getObject()).ifPresent(region -> { if (this.close) { if (!region.getRegionService().isClosed()) { try { region.close(); } catch (Exception ignore) { } } } if (this.destroy) { region.destroyRegion(); } }); }
/** * Closes and destroys the {@link Region}. * * @throws Exception if {@code destroy()} fails. * @see org.springframework.beans.factory.DisposableBean * @see org.apache.geode.cache.Region#close() * @see org.apache.geode.cache.Region#destroyRegion() */ @Override public void destroy() throws Exception { Optional.ofNullable(getObject()).ifPresent(region -> { if (this.close) { if (!region.getRegionService().isClosed()) { try { region.close(); } catch (Exception ignore) { } } } if (this.destroy) { region.destroyRegion(); } }); }
/** * Set the underlying RegionService (Pivotal GemFire Cache) used for registering Queries. * * @param cache the RegionService (Pivotal GemFire Cache) used for registering Queries. * @see org.apache.geode.cache.RegionService */ public void setCache(RegionService cache) { setQueryService(cache.getQueryService()); }
/** * Closes and destroys the {@link Region}. * * @throws Exception if destroy fails. * @see org.springframework.beans.factory.DisposableBean */ @Override public void destroy() throws Exception { Optional.ofNullable(getObject()).ifPresent(region -> { if (isClose()) { if (!region.getRegionService().isClosed()) { try { region.close(); } catch (Exception ignore) { } } } if (isDestroy()) { region.destroyRegion(); } }); }
/** * Set the underlying RegionService (GemFire Cache) used for registering Queries. * * @param cache the RegionService (GemFire Cache) used for registering Queries. * @see org.apache.geode.cache.RegionService */ public void setCache(RegionService cache) { setQueryService(cache.getQueryService()); }
/** * Closes and destroys the {@link Region}. * * @throws Exception if destroy fails. * @see org.springframework.beans.factory.DisposableBean */ @Override public void destroy() throws Exception { Optional.ofNullable(getObject()).ifPresent(region -> { if (isClose()) { if (!region.getRegionService().isClosed()) { try { region.close(); } catch (Exception ignore) { } } } if (isDestroy()) { region.destroyRegion(); } }); }
QueryService doLookupQueryService() { return Optional.ofNullable(this.queryService).orElseGet(() -> (this.cache instanceof ClientCache ? ((ClientCache) this.cache).getLocalQueryService() : this.cache.getQueryService())); }
QueryService queryServiceFrom(Region<?, ?> region) { return region.getRegionService().getQueryService(); }
QueryService queryServiceFrom(Region<?, ?> region) { return region.getRegionService().getQueryService(); }
public static <T extends RegionService> T mockQueryService(T regionService) { QueryService mockQueryService = mockQueryService(); when(regionService.getQueryService()).thenReturn(mockQueryService); if (regionService instanceof ClientCache) { when(((ClientCache) regionService).getLocalQueryService()).thenReturn(mockQueryService); } return regionService; }
private CqQuery startCQ(ClientCache cache, Region region) throws CqException, RegionNotFoundException, CqExistsException { // Get cache and queryService - refs to local cache and QueryService CqAttributesFactory cqf = new CqAttributesFactory(); cqf.addCqListener(new RandomEventListener()); CqAttributes cqa = cqf.create(); String cqName = "randomTracker"; String queryStr = "SELECT * FROM /example-region i where i > 70"; QueryService queryService = region.getRegionService().getQueryService(); CqQuery randomTracker = queryService.newCq(cqName, queryStr, cqa); randomTracker.execute(); System.out.println("------- CQ is running\n"); return randomTracker; }