/** * 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)); } }
/** * Verify that the command line tool for listing missing disk stores contains the PersistentIDs in * the given set. * * @param expected The members that are expected to be in the results of the * list-missing-disk-stores command line tool. */ private static void verifyMissingDiskStoresCommandLineTool(Set<PersistentID> expected) { // Workaround to bug 42432; when this bug is fixed, remove the following if if (HostHelper.isWindows() && !CliHelperPrms.getUseCli()) { Log.getLogWriter() .info("To avoid bug 42432, not running list-missing-disk-stores command line tool"); return; } String result = PersistenceUtil.runListMissingDiskStores(); // convert result in to List of diskDirs List<String> actualDiskIds = new ArrayList(); String[] tokens = result.split("\n"); if (CliHelperPrms .getUseCli()) { // result from gfsh is different than the old gemfire script output for (String line : tokens) { if (line.indexOf("vm_") >= 0) { String[] lineTokens = line.split("[\\s]+"); // split on white space actualDiskIds.add(lineTokens[0]); // diskId is first token } } } else { for (String line : tokens) { // make resultLines contain only DiskStores Matcher matcher = PersistenceUtil.DISK_STORE_ID.matcher(line); if (matcher.matches()) { actualDiskIds.add(matcher.group(1)); } } } // convert expected into List of diskDirs List<String> expectedDiskDirs = new ArrayList(); for (PersistentID id : expected) { expectedDiskDirs.add(id.getUUID().toString()); } // find disk dirs missing or extra in command line tool results List<String> missing = new ArrayList(expectedDiskDirs); List<String> extra = new ArrayList(actualDiskIds); missing.removeAll(actualDiskIds); extra.removeAll(expectedDiskDirs); if (missing.size() > 0) { throw new TestException( "The following DiskStore IDs were expected in the result of" + " list or show missing-disk-stores command line tool: " + missing + ", result of command line tool is " + result); } if (extra.size() > 0) { throw new TestException( "The following unexpected DiskStore IDs were returned" + " from list or show missing-disk-stores command line tool: " + extra + ", expected " + expected); } Log.getLogWriter().info("list or show missing-disk-stores command returned expected results"); }