@Override public String getCacheLoader() { Object o = this.ra.getCacheLoader(); if (o == null) { return ""; } else { return o.toString(); } }
@Test public void executeFunctionGivenARegionWithNonJdbcLoaderDoesNotRemoveTheLoader() { when(regionAttributes.getCacheLoader()).thenReturn(mock(CacheLoader.class)); when(service.getMappingForRegion(eq(regionName))).thenReturn(mapping); function.executeFunction(context); verify(regionMutator, never()).setCacheLoader(null); }
@Test public void executeFunctionGivenARegionWithJdbcLoaderRemovesTheLoader() { when(regionAttributes.getCacheLoader()).thenReturn(mock(JdbcLoader.class)); when(service.getMappingForRegion(eq(regionName))).thenReturn(mapping); function.executeFunction(context); verify(regionMutator, times(1)).setCacheLoader(null); }
/** * Creates PartitionedRegionDataStore for dataStorage of PR and starts a PartitionService to * handle remote operations on this DataStore from other participating nodes. * * @param pr PartitionedRegion associated with this DataStore. */ PartitionedRegionDataStore(final PartitionedRegion pr) { final int bucketCount = pr.getTotalNumberOfBuckets(); this.localBucket2RegionMap = new ConcurrentHashMap<Integer, BucketRegion>(bucketCount); this.partitionedRegion = pr; this.bucketCreationLock = new StoppableReentrantReadWriteLock(pr.getCancelCriterion()); if (pr.getAttributes().getCacheLoader() != null) { this.loader = pr.getAttributes().getCacheLoader(); if (logger.isDebugEnabled()) { logger.debug("Installing cache loader from partitioned region attributes: {}", loader); } } // this.maximumLocalBytes = (long) (pr.getLocalMaxMemory() * // PartitionedRegionHelper.BYTES_PER_MB // * this.partitionedRegion.rebalanceThreshold); this.maximumLocalBytes = (pr.getLocalMaxMemory() * PartitionedRegionHelper.BYTES_PER_MB); // this.bucketStats = new CachePerfStats(pr.getSystem(), "partition-" + pr.getName()); this.bucketStats = new RegionPerfStats(pr.getCache(), pr.getCachePerfStats(), "partition-" + pr.getName()); this.keysOfInterest = new ConcurrentHashMap(); }
continue; } else { if (n.isCacheLoaderAttached() && pr.getAttributes().getCacheLoader() == null) { throw new IllegalStateException( String.format( new Object[] {this.pr.getName()})); if (!n.isCacheLoaderAttached() && pr.getAttributes().getCacheLoader() != null) { throw new IllegalStateException( String.format(
CacheLoader loader = ra.getCacheLoader(); if (loader != null) { allCacheLoaders.add(loader);
"poolName is not the same: " + this.poolName + " != " + other.getPoolName()); if (!equal(this.cacheLoader, other.getCacheLoader())) { throw new RuntimeException("CacheLoader are not the same");
public static RegionAttributesData getRegionAttributesData(RegionAttributes<?, ?> regAttrs) { if (regAttrs.getCacheLoader() != null) { cacheLoaderClassName = regAttrs.getCacheLoader().getClass().getCanonicalName();
CacheLoader<?, ?> cacheLoader = ra.getCacheLoader();
private void cleanupRegionAndQueue(Cache cache, String regionName) { String queueName = CreateMappingCommand.createAsyncEventQueueName(regionName); Region<?, ?> region = cache.getRegion(regionName); if (region != null) { CacheLoader<?, ?> loader = region.getAttributes().getCacheLoader(); if (loader instanceof JdbcLoader) { region.getAttributesMutator().setCacheLoader(null); } CacheWriter<?, ?> writer = region.getAttributes().getCacheWriter(); if (writer instanceof JdbcWriter) { region.getAttributesMutator().setCacheWriter(null); } Set<String> queueIds = region.getAttributes().getAsyncEventQueueIds(); if (queueIds.contains(queueName)) { region.getAttributesMutator().removeAsyncEventQueueId(queueName); } } InternalAsyncEventQueue queue = (InternalAsyncEventQueue) cache.getAsyncEventQueue(queueName); if (queue != null) { queue.stop(); queue.destroy(); } } }
generate(CACHE_LOADER, attrs.getCacheLoader());
byte loaderByte = (byte) (getAttributes().getCacheLoader() != null ? 0x01 : 0x00); byte writerByte = (byte) (getAttributes().getCacheWriter() != null ? 0x02 : 0x00); this.node.setLoaderWriterByte((byte) (loaderByte + writerByte));
DistributionConfig.GEMFIRE_PREFIX + "mimimumPartitionedRegionReadRedundancy", 0); this.haveCacheLoader = regionAttributes.getCacheLoader() != null;
this.gatewaySenderIds = new HashSet<String>(attrs.getGatewaySenderIds()); this.asyncEventQueueIds = new HashSet<String>(attrs.getAsyncEventQueueIds()); this.cacheLoader = attrs.getCacheLoader(); this.cacheWriter = attrs.getCacheWriter(); this.entryIdleTimeout = attrs.getEntryIdleTimeout();
assignCacheLoader(attrs.getCacheLoader()); assignCacheWriter(attrs.getCacheWriter()); this.regionTimeToLive = attrs.getRegionTimeToLive().getTimeout();
new ArrayList<>(Arrays.asList(regionAttributes.getCacheListeners())); this.regionAttributes.cacheLoader = regionAttributes.getCacheLoader(); this.regionAttributes.cacheWriter = regionAttributes.getCacheWriter(); this.regionAttributes.regionTimeToLive = regionAttributes.getRegionTimeToLive().getTimeout();
this.cacheLoaderDesc = getDesc(attr.getCacheLoader()); this.cacheWriterDesc = getDesc(attr.getCacheWriter()); this.cacheListenerDescs = getDescs(attr.getCacheListeners());
AttributesFactory factory = new AttributesFactory(); RegionAttributes attrs = factory.create(); assertNull(attrs.getCacheLoader()); assertNull(attrs.getCacheWriter()); assertNull(attrs.getCacheListener());
if (parentIsUserSpecified) { if (parentWithHas.hasCacheLoader()) { setCacheLoader(parent.getCacheLoader()); setCacheLoader(parent.getCacheLoader());
.orElse(EvictionAttributes.DEFAULT_ENTRIES_MAXIMUM)); AtomicReference<CacheLoader<K, V>> cacheLoader = new AtomicReference<>(baseRegionAttributes.getCacheLoader()); .when(mockAttributesMutator).removeGatewaySenderId(anyString()); doAnswer(newSetter(cacheLoader, baseRegionAttributes.getCacheLoader())) .when(mockAttributesMutator).setCacheLoader(any(CacheLoader.class)); .thenAnswer(invocation -> cacheListeners.toArray(new CacheListener[cacheListeners.size()])); when(mockRegionAttributes.getCacheLoader()).thenAnswer(newGetter(cacheLoader::get)); when(mockRegionAttributes.getCacheWriter()).thenAnswer(newGetter(cacheWriter::get)); when(mockRegionAttributes.getCloningEnabled()).thenAnswer(newGetter(cloningEnabled::get));