use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class DiskRegionIllegalArguementsJUnitTest method setUp.
@Before
public void setUp() throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
// to keep diskPerf logs smaller
props.setProperty(LOG_LEVEL, "config");
props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
props.setProperty(ENABLE_TIME_STATISTICS, "true");
props.setProperty(STATISTIC_ARCHIVE_FILE, "stats.gfs");
cache = new CacheFactory(props).create();
ds = cache.getDistributedSystem();
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class PersistentPartitionedRegionJUnitTest method createRegion.
private Region createRegion(int ttl, boolean isHeapEviction, boolean isEntryEviction) {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOG_LEVEL, "info");
// props.setProperty("log-file", "junit.log");
cache = new CacheFactory(props).create();
cache.createDiskStoreFactory().setMaxOplogSize(1).setDiskDirs(new File[] { dir }).create("disk");
RegionFactory<Object, Object> rf = cache.createRegionFactory().setDataPolicy(DataPolicy.PERSISTENT_PARTITION).setDiskStoreName("disk");
rf.setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(1).create());
if (ttl > 0) {
rf.setEntryTimeToLive(new ExpirationAttributes(ttl, ExpirationAction.DESTROY));
}
if (isEntryEviction) {
rf.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(10, EvictionAction.OVERFLOW_TO_DISK));
} else if (isHeapEviction) {
rf.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes(ObjectSizer.DEFAULT, EvictionAction.OVERFLOW_TO_DISK));
}
Region region = rf.create("region");
return region;
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class PRClientServerRegionFunctionExecutionFailoverDUnitTest method createServerWithLocator.
public int createServerWithLocator(String locator, boolean isAccessor, ArrayList commonAttrs) {
Properties props = new Properties();
props = new Properties();
props.setProperty(LOCATORS, locator);
DistributedSystem ds = getSystem(props);
cache = new CacheFactory(props).create(ds);
CacheServer server = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setPort(port);
server.setHostnameForClients("localhost");
try {
server.start();
} catch (IOException e) {
Assert.fail("Failed to start server ", e);
}
PartitionAttributesFactory paf = new PartitionAttributesFactory();
if (isAccessor) {
paf.setLocalMaxMemory(0);
}
paf.setTotalNumBuckets(((Integer) commonAttrs.get(3)).intValue()).setRedundantCopies(((Integer) commonAttrs.get(2)).intValue());
AttributesFactory attr = new AttributesFactory();
attr.setPartitionAttributes(paf.create());
region = cache.createRegion(regionName, attr.create());
assertNotNull(region);
LogWriterUtils.getLogWriter().info("Partitioned Region " + regionName + " created Successfully :" + region.toString());
return port;
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class UnregisterInterestDUnitTest method createCacheAndStartServer.
public static Integer createCacheAndStartServer() throws Exception {
DistributedSystem ds = new UnregisterInterestDUnitTest().getSystem();
ds.disconnect();
Properties props = new Properties();
props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
CacheFactory cf = new CacheFactory(props);
cache = cf.create();
RegionFactory rf = ((GemFireCacheImpl) cache).createRegionFactory(RegionShortcut.REPLICATE);
rf.create(regionname);
CacheServer server = ((GemFireCacheImpl) cache).addCacheServer();
server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
server.start();
return server.getPort();
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class CustomConfigWithCacheIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
Configurator.shutdown();
BasicAppender.clearInstance();
this.beforeConfigFileProp = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
this.beforeLevel = StatusLogger.getLogger().getLevel();
this.customConfigFile = createConfigFileIn(this.temporaryFolder.getRoot());
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.customConfigFile.getAbsolutePath());
Properties gemfireProperties = new Properties();
gemfireProperties.put(LOCATORS, "");
gemfireProperties.put(MCAST_PORT, "0");
gemfireProperties.put(LOG_LEVEL, "info");
this.cache = new CacheFactory(gemfireProperties).create();
}
Aggregations