public Cache getCache() { return this.region.getCache(); }
/** * A fake region, which contains a fake cache and some other fake attributes */ public static Region region(String name, Cache cache) { Region region = mock(Region.class); RegionAttributes attributes = mock(RegionAttributes.class); DataPolicy policy = mock(DataPolicy.class); when(region.getAttributes()).thenReturn(attributes); when(attributes.getDataPolicy()).thenReturn(policy); when(region.getCache()).thenReturn(cache); when(region.getRegionService()).thenReturn(cache); when(region.getName()).thenReturn(name); when(region.getFullPath()).thenReturn("/" + name); return region; }
private void log(EntryEvent event) { StringBuilder builder = new StringBuilder(); builder.append("DebugCacheListener: Received ").append(event.getOperation()).append(" for key=") .append(event.getKey()); if (event.getNewValue() != null) { builder.append("; value=").append(event.getNewValue()); } event.getRegion().getCache().getLogger().info(builder.toString()); }
public CompactRangeIndex(InternalCache cache, String indexName, Region region, String fromClause, String indexedExpression, String projectionAttributes, String origFromClause, String origIndexExpr, String[] definitions, IndexStatistics stats) { super(cache, indexName, region, fromClause, indexedExpression, projectionAttributes, origFromClause, origIndexExpr, definitions, stats); if (IndexManager.IS_TEST_LDM) { indexStore = new MapIndexStore( ((LocalRegion) region).getIndexMap(indexName, indexedExpression, origFromClause), region); } else { indexStore = new MemoryIndexStore(region, internalIndexStats, (InternalCache) region.getCache()); } }
public RangeIndexStatistics(String indexName) { this.vsdStats = new IndexStats(getRegion().getCache().getDistributedSystem(), indexName); }
public MapIndexStatistics(String indexName) { this.vsdStats = new IndexStats(getRegion().getCache().getDistributedSystem(), indexName); }
public RangeIndexStatistics(String indexName) { this.vsdStats = new IndexStats(getRegion().getCache().getDistributedSystem(), indexName); }
public PartitionedIndexStatistics(String indexName) { this.vsdStats = new IndexStats(getRegion().getCache().getDistributedSystem(), indexName); }
public RangeIndexStatistics(String indexName) { this.vsdStats = new IndexStats(getRegion().getCache().getDistributedSystem(), indexName); }
private void executeHA(FunctionContext context) { RegionFunctionContext rcontext = (RegionFunctionContext) context; Region region = rcontext.getDataSet(); region.getCache().getLogger().fine("executeHA#execute( " + rcontext + " )"); try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } rcontext.getResultSender().lastResult(rcontext.getArguments()); }
/** * This is an accessor method used to get the reference of this region. If this region is not yet * initialized, then it attempts to create it. * * @param cache the Cache we are currently using * @return ClientHealthMonitoringRegion reference. */ public static synchronized Region getInstance(InternalCache cache) { if (currentInstance != null && currentInstance.getCache() == cache && !cache.isClosed()) { return currentInstance; } if (cache == null || cache.isClosed()) { return null; // give up } initialize(cache); return currentInstance; }
Object verifyAndGetPdxDomainObject(Object value) { if (value instanceof StructImpl) { // Doing hasPdx check first, since its cheaper. if (((StructImpl) value).isHasPdx() && !((InternalCache) this.region.getCache()).getPdxReadSerializedByAnyGemFireServices()) { // Set the pdx values for the struct object. StructImpl v = (StructImpl) value; Object[] fieldValues = v.getPdxFieldValues(); return new StructImpl((StructTypeImpl) v.getStructType(), fieldValues); } } else if (value instanceof PdxInstance && !((InternalCache) this.region.getCache()).getPdxReadSerializedByAnyGemFireServices()) { return ((PdxInstance) value).getObject(); } return value; }
@Before public void createMocksAndCommonObjects() throws Exception { mockContext = mock(InternalRegionFunctionContext.class); mockResultSender = mock(ResultSender.class); mockRegion = mock(Region.class); mockAEQ = mock(AsyncEventQueueImpl.class); mockIndex = mock(LuceneIndexImpl.class); mockService = mock(InternalLuceneService.class); mockCache = mock(InternalCache.class); waitArgs = new WaitUntilFlushedFunctionContext(indexName, 10000, TimeUnit.MILLISECONDS); when(mockRegion.getCache()).thenReturn(mockCache); when(mockRegion.getFullPath()).thenReturn(regionPath); when(mockCache.getService(any())).thenReturn(mockService); when(mockService.getIndex(eq("index"), eq(regionPath))).thenReturn(mockIndex); } }
public RegionSubRegionSnapshot(Region reg) { this(); this.name = reg.getName(); if (reg instanceof PartitionedRegion) { PartitionedRegion p_reg = (PartitionedRegion) reg; this.entryCount = p_reg.entryCount(true); } else { this.entryCount = reg.entrySet().size(); } final LogWriter logger = reg.getCache().getLogger(); if ((logger != null) && logger.fineEnabled()) { logger.fine("RegionSubRegionSnapshot Region entry count =" + this.entryCount + " for region =" + this.name); } }
/** * Tests the {@link Region#getCache} method (for what it's worth) */ @Test public void testGetCache() throws CacheException { String name = this.getUniqueName(); Region region = createRegion(name); assertSame(this.getCache(), region.getCache()); }
@Override public void save(File snapshot, SnapshotFormat format, SnapshotOptions<K, V> options) throws IOException { // we can't be in a transaction since that will inline the function execution if (region.getCache().getCacheTransactionManager().exists()) { throw new IllegalStateException("Unable to save snapshot during a transaction"); } if (shouldRunInParallel(options)) { snapshotInParallel(new ParallelArgs<>(snapshot, format, options), new ParallelExportFunction<K, V>()); } else { exportOnMember(snapshot, format, options); } }
/** * Gathers details about the specified partitioned region. Returns null if the partitioned region * is not locally defined. * * @param region the region to get info about * @return details about the specified partitioned region * @since GemFire 6.0 */ public static PartitionRegionInfo getPartitionRegionInfo(final Region<?, ?> region) { try { PartitionedRegion partitionedRegion = isPartitionedCheck(region); InternalCache cache = (InternalCache) region.getCache(); return partitionedRegion.getRedundancyProvider().buildPartitionedRegionInfo(false, cache.getInternalResourceManager().getLoadProbe()); } catch (ClassCastException ignore) { // not a PR so return null } return null; }
@Override public void execute(FunctionContext<Object> context) { RegionFunctionContext ctx = (RegionFunctionContext) context; ResultSender<Boolean> resultSender = ctx.getResultSender(); Region region = ctx.getDataSet(); Cache cache = region.getCache(); String indexName = (String) ctx.getArguments(); if (indexName == null) { throw new IllegalArgumentException("Missing index name"); } LuceneService luceneService = LuceneServiceProvider.get(cache); LuceneIndex luceneIndex = luceneService.getIndex(indexName, region.getFullPath()); if (luceneIndex == null) { resultSender.lastResult(false); } else { resultSender.lastResult(luceneIndex.isIndexingInProgress()); } }
@Override public void execute(FunctionContext context) { try { Region<K, V> local = PartitionRegionHelper.getLocalDataForContext((RegionFunctionContext) context); ParallelArgs<K, V> args = (ParallelArgs<K, V>) context.getArguments(); File f = args.getOptions().getMapper().mapExportPath( local.getCache().getDistributedSystem().getDistributedMember(), args.getFile()); if (f == null || f.isDirectory()) { throw new IOException(String.format("File is invalid or is a directory: %s", f)); } local.getSnapshotService().save(f, args.getFormat(), args.getOptions()); context.getResultSender().lastResult(Boolean.TRUE); } catch (Exception e) { context.getResultSender().sendException(e); } }
public DummyQRegion(Region region) { super(region, false); Class constraint = region.getAttributes().getValueConstraint(); if (constraint != null) valueType = TypeUtils.getObjectType(constraint); constraint = region.getAttributes().getKeyConstraint(); if (constraint != null) keyType = TypeUtils.getObjectType(constraint); values = new ResultsBag(((HasCachePerfStats) region.getCache()).getCachePerfStats()); values.setElementType(valueType); keys = new ResultsSet(); keys.setElementType(keyType); entries = new ResultsSet(); // gets key and value types from region entries.setElementType(TypeUtils.getRegionEntryType(region)); }