Search in sources :

Example 1 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class CqQueryDUnitTest method performGC.

private void performGC(VM server, final String regionName) {
    SerializableRunnable task = new CacheSerializableRunnable("perform GC") {

        public void run2() throws CacheException {
            Region subregion = getCache().getRegion("root/" + regionName);
            DistributedTombstoneOperation gc = DistributedTombstoneOperation.gc((DistributedRegion) subregion, new EventID(getCache().getDistributedSystem()));
            gc.distribute();
        }
    };
    server.invoke(task);
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) DistributedTombstoneOperation(org.apache.geode.internal.cache.DistributedTombstoneOperation) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Region(org.apache.geode.cache.Region) EventID(org.apache.geode.internal.cache.EventID)

Example 2 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class CqQueryDUnitTest method createPartitionRegion.

public void createPartitionRegion(final VM server, final String[] regionNames) {
    SerializableRunnable createRegion = new CacheSerializableRunnable("Create Region") {

        public void run2() throws CacheException {
            RegionFactory rf = getCache().createRegionFactory(RegionShortcut.PARTITION);
            for (int i = 0; i < regionNames.length; i++) {
                rf.create(regionNames[i]);
            }
        }
    };
    server.invoke(createRegion);
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) RegionFactory(org.apache.geode.cache.RegionFactory) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable)

Example 3 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class CqQueryDUnitTest method createClient.

/* Create Client */
public void createClient(VM client, final int[] serverPorts, final String serverHost, final String redundancyLevel) {
    SerializableRunnable createQService = new CacheSerializableRunnable("Create Client") {

        public void run2() throws CacheException {
            LogWriterUtils.getLogWriter().info("### Create Client. ###");
            // Initialize CQ Service.
            try {
                getCache().getQueryService();
            } catch (Exception cqe) {
                cqe.printStackTrace();
                fail("Failed to getCQService.");
            }
            AttributesFactory regionFactory = new AttributesFactory();
            regionFactory.setScope(Scope.LOCAL);
            if (redundancyLevel != null) {
                ClientServerTestCase.configureConnectionPool(regionFactory, serverHost, serverPorts, true, Integer.parseInt(redundancyLevel), -1, null);
            } else {
                ClientServerTestCase.configureConnectionPool(regionFactory, serverHost, serverPorts, true, -1, -1, null);
            }
            for (int i = 0; i < regions.length; i++) {
                createRegion(regions[i], regionFactory.createRegionAttributes());
                LogWriterUtils.getLogWriter().info("### Successfully Created Region on Client :" + regions[i]);
            // region1.getAttributesMutator().setCacheListener(new CqListener());
            }
        }
    };
    client.invoke(createQService);
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) CqAttributesFactory(org.apache.geode.cache.query.CqAttributesFactory) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CqExistsException(org.apache.geode.cache.query.CqExistsException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CqClosedException(org.apache.geode.cache.query.CqClosedException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 4 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class CqQueryDUnitTest method crashServer.

public void crashServer(VM server) {
    server.invoke(new SerializableRunnable("Crash CacheServer") {

        public void run() {
            org.apache.geode.cache.client.internal.ConnectionImpl.setTEST_DURABLE_CLIENT_CRASH(true);
            LogWriterUtils.getLogWriter().info("### Crashing CacheServer. ###");
            stopBridgeServer(getCache());
        }
    });
    Wait.pause(2 * 1000);
}
Also used : SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable)

Example 5 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class CqQueryDUnitTest method closeClient.

/* Close Client */
public void closeClient(VM client) {
    SerializableRunnable closeCQService = new CacheSerializableRunnable("Close Client") {

        public void run2() throws CacheException {
            LogWriterUtils.getLogWriter().info("### Close Client. ###");
            try {
                ((DefaultQueryService) getCache().getQueryService()).closeCqService();
            } catch (Exception ex) {
                LogWriterUtils.getLogWriter().info("### Failed to get CqService during ClientClose() ###");
            }
        }
    };
    client.invoke(closeCQService);
    Wait.pause(2 * 1000);
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService) CqExistsException(org.apache.geode.cache.query.CqExistsException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CqClosedException(org.apache.geode.cache.query.CqClosedException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Aggregations

SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)741 VM (org.apache.geode.test.dunit.VM)405 Test (org.junit.Test)403 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)353 Region (org.apache.geode.cache.Region)347 Host (org.apache.geode.test.dunit.Host)344 Cache (org.apache.geode.cache.Cache)274 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)259 CacheException (org.apache.geode.cache.CacheException)207 AttributesFactory (org.apache.geode.cache.AttributesFactory)204 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)198 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)166 LocalRegion (org.apache.geode.internal.cache.LocalRegion)160 IOException (java.io.IOException)145 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)120 Properties (java.util.Properties)66 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)66 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)65 IgnoredException (org.apache.geode.test.dunit.IgnoredException)61 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)53