Search in sources :

Example 1 with PartitionAttributes

use of org.apache.geode.cache.PartitionAttributes 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 2 with PartitionAttributes

use of org.apache.geode.cache.PartitionAttributes 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 3 with PartitionAttributes

use of org.apache.geode.cache.PartitionAttributes 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)

Example 4 with PartitionAttributes

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

the class PartitionedRegionCqQueryDUnitTest 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 attr = new AttributesFactory();
            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);
            }
            try {
                startBridgeServer(port, true);
            } catch (Exception ex) {
                Assert.fail("While starting CacheServer", ex);
            }
        }
    };
    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) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 5 with PartitionAttributes

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

the class LuceneIndexForPartitionedRegion method createLuceneListenersAndFileChunkRegions.

protected void createLuceneListenersAndFileChunkRegions(AbstractPartitionedRepositoryManager partitionedRepositoryManager) {
    partitionedRepositoryManager.setUserRegionForRepositoryManager();
    RegionShortcut regionShortCut;
    final boolean withPersistence = withPersistence();
    RegionAttributes regionAttributes = dataRegion.getAttributes();
    final boolean withStorage = regionAttributes.getPartitionAttributes().getLocalMaxMemory() > 0;
    // 4) Offheap to Offheap
    if (!withStorage) {
        regionShortCut = RegionShortcut.PARTITION_PROXY;
    } else if (withPersistence) {
        // TODO: add PartitionedRegionAttributes instead
        regionShortCut = RegionShortcut.PARTITION_PERSISTENT;
    } else {
        regionShortCut = RegionShortcut.PARTITION;
    }
    // create PR fileAndChunkRegion, but not to create its buckets for now
    final String fileRegionName = createFileRegionName();
    PartitionAttributes partitionAttributes = dataRegion.getPartitionAttributes();
    DM dm = this.cache.getInternalDistributedSystem().getDistributionManager();
    LuceneBucketListener lucenePrimaryBucketListener = new LuceneBucketListener(partitionedRepositoryManager, dm);
    if (!fileRegionExists(fileRegionName)) {
        fileAndChunkRegion = createFileRegion(regionShortCut, fileRegionName, partitionAttributes, regionAttributes, lucenePrimaryBucketListener);
    }
    fileSystemStats.setBytesSupplier(() -> getFileAndChunkRegion().getPrStats().getDataStoreBytesInUse());
}
Also used : RegionAttributes(org.apache.geode.cache.RegionAttributes) RegionShortcut(org.apache.geode.cache.RegionShortcut) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) DM(org.apache.geode.distributed.internal.DM)

Aggregations

PartitionAttributes (org.apache.geode.cache.PartitionAttributes)129 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)117 AttributesFactory (org.apache.geode.cache.AttributesFactory)107 Region (org.apache.geode.cache.Region)82 Test (org.junit.Test)67 Cache (org.apache.geode.cache.Cache)66 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)61 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)49 Host (org.apache.geode.test.dunit.Host)48 VM (org.apache.geode.test.dunit.VM)48 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)47 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)38 RegionAttributes (org.apache.geode.cache.RegionAttributes)28 CacheException (org.apache.geode.cache.CacheException)26 LocalRegion (org.apache.geode.internal.cache.LocalRegion)26 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)21 BucketRegion (org.apache.geode.internal.cache.BucketRegion)19 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)18 RebalanceResults (org.apache.geode.cache.control.RebalanceResults)16 HashSet (java.util.HashSet)15