/** * Sets the scope for the next {@code RegionAttributes} created. * * @param scopeType the type of Scope to use for the region * @return a reference to this RegionFactory object * @throws IllegalArgumentException if scopeType is null * @see AttributesFactory#setScope */ public RegionFactory<K, V> setScope(Scope scopeType) { this.attrsFactory.setScope(scopeType); return this; }
@Override public void run2() throws CacheException { { // root region must be DACK because its used to sync up async subregions AttributesFactory<?, ?> factory = new AttributesFactory<>(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.EMPTY); createRootRegion(factory.create()); } { AttributesFactory<?, ?> factory = new AttributesFactory<>(getRegionAttributes()); createRegion(name, factory.create()); } // reset slow org.apache.geode.internal.cache.InitialImageOperation.slowImageProcessing = 0; } });
@Override public void run2() throws CacheException { { // root region must be DACK because its used to sync up async subregions AttributesFactory<?, ?> factory = new AttributesFactory<>(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.EMPTY); createRootRegion(factory.create()); } { AttributesFactory<?, ?> factory = new AttributesFactory<>(getRegionAttributes()); createRegion(name, factory.create()); } // reset slow org.apache.geode.internal.cache.InitialImageOperation.slowImageProcessing = 0; } });
private void initAttributeFactoryDefaults() { this.attrsFactory.setScope(Scope.LOCAL); this.attrsFactory.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL)); }
/** * Returns region attributes for a <code>LOCAL</code> region */ protected RegionAttributes getRegionAttributes() { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); return factory.create(); }
@Override public void run2() throws CacheException { { // root region must be DACK because its used to sync up async subregions AttributesFactory<?, ?> factory = new AttributesFactory<>(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.EMPTY); createRootRegion(factory.create()); } { AttributesFactory<?, ?> factory = new AttributesFactory<>(getRegionAttributes()); factory.setDataPolicy(DataPolicy.REPLICATE); createRegion(name, factory.create()); } // reset slow org.apache.geode.internal.cache.InitialImageOperation.slowImageProcessing = 0; } });
public static Region createRegion(String regionName, Class valueConstraint, Scope scope) { try { AttributesFactory attributesFactory = new AttributesFactory(); attributesFactory.setValueConstraint(valueConstraint); if (scope != null) { attributesFactory.setScope(scope); } RegionAttributes regionAttributes = attributesFactory.create(); return cache.createRegion(regionName, regionAttributes); } catch (Exception e) { throw new AssertionError(e); } }
protected void createCache() throws CacheException { Properties p = new Properties(); p.setProperty(MCAST_PORT, "0"); // loner this.cache = (GemFireCacheImpl) CacheFactory.create(DistributedSystem.connect(p)); AttributesFactory<String, String> af = new AttributesFactory<>(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setIndexMaintenanceSynchronous(true); this.region = this.cache.createRegion("TXTest", af.create()); this.txMgr = this.cache.getCacheTransactionManager(); }
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(); }
/** * This method creates a local region with all the default values. The cache created is a loner, * so this is only suitable for single VM tests. */ public static Region createLocalRegion(String regionName) throws RegionExistsException { AttributesFactory attr = new AttributesFactory(); attr.setScope(Scope.LOCAL); Region localRegion = createCache().createRegion(regionName, attr.create()); return localRegion; }
public static void createPool(PoolAttributes poolAttr) throws Exception { Properties props = new Properties(); props.setProperty(MCAST_PORT, "0"); props.setProperty(LOCATORS, ""); DistributedSystem ds = new CacheServerTestUtil().getSystem(props);; PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(poolAttr); PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setPoolName(p.getName()); RegionAttributes attrs = factory.create(); pool = p; }
protected void startBridgeClient(final Pool pool, final String[] regions) throws Exception { Properties props = new Properties(); props.setProperty(MCAST_PORT, String.valueOf(0)); props.setProperty(LOCATORS, ""); DistributedSystem ds = getSystem(props); Cache cache = CacheFactory.create(ds); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setPoolName(POOL_NAME); PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(pool); LocatorDiscoveryCallback locatorCallback = new MyLocatorCallback(); remoteObjects.put(CALLBACK_KEY, locatorCallback); pf.setLocatorDiscoveryCallback(locatorCallback); pf.create(POOL_NAME); RegionAttributes attrs = factory.create(); for (int i = 0; i < regions.length; i++) { cache.createRegion(regions[i], attrs); } remoteObjects.put(CACHE_KEY, cache); }
public static void createCacheServer(String regionName, Boolean notifyBySubscription, Integer serverPort) throws Exception { Properties props = new Properties(); props.setProperty(MCAST_PORT, "0"); props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]"); new CacheServerTestUtil().createCache(props); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setEnableBridgeConflation(true); factory.setDataPolicy(DataPolicy.REPLICATE); RegionAttributes attrs = factory.create(); cache.createRegion(regionName, attrs); CacheServer server = cache.addCacheServer(); server.setPort(serverPort.intValue()); server.setNotifyBySubscription(notifyBySubscription.booleanValue()); server.start(); }
public static Integer createCacheServer(String regionName1, String regionName2, Boolean notifyBySubscription) throws Exception { new CacheServerTestUtil().createCache(new Properties()); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setEnableBridgeConflation(true); factory.setDataPolicy(DataPolicy.REPLICATE); RegionAttributes attrs = factory.create(); if (!regionName1.equals("")) { cache.createRegion(regionName1, attrs); } if (!regionName2.equals("")) { cache.createRegion(regionName2, attrs); } CacheServer server1 = cache.addCacheServer(); int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); server1.setPort(port); server1.setNotifyBySubscription(notifyBySubscription.booleanValue()); server1.start(); return new Integer(server1.getPort()); }
private RegionAttributes createRegionAttributes(boolean isConcurrencyChecksEnabled) { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.REPLICATE); factory.setConcurrencyChecksEnabled(isConcurrencyChecksEnabled); // RegionAttributes ra = factory.create(); return ra; }
private RegionAttributes createRegionAttributes(boolean isConcurrencyChecksEnabled) { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.REPLICATE); factory.setConcurrencyChecksEnabled(isConcurrencyChecksEnabled); // RegionAttributes ra = factory.create(); return ra; }
/** * Create client regions */ public static void createCacheClients(Pool poolAttr, String regionName1, String regionName2, Properties dsProperties) throws Exception { new CacheServerTestUtil().createCache(dsProperties); // Initialize region1 PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(poolAttr); Pool p = pf.create("CacheServerTestUtil1"); AttributesFactory factory1 = new AttributesFactory(); factory1.setScope(Scope.LOCAL); factory1.setPoolName(p.getName()); cache.createRegion(regionName1, factory1.create()); // Initialize region2 p = pf.create("CacheServerTestUtil2"); AttributesFactory factory2 = new AttributesFactory(); factory2.setScope(Scope.LOCAL); factory2.setPoolName(p.getName()); cache.createRegion(regionName2, factory2.create()); }
public static Region createOrGetExistingExportLogsRegion(boolean isInitiatingMember, InternalCache cache) throws IOException, ClassNotFoundException { InternalCacheForClientAccess cacheForClientAccess = cache.getCacheForProcessingClientRequests(); Region exportLogsRegion = cacheForClientAccess.getInternalRegion(EXPORT_LOGS_REGION); if (exportLogsRegion == null) { AttributesFactory<String, Configuration> regionAttrsFactory = new AttributesFactory<>(); regionAttrsFactory.setDataPolicy(DataPolicy.EMPTY); regionAttrsFactory.setScope(Scope.DISTRIBUTED_ACK); if (isInitiatingMember) { regionAttrsFactory.setCacheWriter(new ExportLogsCacheWriter()); } InternalRegionArguments internalArgs = new InternalRegionArguments(); internalArgs.setIsUsedForMetaRegion(true); exportLogsRegion = cacheForClientAccess.createInternalRegion(EXPORT_LOGS_REGION, regionAttrsFactory.create(), internalArgs); } return exportLogsRegion; }
public static void createCacheClient(Pool poolAttr, String regionName1, String regionName2) throws Exception { new CacheServerTestUtil().createCache(getClientProperties()); PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(poolAttr); PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setPoolName(p.getName()); RegionAttributes attrs = factory.create(); cache.createRegion(regionName1, attrs); cache.createRegion(regionName2, attrs); pool = p; }
@Override public void run2() { try { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); // can't be local since used with // registerInterest factory.setCacheLoader(new CacheServerCacheLoader()); beginCacheXml(); createRootRegion(rName, factory.create()); startBridgeServer(port); finishCacheXml(rName + "-" + port); Region region = getRootRegion(rName); assertNotNull(region); region.put(BridgeServerKey, new Integer(port)); // A unique key/value to identify the // BridgeServer } catch (Exception e) { getSystem().getLogWriter().severe(e); fail("Failed to start CacheServer " + e); } } });