use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class DistributedCacheOperationTest method shouldBeMockable.
@Test
public void shouldBeMockable() throws Exception {
DistributedCacheOperation mockDistributedCacheOperation = mock(DistributedCacheOperation.class);
CacheOperationMessage mockCacheOperationMessage = mock(CacheOperationMessage.class);
Map<InternalDistributedMember, PersistentMemberID> persistentIds = new HashMap<>();
when(mockDistributedCacheOperation.supportsDirectAck()).thenReturn(false);
mockDistributedCacheOperation.waitForAckIfNeeded(mockCacheOperationMessage, persistentIds);
verify(mockDistributedCacheOperation, times(1)).waitForAckIfNeeded(mockCacheOperationMessage, persistentIds);
assertThat(mockDistributedCacheOperation.supportsDirectAck()).isFalse();
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class PartitionedRegionLoadModelJUnitTest method testRedundancySatisficationWithOfflineMembers.
/**
* Test to make sure than redundancy satisfaction ignores offline members
*/
@Test
public void testRedundancySatisficationWithOfflineMembers() throws Exception {
PartitionedRegionLoadModel model = new PartitionedRegionLoadModel(bucketOperator, 1, 5, getAddressComparor(false), Collections.<InternalDistributedMember>emptySet(), null);
InternalDistributedMember member1 = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 1);
InternalDistributedMember member2 = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 2);
PartitionMemberInfoImpl details1 = buildDetails(member1, 200, 200, new long[] { 30, 0, 28, 30, 23 }, new long[] { 1, 0, 1, 1, 1 });
PartitionMemberInfoImpl details2 = buildDetails(member2, 200, 200, new long[] { 0, 23, 0, 0, 0 }, new long[] { 0, 1, 0, 0, 0 });
// Two buckets have an offline members
Set<PersistentMemberID> o = Collections.singleton(new PersistentMemberID());
Set<PersistentMemberID> x = Collections.emptySet();
final OfflineMemberDetailsImpl offlineDetails = new OfflineMemberDetailsImpl(new Set[] { x, x, o, o, x });
model.addRegion("primary", Arrays.asList(details1, details2), offlineDetails, true);
assertEquals(3, doMoves(new CompositeDirector(true, true, false, false), model));
List<Create> expectedCreates = new ArrayList<Create>();
expectedCreates.add(new Create(member2, 0));
expectedCreates.add(new Create(member1, 1));
expectedCreates.add(new Create(member2, 4));
assertEquals(expectedCreates, bucketOperator.creates);
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class PartitionedRegionLoadModelJUnitTest method testRebalancingWithOfflineMembers.
@Test
public void testRebalancingWithOfflineMembers() throws Exception {
PartitionedRegionLoadModel model = new PartitionedRegionLoadModel(bucketOperator, 1, 6, getAddressComparor(false), Collections.<InternalDistributedMember>emptySet(), null);
InternalDistributedMember member1 = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 1);
InternalDistributedMember member2 = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 2);
PartitionMemberInfoImpl details1 = buildDetails(member1, 480, 480, new long[] { 1, 1, 1, 1, 1, 1 }, new long[] { 1, 1, 1, 1, 1, 1 });
PartitionMemberInfoImpl details2 = buildDetails(member2, 480, 480, new long[] { 0, 0, 0, 0, 0, 0 }, new long[] { 0, 0, 0, 0, 0, 0 });
// Each bucket has an offline member
Set<PersistentMemberID> o = Collections.singleton(new PersistentMemberID());
Set<PersistentMemberID> x = Collections.emptySet();
final OfflineMemberDetailsImpl offlineDetails = new OfflineMemberDetailsImpl(new Set[] { o, o, o, o, o, o });
model.addRegion("primary", Arrays.asList(details1, details2), offlineDetails, true);
assertEquals(3, doMoves(new CompositeDirector(true, true, true, true), model));
List<Move> expectedMoves = new ArrayList<Move>();
expectedMoves.add(new Move(member1, member2));
expectedMoves.add(new Move(member1, member2));
expectedMoves.add(new Move(member1, member2));
assertEquals(expectedMoves, bucketOperator.bucketMoves);
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class OfflineMembersDetailsJUnitTest method testSerialization.
@Test
public void testSerialization() throws Exception {
Set<PersistentMemberID>[] offlineMembers = new Set[5];
for (int i = 0; i < offlineMembers.length; i++) {
offlineMembers[i] = new HashSet<PersistentMemberID>();
offlineMembers[i].add(new PersistentMemberID(DiskStoreID.random(), InetAddress.getLocalHost(), "a", System.currentTimeMillis(), (short) 0));
}
OfflineMemberDetailsImpl details = new OfflineMemberDetailsImpl(offlineMembers);
ByteArrayOutputStream boas = new ByteArrayOutputStream();
DataOutput out = new DataOutputStream(boas);
details.toData(out);
OfflineMemberDetailsImpl details2 = new OfflineMemberDetailsImpl();
details2.fromData(new DataInputStream(new ByteArrayInputStream(boas.toByteArray())));
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class DiskIFJUnitTest method testEmptyIF.
@Test
public void testEmptyIF() throws Exception {
diskProps.setPersistBackup(true);
diskProps.setRegionName("testEmptyIF");
LocalRegion lr = (LocalRegion) DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
DiskRegion dr = lr.getDiskRegion();
assertEquals(null, dr.getMyInitializingID());
PersistentMemberID myId = dr.getMyPersistentID();
assertNotNull(myId);
assertTrue(dr.getOnlineMembers().isEmpty());
assertTrue(dr.getOfflineMembers().isEmpty());
assertTrue(dr.getOfflineAndEqualMembers().isEmpty());
// do recovery
close(lr);
lr = (LocalRegion) DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
dr = lr.getDiskRegion();
assertEquals(null, dr.getMyInitializingID());
assertEquals(myId, dr.getMyPersistentID());
assertTrue(dr.getOnlineMembers().isEmpty());
assertTrue(dr.getOfflineMembers().isEmpty());
assertTrue(dr.getOfflineAndEqualMembers().isEmpty());
dr.forceIFCompaction();
assertEquals(null, dr.getMyInitializingID());
assertEquals(myId, dr.getMyPersistentID());
assertTrue(dr.getOnlineMembers().isEmpty());
assertTrue(dr.getOfflineMembers().isEmpty());
assertTrue(dr.getOfflineAndEqualMembers().isEmpty());
// do recovery
close(lr);
lr = (LocalRegion) DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
dr = lr.getDiskRegion();
assertEquals(null, dr.getMyInitializingID());
assertEquals(myId, dr.getMyPersistentID());
assertTrue(dr.getOnlineMembers().isEmpty());
assertTrue(dr.getOfflineMembers().isEmpty());
assertTrue(dr.getOfflineAndEqualMembers().isEmpty());
}
Aggregations