Author: challngr Date: Mon May 19 15:20:41 2014 New Revision: 1595930 URL: http://svn.apache.org/r1595930 Log: UIMA-3824 Initial query load.
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-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/IRmJob.java uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/NodePool.java uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Scheduler.java uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/User.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=1595930&r1=1595929&r2=1595930&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/src/main/admin/rm_qload (original) +++ uima/sandbox/uima-ducc/trunk/src/main/admin/rm_qload Mon May 19 15:20:41 2014 @@ -43,7 +43,7 @@ class DuccRmQLoad(DuccUtil): 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', '--qnodes') + self.spawn(self.java(), DUCC_JVM_OPTS, 'org.apache.uima.ducc.common.main.DuccRmAdmin', '--qload') return 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=1595930&r1=1595929&r2=1595930&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 Mon May 19 15:20:41 2014 @@ -19,7 +19,7 @@ package org.apache.uima.ducc.common.admin.event; public class RmAdminQLoadReply - extends DuccAdminEvent + extends RmAdminReply { private static final long serialVersionUID = -8101741014979144426L; @@ -30,13 +30,17 @@ public class RmAdminQLoadReply int sharesAvailable; // total shares available for scheduling (busy plus empty) int sharesFree; // total shares unused - int sharesDemanded; // shares that would be used in an infinite-share system - + int[] sharesDemanded; // shares that would be used in an infinite-share system + int[] sharesAwarded; // shares assigned, less pending preemptions, plus pending expansions + int[] machinesOnline; // machines available for scheduling + int[] machinesFree; // machines with no assignments + int[] machinesVirtual; // machines after carving out space int pendingEvictions; // number of evictions started but not confirmed int pendingExpansions; // number of expansions started but not confirmed public RmAdminQLoadReply() { + super(null); } public int getNodesOnline() { @@ -104,26 +108,104 @@ public class RmAdminQLoadReply this.pendingExpansions = pending_expansions; } - public int getSharesDemanded() { + public int[] getSharesDemanded() { return sharesDemanded; } - public void setSharesDemanded(int shares_demanded) { + public void setSharesDemanded(int[] shares_demanded) { this.sharesDemanded = shares_demanded; } + public int[] getSharesAwarded() { + return sharesAwarded; + } + + public void setSharesAwarded(int[] shares_awarded) { + this.sharesAwarded = shares_awarded; + } + + public int[] getMachinesOnline() { + return machinesOnline; + } + + public void setMachinesOnline(int[] machines_online) { + this.machinesOnline = machines_online; + } + + public int[] getMachinesFree() { + return machinesFree; + } + + public void setMachinesFree(int[] machines_free) { + this.machinesFree = machines_free; + } + + public int[] getVirtualMachinesFree() { + int[] vm = machinesVirtual.clone(); + int len = vm.length; + for ( int o = 1; o < len; o++ ) { // counting by share order + //nFreeSharesByOrder[o] = nMachinesByOrder[o] * o; + for ( int p = o+1; p < len; p++ ) { + if ( vm[p] != 0 ) { + vm[o] += (p / o) * vm[p]; + } + } + } + + return vm; + } + + public int[] getMachinesVirtual() { + return this.machinesVirtual; + } + + public void setMachinesVirtual(int[] machines_virtual) { + this.machinesVirtual = machines_virtual; + } + + private String fmtArray(int[] array) + { + Object[] vals = new Object[array.length]; + StringBuffer sb = new StringBuffer(); + + for ( int i = 0; i < array.length; i++ ) { + sb.append("%3s "); + vals[i] = Integer.toString(array[i]); + } + return String.format(sb.toString(), vals); + } + public String toString() { StringBuffer sb = new StringBuffer(); - String hdr = "%10s %9s %12s %9s %16s %10s %14s %16s %17s"; - String fmt = "%10d %9d %12d %9d %16d %10d %14d %16d %17d"; + String hdr = "%10s %9s %12s %9s %16s %10s %16s %17s"; + String fmt = "%10d %9d %12d %9d %16d %10d %16d %17d"; sb.append(String.format(hdr, "TotalNodes", "DeadNOdes", "OfflineNodes", "FreeNodes", - "SharesAvailable", "SharesFree", "SharesDemanded", + "SharesAvailable", "SharesFree", "PendingEvictions", "PendingExpansions")); + sb.append("\n"); sb.append(String.format(fmt, nodesOnline, nodesDead, nodesOffline, nodesFree, - sharesAvailable, sharesFree, sharesDemanded, + sharesAvailable, sharesFree, pendingEvictions, pendingExpansions)); + + sb.append("\nOnline Hosts By Order:\n"); + sb.append(fmtArray(machinesOnline)); + + sb.append("\nFree Hosts By Order:\n"); + sb.append(fmtArray(machinesFree)); + + sb.append("\nFree Shares By Order:\n"); + sb.append(fmtArray(machinesVirtual)); + + sb.append("\nFree Virtual Shares By Order:\n"); + sb.append(fmtArray(getVirtualMachinesFree())); + + sb.append("\nWanted Shares By Order:\n"); + sb.append(fmtArray(sharesDemanded)); + + sb.append("\nAwarded Shares By Order:\n"); + sb.append(fmtArray(sharesAwarded)); return sb.toString(); } Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/IRmJob.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/IRmJob.java?rev=1595930&r1=1595929&r2=1595930&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/IRmJob.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/IRmJob.java Mon May 19 15:20:41 2014 @@ -79,6 +79,11 @@ public interface IRmJob public int countNSharesLost(); /** + * For queries - how many processes do I want in a perfect world? + */ + public int queryDemand(); + + /** * Eviction policies, configurable. */ public int shrinkByOrderByMachine(int shares, int order, boolean force, NodePool np); // shrink by largest machine first, minimize fragmentation Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/NodePool.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/NodePool.java?rev=1595930&r1=1595929&r2=1595930&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/NodePool.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/NodePool.java Mon May 19 15:20:41 2014 @@ -86,7 +86,7 @@ class NodePool //int neededByOrder[]; // for each order, how many N-shares do I want to add? // int shareExpansion[]; - int machineExpansion[]; + Map<Integer, Integer> onlineMachinesByOrder = new HashMap<Integer, Integer>(); // all online machines HashMap<Integer, HashMap<Node, Machine>> virtualMachinesByOrder; static int maxorder = 0; @@ -113,6 +113,7 @@ class NodePool this.evictionPolicy = ep; this.depth = depth; this.order = order; + } NodePool getParent() @@ -222,6 +223,8 @@ class NodePool mlist = allMachines; } + if ( mlist == null ) return 0; + for ( Machine m : mlist.values() ) { if ( m.isFree() ) { cnt++; @@ -621,8 +624,6 @@ class NodePool nPendingByOrder = new int[maxorder + 1]; machinesToPreempt = new int[maxorder + 1]; - // shareExpansion = new int[maxorder + 1]; - machineExpansion = new int[maxorder + 1]; virtualMachinesByOrder = new HashMap<Integer, HashMap<Node, Machine>>(); for ( Integer i : machinesByOrder.keySet() ) { @@ -726,6 +727,30 @@ class NodePool return np; } + private synchronized void incrementOnlineByOrder(int order) + { + if ( ! onlineMachinesByOrder.containsKey(order) ) { + onlineMachinesByOrder.put(order, 1); + } else { + onlineMachinesByOrder.put(order, onlineMachinesByOrder.get(order) + 1); + } + } + + private synchronized void decrementOnlineByOrder(int order) + { + onlineMachinesByOrder.put(order, onlineMachinesByOrder.get(order) - 1); + } + + synchronized void getOnlineByOrder(int[] ret) // for queries + { + for ( int o: onlineMachinesByOrder.keySet() ) { + ret[o] += onlineMachinesByOrder.get(o); + } + for ( NodePool child : children.values() ) { + child.getOnlineByOrder(ret); + } + } + /** * Handle a new node update. */ @@ -762,10 +787,12 @@ class NodePool m.setShareOrder(order); // hardware changes. } + // TODO soon ... can I just combine this with the code directly below: allMachines.put(node, m); machinesByName.put(m.getId(), m); machinesByIp.put(m.getIp(), m); HashMap<Node, Machine> mlist = machinesByOrder.get(order); + incrementOnlineByOrder(order); if ( mlist == null ) { mlist = new HashMap<Node, Machine>(); machinesByOrder.put(order, mlist); @@ -781,6 +808,7 @@ class NodePool allMachines.put(machine.key(), machine); // global list machinesByName.put(machine.getId(), machine); machinesByIp.put(machine.getIp(), machine); + incrementOnlineByOrder(order); machine.setNodepool(this); total_shares += order; @@ -828,6 +856,7 @@ class NodePool } allMachines.remove(m.key()); + decrementOnlineByOrder(order); total_shares -= order; disableMap.put(m.key(), m); @@ -1437,17 +1466,6 @@ class NodePool return expansions; } -// void setShareExpansion(int count, int order) -// { -// shareExpansion[order] += count; -// } - - - void setMachineExpansion(int count, int order) - { - machineExpansion[order] += count; - } - /** * This prints garbage unless you call reset() first. */ Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java?rev=1595930&r1=1595929&r2=1595930&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/RmJob.java Mon May 19 15:20:41 2014 @@ -262,6 +262,12 @@ public class RmJob return machineList; } + public int queryDemand() + { + if ( getSchedulingPolicy() == Policy.FAIR_SHARE ) return getJobCap(); + return countInstances(); + } + /** * There are a fair number of piddling little methods to manage shares. This high granularity is * needed in order to manage bits and pieces of the bookkeeping from different threads and queues 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=1595930&r1=1595929&r2=1595930&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 Mon May 19 15:20:41 2014 @@ -137,7 +137,7 @@ public class Scheduler // 1.0.3 - fix bad check in recursion in NodepoolScheduler.doEvictions final static int rmversion_major = 1; final static int rmversion_minor = 0; - final static int rmversion_ptf = 3; + final static int rmversion_ptf = 4; final static String rmversion_string = null; boolean initialized = false; // we refuse nodeupdates until this is true @@ -1089,18 +1089,16 @@ public class Scheduler public synchronized RmAdminQLoadReply queryLoad() { RmAdminQLoadReply reply = new RmAdminQLoadReply(); - /** - int nodesOnline; // number of schedulable nodes - int nodesDead; // number of nodes marked dead - int nodesOffline; // number of nodes varied off - int nodesFree; // number of nodes with nothing on them - */ + int online = 0; int dead = 0; int offline = 0; int free = 0; int shares_available = 0; int shares_free = 0; + int[] onlineMachines = NodePool.makeArray(); + int[] freeMachines = NodePool.makeArray(); + int[] virtualMachines = NodePool.makeArray(); for ( NodePool np : nodepools ) { online += np.countMachines(); @@ -1110,7 +1108,26 @@ public class Scheduler shares_available += np.countTotalShares(); shares_free += np.countQShares(); + np.getOnlineByOrder(onlineMachines); + + for ( int i = 1; i < freeMachines.length; i++ ) { + freeMachines[i] += np.countFreeMachines(i, true); + } + + int[] t = np.cloneVMachinesByOrder(); + for ( int i = 1; i < virtualMachines.length; i++ ) { + virtualMachines[i] += t[i]; + } + } + + int[] demanded = NodePool.makeArray(); + int[] awarded = NodePool.makeArray(); + for ( IRmJob j : allJobs.values() ) { + int o = j.getShareOrder(); + demanded[o] += j.queryDemand(); + awarded[o] += j.countNShares(); } + reply.setNodesOnline(online); reply.setNodesDead(dead); reply.setNodesOffline(offline); @@ -1119,6 +1136,11 @@ public class Scheduler reply.setSharesFree(shares_free); reply.setPendingExpansions(pending_expansions); reply.setPendingEvictions(pending_evictions); + reply.setSharesDemanded(demanded); + reply.setSharesAwarded(awarded); + reply.setMachinesOnline(onlineMachines); + reply.setMachinesFree(freeMachines); + reply.setMachinesVirtual(virtualMachines); return reply; } Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/User.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/User.java?rev=1595930&r1=1595929&r2=1595930&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/User.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/User.java Mon May 19 15:20:41 2014 @@ -33,7 +33,7 @@ public class User private int pure_fair_share; // uncapped un-bonused counts private int share_wealth; // defrag, how many relevent Q shares do i really have? private int[] given_by_order = null; - private int[] wanted_by_order = null; + private int[] wanted_by_order = null; // transient and not immutable, can't use for queries private int totalWantedByOrder = 0; // transient, calculated for each schedule private static Comparator<IEntity> apportionmentSorter = new ApportionmentSorterCl();