protected Region createRegion(String regionName, RegionShortcut shortcut) { return this.cache.createRegionFactory(shortcut).create(regionName); } }
public void createReplicateRegion(String name) { cache.createRegionFactory(RegionShortcut.REPLICATE).create(name); }
public void createLocalRegion(String name) { cache.createRegionFactory(RegionShortcut.LOCAL).create(name); }
@Override public void run2() throws CacheException { Cache cache = getCache(); RegionAttributes<?, ?> regionAttribs = getRegionAttributes(); cache.createRegionFactory(regionAttribs).create("R1"); } };
protected static Region<Object, ValueWrapper> getMemcachedRegion(Cache cache) { Region<Object, ValueWrapper> r = cache.getRegion(GemFireMemcachedServer.REGION_NAME); if (r == null) { synchronized (AbstractCommand.class) { r = cache.getRegion(GemFireMemcachedServer.REGION_NAME); if (r == null) { RegionFactory<Object, ValueWrapper> rf = cache.createRegionFactory(RegionShortcut.PARTITION); r = rf.create(GemFireMemcachedServer.REGION_NAME); } } } return r; }
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); }
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); }
static void putForClient() { Cache cache = new ClientServerMiscDUnitTestBase().getCache(); Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2); if (r2 == null) { r2 = cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME2); } r2.put(k1, "client2_k1"); r2.put(k2, "client2_k2"); }
private Region<String, PdxInstance> getRegion(String table) { Region<String, PdxInstance> r = cache.getRegion(table); if (r == null) { try { if (isClient) { ClientRegionFactory<String, PdxInstance> crf = ((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY); r = crf.create(table); } else { RegionFactory<String, PdxInstance> rf = ((Cache) cache).createRegionFactory(RegionShortcut.PARTITION); r = rf.create(table); } } catch (RegionExistsException e) { // another thread created the region r = cache.getRegion(table); } } return r; } }
@Override public void run2() throws CacheException { getLogger().fine("### Create subregion. ###"); Region root = cache.getRegion(rootName); if (root == null) { root = cache.createRegionFactory().create(rootName); } RegionAttributes ra = null; if (regionAttributes == null) { ra = new AttributesFactory().create(); } root.createSubregion(name, ra); } });
public static void createReplicatedRegionWithAsyncEventQueue(String regionName, String asyncQueueIds, Boolean offHeap) { IgnoredException exp1 = IgnoredException.addIgnoredException(ForceReattemptException.class.getName()); try { AttributesFactory fact = new AttributesFactory(); addAsyncEventQueueIds(fact, asyncQueueIds); fact.setDataPolicy(DataPolicy.REPLICATE); fact.setOffHeap(offHeap); RegionFactory regionFactory = cache.createRegionFactory(fact.create()); Region r = regionFactory.create(regionName); assertNotNull(r); } finally { exp1.remove(); } }
public static void createReplicatedRegionWithCacheLoaderAndAsyncEventQueue(String regionName, String asyncQueueIds) { AttributesFactory fact = new AttributesFactory(); addAsyncEventQueueIds(fact, asyncQueueIds); fact.setDataPolicy(DataPolicy.REPLICATE); // set the CacheLoader fact.setCacheLoader(new MyCacheLoader()); RegionFactory regionFactory = cache.createRegionFactory(fact.create()); Region r = regionFactory.create(regionName); assertNotNull(r); }
protected int startBridgeServer(final String[] groups, final String locators, final String[] regions, final ServerLoadProbe probe, final boolean useGroupsProperty) throws IOException { CacheFactory cacheFactory = new CacheFactory().set(MCAST_PORT, "0").set(LOCATORS, locators); if (useGroupsProperty && groups != null) { cacheFactory.set(GROUPS, StringUtils.join(groups, ",")); } Cache cache = cacheFactory.create(); for (String regionName : regions) { cache.createRegionFactory(RegionShortcut.REPLICATE).setEnableSubscriptionConflation(true) .create(regionName); } CacheServer server = cache.addCacheServer(); server.setPort(0); if (!useGroupsProperty) { server.setGroups(groups); } server.setLoadProbe(probe); server.start(); remoteObjects.put(CACHE_KEY, cache); return server.getPort(); }
@Before public void setUp() throws Exception { cache = new CacheFactory().set(ConfigurationProperties.LOCATORS, "").create(); Region region = cache.createRegionFactory(RegionShortcut.LOCAL).create("region"); IntStream.range(0, 2).forEach(i -> region.put("key" + i, new PortfolioPdx(i))); }
public static void createColocatedPartitionedRegionWithAsyncEventQueue(String regionName, String asyncEventQueueId, Integer totalNumBuckets, String colocatedWith) { IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName()); IgnoredException exp1 = IgnoredException.addIgnoredException(PartitionOfflineException.class.getName()); try { AttributesFactory fact = new AttributesFactory(); PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(totalNumBuckets); pfact.setColocatedWith(colocatedWith); fact.setPartitionAttributes(pfact.create()); Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId) .create(regionName); assertNotNull(r); } finally { exp.remove(); exp1.remove(); } }
public static void createPartitionedRegionWithAsyncEventQueue(String regionName, String asyncEventQueueId, Boolean offHeap) { IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName()); IgnoredException exp1 = IgnoredException.addIgnoredException(PartitionOfflineException.class.getName()); try { AttributesFactory fact = new AttributesFactory(); PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(16); fact.setPartitionAttributes(pfact.create()); fact.setOffHeap(offHeap); Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId) .create(regionName); assertNotNull(r); } finally { exp.remove(); exp1.remove(); } }
public static void createPartitionedRegionAccessorWithAsyncEventQueue(String regionName, String asyncEventQueueId) { AttributesFactory fact = new AttributesFactory(); PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(16); pfact.setLocalMaxMemory(0); fact.setPartitionAttributes(pfact.create()); Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId) .create(regionName); // fact.create()).create(regionName); assertNotNull(r); }
protected int startBridgeServerWithEmbeddedLocator(final String[] groups, final String locators, final String[] regions, final ServerLoadProbe probe) throws IOException { Cache cache = new CacheFactory().set(MCAST_PORT, "0").set(LOCATORS, locators) .set(START_LOCATOR, locators).create(); for (String regionName : regions) { cache.createRegionFactory(RegionShortcut.REPLICATE).setEnableSubscriptionConflation(true) .create(regionName); } CacheServer server = cache.addCacheServer(); server.setGroups(groups); server.setLoadProbe(probe); server.setPort(0); server.start(); remoteObjects.put(CACHE_KEY, cache); return server.getPort(); }
public static void createPartitionedRegionWithCacheLoaderAndAsyncQueue(String regionName, String asyncEventQueueId) { AttributesFactory fact = new AttributesFactory(); PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(16); fact.setPartitionAttributes(pfact.create()); // set the CacheLoader implementation fact.setCacheLoader(new MyCacheLoader()); Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId) .create(regionName); assertNotNull(r); }
@Before public void before() throws Exception { locator = lsRule.startLocatorVM(0, l -> l.withHttpService()); server = lsRule.startServerVM(1, locator.getPort()); server.invoke(() -> { Cache cache = ClusterStartupRule.getCache(); RegionFactory factory = cache.createRegionFactory(RegionShortcut.REPLICATE); Region region = factory.create(REGION_1); cache.getQueryService().createIndex(INDEX_1, "key", INDEX_REGION_NAME); region.put(1, new Stock("SUNW", 10)); region.get(1); }); connectGfsh(locator); }