Search in sources :

Example 61 with RegionAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.

the class CacheXml66DUnitTest method testBridgeAttributesRelatedToHAOverFlow65.

@Test
public void testBridgeAttributesRelatedToHAOverFlow65() throws Exception {
    CacheCreation cache = new CacheCreation();
    cache.setMessageSyncInterval(3445);
    CacheServer bs = cache.addCacheServer();
    ClientSubscriptionConfig csc = bs.getClientSubscriptionConfig();
    csc.setEvictionPolicy("entry");
    cache.getLogger().config("EvictionPolicy : " + csc.getEvictionPolicy());
    csc.setCapacity(501);
    cache.getLogger().config("EvictionCapacity : " + csc.getCapacity());
    File overflowDirectory = new File("overFlow");
    overflowDirectory.mkdirs();
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    File[] dirs1 = new File[] { overflowDirectory };
    DiskStore ds1 = dsf.setDiskDirs(dirs1).create(getUniqueName());
    csc.setDiskStoreName(getUniqueName());
    try {
        csc.setOverflowDirectory("overFlow");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_Deprecated_API_0_Cannot_Mix_With_DiskStore_1.toLocalizedString("setOverflowDirectory", getUniqueName())));
    }
    cache.getLogger().config("Eviction disk store : " + csc.getDiskStoreName());
    bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setDataPolicy(DataPolicy.NORMAL);
    cache.createVMRegion("rootNORMAL", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    CacheServer server = (CacheServer) cache.getCacheServers().iterator().next();
    assertNotNull(server);
    ClientSubscriptionConfig chaqf = server.getClientSubscriptionConfig();
    assertEquals("entry", chaqf.getEvictionPolicy());
    assertEquals(501, chaqf.getCapacity());
    DiskStore dsi = cache.findDiskStore(chaqf.getDiskStoreName());
    assertEquals("overFlow", dsi.getDiskDirs()[0].toString());
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

Example 62 with RegionAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.

the class CacheXml66DUnitTest method testEnableAsyncConflationAttribute.

/**
   * Test EnableAsyncConflation region attribute
   * 
   * @since GemFire 4.2
   */
@Test
public void testEnableAsyncConflationAttribute() throws Exception {
    CacheCreation cache = new CacheCreation();
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setEnableAsyncConflation(true);
    cache.createRegion("root", attrs);
    testXml(cache);
    assertEquals(true, cache.getRegion("root").getAttributes().getEnableAsyncConflation());
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Test(org.junit.Test)

Example 63 with RegionAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.

the class CacheXml66DUnitTest method testNoConnectionPools.

@Test
public void testNoConnectionPools() throws Exception {
    CacheCreation cache = new CacheCreation();
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setPoolName("mypool");
    cache.createVMRegion("rootNORMAL", attrs);
    IgnoredException expectedException = IgnoredException.addIgnoredException(LocalizedStrings.AbstractRegion_THE_CONNECTION_POOL_0_HAS_NOT_BEEN_CREATED.toLocalizedString("mypool"));
    try {
        testXml(cache);
        fail("expected IllegalStateException");
    } catch (IllegalStateException expected) {
    } finally {
        expectedException.remove();
    }
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) IgnoredException(org.apache.geode.test.dunit.IgnoredException) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Test(org.junit.Test)

Example 64 with RegionAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.

the class CacheXml66DUnitTest method testExplicitConnectionPool.

/**
   * test for enabling PRsingleHop feature. Test for enabling multiuser-authentication attribute.
   */
@Test
public void testExplicitConnectionPool() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    PoolFactory f = cache.createPoolFactory();
    f.addServer(ALIAS2, 3777).addServer(ALIAS1, 3888);
    f.setFreeConnectionTimeout(12345).setLoadConditioningInterval(12345).setSocketBufferSize(12345).setThreadLocalConnections(true).setPRSingleHopEnabled(true).setReadTimeout(12345).setMinConnections(12346).setMaxConnections(12347).setRetryAttempts(12348).setIdleTimeout(12349).setPingInterval(12350).setStatisticInterval(12351).setServerGroup("mygroup").setSubscriptionRedundancy(12345).setSubscriptionMessageTrackingTimeout(12345).setSubscriptionAckInterval(333).setMultiuserAuthentication(true);
    f.create("mypool");
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setPoolName("mypool");
    // required for multiuser mode
    attrs.setDataPolicy(DataPolicy.EMPTY);
    cache.createVMRegion("rootNORMAL", attrs);
    IgnoredException.addIgnoredException("Connection refused: connect");
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Region r = c.getRegion("rootNORMAL");
    assertNotNull(r);
    assertEquals("mypool", r.getAttributes().getPoolName());
    Pool cp = PoolManager.find("mypool");
    assertNotNull(cp);
    assertEquals(0, cp.getLocators().size());
    assertEquals(2, cp.getServers().size());
    assertEquals(createINSA(ALIAS2, 3777), cp.getServers().get(0));
    assertEquals(createINSA(ALIAS1, 3888), cp.getServers().get(1));
    assertEquals(12345, cp.getFreeConnectionTimeout());
    assertEquals(12345, cp.getLoadConditioningInterval());
    assertEquals(12345, cp.getSocketBufferSize());
    assertEquals(true, cp.getThreadLocalConnections());
    assertEquals(true, cp.getPRSingleHopEnabled());
    assertEquals(12345, cp.getReadTimeout());
    assertEquals(12346, cp.getMinConnections());
    assertEquals(12347, cp.getMaxConnections());
    assertEquals(12348, cp.getRetryAttempts());
    assertEquals(12349, cp.getIdleTimeout());
    assertEquals(12350, cp.getPingInterval());
    assertEquals(12351, cp.getStatisticInterval());
    assertEquals("mygroup", cp.getServerGroup());
    // TODO: commented this out until queues are implemented
    // assertIndexDetailsEquals(true, cp.getQueueEnabled());
    assertEquals(12345, cp.getSubscriptionRedundancy());
    assertEquals(12345, cp.getSubscriptionMessageTrackingTimeout());
    assertEquals(333, cp.getSubscriptionAckInterval());
    assertEquals(true, cp.getMultiuserAuthentication());
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Pool(org.apache.geode.cache.client.Pool) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

Example 65 with RegionAttributesCreation

use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.

the class CacheXml66DUnitTest method testNestedRegions.

/**
   * Tests nested regions
   */
@Test
public void testNestedRegions() throws Exception {
    CacheCreation cache = new CacheCreation();
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setScope(Scope.DISTRIBUTED_NO_ACK);
    RegionCreation root = (RegionCreation) cache.createRegion("root", attrs);
    {
        attrs = new RegionAttributesCreation(cache);
        attrs.setScope(Scope.DISTRIBUTED_NO_ACK);
        attrs.setMirrorType(MirrorType.KEYS_VALUES);
        attrs.setInitialCapacity(142);
        attrs.setLoadFactor(42.42f);
        attrs.setStatisticsEnabled(false);
        root.createSubregion("one", attrs);
    }
    {
        attrs = new RegionAttributesCreation(cache);
        attrs.setScope(Scope.DISTRIBUTED_ACK);
        attrs.setMirrorType(MirrorType.KEYS);
        attrs.setInitialCapacity(242);
        Region region = root.createSubregion("two", attrs);
        {
            attrs = new RegionAttributesCreation(cache);
            attrs.setScope(Scope.GLOBAL);
            attrs.setLoadFactor(43.43f);
            region.createSubregion("three", attrs);
        }
    }
    testXml(cache);
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) RegionCreation(org.apache.geode.internal.cache.xmlcache.RegionCreation) Test(org.junit.Test)

Aggregations

RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)87 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)86 Test (org.junit.Test)85 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)64 Region (org.apache.geode.cache.Region)37 Cache (org.apache.geode.cache.Cache)35 LocalRegion (org.apache.geode.internal.cache.LocalRegion)32 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)28 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)28 ClientCache (org.apache.geode.cache.client.ClientCache)27 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)17 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)14 File (java.io.File)13 RegionAttributes (org.apache.geode.cache.RegionAttributes)11 RegionCreation (org.apache.geode.internal.cache.xmlcache.RegionCreation)11 DiskWriteAttributesFactory (org.apache.geode.cache.DiskWriteAttributesFactory)10 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)9 CacheServer (org.apache.geode.cache.server.CacheServer)8 AttributesFactory (org.apache.geode.cache.AttributesFactory)7 PartitionAttributes (org.apache.geode.cache.PartitionAttributes)7