use of org.apache.geode.internal.cache.persistence.PersistentMemberManager in project geode by apache.
the class ShowMissingDiskStoresFunction method execute.
@Override
public void execute(FunctionContext context) {
final Set<PersistentMemberPattern> memberMissingIDs = new HashSet<PersistentMemberPattern>();
Set<ColocatedRegionDetails> missingColocatedRegions = new HashSet<ColocatedRegionDetails>();
if (context == null) {
throw new RuntimeException();
}
try {
final InternalCache cache = getCache();
if (cache != null && !cache.isClosed()) {
final DistributedMember member = cache.getMyId();
// Missing DiskStores
PersistentMemberManager mm = cache.getPersistentMemberManager();
Map<String, Set<PersistentMemberID>> waitingRegions = mm.getWaitingRegions();
for (Set<PersistentMemberID> entry : waitingRegions.values()) {
for (PersistentMemberID id : entry) {
memberMissingIDs.add(new PersistentMemberPattern(id));
}
}
// Missing colocated regions
Set<PartitionedRegion> prs = cache.getPartitionedRegions();
for (PartitionedRegion pr : prs) {
List<String> missingChildRegions = pr.getMissingColocatedChildren();
for (String child : missingChildRegions) {
missingColocatedRegions.add(new ColocatedRegionDetails(member.getHost(), member.getName(), pr.getFullPath(), child));
}
}
}
if (memberMissingIDs.isEmpty() && missingColocatedRegions.isEmpty()) {
context.getResultSender().lastResult(null);
} else {
if (!memberMissingIDs.isEmpty()) {
if (missingColocatedRegions.isEmpty()) {
context.getResultSender().lastResult(memberMissingIDs);
} else {
context.getResultSender().sendResult(memberMissingIDs);
}
}
if (!missingColocatedRegions.isEmpty()) {
context.getResultSender().lastResult(missingColocatedRegions);
}
}
} catch (Exception e) {
context.getResultSender().sendException(e);
}
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberManager in project geode by apache.
the class DiskManagementDUnitTest method testMissingMembers.
/**
* Checks the test case of missing disks and revoking them through MemberMXBean interfaces
*/
@Test
public void testMissingMembers() throws Exception {
VM memberVM1 = this.memberVMs[0];
VM memberVM2 = this.memberVMs[1];
createPersistentRegion(memberVM1);
createPersistentRegion(memberVM2);
putAnEntry(memberVM1);
this.managerVM.invoke("checkForMissingDiskStores", () -> {
ManagementService service = this.managementTestRule.getManagementService();
DistributedSystemMXBean distributedSystemMXBean = service.getDistributedSystemMXBean();
PersistentMemberDetails[] missingDiskStores = distributedSystemMXBean.listMissingDiskStores();
assertThat(missingDiskStores).isNull();
});
closeRegion(memberVM1);
updateTheEntry(memberVM2, "C");
closeRegion(memberVM2);
AsyncInvocation creatingPersistentRegionAsync = createPersistentRegionAsync(memberVM1);
memberVM1.invoke(() -> await().until(() -> {
GemFireCacheImpl cache = (GemFireCacheImpl) this.managementTestRule.getCache();
PersistentMemberManager persistentMemberManager = cache.getPersistentMemberManager();
Map<String, Set<PersistentMemberID>> regions = persistentMemberManager.getWaitingRegions();
return !regions.isEmpty();
}));
assertThat(creatingPersistentRegionAsync.isAlive()).isTrue();
this.managerVM.invoke("revokeMissingDiskStore", () -> {
ManagementService service = this.managementTestRule.getManagementService();
DistributedSystemMXBean bean = service.getDistributedSystemMXBean();
PersistentMemberDetails[] missingDiskStores = bean.listMissingDiskStores();
assertThat(missingDiskStores).isNotNull().hasSize(1);
assertThat(bean.revokeMissingDiskStores(missingDiskStores[0].getDiskStoreId())).isTrue();
});
await(creatingPersistentRegionAsync);
verifyRecoveryStats(memberVM1, true);
// Check to make sure we recovered the old value of the entry.
memberVM1.invoke("check for the entry", () -> {
Cache cache = this.managementTestRule.getCache();
Region region = cache.getRegion(REGION_NAME);
assertThat(region.get("A")).isEqualTo("B");
});
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberManager in project geode by apache.
the class DistributedSystemBridgeJUnitTest method testPrepareErrorAbortsBackup.
@Test
public void testPrepareErrorAbortsBackup() throws Exception {
DM dm = cache.getDistributionManager();
PersistentMemberManager memberManager = mock(PersistentMemberManager.class);
BackupManager backupManager = mock(BackupManager.class);
when(cache.startBackup(any())).thenReturn(backupManager);
when(cache.getPersistentMemberManager()).thenReturn(memberManager);
when(cache.getBackupManager()).thenReturn(backupManager);
when(dm.putOutgoing(isA(PrepareBackupRequest.class))).thenThrow(new RuntimeException("Fail the prepare"));
DistributedSystemBridge bridge = new DistributedSystemBridge(null);
try {
bridge.backupAllMembers("/tmp", null);
fail("Should have failed with an exception");
} catch (RuntimeException expected) {
}
verify(dm).putOutgoing(isA(FinishBackupRequest.class));
verify(backupManager).finishBackup(any(), any(), eq(true));
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberManager in project geode by apache.
the class DistributedSystemBridgeJUnitTest method createCache.
@Before
public void createCache() throws IOException {
cache = Fakes.cache();
PersistentMemberManager memberManager = mock(PersistentMemberManager.class);
backupManager = mock(BackupManager.class);
when(cache.startBackup(any())).thenReturn(backupManager);
when(cache.getPersistentMemberManager()).thenReturn(memberManager);
when(cache.getBackupManager()).thenReturn(backupManager);
DLockService dlock = mock(DLockService.class);
when(dlock.lock(any(), anyLong(), anyLong())).thenReturn(true);
DLockService.addLockServiceForTests(BackupDataStoreHelper.LOCK_SERVICE_NAME, dlock);
GemFireCacheImpl.setInstanceForTests(cache);
}
Aggregations