/** * Sets the cache writer for the next {@code RegionAttributes} created. * * @param cacheWriter the cache writer or null if no cache writer * @return a reference to this RegionFactory object * @see AttributesFactory#setCacheWriter */ public RegionFactory<K, V> setCacheWriter(CacheWriter<K, V> cacheWriter) { this.attrsFactory.setCacheWriter(cacheWriter); return this; }
result .setCacheWriterClass(new ClassName<>(foundRegion.getCacheWriter().getClass().getName())); afactory.setCacheWriter(null);
CacheWriter writer = (CacheWriter) Class.forName(configuration.getCacheWriterName()).newInstance(); requestedFactory.setCacheWriter(writer); } catch (InstantiationException e) { throw new RuntimeException("Could not set a cacheWriter for the region", e);
public static Region createOrGetExistingExportLogsRegion(boolean isInitiatingMember, InternalCache cache) throws IOException, ClassNotFoundException { InternalCacheForClientAccess cacheForClientAccess = cache.getCacheForProcessingClientRequests(); Region exportLogsRegion = cacheForClientAccess.getInternalRegion(EXPORT_LOGS_REGION); if (exportLogsRegion == null) { AttributesFactory<String, Configuration> regionAttrsFactory = new AttributesFactory<>(); regionAttrsFactory.setDataPolicy(DataPolicy.EMPTY); regionAttrsFactory.setScope(Scope.DISTRIBUTED_ACK); if (isInitiatingMember) { regionAttrsFactory.setCacheWriter(new ExportLogsCacheWriter()); } InternalRegionArguments internalArgs = new InternalRegionArguments(); internalArgs.setIsUsedForMetaRegion(true); exportLogsRegion = cacheForClientAccess.createInternalRegion(EXPORT_LOGS_REGION, regionAttrsFactory.create(), internalArgs); } return exportLogsRegion; }
public final <K, V> Region<K, V> createRegion(final String name, final String rootName, final RegionAttributes<K, V> attributes) throws CacheException { Region<K, V> root = getRootRegion(rootName); if (root == null) { // don't put listeners on root region AttributesFactory<K, V> attributesFactory = new AttributesFactory<>(attributes); ExpirationAttributes expiration = ExpirationAttributes.DEFAULT; attributesFactory.setCacheLoader(null); attributesFactory.setCacheWriter(null); attributesFactory.setPoolName(null); attributesFactory.setPartitionAttributes(null); attributesFactory.setRegionTimeToLive(expiration); attributesFactory.setEntryTimeToLive(expiration); attributesFactory.setRegionIdleTimeout(expiration); attributesFactory.setEntryIdleTimeout(expiration); RegionAttributes<K, V> rootAttrs = attributesFactory.create(); root = createRootRegion(rootName, rootAttrs); } return root.createSubregion(name, attributes); }
factory.setCacheWriter(new CacheWriterAdapter() { @Override public void beforeUpdate(EntryEvent event) throws CacheWriterException {
/** * @since GemFire 5.7 */ @Test public void testConnectionPool() { CacheLoader cl = new CacheLoader() { @Override public Object load(LoaderHelper helper) throws CacheLoaderException { return null; } @Override public void close() {} }; AttributesFactory factory = new AttributesFactory(); factory.setPoolName("mypool"); factory = new AttributesFactory(); factory.setCacheWriter(new CacheWriterAdapter()); factory.setPoolName("mypool"); factory = new AttributesFactory(); factory.setCacheLoader(cl); factory.setPoolName("mypool"); }
factory.setCacheWriter(new CacheWriterAdapter<Object, Object>() {
CacheWriter writer = (CacheWriter) Class.forName(configuration.getCacheWriterName()).newInstance(); requestedFactory.setCacheWriter(writer); } catch (InstantiationException e) { throw new RuntimeException("Could not set a cacheWriter for the region", e);