public static QueryService getQueryService() { return cache.getQueryService(); }
public Index createIndex(String name, String field, String region) throws CacheException { try { return cache.getQueryService().createIndex(name, field, region); } catch (Exception e) { throw new RuntimeException( "Index creation failed for index on region: " + region + "." + field, e); } }
public Index createHashIndex(String name, String field, String region) { try { return cache.getQueryService().createHashIndex(name, field, region); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException( "Index creation failed for index on region: " + region + "." + field, e); } }
static QueryService getQueryService() { return _cache.getQueryService(); }
public RegionProvider(Region<ByteArrayWrapper, ByteArrayWrapper> stringsRegion, Region<ByteArrayWrapper, HyperLogLogPlus> hLLRegion, Region<String, RedisDataType> redisMetaRegion, ConcurrentMap<ByteArrayWrapper, ScheduledFuture<?>> expirationsMap, ScheduledExecutorService expirationExecutor, RegionShortcut defaultShortcut) { if (stringsRegion == null || hLLRegion == null || redisMetaRegion == null) throw new NullPointerException(); this.regions = new ConcurrentHashMap<>(); this.stringsRegion = stringsRegion; this.hLLRegion = hLLRegion; this.redisMetaRegion = redisMetaRegion; this.cache = GemFireCacheImpl.getInstance(); this.queryService = cache.getQueryService(); this.expirationsMap = expirationsMap; this.expirationExecutor = expirationExecutor; this.defaultRegionType = defaultShortcut; this.locks = new ConcurrentHashMap<>(); }
/** * Execute queries by removing any DISTINCT clause if present * */ public Object[] executeQueriesWithoutDistinct(String qarr[]) { QueryService qs = cache.getQueryService(); Object[] result = new Object[qarr.length]; String query = null; int j = 0; for (int i = 0; i < qarr.length; i++) { query = queries.get(qarr[i]); if (query.indexOf("distinct") > -1) query = query.replace("distinct", ""); if (query.indexOf("DISTINCT") > -1) query = query.replace("DISTINCT", ""); // hydra.getLogWriter().info("\nExecuting query: " + query); try { result[j++] = qs.newQuery(query).execute(); } catch (Exception e) { throw new RuntimeException(e); } } return result; }
public static QueryService getQueryService() { if (cache.isClosed()) startCache(); return cache.getQueryService(); }
/** * Execute queries by adding a DISTINCT clause if not present * */ public Object[] executeQueriesWithDistinct(String qarr[]) { QueryService qs = cache.getQueryService(); Object[] result = new Object[qarr.length]; String query = null; int j = 0; for (final String aQarr : qarr) { query = queries.get(aQarr); if (!query.toLowerCase().contains("distinct")) { query = query.replaceFirst("select", "select distinct"); } // hydra.getLogWriter().info("\nExecuting query: " + query); try { result[j++] = qs.newQuery(query).execute(); } catch (Exception e) { throw new RuntimeException(e); } } return result; }
/** * Executes queries corresponding to the keys passed using array<br> * <P> * <code> * String[] arr = {"1", "2", "3"};<br> * new QueryTestUtils().executeQueries(arr); * </code> * </P> * * @param qarr Array of keys, queries in the values mapped are executed * @return Object array containing SelectResults */ public Object[] executeQueries(String qarr[]) throws Exception { QueryService qs = cache.getQueryService(); Object[] result = new Object[qarr.length]; String query = null; int j = 0; for (int i = 0; i < qarr.length; i++) { query = queries.get(qarr[i]); result[j++] = qs.newQuery(query).execute(); } return result; }
@Before public void setup() { counter = new AtomicLong(0L); testResultSender = new TestResultSender(); mockQueryService = mock(QueryService.class, "QueryService"); mockFunctionContext = mock(FunctionContext.class, "FunctionContext"); final Cache mockCache = mock(Cache.class, "Cache"); final DistributedSystem mockDistributedSystem = mock(DistributedSystem.class, "DistributedSystem"); final DistributedMember mockDistributedMember = mock(DistributedMember.class, "DistributedMember"); when(mockCache.getQueryService()).thenReturn(mockQueryService); when(mockCache.getDistributedSystem()).thenReturn(mockDistributedSystem); when(mockDistributedSystem.getDistributedMember()).thenReturn(mockDistributedMember); when(mockDistributedMember.getId()).thenReturn(mockMemberId); when(mockDistributedMember.getName()).thenReturn(mockMemberName); when(mockFunctionContext.getCache()).thenReturn(mockCache); when(mockFunctionContext.getResultSender()).thenReturn(testResultSender); }
@Override public void execute(final FunctionContext context) { try { final Set<IndexDetails> indexDetailsSet = new HashSet<IndexDetails>(); final Cache cache = context.getCache(); final DistributedMember member = cache.getDistributedSystem().getDistributedMember(); for (final Index index : cache.getQueryService().getIndexes()) { indexDetailsSet.add(new IndexDetails(member, index)); } context.getResultSender().lastResult(indexDetailsSet); } catch (Exception e) { context.getResultSender().sendException(e); } } }
Collection<Index> indexesForRegion = this.cache.getQueryService().getIndexes(region); for (Index index : indexesForRegion) { generate(index);
private void setUp() throws CacheException { this.ds = DistributedSystem.connect(new Properties()); this.cache = CacheFactory.create(ds); AttributesFactory attributesFactory = new AttributesFactory(); attributesFactory.setValueConstraint(Portfolio.class); this.regionAttributes = attributesFactory.create(); this.qs = this.cache.getQueryService(); }
@Override public void execute(FunctionContext<Set<RegionConfig.Index>> context) { Cache cache = context.getCache(); QueryService queryService = cache.getQueryService(); ResultSender<CliFunctionResult> sender = context.getResultSender(); String memberId = cache.getDistributedSystem().getDistributedMember().getId();
@Before public void before() throws Exception { locator = lsRule.startLocatorVM(0, l -> l.withHttpService()); server = lsRule.startServerVM(1, locator.getPort()); server.invoke(() -> { Cache cache = ClusterStartupRule.getCache(); RegionFactory factory = cache.createRegionFactory(RegionShortcut.REPLICATE); Region region = factory.create(REGION_1); cache.getQueryService().createIndex(INDEX_1, "key", INDEX_REGION_NAME); region.put(1, new Stock("SUNW", 10)); region.get(1); }); connectGfsh(locator); }
final Query query = c.getQueryService().newQuery(oql);
region2 = Fakes.region("Region2", cache); function = spy(CreateDefinedIndexesFunction.class); doReturn(queryService).when(cache).getQueryService();
Cache cache = ((InternalCache) context.getCache()).getCacheForProcessingClientRequests(); memberId = cache.getDistributedSystem().getDistributedMember().getId(); QueryService queryService = cache.getQueryService(); String indexName = indexInfo.getName(); String regionPath = indexInfo.getFromClause();
Cache cache = context.getCache(); memberId = cache.getDistributedSystem().getDistributedMember().getId(); QueryService queryService = cache.getQueryService(); String indexName = indexInfo.getName(); String indexedExpression = indexInfo.getExpression();
query = proxyCaches[multiUserIndex].getQueryService().newQuery(queryString); } else { region.getCache().getQueryService().newQuery(queryString);