public String getValueConstraint() { Class constraint = this.ra.getValueConstraint(); if (constraint == null) { return ""; } else { return constraint.getName(); } }
public String getValueConstraint() { Class constraint = this.ra.getValueConstraint(); if (constraint == null) { return ""; } else { return constraint.getName(); } }
public PrimaryKeyIndex(String indexName, Region region,String fromClause, String indexedExpression, String projectionAttributes, String origFromClause, String origIndxExpr, String[] defintions, IndexStatistics indexStatistics) { super(indexName, region, fromClause, indexedExpression, projectionAttributes, origFromClause, origIndxExpr, defintions, indexStatistics); //TODO : Asif Check if the below is correct Class constr = region.getAttributes().getValueConstraint(); if (constr == null) constr = Object.class; this.indexResultType = new ObjectTypeImpl(constr); markValid(true); }
public PrimaryKeyIndex(String indexName, Region region,String fromClause, String indexedExpression, String projectionAttributes, String origFromClause, String origIndxExpr, String[] defintions, IndexStatistics indexStatistics) { super(indexName, region, fromClause, indexedExpression, projectionAttributes, origFromClause, origIndxExpr, defintions, indexStatistics); //TODO : Asif Check if the below is correct Class constr = region.getAttributes().getValueConstraint(); if (constr == null) constr = Object.class; this.indexResultType = new ObjectTypeImpl(constr); markValid(true); }
public Region getRandomRegionWithValueConstrains() { Region aRegion = null; Set<Region<?,?>> allRegions = new HashSet<Region<?,?>>(); Set<Region<?,?>> rootRegions = CacheHelper.getCache().rootRegions(); allRegions.addAll(rootRegions); for (Region region : rootRegions) { allRegions.addAll((Set<Region<?,?>>)region.subregions(true)); } int attempts = 0; do { attempts++; int regionNumber = (new Random()).nextInt(numOfRegions); aRegion = (Region)CacheHelper.getCache().rootRegions().toArray()[regionNumber]; Log.getLogWriter().info( "Obtained region for region operation: " + aRegion.getName() + " ValueConstraint for the region is: " + aRegion.getAttributes().getValueConstraint()); } while (aRegion.getAttributes().getValueConstraint() != null && attempts < 100); if(attempts == 100) { throw new TestException("Could not obtain a region with ValueConstrainsts are 100 attempts"); } return aRegion; }
buf.append("\n scope: " + r.getScope()); buf.append("\n statisticsEnabled: " + r.getStatisticsEnabled()); buf.append("\n valueConstraint: " + r.getValueConstraint()); return buf.toString();
buf.append("\n scope: " + r.getScope()); buf.append("\n statisticsEnabled: " + r.getStatisticsEnabled()); buf.append("\n valueConstraint: " + r.getValueConstraint()); return buf.toString();
public void testSetValueConstraint() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(LOCAL); r1 = factory.setValueConstraint(String.class).create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(String.class, ra.getValueConstraint()); } finally { cleanUpRegion(r1); } }
/** Creates a new instance of QRegion */ public QRegion(Region region, boolean includeKeys) { if (region == null) throw new IllegalArgumentException(LocalizedStrings.QRegion_REGION_CAN_NOT_BE_NULL.toLocalizedString()); this.region = region; Class constraint = this.region.getAttributes().getValueConstraint(); if (constraint == null) constraint = Object.class; ResultsCollectionWrapper res = null; if (includeKeys) { res = new ResultsCollectionWrapper(TypeUtils.getObjectType(constraint), this.region.entrySet()); } else { res = new ResultsCollectionWrapper(TypeUtils.getObjectType(constraint), this.region.values()); } res.setModifiable(false); this.values = res; }
public void testSetValueConstraint() throws CacheException, IOException { ClientCache c = new ClientCacheFactory().create(); Region r1 = null; try { ClientRegionFactory factory = c.createClientRegionFactory(CACHING_PROXY); r1 = factory.setValueConstraint(String.class).create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(String.class, ra.getValueConstraint()); } finally { cleanUpRegion(r1); } }
/** Creates a new instance of QRegion */ public QRegion(Region region, boolean includeKeys) { if (region == null) throw new IllegalArgumentException(LocalizedStrings.QRegion_REGION_CAN_NOT_BE_NULL.toLocalizedString()); this.region = region; Class constraint = this.region.getAttributes().getValueConstraint(); if (constraint == null) constraint = Object.class; ResultsCollectionWrapper res = null; if (includeKeys) { res = new ResultsCollectionWrapper(TypeUtils.getObjectType(constraint), this.region.entrySet()); } else { res = new ResultsCollectionWrapper(TypeUtils.getObjectType(constraint), this.region.values()); } res.setModifiable(false); if (!DefaultQueryService.COPY_ON_READ_AT_ENTRY_LEVEL) { res.setIgnoreCopyOnReadForQuery(true); } this.values = res; }
Class constraint = region.getAttributes().getValueConstraint(); if (constraint == null) constraint = Object.class;
protected void addObject(Region aRegion, boolean logAddition) { String name = NameFactory.getNextPositiveObjectNameInLimit(maxObjects); Object anObj = getObjectToAdd(aRegion.getAttributes().getValueConstraint().getName()); String callback = createCallbackPrefix + ProcessMgr.getProcessId(); if (logAddition) Log.getLogWriter().info( "addObject: calling put for name " + name + ", object " + TestHelper.toString(anObj) + " callback is " + callback + ", region is " + aRegion.getFullPath()); try { aRegion.put(name, anObj, callback); QueryBB.putQueryValidator(new QueryValidator("add", name, true, true, anObj)); } catch (RegionDestroyedException e) { handleRegionDestroyedException(aRegion, e); } catch (Exception e) { throw new TestException(TestHelper.getStackTrace(e)); } long numPut = EventBB.incrementCounter("EventBB.NUM_CREATE", EventBB.NUM_CREATE); }
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(((GemFireCacheImpl)region.getCache()).getCachePerfStats()); values.setElementType(valueType); keys = new ResultsSet(); keys.setElementType(keyType); entries = new ResultsSet(); entries.setElementType(TypeUtils.getRegionEntryType(region)); // gets key and value types from region }
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(((GemFireCacheImpl)region.getCache()).getCachePerfStats()); values.setElementType(valueType); keys = new ResultsSet(); keys.setElementType(keyType); entries = new ResultsSet(); entries.setElementType(TypeUtils.getRegionEntryType(region)); // gets key and value types from region }
public static void assertEquals(RegionAttributes ra1, RegionAttributes ra2) { assertEquals(ra1.getScope(), ra2.getScope()); assertEquals(ra1.getKeyConstraint(), ra2.getKeyConstraint()); assertEquals(ra1.getValueConstraint(), ra2.getValueConstraint()); assertEquals(ra1.getCacheListener(), ra2.getCacheListener()); assertEquals(ra1.getCacheWriter(), ra2.getCacheWriter()); assertEquals(ra1.getCacheLoader(), ra2.getCacheLoader()); assertEquals(ra1.getStatisticsEnabled(), ra2.getStatisticsEnabled()); assertEquals(ra1.getConcurrencyLevel(), ra2.getConcurrencyLevel()); assertEquals(ra1.getInitialCapacity(), ra2.getInitialCapacity()); assertTrue(ra1.getLoadFactor() == ra2.getLoadFactor()); assertEquals(ra1.getEarlyAck(), ra2.getEarlyAck()); assertEquals(ra1.isDiskSynchronous(), ra2.isDiskSynchronous()); assertEquals(ra1.getDiskStoreName(), ra2.getDiskStoreName()); }
public QRegion(Region region, boolean includeKeys, ExecutionContext context) { if (region == null) throw new IllegalArgumentException(LocalizedStrings.QRegion_REGION_CAN_NOT_BE_NULL.toLocalizedString()); Class constraint = region.getAttributes().getValueConstraint(); if (constraint == null) constraint = Object.class; ResultsCollectionWrapper res = null; if (context.getBucketList() != null && region instanceof PartitionedRegion) { final PartitionedRegion pr = (PartitionedRegion)region; LocalDataSet localData = new LocalDataSet(pr, new THashSet( context.getBucketList()), pr.getTXState()); this.region = localData; if (includeKeys) { res = new ResultsCollectionWrapper(TypeUtils.getObjectType(constraint), localData.localEntrySet()); } else { res = new ResultsCollectionWrapper(TypeUtils.getObjectType(constraint), localData.localValues()); } } else { this.region = region; if (includeKeys) { res = new ResultsCollectionWrapper(TypeUtils.getObjectType(constraint), region.entrySet()); } else { res = new ResultsCollectionWrapper(TypeUtils.getObjectType(constraint), region.values()); } } res.setModifiable(false); this.values = res; }
public static void assertEquals(RegionAttributes ra1, RegionAttributes ra2) { assertEquals(ra1.getScope(), ra2.getScope()); assertEquals(ra1.getKeyConstraint(), ra2.getKeyConstraint()); assertEquals(ra1.getValueConstraint(), ra2.getValueConstraint()); assertEquals(ra1.getCacheListener(), ra2.getCacheListener()); assertEquals(ra1.getCacheWriter(), ra2.getCacheWriter()); assertEquals(ra1.getCacheLoader(), ra2.getCacheLoader()); assertEquals(ra1.getStatisticsEnabled(), ra2.getStatisticsEnabled()); assertEquals(ra1.getConcurrencyLevel(), ra2.getConcurrencyLevel()); assertEquals(ra1.getInitialCapacity(), ra2.getInitialCapacity()); assertTrue(ra1.getLoadFactor() == ra2.getLoadFactor()); assertEquals(ra1.getEarlyAck(), ra2.getEarlyAck()); assertEquals(ra1.isDiskSynchronous(), ra2.isDiskSynchronous()); assertEquals(ra1.getDiskStoreName(), ra2.getDiskStoreName()); }
RegionAttributes attrs = cache.getRegionAttributes(id); assertEquals(keyConstraint, attrs.getKeyConstraint()); assertEquals(valueConstraint, attrs.getValueConstraint()); assertEquals(45, attrs.getEntryIdleTimeout().getTimeout()); assertEquals(ExpirationAction.INVALIDATE, attrs.getEntryIdleTimeout().getAction()); assertEquals(valueConstraint, attrs.getValueConstraint()); assertEquals(45, attrs.getEntryIdleTimeout().getTimeout()); assertEquals(ExpirationAction.INVALIDATE, attrs.getEntryIdleTimeout().getAction()); assertEquals(Long.class, attrs.getValueConstraint()); assertEquals(90, attrs.getEntryIdleTimeout().getTimeout()); assertEquals(ExpirationAction.DESTROY, attrs.getEntryIdleTimeout().getAction());
/** * Updates the entry with the given key (<code>name</code>) in the given * region. */ protected void updateObject(Region aRegion, Object name) { Object anObj = null; try { anObj = aRegion.get(name); } catch (CacheLoaderException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (TimeoutException e) { throw new TestException(TestHelper.getStackTrace(e)); } Object newObj = getUpdateObject(aRegion.getAttributes().getValueConstraint().getName()); try { String callback = updateCallbackPrefix + ProcessMgr.getProcessId(); Log.getLogWriter().info( "updateObject: replacing name " + name + " with " + TestHelper.toString(newObj) + "; old value is " + TestHelper.toString(anObj) + ", callback is " + callback); aRegion.put(name, newObj, callback); Log.getLogWriter().info("Done with call to put (update)"); } catch (Exception e) { throw new TestException(TestHelper.getStackTrace(e)); } QueryBB.putQueryValidator(new QueryValidator("update", name, true, true, newObj)); long numUpdate = EventBB.incrementCounter("EventBB.NUM_UPDATE", EventBB.NUM_UPDATE); }