Search in sources :

Example 21 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 22 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 23 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 24 with CacheFactory

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

Example 25 with CacheFactory

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

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