/** * 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; }