Author: challngr Date: Thu May 8 17:56:57 2014 New Revision: 1593355 URL: http://svn.apache.org/r1593355 Log: UIMA-3811 Fix entry into eviction loop.
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.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/NodepoolScheduler.java Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.java?rev=1593355&r1=1593354&r2=1593355&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/JobManagerConverter.java Thu May 8 17:56:57 2014 @@ -152,7 +152,7 @@ public class JobManagerConverter */ void jobUpdate(Object state, IDuccWork job) { - String methodName = "jobUpate"; + String methodName = "jobUpdate"; IDuccSchedulingInfo si = job.getSchedulingInfo(); DuccId jobid = job.getDuccId(); 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=1593355&r1=1593354&r2=1593355&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 Thu May 8 17:56:57 2014 @@ -102,9 +102,14 @@ class NodePool NodePool(NodePool parent, String id, Map<String, String> nodes, EvictionPolicy ep, int depth, int order) { + String methodName = "NodePool.<init>"; this.parent = parent; this.id = id; this.subpoolNames = nodes; + if ( nodes == null ) { // unlikely, but not illegal + this.subpoolNames = new HashMap<String, String>(); + logger.warn(methodName, null, "Nodepool", id, ": no nodes in node list"); + } this.evictionPolicy = ep; this.depth = depth; this.order = order; @@ -130,6 +135,15 @@ class NodePool return allShares.size(); } + int countOccupiedShares() + { + int count = allShares.size(); + for ( NodePool np : children.values() ) { + count += np.countOccupiedShares(); + } + return count; + } + void removeShare(Share s) { allShares.remove(s); Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/NodepoolScheduler.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/NodepoolScheduler.java?rev=1593355&r1=1593354&r2=1593355&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/NodepoolScheduler.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/NodepoolScheduler.java Thu May 8 17:56:57 2014 @@ -423,7 +423,7 @@ public class NodepoolScheduler int rgiven = tgiven % o; // residual - remainder int twanted = wbo[0] + gbo[0]; // actual wanted: still wanted plus alredy given // if ( twanted <= fragmentationThreshold ) { // if under the defrag limit, round up - if ( rgiven > 0 ) { + if ( (rgiven > 0) && ( given == 0) ) { given = Math.min( ++given, nshares[o] ); // UIMA-3664 } // } // if not under the defrag limit, round down @@ -472,7 +472,7 @@ public class NodepoolScheduler while ( iter.hasNext() ) { IEntity e = iter.next(); if ( e.getWantedByOrder()[0] == 0 ) { - logger.info(methodName, null, descr, e.getName(), "reaped, nothing more wanted:", fmtArray(e.getWantedByOrder())); + // logger.info(methodName, null, descr, e.getName(), "reaped, nothing more wanted:", fmtArray(e.getWantedByOrder())); iter.remove(); } } @@ -492,8 +492,8 @@ public class NodepoolScheduler } } if ( purge ) { - logger.info(methodName, null, descr, e.getName(), "reaped, nothing more usablee:", fmtArray(e.getWantedByOrder()), "usable:", - fmtArray(nshares)); + //logger.info(methodName, null, descr, e.getName(), "reaped, nothing more usablee:", fmtArray(e.getWantedByOrder()), "usable:", + // fmtArray(nshares)); iter.remove(); } } @@ -523,7 +523,7 @@ public class NodepoolScheduler // entity weights, but we're not doing that (assuming all weights are 1). // boolean given = true; - int bonus = 0; + //int bonus = 0; while ( (nshares[1] > 0) && (given)) { given = false; for ( IEntity e : entities ) { @@ -534,7 +534,7 @@ public class NodepoolScheduler int canuse = wbo[o] - gbo[o]; while ( (canuse > 0 ) && (vshares[o] > 0) ) { gbo[o]++; - bonus++; + //bonus++; canuse = wbo[o] - gbo[o]; removeSharesByOrder(vshares, nshares, 1, o); given = true; @@ -543,18 +543,26 @@ public class NodepoolScheduler } } } - - if ( bonus > 0 ) { - logger.debug(methodName, null, descr, "Final after bonus:"); - for ( IEntity e : entities ) { - int[] gbo = e.getGivenByOrder(); // nshares - logger.debug(methodName, null, descr, String.format("%12s %s", e.getName(), fmtArray(gbo))); - } - logger.debug(methodName, null, descr, "vshares", fmtArray(vshares)); - logger.debug(methodName, null, descr, "nshares", fmtArray(nshares)); - } else { - logger.debug(methodName, null, descr, "No bonus to give."); - } + + logger.debug(methodName, null, descr, "Final apportionment:"); + for ( IEntity e : entities ) { + int[] gbo = e.getGivenByOrder(); // nshares + logger.debug(methodName, null, descr, String.format("%12s gbo%s", e.getName(), fmtArray(gbo))); + } + logger.debug(methodName, null, descr, "vshares", fmtArray(vshares)); + logger.debug(methodName, null, descr, "nshares", fmtArray(nshares)); + + // if ( bonus > 0 ) { + // logger.debug(methodName, null, descr, "Final after bonus:"); + // for ( IEntity e : entities ) { + // int[] gbo = e.getGivenByOrder(); // nshares + // logger.debug(methodName, null, descr, String.format("%12s %s", e.getName(), fmtArray(gbo))); + // } + // logger.debug(methodName, null, descr, "vshares", fmtArray(vshares)); + // logger.debug(methodName, null, descr, "nshares", fmtArray(nshares)); + // } else { + // logger.debug(methodName, null, descr, "No bonus to give."); + // } } @@ -1500,18 +1508,18 @@ public class NodepoolScheduler * 1. Evict shares for jobs that originate in each node pool * 2. Evict shares that have spilled into lower-level pools. */ - private static int stop_here_de = 0; + // private static int stop_here_de = 0; protected void doEvictions(NodePool nodepool) { String methodName = "doEvictions"; - logger.info(methodName, null, "--- stop_here_de", stop_here_de); - if ( stop_here_de == 7 ) { - @SuppressWarnings("unused") - int stophere; - stophere=1; - } - stop_here_de++; + // logger.info(methodName, null, "--- stop_here_de", stop_here_de); + // if ( stop_here_de == 7 ) { + // @SuppressWarnings("unused") + // int stophere; + // stophere=1; + // } + // stop_here_de++; for ( NodePool np : nodepool.getChildrenDescending() ) { // recurse down the tree doEvictions(np); // depth-first traversal @@ -1531,6 +1539,11 @@ public class NodepoolScheduler int current = j.countNShares(); // currently allocated, plus pending, less those removed by earlier preemption int needed = (counted - current); int order = j.getShareOrder(); + + // if ( needed < 0 ) { + // int stophere = 1; + // stophere++; + // } logger.info(methodName, j.getId(), String.format("%12s %7d %7d %6d %5d", npn, counted, current, needed, order)); needed = Math.abs(needed); @@ -1542,7 +1555,7 @@ public class NodepoolScheduler } logger.debug(methodName, null, nodepool.getId(), "NeededByOrder before any eviction:", Arrays.toString(neededByOrder)); - if ( (nodepool.countShares() > 0) && (total_needed > 0) ) { + if ( (nodepool.countOccupiedShares() > 0) && (total_needed > 0) ) { nodepool.doEvictionsByMachine(neededByOrder, false); } }