use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class SSLConfigIntegrationJUnitTest method testIsClusterSSLRequireAuthentication.
@Test
public void testIsClusterSSLRequireAuthentication() {
Cache mCache = new CacheFactory().set(MCAST_PORT, "0").set(JMX_MANAGER, "true").create();
ManagementService mService = ManagementService.getManagementService(mCache);
MemberMXBean mMemberBean = mService.getMemberMXBean();
GemFireProperties mGemFireProperties = mMemberBean.listGemFireProperties();
assertTrue(mGemFireProperties.isServerSSLRequireAuthentication());
assertTrue(mGemFireProperties.isClusterSSLRequireAuthentication());
assertTrue(mGemFireProperties.isGatewaySSLRequireAuthentication());
assertTrue(mGemFireProperties.isJmxManagerSSLRequireAuthentication());
mCache.close();
}
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 WANBootStrapping_Site1_Add method main.
public static void main(String[] args) {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DistributedSystemListener", "com.main.MyDistributedSystemListener");
// Create a locator and a cache
System.out.println("Creating cache ...It will take some time..");
Cache cache = new CacheFactory().set(MCAST_PORT, "0").set(DISTRIBUTED_SYSTEM_ID, "" + 1).set(LOCATORS, "localhost[" + 10101 + "]").set(START_LOCATOR, "localhost[" + 10101 + "],server=true,peer=true,hostname-for-clients=localhost").set(LOG_LEVEL, "warning").create();
System.out.println("Cache Created");
// to create region and a gateway sender ask to run
// WANBootStrapping_Site2_Add program
System.out.println("Run WANBootStrapping_Site2_Add");
// get the region
Region region = cache.getRegion("MyRegion");
while (region == null) {
region = cache.getRegion("MyRegion");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
// put data in region
for (int i = 0; i < 100; i++) {
System.out.println("Create Entry : key_" + i + ", value_" + i);
region.put("key_" + i, "value_" + i);
}
System.out.println("Entry Create Operation completed");
Set<GatewaySender> gatewaySenders = cache.getGatewaySenders();
GatewaySender sender = gatewaySenders.iterator().next();
// make sure that gateway sender is running
if (sender.isRunning()) {
System.out.println("Sender " + sender.getId() + " is running");
}
// to stop gateway sender ask to run WANBootStrapping_Site2_Remove program
while (sender.isRunning()) {
System.out.println("Waitng for sender to stop through DistributedSystemListener");
System.out.println("Start WANBootStrapping_Site2_Remove");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Sender " + sender.getId() + " is stopped");
System.exit(0);
}
Aggregations