Search in sources :

Example 51 with DiskStoreID

use of org.apache.geode.internal.cache.persistence.DiskStoreID in project geode by apache.

the class GIIDeltaDUnitTest method assignVMsToPandR.

// P should have smaller diskstore ID than R's
protected void assignVMsToPandR(final VM vm0, final VM vm1) {
    DiskStoreID dsid0 = getMemberID(vm0);
    DiskStoreID dsid1 = getMemberID(vm1);
    int compare = dsid0.compareTo(dsid1);
    LogWriterUtils.getLogWriter().info("Before assignVMsToPandR, dsid0 is " + dsid0 + ",dsid1 is " + dsid1 + ",compare=" + compare);
    if (compare > 0) {
        P = vm0;
        R = vm1;
    } else {
        P = vm1;
        R = vm0;
    }
    LogWriterUtils.getLogWriter().info("After assignVMsToPandR, P is " + P.getPid() + "; R is " + R.getPid() + " for region " + REGION_NAME);
}
Also used : DiskStoreID(org.apache.geode.internal.cache.persistence.DiskStoreID)

Example 52 with DiskStoreID

use of org.apache.geode.internal.cache.persistence.DiskStoreID in project geode by apache.

the class ShowMissingDiskStoresFunctionJUnitTest method testExecuteReturnsMissingDiskStores.

@Test
public void testExecuteReturnsMissingDiskStores() throws Throwable {
    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
    List<?> results = null;
    when(cache.getPersistentMemberManager()).thenReturn(memberManager);
    // Fake missing disk-stores
    Set<PersistentMemberID> regions1 = new HashSet<PersistentMemberID>();
    regions1.add(new PersistentMemberID(new DiskStoreID(), InetAddress.getLocalHost(), "/diskStore1", 1L, (short) 1));
    regions1.add(new PersistentMemberID(new DiskStoreID(), InetAddress.getLocalHost(), "/diskStore2", 2L, (short) 2));
    Map<String, Set<PersistentMemberID>> mapMember1 = new HashMap<String, Set<PersistentMemberID>>();
    ;
    mapMember1.put("member1", regions1);
    when(memberManager.getWaitingRegions()).thenReturn(mapMember1);
    smdsFunc.execute(context);
    results = resultSender.getResults();
    assertNotNull(results);
    assertEquals(1, results.size());
    Set<?> detailSet = (Set<?>) results.get(0);
    assertEquals(2, detailSet.toArray().length);
    assertTrue(detailSet.toArray()[0] instanceof PersistentMemberPattern);
    assertTrue(detailSet.toArray()[1] instanceof PersistentMemberPattern);
    // Results are not sorted so verify results in either order
    if (((PersistentMemberPattern) detailSet.toArray()[0]).getDirectory().equals("/diskStore1")) {
        assertEquals("/diskStore2", ((PersistentMemberPattern) detailSet.toArray()[1]).getDirectory());
    } else if (((PersistentMemberPattern) detailSet.toArray()[0]).getDirectory().equals("/diskStore2")) {
        assertEquals("/diskStore1", ((PersistentMemberPattern) detailSet.toArray()[1]).getDirectory());
    } else {
        fail("Incorrect missing colocated region results");
    }
}
Also used : PersistentMemberPattern(org.apache.geode.internal.cache.persistence.PersistentMemberPattern) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) DiskStoreID(org.apache.geode.internal.cache.persistence.DiskStoreID) HashSet(java.util.HashSet) PersistentMemberID(org.apache.geode.internal.cache.persistence.PersistentMemberID) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 53 with DiskStoreID

use of org.apache.geode.internal.cache.persistence.DiskStoreID in project geode by apache.

the class ShowMissingDiskStoresFunctionJUnitTest method testExecuteReturnsMissingStoresAndRegions.

@Test
public void testExecuteReturnsMissingStoresAndRegions() throws Throwable {
    ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
    List<?> results = null;
    when(cache.getPersistentMemberManager()).thenReturn(memberManager);
    // Fake missing disk-stores
    Set<PersistentMemberID> regions1 = new HashSet<PersistentMemberID>();
    regions1.add(new PersistentMemberID(new DiskStoreID(), InetAddress.getLocalHost(), "/diskStore1", 1L, (short) 1));
    regions1.add(new PersistentMemberID(new DiskStoreID(), InetAddress.getLocalHost(), "/diskStore2", 2L, (short) 2));
    Map<String, Set<PersistentMemberID>> mapMember1 = new HashMap<String, Set<PersistentMemberID>>();
    ;
    mapMember1.put("member1", regions1);
    when(memberManager.getWaitingRegions()).thenReturn(mapMember1);
    // Fake missing colocated regions
    Set<PartitionedRegion> prs = new HashSet<PartitionedRegion>();
    prs.add(pr1);
    prs.add(pr2);
    List<String> missing1 = new ArrayList<String>(Arrays.asList("child1", "child2"));
    when(cache.getPartitionedRegions()).thenReturn(prs);
    when(pr1.getMissingColocatedChildren()).thenReturn(missing1);
    when(pr1.getFullPath()).thenReturn("/pr1");
    smdsFunc.execute(context);
    results = resultSender.getResults();
    assertEquals(2, results.size());
    for (Object result : results) {
        Set<?> detailSet = (Set<?>) result;
        if (detailSet.toArray()[0] instanceof PersistentMemberPattern) {
            assertEquals(2, detailSet.toArray().length);
            assertTrue(detailSet.toArray()[1] instanceof PersistentMemberPattern);
            // Results are not sorted so verify results in either order
            if (((PersistentMemberPattern) detailSet.toArray()[0]).getDirectory().equals("/diskStore1")) {
                assertEquals("/diskStore2", ((PersistentMemberPattern) detailSet.toArray()[1]).getDirectory());
            } else if (((PersistentMemberPattern) detailSet.toArray()[0]).getDirectory().equals("/diskStore2")) {
                assertEquals("/diskStore1", ((PersistentMemberPattern) detailSet.toArray()[1]).getDirectory());
            } else {
                fail("Incorrect missing colocated region results");
            }
        } else if (detailSet.toArray()[0] instanceof ColocatedRegionDetails) {
            assertEquals(2, detailSet.toArray().length);
            assertTrue(detailSet.toArray()[1] instanceof ColocatedRegionDetails);
            assertEquals("/pr1", ((ColocatedRegionDetails) detailSet.toArray()[0]).getParent());
            assertEquals("/pr1", ((ColocatedRegionDetails) detailSet.toArray()[1]).getParent());
            // Results are not sorted so verify results in either order
            if (((ColocatedRegionDetails) detailSet.toArray()[0]).getChild().equals("child1")) {
                assertEquals("child2", ((ColocatedRegionDetails) detailSet.toArray()[1]).getChild());
            } else if (((ColocatedRegionDetails) detailSet.toArray()[0]).getChild().equals("child2")) {
                assertEquals("child1", ((ColocatedRegionDetails) detailSet.toArray()[1]).getChild());
            } else {
                fail("Incorrect missing colocated region results");
            }
        } else {
            fail("Unexpected result type: " + detailSet.toArray()[0].getClass());
        }
    }
}
Also used : PersistentMemberPattern(org.apache.geode.internal.cache.persistence.PersistentMemberPattern) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PersistentMemberID(org.apache.geode.internal.cache.persistence.PersistentMemberID) ColocatedRegionDetails(org.apache.geode.internal.cache.partitioned.ColocatedRegionDetails) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) DiskStoreID(org.apache.geode.internal.cache.persistence.DiskStoreID) HashSet(java.util.HashSet) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

DiskStoreID (org.apache.geode.internal.cache.persistence.DiskStoreID)53 Test (org.junit.Test)38 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)26 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)26 RegionVersionVector (org.apache.geode.internal.cache.versions.RegionVersionVector)19 UnitTest (org.apache.geode.test.junit.categories.UnitTest)11 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)10 HashMap (java.util.HashMap)5 Category (org.junit.experimental.categories.Category)4 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 DiskAccessException (org.apache.geode.cache.DiskAccessException)3 PersistentMemberID (org.apache.geode.internal.cache.persistence.PersistentMemberID)3 Int2ObjectMap (it.unimi.dsi.fastutil.ints.Int2ObjectMap)2 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)2 PersistentMemberPattern (org.apache.geode.internal.cache.persistence.PersistentMemberPattern)2