/** * get a entry from local monitoring region * * @param name MBean name * @return the value */ public Object getEntryFromLocalMonitoringRegion(ObjectName name) { return localMonitoringRegion.get(name.toString()); }
@Override public void run2() throws CacheException { Region<Object, Object> region = getRootRegion().getSubregion(name); Object got = region.get(key); assertThat(got).isEqualTo(value); } });
/** * This method prints the content of the allPartitionedRegion's contents for this * PartitionedRegion. */ public void dumpSelfEntryFromAllPartitionedRegions() { StringBuilder sb = new StringBuilder(this.prRoot.getFullPath()); sb.append("Dumping allPartitionedRegions for "); sb.append(this); sb.append("\n"); sb.append(this.prRoot.get(getRegionIdentifier())); logger.debug(sb.toString()); }
@Override public V remove(final Object key) { try { V oldValue = region.get(key, callbackArg); region.destroy(key, callbackArg); return oldValue; } catch (EntryNotFoundException e) { return null; } }
@Override public void run2() throws CacheException { Region<Object, Object> region = getRootRegion().getSubregion(name); Object got = region.get(key); assertThat(got).isEqualTo(value); } });
@Override public Object get(Object key) throws CacheLoaderException, TimeoutException { try { preOp(); return this.realRegion.get(key); } finally { postOp(); } }
@Override public Object get(Object key, Object callbackArgument) throws TimeoutException, CacheLoaderException { try { preOp(); return this.realRegion.get(key, callbackArgument); } finally { postOp(); } }
/** * To be used for CacheLoader related tests */ public static void doGets(String regionName, int numGets) { Region r = cache.getRegion(Region.SEPARATOR + regionName); assertNotNull(r); for (long i = 0; i < numGets; i++) { r.get(i); } }
@Before public void setUp() throws Exception { regionStub = mock(Region.class); when(regionStub.get(TEST_KEY1)).thenReturn(TEST_VALUE1); when(regionStub.get(TEST_KEY2)).thenReturn(TEST_VALUE2); when(regionStub.get(TEST_KEY3)).thenReturn(TEST_VALUE3); when(regionStub.get(NO_VALUE_PRESENT_FOR_THIS_KEY)).thenReturn(null); when(regionStub.get(TEST_INVALID_KEY)) .thenThrow(new CacheLoaderException("Let's pretend that didn't work")); when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub); operationHandler = new GetAllRequestOperationHandler(); }
@Override public <K, V> V get(String regionName, K key) { security.authorize(DATA, READ, regionName, key); Region<K, V> region = getRegion(regionName); Object value = region.get(key); return (V) security.postProcess(regionName, key, value); }
@Override public Object getDeserializedValue() { if (indexOnValues) { return region.get(entry.getRegionKey().getDeserializedForReading()); } else if (indexOnRegionKeys) { return getDeserializedRegionKey(); } else { return new EntrySet(getDeserializedRegionKey(), region.get(entry.getRegionKey().getDeserializedForReading())); } }
@Before public void setUp() throws Exception { Region regionStub = mock(Region.class); when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE); when(regionStub.get(MISSING_KEY)).thenReturn(null); when(regionStub.get(NULLED_KEY)).thenReturn(null); when(regionStub.containsKey(MISSING_KEY)).thenReturn(false); when(regionStub.containsKey(NULLED_KEY)).thenReturn(true); when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub); when(cacheStub.getRegion(MISSING_REGION)).thenReturn(null); operationHandler = new GetRequestOperationHandler(); }
public void updatePRConfigWithNewSetOfGatewaySenders(Set<String> gatewaySendersToAdd) { PartitionRegionHelper.assignBucketsToPartitions(this); PartitionRegionConfig prConfig = this.prRoot.get(getRegionIdentifier()); prConfig.setGatewaySenderIds(gatewaySendersToAdd); updatePRConfig(prConfig, false); }
@Test public void getAllWithRegionLevelAuthorizationSucceeds() { authorize(DATA, READ, REGION, ALL); Map<Object, Object> okValues = new HashMap<>(); Map<Object, Exception> exceptionValues = new HashMap<>(); when(region.get("b")).thenReturn("existing value"); authorizingCache.getAll(REGION, Arrays.asList("a", "b"), okValues::put, exceptionValues::put); verify(region).get("a"); verify(region).get("b"); assertThat(okValues).containsOnly(entry("a", null), entry("b", "existing value")); assertThat(exceptionValues).isEmpty(); }
@Override public Object get(Object key) { ClientUpdateMessageImpl msg = (ClientUpdateMessageImpl) map.get(key); if (msg != null) { msg.setEventIdentifier(((HAEventWrapper) key).getEventId()); if (msg.hasCqs()) { msg.setClientCqs(((HAEventWrapper) key).getClientCqs()); } } return msg; }
protected void verify100Int(boolean verifySize) { if (verifySize) { assertEquals(100, region.size()); } for (int i = 0; i < 100; i++) { Integer key = i; assertTrue(region.containsKey(key)); assertEquals(key, region.get(key)); } }
@Override public void beforeUpdate(EntryEvent<Object, Object> event) throws CacheWriterException { if (!event.getRegion().get(event.getKey()).equals(event.getNewValue())) { PdxRegistryMismatchException ex = new PdxRegistryMismatchException( "Trying to add a PDXType with the same id as an existing PDX type. id=" + event.getKey() + ", existing pdx type " + event.getOldValue() + ", new type " + event.getNewValue()); throw new CacheWriterException(ex); } }
@Test public void getIsPostProcessed() { authorize(DATA, READ, REGION, "a"); when(security.postProcess(REGION, "a", "value")).thenReturn("spam"); when(region.get("a")).thenReturn("value"); assertEquals("spam", authorizingCache.get(REGION, "a")); }
@Test public void get() { authorize(DATA, READ, REGION, "a"); when(region.get("a")).thenReturn("value"); assertEquals("value", authorizingCache.get(REGION, "a")); }
private PartitionRegionConfig getPRConfigWithLatestExpirationAttributes() { PartitionRegionConfig prConfig = this.prRoot.get(getRegionIdentifier()); return new PartitionRegionConfig(prConfig.getPRId(), prConfig.getFullPath(), prConfig.getPartitionAttrs(), prConfig.getScope(), prConfig.getEvictionAttributes(), this.getRegionIdleTimeout(), this.getRegionTimeToLive(), this.getEntryIdleTimeout(), this.getEntryTimeToLive(), prConfig.getGatewaySenderIds()); }