Search in sources :

Example 41 with LocalRegion

use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.

the class HAClearDUnitTest method clearRegionFromServer.

// function to perform clear operation from server.
private CacheSerializableRunnable clearRegionFromServer() {
    CacheSerializableRunnable clearFromServer = new CacheSerializableRunnable("clearFromServer") {

        public void run2() {
            LocalRegion region = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
            assertNotNull(region);
            region.clear();
        }
    };
    return clearFromServer;
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Example 42 with LocalRegion

use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.

the class PersistentRecoveryOrderDUnitTest method getRVV.

protected RegionVersionVector getRVV(VM vm) throws IOException, ClassNotFoundException {
    SerializableCallable createData = new SerializableCallable("getRVV") {

        public Object call() throws Exception {
            Cache cache = getCache();
            LocalRegion region = (LocalRegion) cache.getRegion(REGION_NAME);
            RegionVersionVector rvv = region.getVersionVector();
            rvv = rvv.getCloneForTransmission();
            HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
            // Using gemfire serialization because
            // RegionVersionVector is not java serializable
            DataSerializer.writeObject(rvv, hdos);
            return hdos.toByteArray();
        }
    };
    byte[] result = (byte[]) vm.invoke(createData);
    ByteArrayInputStream bais = new ByteArrayInputStream(result);
    return DataSerializer.readObject(new DataInputStream(bais));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) RegionVersionVector(org.apache.geode.internal.cache.versions.RegionVersionVector) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DataInputStream(java.io.DataInputStream) Cache(org.apache.geode.cache.Cache)

Example 43 with LocalRegion

use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.

the class VerifyUpdatesFromNonInterestEndPointDUnitTest method createEntries.

public static void createEntries() {
    try {
        LocalRegion r1 = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
        if (!r1.containsKey("key-1")) {
            r1.create("key-1", "key-1");
        }
        if (!r1.containsKey("key-2")) {
            r1.create("key-2", "key-2");
        }
        assertEquals(r1.getEntry("key-1").getValue(), "key-1");
        assertEquals(r1.getEntry("key-2").getValue(), "key-2");
    } catch (Exception ex) {
        Assert.fail("failed while createEntries()", ex);
    }
}
Also used : LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Example 44 with LocalRegion

use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.

the class CompressionStatsDUnitTest method getTotalDecompressions.

/**
   * Returns the number of decompressions stat for a region.
   * 
   * @param regionName a region.
   */
private long getTotalDecompressions(String regionName) {
    LocalRegion region = (LocalRegion) getCache().getRegion(regionName);
    assertNotNull(region);
    return region.getCachePerfStats().getTotalDecompressions();
}
Also used : LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Example 45 with LocalRegion

use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.

the class CompressionStatsDUnitTest method getTotalCompressionTime.

/**
   * Returns the total compression time stat for a region.
   * 
   * @param regionName a region.
   */
private long getTotalCompressionTime(String regionName) {
    LocalRegion region = (LocalRegion) getCache().getRegion(regionName);
    assertNotNull(region);
    return region.getCachePerfStats().getTotalCompressionTime();
}
Also used : LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Aggregations

LocalRegion (org.apache.geode.internal.cache.LocalRegion)243 Test (org.junit.Test)103 Region (org.apache.geode.cache.Region)70 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)54 IOException (java.io.IOException)50 AttributesFactory (org.apache.geode.cache.AttributesFactory)42 VM (org.apache.geode.test.dunit.VM)39 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)38 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)37 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)34 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)34 Cache (org.apache.geode.cache.Cache)31 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)31 Host (org.apache.geode.test.dunit.Host)31 Iterator (java.util.Iterator)29 QueryService (org.apache.geode.cache.query.QueryService)29 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)27 CancelException (org.apache.geode.CancelException)26 CacheException (org.apache.geode.cache.CacheException)26 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)25