/** * Forces recovery by revoking the members the system is waiting for. It is the responsibility of * the caller to know that the correct members are being waited for since this will revoke all * waiting members. * * @param doValidation If true, then validate the missing disk stores (used for serial tests or * tests that are in a silent phase), if false then don't do validation (used for concurrent * tests). */ public static void forceRecovery(boolean doValidation) { AdminDistributedSystem adminDS = AdminHelper.getAdminDistributedSystem(); Set<PersistentID> waitingForMembers; try { waitingForMembers = adminDS.getMissingPersistentMembers(); if (doValidation) { verifyMissingDiskStoresCommandLineTool(waitingForMembers); } for (PersistentID persistId : waitingForMembers) { boolean revokeWithCommandLineTool = TestConfig.tab().getRandGen().nextBoolean(); // workaround for bug 42432; when this bug is fixed remove the following if if (HostHelper.isWindows()) { revokeWithCommandLineTool = false; // force usage of API } if (CliHelperPrms.getUseCli()) { revokeWithCommandLineTool = true; } if (revokeWithCommandLineTool) { // revoke with command line tool PersistenceUtil.runRevokeMissingDiskStore(persistId); } else { Log.getLogWriter().info("Revoking PersistentID " + persistId); adminDS.revokePersistentMember(persistId.getUUID()); } } } catch (AdminException e) { throw new TestException(TestHelper.getStackTrace(e)); } }
/** Performs a backup. */ protected static void performBackup() { long execution = RecoveryBB.getBB().getSharedCounters().read(RecoveryBB.executionNumber); File backupDir = createBackupDir(execution); File baselineDir = (execution > 1 ? getBackupDir(execution - 1) : null); try { BackupStatus status = AdminHelper.getAdminDistributedSystem().backupAllMembers(backupDir, baselineDir); } catch (AdminException e) { throw new TestException(TestHelper.getStackTrace(e)); } }
/** * Verify that the system is waiting for member(s) to come up before recovering. * * @param expectedWaitingForMember This specifies the vmID of the member the system should be * waiting for. * @param membersWaiting This is a List of the members that should be waiting. */ protected static void verifyWaiting( ClientVmInfo expectedWaitingForMember, List<ClientVmInfo> membersWaiting) { AdminDistributedSystem adminDS = AdminHelper.getAdminDistributedSystem(); boolean conditionPreviouslyMet = false; do { try { Set<PersistentID> waitingForMembers = adminDS.getMissingPersistentMembers(); Log.getLogWriter() .info( "System is waiting for " + waitingForMembers.size() + " member(s); " + waitingForMembers + ", test is expecting the system to be waiting for member with vmID " + expectedWaitingForMember.getVmid()); Set vmsWaitingFor = new TreeSet(); for (PersistentID id : waitingForMembers) { String diskDirWaitingFor = id.getDirectory(); String searchStr = "vm_"; int index = diskDirWaitingFor.indexOf(searchStr) + searchStr.length(); int index2 = diskDirWaitingFor.indexOf("_", index); String vmIdStr = diskDirWaitingFor.substring(index, index2); vmsWaitingFor.add(vmIdStr); } if (vmsWaitingFor.size() == 1) { // waiting for correct number of members String singleVmWaitingFor = (String) vmsWaitingFor.iterator().next(); if (singleVmWaitingFor.equals( expectedWaitingForMember .getVmid() .toString())) { // waiting for 1 member only; it is the correct member // now we found what we were waiting for, but to make sure the product sticks with this // over a period of time; we will sleep and check again Log.getLogWriter().info("System is waiting for expected member " + waitingForMembers); if (conditionPreviouslyMet) { // this is the second time the condition has been met verifyMissingDiskStoresCommandLineTool(waitingForMembers); Log.getLogWriter() .info( "Verified that the system is waiting on vm ID " + expectedWaitingForMember.getVmid() + "; system is waiting for vm with ID " + singleVmWaitingFor); return; } else { // this if the first time the correct condition has been met conditionPreviouslyMet = true; Log.getLogWriter() .info( "Sleeping for 180 seconds to make sure the member the system is waiting for does not change"); MasterController.sleepForMs(180000); } } else { Log.getLogWriter() .info( "System is not waiting for the expected member " + expectedWaitingForMember.getVmid()); conditionPreviouslyMet = false; } } else { Log.getLogWriter() .info( "System is not waiting for the expected member " + expectedWaitingForMember.getVmid()); conditionPreviouslyMet = false; } } catch (AdminException e) { throw new TestException(TestHelper.getStackTrace(e)); } MasterController.sleepForMs(2000); } while (true); }