Search in sources :

Example 56 with CacheFactory

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();
}
Also used : ManagementService(org.apache.geode.management.ManagementService) GemFireProperties(org.apache.geode.management.GemFireProperties) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache) MemberMXBean(org.apache.geode.management.MemberMXBean) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 57 with CacheFactory

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;
}
Also used : ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) Before(org.junit.Before)

Example 58 with CacheFactory

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());
}
Also used : URISyntaxException(java.net.URISyntaxException) CacheFactory(org.apache.geode.cache.CacheFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) File(java.io.File)

Example 59 with CacheFactory

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());
    }
}
Also used : InternalCache(org.apache.geode.internal.cache.InternalCache) CacheServer(org.apache.geode.cache.server.CacheServer) Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 60 with CacheFactory

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);
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) Region(org.apache.geode.cache.Region) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache)

Aggregations

CacheFactory (org.apache.geode.cache.CacheFactory)125 Properties (java.util.Properties)51 Test (org.junit.Test)51 Cache (org.apache.geode.cache.Cache)44 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)38 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)28 Region (org.apache.geode.cache.Region)21 ClientCacheFactory (org.apache.geode.cache.client.ClientCacheFactory)18 CacheServer (org.apache.geode.cache.server.CacheServer)17 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)17 File (java.io.File)15 Before (org.junit.Before)14 SerializationTest (org.apache.geode.test.junit.categories.SerializationTest)13 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)12 ClientCache (org.apache.geode.cache.client.ClientCache)11 Host (org.apache.geode.test.dunit.Host)11 IOException (java.io.IOException)10 AttributesFactory (org.apache.geode.cache.AttributesFactory)10 PdxType (org.apache.geode.pdx.internal.PdxType)9 MyPdxSerializer (com.examples.snapshot.MyPdxSerializer)8