use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class RestInterfaceJUnitTest method setupGemFire.
@Before
public void setupGemFire() {
AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion());
if (agentUtil.findWarLocation("geode-web-api") == null) {
fail("unable to locate geode-web-api WAR file");
}
if (gemfireCache == null) {
gemfireProperties = (gemfireProperties != null ? gemfireProperties : new Properties());
gemfireCache = new CacheFactory().setPdxSerializer(new ReflectionBasedAutoSerializer(Person.class.getName().replaceAll("\\$", "."))).setPdxReadSerialized(true).setPdxIgnoreUnreadFields(false).set("name", getClass().getSimpleName()).set(MCAST_PORT, "0").set(LOG_LEVEL, "config").set(HTTP_SERVICE_BIND_ADDRESS, "localhost").set(HTTP_SERVICE_PORT, String.valueOf(getHttpServicePort())).set(START_DEV_REST_API, "true").create();
RegionFactory<String, Object> peopleRegionFactory = gemfireCache.createRegionFactory();
peopleRegionFactory.setDataPolicy(DataPolicy.PARTITION);
peopleRegionFactory.setKeyConstraint(String.class);
peopleRegionFactory.setValueConstraint(Object.class);
people = peopleRegionFactory.create("People");
}
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class InternalLocator method startCache.
private void startCache(DistributedSystem ds) {
InternalCache internalCache = GemFireCacheImpl.getInstance();
if (internalCache == null) {
logger.info("Creating cache for locator.");
this.myCache = (InternalCache) new CacheFactory(ds.getProperties()).create();
internalCache = this.myCache;
} else {
logger.info("Using existing cache for locator.");
((InternalDistributedSystem) ds).handleResourceEvent(ResourceEvent.LOCATOR_START, this);
}
startJmxManagerLocationService(internalCache);
startSharedConfigurationService(internalCache);
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class ClientServerRegisterInterestsDUnitTest method setupGemFireCacheServer.
private void setupGemFireCacheServer() {
Host localhost = Host.getHost(0);
gemfireServerVm = localhost.getVM(0);
serverPort.set(AvailablePortHelper.getRandomAvailableTCPPort());
gemfireServerVm.invoke(new SerializableRunnable() {
@Override
public void run() {
try {
Cache cache = new CacheFactory().set("name", "ClientServerRegisterInterestsTestGemFireServer").set(MCAST_PORT, "0").set(LOG_FILE, "clientServerRegisterInterestsTest.log").set(LOG_LEVEL, "config").create();
RegionFactory<String, String> regionFactory = cache.createRegionFactory();
regionFactory.setDataPolicy(DataPolicy.REPLICATE);
regionFactory.setKeyConstraint(String.class);
regionFactory.setValueConstraint(String.class);
Region<String, String> example = regionFactory.create("Example");
assertNotNull("The 'Example' Region was not properly configured and initialized!", example);
assertEquals("/Example", example.getFullPath());
assertEquals("Example", example.getName());
assertTrue(example.isEmpty());
example.put("1", "ONE");
assertFalse(example.isEmpty());
assertEquals(1, example.size());
CacheServer cacheServer = cache.addCacheServer();
cacheServer.setPort(serverPort.get());
cacheServer.setMaxConnections(10);
ClientSubscriptionConfig clientSubscriptionConfig = cacheServer.getClientSubscriptionConfig();
clientSubscriptionConfig.setCapacity(100);
clientSubscriptionConfig.setEvictionPolicy("entry");
cacheServer.start();
assertTrue("Cache Server is not running!", cacheServer.isRunning());
} catch (UnknownHostException ignore) {
throw new RuntimeException(ignore);
} catch (IOException e) {
throw new RuntimeException(String.format("Failed to start the GemFire Cache Server listening on port (%1$d) due to IO error!", serverPort.get()), e);
}
}
});
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class RemoveAllCacheListenerClientServerRegressionTest method setupGemFireCacheServer.
// ================================================================================
private void setupGemFireCacheServer(RegionShortcut shortcut, boolean concChecks) {
serverVM = Host.getHost(0).getVM(0);
serverPort.set(AvailablePortHelper.getRandomAvailableTCPPort());
String serverName = this.getClass().getSimpleName() + "_server";
serverVM.invoke(new SerializableRunnable() {
@Override
public void run() {
try {
Cache cache = new CacheFactory().set("name", serverName).set(MCAST_PORT, "0").set(LOG_FILE, serverName + ".log").set(LOG_LEVEL, "config").set("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]").create();
RegionFactory<String, String> regionFactory = cache.createRegionFactory(shortcut);
regionFactory.addCacheListener(new TestListener());
regionFactory.setConcurrencyChecksEnabled(concChecks);
regionFactory.create(REGION_NAME);
CacheServer cacheServer = cache.addCacheServer();
cacheServer.setPort(serverPort.get());
cacheServer.setMaxConnections(10);
cacheServer.start();
assertTrue("Cache Server is not running!", cacheServer.isRunning());
} catch (UnknownHostException ignore) {
throw new RuntimeException(ignore);
} catch (IOException e) {
throw new RuntimeException("Failed to start cache server " + serverName + " on port " + serverPort.get() + ": " + e.getStackTrace());
}
}
});
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class ParallelSnapshotDUnitTest method loadCache.
public void loadCache() throws Exception {
SerializableCallable setup = new SerializableCallable() {
@Override
public Object call() throws Exception {
CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
Cache cache = getCache(cf);
RegionGenerator rgen = new RegionGenerator();
rgen.createRegion(cache, null, RegionType.PARTITION, "test");
return null;
}
};
forEachVm(setup, true);
}
Aggregations