/** * Return a List of all other vms except for one along with a parallel stop mode list, and also * return the one vm not in the list. * * @return [0] (List<ClientVmInfo>)A List of ClientVmInfo instances; this includes all vms except * the current vm and except for one other vm. [1] (List<String>) A parallel List to [0] * containing stop modes. [2] (ClientVMInfo) The ClientVmInfo instance of the one vm excluded * from [0] (other than this vm) [3] (String) The stop mode for [2] [4] (List<ClientVmInfo>) A * List of ClientVmInfo instances for all vms except this one. [5] (List<String>) A parallel * List to [4] of stop modes. */ public static Object[] getOtherVMsDivided(String[] excludedClientNames) { Vector<Integer> otherVmIDs = ClientVmMgr.getOtherClientVmids(); List<ClientVmInfo> allOtherVMs = new ArrayList(); List<String> stopModeList = new ArrayList(); for (int i = 0; i < otherVmIDs.size(); i++) { ClientVmInfo info = new ClientVmInfo(otherVmIDs.get(i)); ClientVmInfo infoFromBB = (ClientVmInfo) StopStartBB.getBB().getSharedMap().get(VmInfoKey + otherVmIDs.get(i)); if (infoFromBB != null) { info = infoFromBB; } String clientName = info.getClientName(); if (clientName == null) { allOtherVMs.add(info); stopModeList.add(TestConfig.tab().stringAt(StopStartPrms.stopModes)); } else { boolean inExcludedNames = false; for (String excludeName : excludedClientNames) { if (clientName.indexOf(excludeName) >= 0) inExcludedNames = true; break; } if (!inExcludedNames) { allOtherVMs.add(info); stopModeList.add(TestConfig.tab().stringAt(StopStartPrms.stopModes)); } } } List<ClientVmInfo> allOtherVMsExceptOne = allOtherVMs.subList(0, allOtherVMs.size() - 1); List<String> stopModesExceptOne = stopModeList.subList(0, stopModeList.size() - 1); ClientVmInfo remainingVM = allOtherVMs.get(allOtherVMs.size() - 1); String remainingStopMode = stopModeList.get(stopModeList.size() - 1); return new Object[] { allOtherVMsExceptOne, stopModesExceptOne, remainingVM, remainingStopMode, allOtherVMs, stopModeList }; }
/** * Return a List of all other vms except for one along with a parallel stop mode list, and also * return the one vm not in the list. * * @return [0] (List<ClientVmInfo>)A List of ClientVmInfo instances; this includes all vms except * the current vm and except for one other vm. [1] (List<String>) A parallel List to [0] * containing stop modes. [2] (ClientVMInfo) The ClientVmInfo instance of the one vm excluded * from [0] (other than this vm) [3] (String) The stop mode for [2] [4] (List<ClientVmInfo>) A * List of ClientVmInfo instances for all vms except this one. [5] (List<String>) A parallel * List to [4] of stop modes. */ public static Object[] getOtherVMsDivided() { Vector<Integer> otherVmIDs = ClientVmMgr.getOtherClientVmids(); List<ClientVmInfo> allOtherVMs = new ArrayList(); List<String> stopModeList = new ArrayList(); for (int i = 0; i < otherVmIDs.size(); i++) { ClientVmInfo info = new ClientVmInfo(otherVmIDs.get(i)); allOtherVMs.add(info); stopModeList.add(TestConfig.tab().stringAt(StopStartPrms.stopModes)); } List<ClientVmInfo> allOtherVMsExceptOne = allOtherVMs.subList(0, allOtherVMs.size() - 1); List<String> stopModesExceptOne = stopModeList.subList(0, stopModeList.size() - 1); ClientVmInfo remainingVM = allOtherVMs.get(allOtherVMs.size() - 1); String remainingStopMode = stopModeList.get(stopModeList.size() - 1); return new Object[] { allOtherVMsExceptOne, stopModesExceptOne, remainingVM, remainingStopMode, allOtherVMs, stopModeList }; }
/** * Invokes AdminDistributedSystem.shutDownAllMembers() which disconnects all members but leaves * the vms up (because hydra threads remain) including the possibility of this vm being * disconnected, then this actually stops those vms (except this vm if it was targeted in the * shutDownAllMembers...this vm will remain up but disconnect). Stopped vms are stopped with * ON_DEMAND restart. This returns when the vms disconnected by shutDownAllMembers() (other than * this one) are all stopped . * * @param adminDS The admin distributed system instance to use to call shutdownAllMembers. * @param stopModes The stop modes to choose from. * @return An Array [0] List of {@link ClientVmInfo} instances describing the VMs that were * stopped. [1] Set, the return from shutdownAllMembers() * @throws AdminException if the shutDownAllMembers call throws this exception. */ public static Object[] shutDownAllMembers( AdminDistributedSystem adminDS, List<String> stopModes) { if (adminDS == null) { throw new HydraRuntimeException("AdminDistributedSystem cannot be null"); } // Invoke shutDownAllMembers Log.getLogWriter().info("AdminDS " + adminDS + " is shutting down all members..."); Set<DistributedMember> memberSet; try { long startTime = System.currentTimeMillis(); memberSet = adminDS.shutDownAllMembers(); long duration = System.currentTimeMillis() - startTime; Log.getLogWriter() .info( "AdminDS " + adminDS + " shut down (disconnected) the following members " + "(vms remain up): " + memberSet + "; shutDownAll duration " + duration + "ms"); } catch (AdminException e1) { throw new TestException(TestHelper.getStackTrace(e1)); } // Now actually stop the vms. // First get the ClientVmInfos for the members that shutDownAllMembers // disconnected. List<ClientVmInfo> allClientInfos = new ArrayList(); // all members that were shutdown List<ClientVmInfo> allOtherClientInfos = new ArrayList(); // all members that were shutdown except this member ClientVmInfo thisClientInfo = null; // this member, or will remain null if this member was not shutdown List<String> stopModesToUse = new ArrayList(); for (DistributedMember aMember : memberSet) { Integer vmId = null; try { vmId = new Integer(RemoteTestModule.Master.getVmid(aMember.getHost(), aMember.getProcessId())); } catch (java.rmi.RemoteException e) { throw new HydraRuntimeException("Unable to get vmID for " + aMember + ": " + e); } ClientVmInfo infoFromBB = (ClientVmInfo) StopStartBB.getBB().getSharedMap().get("StopStartVMInfo_for_vmid_" + vmId); String clientName = null; if (infoFromBB != null) { clientName = infoFromBB.getClientName(); } ClientVmInfo info = new ClientVmInfo(vmId, clientName, null); allClientInfos.add(info); if (vmId == RemoteTestModule.getMyVmid()) { // shutdownAll disconnected this vm thisClientInfo = info; } else { // aMember is not the current vm allOtherClientInfos.add(info); } stopModesToUse.add( stopModes.get(TestConfig.tab().getRandGen().nextInt(0, stopModes.size() - 1))); } // now actually stop the vms; if this vm is included, do it last Object[] returnArr = new Object[2]; if (thisClientInfo == null) { // shutDownAllMembers did not disconnect this vm // we can just stop all of them now and this vm lives on StopStartVMs.stopVMs(allClientInfos, stopModesToUse); // restart is ON_DEMAND returnArr[0] = allClientInfos; } else { // this vm was disconnected by shutDownAllMembers // first shutdown all other members except this one StopStartVMs.stopVMs(allOtherClientInfos, stopModesToUse.subList(0, stopModesToUse.size())); returnArr[0] = allOtherClientInfos; } returnArr[1] = memberSet; return returnArr; }