use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class DiskOldAPIsJUnitTest 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();
DiskStoreImpl.SET_IGNORE_PREALLOCATE = true;
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class CacheServerTestUtil method createCacheServerFromXml.
public static Integer createCacheServerFromXml(URL url) {
CacheFactory ccf = new CacheFactory();
try {
File cacheXmlFile = new File(url.toURI().getPath());
ccf.set(CACHE_XML_FILE, cacheXmlFile.toURI().getPath());
ccf.set(MCAST_PORT, "0");
ccf.set(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
} catch (URISyntaxException e) {
throw new ExceptionInInitializerError(e);
}
cache = ccf.create();
return new Integer(cache.getCacheServers().get(0).getPort());
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class AcceptorImplDUnitTest method testAcceptorImplCloseCleansUp.
@Test
public void testAcceptorImplCloseCleansUp() throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
try (InternalCache cache = (InternalCache) new CacheFactory(props).create()) {
RegionFactory<Object, Object> regionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
final CacheServer server = cache.addCacheServer();
final int port = AvailablePortHelper.getRandomAvailableTCPPort();
server.setPort(port);
server.start();
regionFactory.create("region1");
assertTrue(cache.isServer());
assertFalse(cache.isClosed());
Awaitility.await("Acceptor is up and running").atMost(10, SECONDS).until(() -> getAcceptorImplFromCache(cache) != null);
AcceptorImpl acceptorImpl = getAcceptorImplFromCache(cache);
cache.close();
Awaitility.await("Acceptor shuts down properly").atMost(10, SECONDS).until(acceptorImpl::isShutdownProperly);
assertTrue(cache.isClosed());
assertFalse(acceptorImpl.isRunning());
}
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class BlockingTimeOutJUnitTest method init.
@SuppressWarnings("deprecation")
private static String init(String className) throws Exception {
DistributedSystem ds = InternalDistributedSystem.getConnectedInstance();
if (ds != null) {
ds.disconnect();
}
logger.debug("PATH11 ");
Properties props = new Properties();
String path = System.getProperty("CACHEXMLFILE");
logger.debug("PATH2 " + path);
int pid = RANDOM;
path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath();
logger.debug("PATH " + path);
/** * Return file as string and then modify the string accordingly ** */
String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml"));
file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid);
String modified_file_str = modifyFile(file_as_str);
FileOutputStream fos = new FileOutputStream(path);
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(fos));
wr.write(modified_file_str);
wr.flush();
wr.close();
props.setProperty(CACHE_XML_FILE, path);
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
String tableName = "";
cache = new CacheFactory(props).create();
if (className != null && !className.equals("")) {
String time = new Long(System.currentTimeMillis()).toString();
tableName = className + time;
createTable(tableName);
}
tblName = tableName;
return tableName;
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class OffHeapIndexJUnitTest method setUp.
@Before
public void setUp() {
Properties props = new Properties();
props.setProperty(LOCATORS, "");
props.setProperty(MCAST_PORT, "0");
props.setProperty(ConfigurationProperties.OFF_HEAP_MEMORY_SIZE, "100m");
this.gfc = (GemFireCacheImpl) new CacheFactory(props).create();
}
Aggregations