Author: challngr Date: Mon Mar 25 18:57:05 2013 New Revision: 1460845 URL: http://svn.apache.org/r1460845 Log: UIMA-2772 Add Node object for scheduled resources to RM published state.
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/Scheduler.java uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/IResource.java uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/Resource.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=1460845&r1=1460844&r2=1460845&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 Mon Mar 25 18:57:05 2013 @@ -599,6 +599,7 @@ public class JobManagerConverter } if ( !scheduler.ready() ) { + // JRC dumpOrchestratorState(jobMap); logger.info(methodName, null, "Orchestrator event is discarded because scheduler is not yet ready."); return; } @@ -765,7 +766,7 @@ public class JobManagerConverter shares = j.getAssignedShares(); if ( shares != null ) { for ( Share s : shares.values() ) { - Resource r = new Resource(s.getId(), s.getNodeIdentity(), s.isPurged(), s.getShareOrder()); + Resource r = new Resource(s.getId(), s.getNode(), s.isPurged(), s.getShareOrder()); all_shares.put(s.getId(), r); //logger.debug(methodName, j.getId(), "Assigned:", s.toString()); } @@ -774,7 +775,7 @@ public class JobManagerConverter shares = shrunken.get(j.getId()); if ( shares != null ) { for ( Share s : shares.values() ) { - Resource r = new Resource(s.getId(), s.getNodeIdentity(), s.isPurged(), s.getShareOrder()); + Resource r = new Resource(s.getId(), s.getNode(), s.isPurged(), s.getShareOrder()); shrunken_shares.put(s.getId(), r); //logger.debug(methodName, j.getId(), "Shrunken:", s.toString()); } @@ -783,7 +784,7 @@ public class JobManagerConverter shares = expanded.get(j.getId()); if ( shares != null ) { for ( Share s : shares.values() ) { - Resource r = new Resource(s.getId(), s.getNodeIdentity(), s.isPurged(), s.getShareOrder()); + Resource r = new Resource(s.getId(), s.getNode(), s.isPurged(), s.getShareOrder()); expanded_shares.put(s.getId(), r); //logger.debug(methodName, j.getId(), "Expanded:", s.toString()); } @@ -808,5 +809,59 @@ public class JobManagerConverter } + // JRC +// void dumpOrchestratorState(DuccWorkMap jobmap) +// { +// String methodName = "dumpOrchetratorState"; +// for ( IDuccWork w : jobmap.values() ) { +// String prefix = "?"; +// switch ( w.getDuccType() ) { +// case Job: +// prefix = "J"; +// break; +// case Service: +// prefix = "S"; +// break; +// case Reservation: +// prefix = "R"; +// break; +// } + +// if ( w.isCompleted() ) { +// logger.info(methodName, w.getDuccId(), "Ignoring completed work", prefix, w.getDuccId()); +// } + +// switch ( w.getDuccType() ) { +// case Job: { +// IDuccWorkExecutable de = (IDuccWorkExecutable) w; +// IDuccProcessMap pm = de.getProcessMap(); +// logger.info(methodName, w.getDuccId(), "Received work of type", prefix, w.getDuccType(), "with", pm.size(), "processes."); +// for ( IDuccProcess proc : pm.values() ) { +// String pid = proc.getPID(); +// ProcessState state = proc.getProcessState(); +// logger.info(methodName, w.getDuccId(), "Found process", pid, "in state", state, "is complete:", proc.isComplete()); +// } +// } +// break; +// case Service: { +// IDuccWorkExecutable de = (IDuccWorkExecutable) w; +// IDuccProcessMap pm = de.getProcessMap(); +// logger.info(methodName, w.getDuccId(), "Received work of type", prefix, w.getDuccType(), "with", pm.size(), "processes."); +// } +// break; +// case Reservation: { +// IDuccWorkReservation de = (IDuccWorkReservation) w; +// IDuccReservationMap rm = de.getReservationMap(); +// logger.info(methodName, w.getDuccId(), "Received work of type", prefix, w.getDuccType(), "with", rm.size(), "nodes."); +// } +// break; +// default: +// logger.info(methodName, w.getDuccId(), "Received work of type ?", w.getDuccType()); +// break; +// } + +// logger.info(methodName, null, "Work:", w); +// } +// } } 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=1460845&r1=1460844&r2=1460845&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 Mar 25 18:57:05 2013 @@ -39,6 +39,8 @@ import org.apache.uima.ducc.common.utils import org.apache.uima.ducc.common.utils.id.DuccId; import org.apache.uima.ducc.common.utils.id.DuccIdFactory; +import com.google.gson.Gson; + /** * This process orchestrates scheduling. @@ -888,9 +890,18 @@ public class Scheduler private int total_arrivals = 0; public void nodeArrives(Node node) { - // String methodName = "nodeArrives"; + String methodName = "nodeArrives"; // The first block insures the node is in the scheduler's records as soon as possible + try { + Gson gson = new Gson(); + String gnode = gson.toJson(node); + logger.info(methodName, null, "GSON:", gnode); + } catch (Exception e) { + // TODO Auto-generated catch block + logger.error(methodName, null, e); + } + total_arrivals++; // report these in the main schedule loop synchronized(this) { // the amount of memory available for shares, adjusted with configured overhead Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java?rev=1460845&r1=1460844&r2=1460845&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/Share.java Mon Mar 25 18:57:05 2013 @@ -18,10 +18,11 @@ */ package org.apache.uima.ducc.rm.scheduler; +import org.apache.uima.ducc.common.Node; import org.apache.uima.ducc.common.NodeIdentity; import org.apache.uima.ducc.common.utils.id.DuccId; -import org.apache.uima.ducc.transport.event.common.ITimeWindow; import org.apache.uima.ducc.transport.event.common.IProcessState.ProcessState; +import org.apache.uima.ducc.transport.event.common.ITimeWindow; @@ -156,6 +157,11 @@ public class Share return machine.getNodeIdentity(); } + public Node getNode() + { + return machine.getNode(); + } + /** * The order of the share itself. */ Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/IResource.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/IResource.java?rev=1460845&r1=1460844&r2=1460845&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/IResource.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/IResource.java Mon Mar 25 18:57:05 2013 @@ -20,6 +20,7 @@ package org.apache.uima.ducc.transport.e import java.io.Serializable; +import org.apache.uima.ducc.common.Node; import org.apache.uima.ducc.common.NodeIdentity; import org.apache.uima.ducc.common.utils.id.DuccId; @@ -42,6 +43,11 @@ public interface IResource extends Seria NodeIdentity getNodeId(); // The node where this resource resides, as provided by the Node Agent /** + * Returns the actual node object for the resource. + */ + Node getNode(); + + /** * If true, this share has been purged because its node went AWOL. */ boolean isPurged(); Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/Resource.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/Resource.java?rev=1460845&r1=1460844&r2=1460845&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/Resource.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/rm/Resource.java Mon Mar 25 18:57:05 2013 @@ -18,16 +18,17 @@ */ package org.apache.uima.ducc.transport.event.rm; +import org.apache.uima.ducc.common.Node; import org.apache.uima.ducc.common.NodeIdentity; import org.apache.uima.ducc.common.utils.id.DuccId; public class Resource implements IResource { private static final long serialVersionUID = 1L; - private DuccId duccId; // DuccId of the share, assigned by RM - private NodeIdentity nodeId; // Node id, assigned by Agent - private boolean purged; // Purged, for node failure - private int qShares; // Number of quantum shares this resource occupies + private DuccId duccId; // DuccId of the share, assigned by RM + private Node node; // Node id, assigned by Agent + private boolean purged; // Purged, for node failure + private int qShares; // Number of quantum shares this resource occupies // dissallow @SuppressWarnings("unused") @@ -35,33 +36,34 @@ public class Resource implements IResour { } - public Resource(DuccId duccId, NodeIdentity nodeId, boolean purged, int qShares) + public Resource(DuccId duccId, Node node, boolean purged, int qShares) { this.duccId = duccId; - this.nodeId = nodeId; + this.node = node; this.purged = purged; this.qShares = qShares; } - @Override public DuccId getId() { return duccId; } - @Override public NodeIdentity getNodeId() { - return nodeId; + return node.getNodeIdentity(); + } + + public Node getNode() + { + return node; } - @Override public boolean isPurged() { return purged; } - @Override public int countShares() { return qShares; @@ -69,6 +71,6 @@ public class Resource implements IResour public String toString() { - return nodeId.getName() + "." + duccId.getFriendly() + ( purged ? "[P]" : ""); + return getNodeId().getName() + "." + duccId.getFriendly() + ( purged ? "[P]" : ""); } }