private boolean isMemoryEvictionConfigured() { boolean result = false; EvictionAttributes ea = region.getAttributes().getEvictionAttributes(); if (ea != null && ea.getAlgorithm().isLRUMemory()) { result = true; } return result; }
public void createPartitionRegion(String name, Class constraint) { ExpirationAttributes expiration = ExpirationAttributes.DEFAULT; PartitionAttributesFactory paf = new PartitionAttributesFactory(); RegionFactory factory = cache.createRegionFactory(RegionShortcut.PARTITION).setPartitionAttributes(paf.create()); if (constraint != null) { factory.setValueConstraint(constraint); } factory.create(name); }
public EvictionAttributesInfo(EvictionAttributes ea) { EvictionAction evictAction = ea.getAction(); if (evictAction != null) { evictionAction = evictAction.toString(); } EvictionAlgorithm evictionAlgo = ea.getAlgorithm(); if (evictionAlgo != null) { evictionAlgorithm = evictionAlgo.toString(); } evictionMaxValue = ea.getMaximum(); }
private static Region<?, ?> createPartitionedRegion(String regionName, Cache cache, Class keyConstraint, Class valueConstraint) { RegionFactory regionFactory = cache.createRegionFactory(); regionFactory.setDataPolicy(DataPolicy.PARTITION); regionFactory.setKeyConstraint(keyConstraint); regionFactory.setValueConstraint(valueConstraint); return regionFactory.create(regionName); }
@Override public <K, V> Set<Integer> getLocalBucketSet(Region<K, V> region) { if (!region.getAttributes().getDataPolicy().withPartitioning()) { return null; } return this.localBucketSet; } }
@Override @SuppressWarnings("rawtypes") public void removeCacheListener() { AttributesMutator mutator = this.region.getAttributesMutator(); CacheListener[] listeners = this.region.getAttributes().getCacheListeners(); for (int i = 0; i < listeners.length; i++) { if (listeners[i] instanceof SerialSecondaryGatewayListener) { mutator.removeCacheListener(listeners[i]); break; } } }
private static RegionAttributes createClientDefaults() { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.LOCAL); // af.setIgnoreJTA(true); In 6.6 and later releases client regions support JTA af.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL)); return af.create(); }
@Override public void beforeDestroy(EntryEvent<String, HttpSession> event) throws CacheWriterException { try { this.backingRegion.destroy(event.getKey(), event.getCallbackArgument()); } catch (EntryNotFoundException e) { // I think it is safe to ignore this exception. The entry could have // expired already in the backing region. } }
@Override public Region<?, ?> getRegion() { // The region will be null mostly for the other node where the gateway event // is serialized return this.region != null ? this.region : CacheFactory.getAnyInstance().getRegion(this.regionPath); }
static Region createRegion(String regionName, Class valueConstraint) throws Exception { AttributesFactory attributesFactory = new AttributesFactory(); attributesFactory.setValueConstraint(valueConstraint); RegionAttributes regionAttributes = attributesFactory.create(); Region region = _cache.createRegion(regionName, regionAttributes); return region; }
/** * @throws org.apache.geode.cache.CacheRuntimeException if no cache created */ protected Region getRegion(DistributedSystem sys) { Cache cache = CacheFactory.getInstance(sys); return cache.getRegion(this.regionName); }
@Override public boolean authorizeOperation(String regionName, OperationContext context) { if (context instanceof ExecuteCQOperationContext) { cache.close(); // return false; throw new CacheClosedException("cache is closed"); } return true; } }
private Integer generateCqRegionEvent(CacheEvent event) { Integer cqEvent = null; if (event.getOperation().isRegionDestroy()) { cqEvent = MessageType.DESTROY_REGION; } else if (event.getOperation().isRegionInvalidate()) { cqEvent = MessageType.INVALIDATE_REGION; } else if (event.getOperation().isClear()) { cqEvent = MessageType.CLEAR_REGION; } return cqEvent; }
protected static Object getLocalValue(final Region region, final Object key) { Region.Entry entry = region.getEntry(key); if (entry != null) { try { // Handle race conditions with concurrent destroy ops return entry.getValue(); } catch (EntryDestroyedException e) { return null; } } else { return null; } }
@Override public V putIfAbsent(final K key, final V value) { try { region.create(key, value, callbackArg); } catch (EntryExistsException e) { return (V) e.getOldValue(); } return null; }
public long getLastAccessedTime() { if (isStatisticsEnabled) { return region.getStatistics().getLastAccessedTime(); } return ManagementConstants.NOT_AVAILABLE_LONG; }
public long getHitCount() { if (isStatisticsEnabled) { return region.getStatistics().getHitCount(); } return ManagementConstants.NOT_AVAILABLE_LONG; }
public long getMissCount() { if (isStatisticsEnabled) { return region.getStatistics().getMissCount(); } return ManagementConstants.NOT_AVAILABLE_LONG; }
private RegionDistributionException createRegionDistributionException() { String s = "MyString"; String regionFullPath = "MyPath"; Set missingRoles = createSetOfRoles(); return new RegionDistributionException(s, regionFullPath, missingRoles); }
public EvictionAttributesInfo(EvictionAttributes ea) { EvictionAction evictAction = ea.getAction(); if (evictAction != null) { evictionAction = evictAction.toString(); } EvictionAlgorithm evictionAlgo = ea.getAlgorithm(); if (evictionAlgo != null) { evictionAlgorithm = evictionAlgo.toString(); } evictionMaxValue = ea.getMaximum(); }