Search in sources :

Example 81 with RegionAttributes

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

the class TestObject20 method createServerCacheOne.

/**
   * This method creates the server cache
   */
public static Integer createServerCacheOne(Integer maxThreads) throws Exception {
    new InstantiatorPropagationDUnitTest().createCache(new Properties());
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setMirrorType(MirrorType.KEYS_VALUES);
    RegionAttributes attrs = factory.create();
    cache.createRegion(REGION_NAME, attrs);
    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    CacheServer server1 = cache.addCacheServer();
    server1.setPort(port);
    server1.setMaxThreads(maxThreads.intValue());
    server1.setNotifyBySubscription(true);
    server1.start();
    return new Integer(port);
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheServer(org.apache.geode.cache.server.CacheServer) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

Example 82 with RegionAttributes

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

the class ParallelQueueRemovalMessageJUnitTest method createBucketRegionQueue.

private void createBucketRegionQueue() {
    // Create InternalRegionArguments
    InternalRegionArguments ira = new InternalRegionArguments();
    ira.setPartitionedRegion(this.queueRegion);
    ira.setPartitionedRegionBucketRedundancy(1);
    BucketAdvisor ba = mock(BucketAdvisor.class);
    ira.setBucketAdvisor(ba);
    InternalRegionArguments pbrIra = new InternalRegionArguments();
    RegionAdvisor ra = mock(RegionAdvisor.class);
    when(ra.getPartitionedRegion()).thenReturn(this.queueRegion);
    pbrIra.setPartitionedRegionAdvisor(ra);
    PartitionAttributes pa = mock(PartitionAttributes.class);
    when(this.queueRegion.getPartitionAttributes()).thenReturn(pa);
    when(this.queueRegion.getBucketName(eq(BUCKET_ID))).thenAnswer(new Answer<String>() {

        @Override
        public String answer(final InvocationOnMock invocation) throws Throwable {
            return PartitionedRegionHelper.getBucketName(queueRegion.getFullPath(), BUCKET_ID);
        }
    });
    when(this.queueRegion.getDataPolicy()).thenReturn(DataPolicy.PARTITION);
    when(pa.getColocatedWith()).thenReturn(null);
    // classes cannot be mocked
    ProxyBucketRegion pbr = new ProxyBucketRegion(BUCKET_ID, this.queueRegion, pbrIra);
    when(ba.getProxyBucketRegion()).thenReturn(pbr);
    // Create RegionAttributes
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setDataPolicy(DataPolicy.REPLICATE);
    factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(100, null, EvictionAction.OVERFLOW_TO_DISK));
    RegionAttributes attributes = factory.create();
    // Create BucketRegionQueue
    BucketRegionQueue realBucketRegionQueue = new BucketRegionQueue(this.queueRegion.getBucketName(BUCKET_ID), attributes, this.rootRegion, this.cache, ira);
    this.bucketRegionQueue = spy(realBucketRegionQueue);
    // (this.queueRegion.getBucketName(BUCKET_ID), attributes, this.rootRegion, this.cache, ira);
    EntryEventImpl entryEvent = EntryEventImpl.create(this.bucketRegionQueue, Operation.DESTROY, mock(EventID.class), "value", null, false, mock(DistributedMember.class));
    doReturn(entryEvent).when(this.bucketRegionQueue).newDestroyEntryEvent(any(), any());
    // when(this.bucketRegionQueue.newDestroyEntryEvent(any(), any())).thenReturn();
    this.bucketRegionQueueHelper = new BucketRegionQueueHelper(this.cache, this.queueRegion, this.bucketRegionQueue);
}
Also used : RegionAdvisor(org.apache.geode.internal.cache.partitioned.RegionAdvisor) RegionAttributes(org.apache.geode.cache.RegionAttributes) EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) InternalRegionArguments(org.apache.geode.internal.cache.InternalRegionArguments) BucketRegionQueueHelper(org.apache.geode.internal.cache.BucketRegionQueueHelper) AttributesFactory(org.apache.geode.cache.AttributesFactory) BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ProxyBucketRegion(org.apache.geode.internal.cache.ProxyBucketRegion) DistributedMember(org.apache.geode.distributed.DistributedMember) EventID(org.apache.geode.internal.cache.EventID) BucketAdvisor(org.apache.geode.internal.cache.BucketAdvisor)

Example 83 with RegionAttributes

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

the class CreateAlterDestroyRegionCommandsDUnitTest method regionAlterGroupTest.

private void regionAlterGroupTest() {
    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, this.alterRegionName);
    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GROUP, "Group1");
    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "5764");
    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    String stringResult = commandResultToString(cmdResult);
    assertEquals(4, countLinesInString(stringResult, false));
    assertEquals(false, stringResult.contains("ERROR"));
    assertTrue(stringContainsLine(stringResult, this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
    assertTrue(stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
    this.alterVm1.invoke(() -> {
        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
        assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
    });
    this.alterVm2.invoke(() -> {
        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
        assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
    });
    commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
    commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
    commandStringBuilder.addOption(CliStrings.ALTER_REGION__GROUP, "Group2");
    commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "6963");
    cmdResult = executeCommand(commandStringBuilder.toString());
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    stringResult = commandResultToString(cmdResult);
    assertEquals(3, countLinesInString(stringResult, false));
    assertEquals(false, stringResult.contains("ERROR"));
    assertFalse(stringContainsLine(stringResult, this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
    assertTrue(stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
    this.alterVm1.invoke(() -> {
        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
        assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
    });
    this.alterVm2.invoke(() -> {
        RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
        assertEquals(6963, attributes.getEvictionAttributes().getMaximum());
    });
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) RegionAttributes(org.apache.geode.cache.RegionAttributes) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult)

Example 84 with RegionAttributes

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

the class GlobalRegionCCEOffHeapDUnitTest method getRegionAttributes.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected RegionAttributes getRegionAttributes(String type) {
    RegionAttributes ra = super.getRegionAttributes(type);
    AttributesFactory factory = new AttributesFactory(ra);
    if (!ra.getDataPolicy().isEmpty()) {
        factory.setOffHeap(true);
    }
    return factory.create();
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes)

Example 85 with RegionAttributes

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

the class DistributedAckRegionCCEOffHeapDUnitTest method getRegionAttributes.

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected RegionAttributes getRegionAttributes(String type) {
    RegionAttributes ra = super.getRegionAttributes(type);
    AttributesFactory factory = new AttributesFactory(ra);
    if (!ra.getDataPolicy().isEmpty()) {
        factory.setOffHeap(true);
    }
    return factory.create();
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes)

Aggregations

RegionAttributes (org.apache.geode.cache.RegionAttributes)590 AttributesFactory (org.apache.geode.cache.AttributesFactory)471 Region (org.apache.geode.cache.Region)256 Test (org.junit.Test)251 Properties (java.util.Properties)158 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)128 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)126 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)118 LocalRegion (org.apache.geode.internal.cache.LocalRegion)112 Cache (org.apache.geode.cache.Cache)99 VM (org.apache.geode.test.dunit.VM)93 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)93 Host (org.apache.geode.test.dunit.Host)89 HashSet (java.util.HashSet)80 CacheException (org.apache.geode.cache.CacheException)65 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)62 CacheServer (org.apache.geode.cache.server.CacheServer)60 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)59 ArrayList (java.util.ArrayList)57 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)56