Search in sources :

Example 61 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class StatsBugDUnitTest method createClientCacheForInvalidates.

/**
   * Initializes the cache client
   * 
   * @param port1 - port for the primary cache-server
   * @param port2 for the secondary cache-server
   * @throws Exception-thrown if any problem occurs in initializing the client
   */
public static void createClientCacheForInvalidates(String host, Integer port1, Integer port2) throws Exception {
    StatsBugDUnitTest test = new StatsBugDUnitTest();
    cache = test.createCache(createProperties1());
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    pool = (PoolImpl) ClientServerTestCase.configureConnectionPool(factory, host, new int[] { port1.intValue(), port2.intValue() }, true, -1, 3, null);
    RegionAttributes attrs = factory.create();
    Region region = cache.createRegion(REGION_NAME, attrs);
    region.registerInterest("ALL_KEYS", false, false);
    LogWriterUtils.getLogWriter().info("Client cache created");
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) Region(org.apache.geode.cache.Region)

Example 62 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class OperationsPropagationDUnitTest method createServerCache.

/**
   * Create the server
   */
public static Integer createServerCache() throws Exception {
    new OperationsPropagationDUnitTest().createCache(new Properties());
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setDataPolicy(DataPolicy.REPLICATE);
    RegionAttributes attrs = factory.create();
    region = cache.createRegion(REGION_NAME, attrs);
    CacheServerImpl server = (CacheServerImpl) cache.addCacheServer();
    assertNotNull(server);
    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    server.setPort(port);
    server.setNotifyBySubscription(true);
    server.start();
    return new Integer(server.getPort());
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

Example 63 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class PutAllDUnitTest method createClientCache2.

/**
   * function to create client cache with HAEventIdPropagationListenerForClient2 as the listener
   **/
public static void createClientCache2(String host, Integer port1) throws Exception {
    int PORT1 = port1.intValue();
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    new PutAllDUnitTest().createCache(props);
    props.setProperty("retryAttempts", "2");
    props.setProperty("endpoints", "ep1=" + host + ":" + PORT1);
    props.setProperty("redundancyLevel", "-1");
    props.setProperty("establishCallbackConnection", "true");
    props.setProperty("LBPolicy", "Sticky");
    props.setProperty("readTimeout", "2000");
    props.setProperty("socketBufferSize", "1000");
    props.setProperty("retryInterval", "250");
    props.setProperty("connectionsPerServer", "2");
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    PoolImpl p = (PoolImpl) ClientServerTestCase.configureConnectionPool(factory, host, PORT1, -1, true, -1, 2, null);
    CacheListener clientListener = new HAEventIdPropagationListenerForClient2();
    factory.setCacheListener(clientListener);
    RegionAttributes attrs = factory.create();
    cache.createRegion(REGION_NAME, attrs);
    Region region = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    assertNotNull(region);
    region.registerInterest("ALL_KEYS", InterestResultPolicy.NONE);
    pool = p;
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) Region(org.apache.geode.cache.Region) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) CacheListener(org.apache.geode.cache.CacheListener)

Example 64 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class PersistentPartitionedRegionOldConfigDUnitTest method getPersistentPRAttributes.

@Override
protected RegionAttributes getPersistentPRAttributes(final int redundancy, final int recoveryDelay, Cache cache, int numBuckets, boolean synchronous) {
    AttributesFactory af = new AttributesFactory();
    PartitionAttributesFactory paf = new PartitionAttributesFactory();
    paf.setRedundantCopies(redundancy);
    paf.setRecoveryDelay(recoveryDelay);
    paf.setTotalNumBuckets(numBuckets);
    af.setPartitionAttributes(paf.create());
    af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
    af.setDiskDirs(getDiskDirs());
    RegionAttributes attr = af.create();
    return attr;
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes)

Example 65 with RegionAttributes

use of org.apache.geode.cache.RegionAttributes in project geode by apache.

the class PersistentPartitionedRegionTestBase method getPersistentPRAttributes.

protected RegionAttributes getPersistentPRAttributes(final int redundancy, final int recoveryDelay, Cache cache, int numBuckets, boolean synchronous) {
    DiskStore ds = cache.findDiskStore("disk");
    if (ds == null) {
        ds = cache.createDiskStoreFactory().setDiskDirs(getDiskDirs()).create("disk");
    }
    AttributesFactory af = new AttributesFactory();
    PartitionAttributesFactory paf = new PartitionAttributesFactory();
    paf.setRedundantCopies(redundancy);
    paf.setRecoveryDelay(recoveryDelay);
    paf.setTotalNumBuckets(numBuckets);
    // Make sure all vms end up with the same local max memory
    paf.setLocalMaxMemory(500);
    af.setPartitionAttributes(paf.create());
    af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
    af.setDiskStoreName("disk");
    af.setDiskSynchronous(synchronous);
    RegionAttributes attr = af.create();
    return attr;
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes)

Aggregations

RegionAttributes (org.apache.geode.cache.RegionAttributes)590 AttributesFactory (org.apache.geode.cache.AttributesFactory)471 Region (org.apache.geode.cache.Region)256 Test (org.junit.Test)251 Properties (java.util.Properties)158 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)128 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)126 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)118 LocalRegion (org.apache.geode.internal.cache.LocalRegion)112 Cache (org.apache.geode.cache.Cache)99 VM (org.apache.geode.test.dunit.VM)93 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)93 Host (org.apache.geode.test.dunit.Host)89 HashSet (java.util.HashSet)80 CacheException (org.apache.geode.cache.CacheException)65 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)62 CacheServer (org.apache.geode.cache.server.CacheServer)60 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)59 ArrayList (java.util.ArrayList)57 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)56