Search in sources :

Example 1 with PartitionAttributesFactory

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

the class PutAllCSDUnitTest method createBridgeServer.

private int createBridgeServer(VM server, final String regionName, final int serverPort, final boolean createPR, final int redundantCopies, final String diskStoreName) {
    return (Integer) server.invoke(new SerializableCallable("Create server") {

        @Override
        @SuppressWarnings("synthetic-access")
        public Object call() throws Exception {
            // Create DS
            Properties config = new Properties();
            config.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
            getSystem(config);
            // Create Region
            AttributesFactory factory = new AttributesFactory();
            Cache cache = getCache();
            // enable concurrency checks (not for disk now - disk doesn't support versions yet)
            if (diskStoreName == null) {
                factory.setConcurrencyChecksEnabled(true);
            }
            // create diskStore if required
            if (diskStoreName != null) {
                DiskStore ds = cache.findDiskStore(diskStoreName);
                if (ds == null) {
                    ds = cache.createDiskStoreFactory().setDiskDirs(getDiskDirs()).create(diskStoreName);
                }
            }
            /*
         * In this test, no cacheLoader should be defined, otherwise, it will create a value for
         * destroyed key factory.setCacheLoader(new CacheServerCacheLoader());
         */
            if (createPR) {
                PartitionAttributesFactory paf = new PartitionAttributesFactory();
                paf.setRedundantCopies(redundantCopies);
                paf.setTotalNumBuckets(TOTAL_BUCKETS);
                factory.setPartitionAttributes(paf.create());
                if (diskStoreName != null) {
                    factory.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
                    factory.setDiskStoreName(diskStoreName);
                } else {
                    factory.setDataPolicy(DataPolicy.PARTITION);
                }
            } else {
                factory.setScope(Scope.DISTRIBUTED_ACK);
                if (diskStoreName != null) {
                    factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
                    factory.setDiskStoreName(diskStoreName);
                } else {
                    factory.setDataPolicy(DataPolicy.REPLICATE);
                }
            }
            createRootRegion(new AttributesFactory().create());
            Region region = createRegion(regionName, factory.create());
            if (createPR) {
                assertTrue(region instanceof PartitionedRegion);
            } else {
                assertTrue(region instanceof DistributedRegion);
            }
            int retPort = startBridgeServer(serverPort);
            LogWriterUtils.getLogWriter().info("Cache Server Started:" + retPort + ":" + serverPort);
            return retPort;
        }
    });
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) CqAttributesFactory(org.apache.geode.cache.query.CqAttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Region(org.apache.geode.cache.Region) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) Cache(org.apache.geode.cache.Cache)

Example 2 with PartitionAttributesFactory

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

the class PRDeltaPropagationDUnitTest method createPR.

public static void createPR(String partitionedRegionName, Integer redundancy, Integer localMaxMemory, Integer totalNumBuckets, Boolean setExpiry, Boolean withCloning, Compressor compressor) {
    PartitionAttributesFactory paf = new PartitionAttributesFactory();
    PartitionAttributes prAttr = paf.setRedundantCopies(redundancy.intValue()).setLocalMaxMemory(localMaxMemory.intValue()).setTotalNumBuckets(totalNumBuckets.intValue()).create();
    AttributesFactory attr = new AttributesFactory();
    attr.setPartitionAttributes(prAttr);
    attr.setDataPolicy(DataPolicy.PARTITION);
    attr.setConcurrencyChecksEnabled(true);
    attr.setCloningEnabled(withCloning);
    if (setExpiry) {
        attr.setStatisticsEnabled(true);
        attr.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.INVALIDATE));
    }
    if (compressor != null) {
        attr.setCompressor(compressor);
    }
    // attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(5));
    assertNotNull(cache);
    deltaPR = cache.createRegion(partitionedRegionName, attr.create());
    assertNotNull(deltaPR);
    LogWriterUtils.getLogWriter().info("Partitioned Region " + partitionedRegionName + " created Successfully :" + deltaPR);
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) CqAttributesFactory(org.apache.geode.cache.query.CqAttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 3 with PartitionAttributesFactory

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

the class QueryMonitorDUnitTest method createPRRegion.

private void createPRRegion() {
    AttributesFactory factory = new AttributesFactory();
    // factory.setDataPolicy(DataPolicy.PARTITION);
    factory.setPartitionAttributes((new PartitionAttributesFactory()).setTotalNumBuckets(8).create());
    createRegion(exampleRegionName, factory.create());
    createRegion(exampleRegionName2, factory.create());
    Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
    exampleRegion.getCache().getLogger().fine("#### CREATING PR REGION....");
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) Region(org.apache.geode.cache.Region)

Example 4 with PartitionAttributesFactory

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

the class PdxQueryCQTestBase method configAndStartBridgeServer.

protected void configAndStartBridgeServer(boolean isPr, boolean isAccessor, boolean asyncIndex, Compressor compressor) {
    AttributesFactory factory = new AttributesFactory();
    if (isPr) {
        PartitionAttributesFactory paf = new PartitionAttributesFactory();
        // factory.setDataPolicy(DataPolicy.PARTITION);
        if (isAccessor) {
            paf.setLocalMaxMemory(0);
        }
        PartitionAttributes prAttr = paf.setTotalNumBuckets(20).setRedundantCopies(0).create();
        factory.setPartitionAttributes(prAttr);
    } else {
        factory.setScope(Scope.DISTRIBUTED_ACK);
        factory.setDataPolicy(DataPolicy.REPLICATE);
    }
    if (asyncIndex) {
        factory.setIndexMaintenanceSynchronous(!asyncIndex);
    }
    if (compressor != null) {
        factory.setCompressor(compressor);
    }
    createRegion(this.regionName, this.rootRegionName, factory.create());
    createRegion(this.regionName2, this.rootRegionName, factory.create());
    try {
        startBridgeServer(0, false);
    } catch (Exception ex) {
        Assert.fail("While starting CacheServer", ex);
    }
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 5 with PartitionAttributesFactory

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

the class PrCqUsingPoolDUnitTest method createServer.

/**
   * Create a bridge server with partitioned region.
   * 
   * @param server VM where to create the bridge server.
   * @param port bridge server port.
   * @param isAccessor if true the under lying partitioned region will not host data on this vm.
   * @param redundantCopies number of redundant copies for the primary bucket.
   */
public void createServer(VM server, final int port, final boolean isAccessor, final int redundantCopies) {
    SerializableRunnable createServer = new CacheSerializableRunnable("Create Cache Server") {

        public void run2() throws CacheException {
            LogWriterUtils.getLogWriter().info("### Create Cache Server. ###");
            // AttributesFactory factory = new AttributesFactory();
            // factory.setScope(Scope.DISTRIBUTED_ACK);
            // factory.setMirrorType(MirrorType.KEYS_VALUES);
            // int maxMem = 0;
            AttributesFactory attr = new AttributesFactory();
            // attr.setValueConstraint(valueConstraint);
            PartitionAttributesFactory paf = new PartitionAttributesFactory();
            if (isAccessor) {
                paf.setLocalMaxMemory(0);
            }
            PartitionAttributes prAttr = paf.setTotalNumBuckets(197).setRedundantCopies(redundantCopies).create();
            attr.setPartitionAttributes(prAttr);
            assertFalse(getSystem().isLoner());
            // 0);
            for (int i = 0; i < regions.length; i++) {
                Region r = createRegion(regions[i], attr.create());
                LogWriterUtils.getLogWriter().info("Server created the region: " + r);
            }
            // pause(2000);
            try {
                startBridgeServer(port, true);
            } catch (Exception ex) {
                Assert.fail("While starting CacheServer", ex);
            }
        // pause(2000);
        }
    };
    server.invoke(createServer);
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) CqAttributesFactory(org.apache.geode.cache.query.CqAttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) Region(org.apache.geode.cache.Region) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Aggregations

PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)340 AttributesFactory (org.apache.geode.cache.AttributesFactory)289 Region (org.apache.geode.cache.Region)173 Test (org.junit.Test)154 Cache (org.apache.geode.cache.Cache)136 PartitionAttributes (org.apache.geode.cache.PartitionAttributes)116 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)112 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)110 VM (org.apache.geode.test.dunit.VM)101 Host (org.apache.geode.test.dunit.Host)99 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)95 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)75 CacheException (org.apache.geode.cache.CacheException)58 LocalRegion (org.apache.geode.internal.cache.LocalRegion)48 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)47 IOException (java.io.IOException)42 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)42 DiskStore (org.apache.geode.cache.DiskStore)41 RegionAttributes (org.apache.geode.cache.RegionAttributes)41 BucketRegion (org.apache.geode.internal.cache.BucketRegion)35