Search in sources :

Example 81 with RegionFactory

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

the class RegionManagementDUnitTest method createLocalRegion_tmp.

private void createLocalRegion_tmp(final VM vm, final String localRegionName) {
    vm.invoke("Create Local region", () -> {
        SystemManagementService service = getSystemManagementService_tmp();
        RegionFactory regionFactory = getCache_tmp().createRegionFactory(RegionShortcut.LOCAL);
        regionFactory.create(localRegionName);
    });
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) SystemManagementService(org.apache.geode.management.internal.SystemManagementService)

Example 82 with RegionFactory

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

the class ManagementTestBase method createPartitionRegion.

/**
   * Creates a partition Region
   */
protected void createPartitionRegion(final VM vm, final String partitionRegionName) {
    vm.invoke("Create Partitioned region", () -> {
        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
        SystemManagementService service = (SystemManagementService) getManagementService();
        RegionFactory rf = cache.createRegionFactory(RegionShortcut.PARTITION_REDUNDANT);
        LogWriterUtils.getLogWriter().info("Creating Par Region");
        rf.create(partitionRegionName);
    });
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) SystemManagementService(org.apache.geode.management.internal.SystemManagementService)

Example 83 with RegionFactory

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

the class ManagementTestBase method createLocalRegion.

/**
   * Creates a Local region
   */
protected void createLocalRegion(final VM vm, final String localRegionName) throws Exception {
    vm.invoke("Create Local region", () -> {
        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
        SystemManagementService service = (SystemManagementService) getManagementService();
        RegionFactory rf = cache.createRegionFactory(RegionShortcut.LOCAL);
        LogWriterUtils.getLogWriter().info("Creating Local Region");
        rf.create(localRegionName);
    });
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) SystemManagementService(org.apache.geode.management.internal.SystemManagementService)

Example 84 with RegionFactory

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

the class RegionManagementDUnitTest method createPartitionRegion_tmp.

private void createPartitionRegion_tmp(final VM vm, final String partitionRegionName) {
    vm.invoke("Create Partitioned region", () -> {
        SystemManagementService service = getSystemManagementService_tmp();
        RegionFactory regionFactory = getCache_tmp().createRegionFactory(RegionShortcut.PARTITION_REDUNDANT);
        regionFactory.create(partitionRegionName);
    });
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) SystemManagementService(org.apache.geode.management.internal.SystemManagementService)

Example 85 with RegionFactory

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

the class DistributionManagerDUnitTest method testKickOutSickMember.

/**
   * Tests that a sick member is kicked out
   */
@Test
public void testKickOutSickMember() throws Exception {
    disconnectAllFromDS();
    IgnoredException.addIgnoredException("10 seconds have elapsed while waiting");
    Host host = Host.getHost(0);
    // VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    // in order to set a small ack-wait-threshold, we have to remove the
    // system property established by the dunit harness
    String oldAckWait = (String) System.getProperties().remove(DistributionConfig.GEMFIRE_PREFIX + ACK_WAIT_THRESHOLD);
    try {
        final Properties props = getDistributedSystemProperties();
        // loner
        props.setProperty(MCAST_PORT, "0");
        props.setProperty(ACK_WAIT_THRESHOLD, "5");
        props.setProperty(ACK_SEVERE_ALERT_THRESHOLD, "5");
        props.setProperty(NAME, "putter");
        getSystem(props);
        Region rgn = (new RegionFactory()).setScope(Scope.DISTRIBUTED_ACK).setDataPolicy(DataPolicy.REPLICATE).create("testRegion");
        basicGetSystem().getLogWriter().info("<ExpectedException action=add>sec have elapsed while waiting for replies</ExpectedException>");
        vm1.invoke(new SerializableRunnable("Connect to distributed system") {

            public void run() {
                props.setProperty(NAME, "sleeper");
                getSystem(props);
                LogWriter log = basicGetSystem().getLogWriter();
                log.info("<ExpectedException action=add>service failure</ExpectedException>");
                log.info("<ExpectedException action=add>org.apache.geode.ForcedDisconnectException</ExpectedException>");
                RegionFactory rf = new RegionFactory();
                Region r = rf.setScope(Scope.DISTRIBUTED_ACK).setDataPolicy(DataPolicy.REPLICATE).addCacheListener(getSleepingListener(true)).create("testRegion");
                myCache = r.getCache();
            }
        });
        // now we have two caches set up, each having an alert listener. Vm1
        // also has a cache listener that will turn off its ability to respond
        // to "are you dead" messages and then sleep
        rgn.put("bomb", "pow!");
        rgn.getCache().close();
        basicGetSystem().getLogWriter().info("<ExpectedException action=remove>sec have elapsed while waiting for replies</ExpectedException>");
        basicGetSystem().disconnect();
        vm1.invoke(new SerializableRunnable("wait for forced disconnect") {

            public void run() {
                // wait a while for the DS to finish disconnecting
                WaitCriterion ev = new WaitCriterion() {

                    public boolean done() {
                        return !basicGetSystem().isConnected();
                    }

                    public String description() {
                        return null;
                    }
                };
                // if this fails it means the sick member wasn't kicked out and something is wrong
                Wait.waitForCriterion(ev, 60 * 1000, 200, true);
                ev = new WaitCriterion() {

                    public boolean done() {
                        return myCache.isClosed();
                    }

                    public String description() {
                        return null;
                    }
                };
                Wait.waitForCriterion(ev, 20 * 1000, 200, false);
                if (!myCache.isClosed()) {
                    if (basicGetSystem().isConnected()) {
                        basicGetSystem().disconnect();
                    }
                    myCache = null;
                    throw new RuntimeException("Test Failed - vm1's cache is not closed");
                }
                if (basicGetSystem().isConnected()) {
                    basicGetSystem().disconnect();
                    throw new RuntimeException("Test Failed - vm1's system should have been disconnected");
                }
                WaitCriterion wc = new WaitCriterion() {

                    public boolean done() {
                        return regionDestroyedInvoked;
                    }

                    public String description() {
                        return "vm1's listener should have received afterRegionDestroyed notification";
                    }
                };
                Wait.waitForCriterion(wc, 30 * 1000, 1000, true);
            }
        });
    } finally {
        if (oldAckWait != null) {
            System.setProperty(DistributionConfig.GEMFIRE_PREFIX + ACK_WAIT_THRESHOLD, oldAckWait);
        }
    }
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) RegionFactory(org.apache.geode.cache.RegionFactory) LogWriter(org.apache.geode.LogWriter) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Region(org.apache.geode.cache.Region) Host(org.apache.geode.test.dunit.Host) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedRestoreSystemProperties(org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

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