Search in sources :

Example 26 with RegionFactory

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

the class Bug43684DUnitTest method createServerCache.

@SuppressWarnings("rawtypes")
public static Integer createServerCache(Boolean isReplicated, Boolean isPrimaryEmpty) throws Exception {
    disconnectFromDS();
    Properties props = new Properties();
    props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
    props.setProperty(STATISTIC_ARCHIVE_FILE, "server_" + OSProcess.getId() + ".gfs");
    props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
    CacheFactory cf = new CacheFactory(props);
    cache = (GemFireCacheImpl) cf.create();
    RegionFactory rf;
    if (isReplicated) {
        RegionShortcut rs = isPrimaryEmpty ? RegionShortcut.REPLICATE_PROXY : RegionShortcut.REPLICATE;
        rf = cache.createRegionFactory(rs);
    } else {
        RegionShortcut rs = isPrimaryEmpty ? RegionShortcut.PARTITION_PROXY : RegionShortcut.PARTITION;
        rf = cache.createRegionFactory(rs);
        rf.setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(numBuckets).create());
    }
    rf.create(REGION_NAME);
    CacheServerImpl server = (CacheServerImpl) cache.addCacheServer();
    server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
    server.start();
    return server.getPort();
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionFactory(org.apache.geode.cache.RegionFactory) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) RegionShortcut(org.apache.geode.cache.RegionShortcut) ClientRegionShortcut(org.apache.geode.cache.client.ClientRegionShortcut) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 27 with RegionFactory

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

the class InterestRegrListenerDUnitTest method setUpServerVM.

public void setUpServerVM() throws Exception {
    Properties gemFireProps = new Properties();
    createCache(gemFireProps);
    RegionFactory factory = cache.createRegionFactory(RegionShortcut.REPLICATE);
    Region r = factory.create("serverRegion");
    r.put("serverkey", "servervalue");
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) Region(org.apache.geode.cache.Region) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

Example 28 with RegionFactory

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

the class MyGatewayEventSubstitutionFilter method createReplicatedRegionWithSenderAndAsyncEventQueue.

public static void createReplicatedRegionWithSenderAndAsyncEventQueue(String regionName, String senderIds, String asyncChannelId, Boolean offHeap) {
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    try {
        AttributesFactory fact = new AttributesFactory();
        if (senderIds != null) {
            StringTokenizer tokenizer = new StringTokenizer(senderIds, ",");
            while (tokenizer.hasMoreTokens()) {
                String senderId = tokenizer.nextToken();
                fact.addGatewaySenderId(senderId);
            }
        }
        fact.setDataPolicy(DataPolicy.REPLICATE);
        fact.setOffHeap(offHeap);
        fact.setScope(Scope.DISTRIBUTED_ACK);
        RegionFactory regionFactory = cache.createRegionFactory(fact.create());
        regionFactory.addAsyncEventQueueId(asyncChannelId);
        Region r = regionFactory.create(regionName);
        assertNotNull(r);
    } finally {
        exp.remove();
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionFactory(org.apache.geode.cache.RegionFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region)

Example 29 with RegionFactory

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

the class MyGatewayEventSubstitutionFilter method createReplicatedRegionWithAsyncEventQueue.

public static void createReplicatedRegionWithAsyncEventQueue(String regionName, String asyncQueueIds, Boolean offHeap) {
    IgnoredException exp1 = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    try {
        AttributesFactory fact = new AttributesFactory();
        addAsyncEventQueueIds(fact, asyncQueueIds);
        fact.setDataPolicy(DataPolicy.REPLICATE);
        fact.setOffHeap(offHeap);
        RegionFactory regionFactory = cache.createRegionFactory(fact.create());
        Region r = regionFactory.create(regionName);
        assertNotNull(r);
    } finally {
        exp1.remove();
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionFactory(org.apache.geode.cache.RegionFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region)

Example 30 with RegionFactory

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

the class CacheManagementDUnitTest method createNotificationRegion.

private void createNotificationRegion(final String memberId) {
    SystemManagementService service = this.managementTestRule.getSystemManagementService();
    Map<ObjectName, NotificationHubListener> notificationHubListenerMap = service.getNotificationHub().getListenerObjectMap();
    await().until(() -> assertThat(notificationHubListenerMap.size()).isEqualTo(1));
    RegionFactory regionFactory = this.managementTestRule.getCache().createRegionFactory(RegionShortcut.REPLICATE);
    for (int i = 1; i <= 15; i++) {
        regionFactory.create(NOTIFICATION_REGION_NAME + i);
    }
    Region region = this.managementTestRule.getCache().getRegion(ManagementConstants.NOTIFICATION_REGION + "_" + memberId);
    assertThat(region).isEmpty();
}
Also used : NotificationHubListener(org.apache.geode.management.internal.NotificationHub.NotificationHubListener) RegionFactory(org.apache.geode.cache.RegionFactory) Region(org.apache.geode.cache.Region) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) ObjectName(javax.management.ObjectName)

Aggregations

RegionFactory (org.apache.geode.cache.RegionFactory)124 Region (org.apache.geode.cache.Region)63 Cache (org.apache.geode.cache.Cache)57 Test (org.junit.Test)54 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)51 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)44 VM (org.apache.geode.test.dunit.VM)44 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)31 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)31 CacheException (org.apache.geode.cache.CacheException)30 Host (org.apache.geode.test.dunit.Host)28 Properties (java.util.Properties)25 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)22 File (java.io.File)21 DiskStore (org.apache.geode.cache.DiskStore)20 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)20 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)20 AttributesFactory (org.apache.geode.cache.AttributesFactory)18 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)17 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)17