/** Call containsKey on the given region and key * * @param aRegion - The region to test for the key. * @param key - The key to use for containsKey. * * @returns true if the region contains an entry with key, false otherwise. */ public boolean containsKey(Region aRegion, Object key) { boolean result = aRegion.containsKey(key); return result; }
public Object call() throws Exception { final Region r = getCache().getRegion(regionName); assertEquals("value", r.putIfAbsent("key0", "newValue")); assertTrue(r.containsKeyOnServer("key0")); assertTrue(r.containsKey("key0")); assertTrue(r.containsValueForKey("key0")); return null; } });
public boolean keyExistsInLocalMonitoringRegion(String key) { if (localMonitoringRegion != null && !localMonitoringRegion.isDestroyed()) { // We want to just check locally without sending a message to the manager. // containsKey does this. return localMonitoringRegion.containsKey(key); } else { return true; // so caller will think he does not need to do a putAll } }
public Object call() throws Exception { final Region r = getCache().getRegion(REP_REG_NAME); final Region pr = getCache().getRegion(PR_REG_NAME); assertEquals(r.get("createKey"), r.get("putAbsentKey")); assertEquals(pr.get("createKey"), pr.get("putAbsentKey")); assertFalse(r.containsKey("createKey")); assertFalse(pr.containsKey("createKey")); assertEquals(r.containsKey("createKey"), r.containsKey("putAbsentKey")); assertEquals(pr.containsKey("createKey"), pr.containsKey("putAbsentKey")); return null; } });
public Object call() throws Exception { final Integer k = new Integer(2); // reload with same key again and again Integer expectedInvocations6 = new Integer(expectedInvocations.incrementAndGet()); Region<Integer, String> r = getCache().getRegion(rName); assertEquals(k.toString(), r.get(k, expectedInvocations6)); // load assertFalse(r.containsKey(k)); Integer expectedInvocations7 = new Integer(expectedInvocations.incrementAndGet()); assertEquals(k.toString(), r.get(k, expectedInvocations7)); // load assertFalse(r.containsKey(k)); return expectedInvocations7; } });
public Object call() throws Exception { final Integer k = new Integer(2); // reload with same key again and again Integer expectedInvocations6 = new Integer(expectedInvocations.incrementAndGet()); Region<Integer, String> r = getCache().getRegion(rName); assertEquals(k.toString(), r.get(k, expectedInvocations6)); // load assertFalse(r.containsKey(k)); Integer expectedInvocations7 = new Integer(expectedInvocations.incrementAndGet()); assertEquals(k.toString(), r.get(k, expectedInvocations7)); // load assertFalse(r.containsKey(k)); return expectedInvocations7; } });
public boolean containsKey(Object key) { try { preOp(); return this.realRegion.containsKey(key); } finally { postOp(); } }
public void run2() throws CacheException { Region r = getRootRegion("ProxyDUnitTest"); assertEquals(true, r.containsKey("createKey")); assertEquals("createValue1", r.getEntry("createKey").getValue()); } });
public boolean containsKey(Object key) { try { preOp(); return this.realRegion.containsKey(key); } finally { postOp(); } }
@Override public Object call() throws Exception { Cache cache = CacheFactory.getAnyInstance(); Region r = cache.getRegion("/REG1"); assertEquals(10, r.size()); for(int i = 0; i < 10; i++) { assertTrue(r.containsKey("name"+i)); assertEquals("value"+i, r.get("name"+i)); } return null; } });
public Object call() throws Exception { Region r = getCache().getRegion(regionName); r.putIfAbsent(key, null); assertTrue(r.containsKey(key)); return null; }}); client.invoke(new SerializableCallable() {
public void run2() throws CacheException { Region r = getRootRegion("ProxyDUnitTest"); assertEquals(true, r.containsKey("putkey")); assertEquals("putvalue1", r.getEntry("putkey").getValue()); r.put("putkey", "putvalue2"); } });
@Override public void run() { Cache cache = getCache(); Region region = cache.getRegion(DATA_REGION_NAME_PATH); assertNotNull(region); assertEquals(true, region.containsKey(key)); region.remove(key); } };
public void test140ContainsKey() { Region<Integer, String> r = createRegion(getName()); for (int i=0; i<100; i++) { r.put(i, "value"+i); } clearBackingCHM(r); assertTrue(r.containsKey(80)); r.destroy(80); assertFalse(r.containsKey(80)); r.invalidate(64); assertTrue(r.containsKey(64)); }
public Object call() throws Exception { final Region r = getCache().getRegion(regionName); assertTrue(r.containsKey("key0")); assertFalse(r.containsValueForKey("key0")); return null; } });
public Object call() throws Exception { final Region r = getCache().getRegion(regionName); assertNull(r.putIfAbsent("key0", "value")); assertTrue(r.containsKey("key0")); return null; } });
public void beforeDestroy(EntryEvent event) { lastEvent = event; if (this.v.isSuspendValidation()) {return;} validate(event); this.v.setPassedValidation(false); assertTrue("IsDestroy Assertion!", this.v.isDestroy()); assertTrue(event.getRegion().containsKey(this.v.getKey())); this.v.setPassedValidation(true); } public void beforeRegionDestroy(RegionEvent event) {
public void beforeUpdate(EntryEvent event) throws CacheWriterException { assertTrue(event.getOperation().isUpdate()); assertTrue(event.getRegion().containsKey(this.key)); assertTrue(event.getRegion().containsValueForKey(this.key)); assertNotNull(event.getRegion().getEntry(this.key)); assertNotSame(this.value, event.getRegion().get(this.key)); this.validationSuccessful = true; }
public void afterDestroy(EntryEvent event) { lastEvent = event; if (this.v.isSuspendValidation()) {return;} validate(event); this.v.setPassedValidation(false); assertTrue("IsDestroy Assertion!", this.v.isDestroy()); assertTrue(!event.getRegion().containsKey(this.v.getKey())); assertTrue(!event.getRegion().containsValueForKey(this.v.getKey())); assertNull(event.getRegion().getEntry(event.getKey())); this.v.setPassedValidation(true); } public void afterRegionInvalidate(RegionEvent event) {
private boolean setXX(Region<ByteArrayWrapper, ByteArrayWrapper> r, Command command, ByteArrayWrapper key, ByteArrayWrapper valueWrapper, ExecutionHandlerContext context) { if(r.containsKey(key)) { checkAndSetDataType(key, context); r.put(key, valueWrapper); command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), SUCCESS)); return true; } else { command.setResponse(Coder.getNilResponse(context.getByteBufAllocator())); return false; } }