Author: challngr Date: Thu May 29 18:20:06 2014 New Revision: 1598355 URL: http://svn.apache.org/r1598355 Log: UIMA-3824 Misc fixes to RM API.
Modified: uima/sandbox/uima-ducc/trunk/src/main/admin/rm_qload uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmAdminQLoadReply.java uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedMachine.java uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedShare.java uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/stop_sim uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Scheduler.java Modified: uima/sandbox/uima-ducc/trunk/src/main/admin/rm_qload URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/src/main/admin/rm_qload?rev=1598355&r1=1598354&r2=1598355&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/src/main/admin/rm_qload (original) +++ uima/sandbox/uima-ducc/trunk/src/main/admin/rm_qload Thu May 29 18:20:06 2014 @@ -21,6 +21,7 @@ import os import sys +import getopt from ducc_util import DuccUtil @@ -35,20 +36,38 @@ class DuccRmQLoad(DuccUtil): print '' print 'Example:' print ' rm_qload' + sys.exit(1) - def main(self): + def main(self, argv): + format = None + + try: + opts, args = getopt.getopt(argv, 'h?', ['console', 'compact']) + except: + self.usage("Invalid arguments " + ' '.join(argv)) + + for ( o, a ) in opts: + if o in ('--console'): + format = o + if o in ('--compact'): + format = o + elif o in ('-h', '?'): + self.usage(None) + + if ( format == None ): + self.usage("Must specify --console or --compact") DUCC_JVM_OPTS = ' -Dducc.deploy.configuration=' + self.DUCC_HOME + "/resources/ducc.properties " DUCC_JVM_OPTS = DUCC_JVM_OPTS + ' -DDUCC_HOME=' + self.DUCC_HOME DUCC_JVM_OPTS = DUCC_JVM_OPTS + ' -Dducc.head=' + self.ducc_properties.get('ducc.head') - self.spawn(self.java(), DUCC_JVM_OPTS, 'org.apache.uima.ducc.common.main.DuccRmAdmin', '--qload') + self.spawn(self.java(), DUCC_JVM_OPTS, 'org.apache.uima.ducc.common.main.DuccRmAdmin', '--qload', format) return if __name__ == "__main__": - stopper = DuccRmQLoad() - stopper.main() + query = DuccRmQLoad() + query.main(sys.argv[1:]) Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmAdminQLoadReply.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmAdminQLoadReply.java?rev=1598355&r1=1598354&r2=1598355&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmAdminQLoadReply.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmAdminQLoadReply.java Thu May 29 18:20:06 2014 @@ -175,7 +175,32 @@ public class RmAdminQLoadReply return String.format(sb.toString(), vals); } - public String toString() + public String toCompact() + { + StringBuffer sb = new StringBuffer(); + + sb.append("OnlineHosts "); + sb.append(fmtArray(machinesOnline)); + + sb.append("\nFreeHosts "); + sb.append(fmtArray(machinesFree)); + + sb.append("\nFreeShares "); + sb.append(fmtArray(machinesVirtual)); + + sb.append("\nVirtualShares "); + sb.append(fmtArray(getVirtualMachinesFree())); + + sb.append("\nWantedShares "); + sb.append(fmtArray(sharesDemanded)); + + sb.append("\nGivenShares "); + sb.append(fmtArray(sharesAwarded)); + + return sb.toString(); + } + + public String toConsole() { StringBuffer sb = new StringBuffer(); @@ -189,22 +214,22 @@ public class RmAdminQLoadReply sharesAvailable, sharesFree, pendingEvictions, pendingExpansions)); - sb.append("\nOnline Hosts By Order:\n"); + sb.append("\nOnline Hosts:\n"); sb.append(fmtArray(machinesOnline)); - sb.append("\nFree Hosts By Order:\n"); + sb.append("\nFree Hosts:\n"); sb.append(fmtArray(machinesFree)); - sb.append("\nFree Shares By Order:\n"); + sb.append("\nFree Shares:\n"); sb.append(fmtArray(machinesVirtual)); - sb.append("\nFree Virtual Shares By Order:\n"); + sb.append("\nVirtual Shares:\n"); sb.append(fmtArray(getVirtualMachinesFree())); - sb.append("\nWanted Shares By Order:\n"); + sb.append("\nWanted Shares:\n"); sb.append(fmtArray(sharesDemanded)); - sb.append("\nAwarded Shares By Order:\n"); + sb.append("\nGivenS hares:\n"); sb.append(fmtArray(sharesAwarded)); return sb.toString(); } Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedMachine.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedMachine.java?rev=1598355&r1=1598354&r2=1598355&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedMachine.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedMachine.java Thu May 29 18:20:06 2014 @@ -51,8 +51,8 @@ public class RmQueriedMachine public long getMemory() { return memory; } public int getShareOrder() { return order; } - static String fmt_s = "%12s %10s %10s %5s %4s %s"; - String fmt_d = "%12s %10s %10d %5d %4d" ; + static String fmt_s = "%14s %14s %10s %5s %4s %s"; + String fmt_d = "%14s %14s %10d %5d %4d" ; public static String header() { return String.format(fmt_s, "Node", "Nodepool", "Memory", "Order", "Free", "Shares\n"); @@ -73,7 +73,7 @@ public class RmQueriedMachine sb.append(String.format(fmt_d, name, nodepoolId, memory, order, order - used)); String spacer = " "; - String altSpacer = "\n" + String.format(fmt_s, " ", " ", " ", " ", " ", " "); // yes, blank, of exactly the right size + String altSpacer = "\n" + String.format(fmt_s, "", "", "", "", "", ""); // yes, blank, of exactly the right size for ( RmQueriedShare s : shares ) { sb.append(spacer); sb.append(s.toConsole()); @@ -97,14 +97,14 @@ public class RmQueriedMachine sb.append(Integer.toString(order)); if ( shares == null ) { - sb.append(Integer.toString(order)); - sb.append(", None"); + sb.append(" 0, None"); } else { int used = 0; for ( RmQueriedShare s : shares ) { used += s.getShareOrder(); } + sb.append(" "); sb.append(Integer.toString(order - used)); for ( RmQueriedShare s : shares ) { sb.append(","); @@ -116,6 +116,6 @@ public class RmQueriedMachine public String toString() { - return String.format("%10s %10d %3d %3d", name, memory, order, shares == null ? 0 : shares.size()); + return String.format("%14s %12d %3d %3d", name, memory, order, shares == null ? 0 : shares.size()); } } Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedShare.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedShare.java?rev=1598355&r1=1598354&r2=1598355&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedShare.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/admin/event/RmQueriedShare.java Thu May 29 18:20:06 2014 @@ -63,7 +63,7 @@ public class RmQueriedShare public String toCompact() { - return String.format("%d %d %d %d %d %s %s %s", jobId, shareId, order, investmentInit, investmentRt, evicted, purged, fixed, initialized); + return String.format("%d %d %d %d %d %s %s %s %s", jobId, shareId, order, investmentInit, investmentRt, evicted, purged, fixed, initialized); } public String toConsole() Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java?rev=1598355&r1=1598354&r2=1598355&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java Thu May 29 18:20:06 2014 @@ -30,6 +30,7 @@ import org.apache.camel.impl.DefaultCame import org.apache.camel.impl.DefaultClassResolver; import org.apache.uima.ducc.common.admin.event.DuccAdminEvent; import org.apache.uima.ducc.common.admin.event.RmAdminQLoad; +import org.apache.uima.ducc.common.admin.event.RmAdminQLoadReply; import org.apache.uima.ducc.common.admin.event.RmAdminQOccupancy; import org.apache.uima.ducc.common.admin.event.RmAdminQOccupancyReply; import org.apache.uima.ducc.common.admin.event.RmAdminReply; @@ -212,12 +213,12 @@ public class DuccRmAdmin * * @throws Exception */ - public RmAdminReply qload() + public RmAdminQLoadReply qload() throws Exception { RmAdminQLoad ql = new RmAdminQLoad(); - return dispatchAndWaitForReply(ql); + return (RmAdminQLoadReply) dispatchAndWaitForReply(ql); } /** @@ -248,10 +249,18 @@ public class DuccRmAdmin return; } - if ( args[0].equals("--qload")) { - if ( args.length != 1 ) usage("Query load takes no arguments."); - RmAdminReply ret = qload(); - System.out.println(ret.toString()); + if ( args[0].equals("--qload")) { + if ( args.length != 2 ) usage("Query load: specify --console or --compact"); + if ( !args[1].equals("--console") && !args[1].equals("--compact") ) { + usage("Invalid argument: " + args[1] + " - specify --console or --compact"); + } + + RmAdminQLoadReply ret = qload(); + if ( args[1].equals("--console") ) { + System.out.println(ret.toConsole()); + } else { + System.out.println(ret.toCompact()); + } return; } @@ -280,8 +289,8 @@ public class DuccRmAdmin System.out.println("Where verbs are:"); System.out.println(" --varyoff string-delimeted-nodes"); System.out.println(" --varyon string-delimeted-nodes"); - System.out.println(" --qload"); - System.out.println(" --qoccupancy"); + System.out.println(" --qload --console|--compact"); + System.out.println(" --qoccupancy --console|--compact"); System.exit(1); } Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/stop_sim URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/stop_sim?rev=1598355&r1=1598354&r2=1598355&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/stop_sim (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/stop_sim Thu May 29 18:20:06 2014 @@ -140,6 +140,7 @@ class StopSim(DuccUtil): if ( (len(components) + len(instances)) == 0 ): for (inst, data) in pids.items(): self.threadpool.invoke(self.signal_process, inst, data, signal) + time.sleep(.1) if ( signal in ('-KILL', '-INT') ): pids.delete(inst) @@ -147,6 +148,7 @@ class StopSim(DuccUtil): for inst in instances: data = pids.get(inst) self.threadpool.invoke(self.signal_process, inst, pids.get(inst), signal) + time.sleep(.1) if ( signal in ('-KILL', '-INT') ): pids.delete(inst) except: Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Scheduler.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Scheduler.java?rev=1598355&r1=1598354&r2=1598355&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Scheduler.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Scheduler.java Thu May 29 18:20:06 2014 @@ -1046,6 +1046,7 @@ public class Scheduler public synchronized String varyon(String[] nodes) { + String methodName = "varyon"; StringBuffer reply = new StringBuffer(); for (String n : nodes ) { @@ -1059,7 +1060,9 @@ public class Scheduler reply.append(n); reply.append("\n"); } else { - reply.append(np.varyon(n)); + String repl = np.varyon(n); + logger.info(methodName, null, repl); + reply.append(repl); reply.append("\n"); } } @@ -1068,6 +1071,7 @@ public class Scheduler public synchronized String varyoff(String[] nodes) { + String methodName = "varyoff"; StringBuffer reply = new StringBuffer(); for (String n : nodes ) { @@ -1081,7 +1085,9 @@ public class Scheduler reply.append(n); reply.append("\n"); } else { - reply.append(np.varyoff(n)); + String repl = np.varyoff(n); + logger.info(methodName, null, repl); + reply.append(repl); reply.append("\n"); } } @@ -1147,14 +1153,6 @@ public class Scheduler return reply; } - private void collectMachinesForQuery(NodePool np, RmAdminQOccupancyReply ret) - { - Collection<Machine> machs = np.getAllMachines().values(); - for ( Machine m : machs ) { - ret.addMachine(m.queryMachine()); - } - } - public synchronized RmAdminQOccupancyReply queryOccupancy() { RmAdminQOccupancyReply ret = new RmAdminQOccupancyReply(); @@ -1178,11 +1176,9 @@ public class Scheduler // Not a cheap query, by the way. // for ( NodePool np : nodepools ) { - collectMachinesForQuery(np, ret); - - Collection<NodePool> pools = np.getChildren().values(); - for ( NodePool npp : pools ) { - collectMachinesForQuery(npp, ret); + Collection<Machine> machs = np.getAllMachines().values(); + for ( Machine m : machs ) { + ret.addMachine(m.queryMachine()); } }