You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2015/10/28 21:16:43 UTC
svn commit: r1711115 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src:
main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/
test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/
Author: degenaro
Date: Wed Oct 28 20:16:43 2015
New Revision: 1711115
URL: http://svn.apache.org/viewvc?rev=1711115&view=rev
Log:
UIMA-2869 DUCC Orchestrator (OR) prematurely returns JD Reservations
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdHostProperties.java
uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java
uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java
uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdHostProperties.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdHostProperties.java?rev=1711115&r1=1711114&r2=1711115&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdHostProperties.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdHostProperties.java Wed Oct 28 20:16:43 2015
@@ -38,6 +38,8 @@ public class JdHostProperties {
private String jdShareQuantum = null; // size, in MB
private String slicesReserve = null; // count, trigger for more
+ // Fetch ducc.propertes applicable to JD Reservations.
+
public JdHostProperties() {
update();
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java?rev=1711115&r1=1711114&r2=1711115&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdReservation.java Wed Oct 28 20:16:43 2015
@@ -35,6 +35,10 @@ public class JdReservation extends JdRes
private static DuccLogger logger = new DuccLogger(JdReservation.class);
private static DuccId jobid = null;
+ // Each instance of JdReservation represents an individual DUCC Reservation
+ // that once Assigned is partitioned into smaller equal sized slices, where
+ // each individual slice is used for a single JD.
+
public JdReservation(IDuccWorkReservation dwr, SizeBytes sizeOfReservation, SizeBytes sizeOfSlice) {
initialize(dwr, sizeOfReservation, sizeOfSlice);
}
@@ -54,6 +58,8 @@ public class JdReservation extends JdRes
}
}
+ // Return the Host for this JdReservation.
+
public String getHost() {
String retVal = null;
NodeIdentity nodeIdentity= getNodeIdentity();
@@ -63,6 +69,8 @@ public class JdReservation extends JdRes
return retVal;
}
+ // Return true if JdReservation is usable.
+
public boolean isUp() {
boolean retVal = false;
ReservationState reservationState = getReservationState();
@@ -78,6 +86,8 @@ public class JdReservation extends JdRes
return retVal;
}
+ // Return the number of slices (capacity) for this JdReservation.
+
public Long getSlicesTotal() {
String location = "getSlicesTotal";
SizeBytes sizeOfReservation = getSizeOfReservation();
@@ -87,6 +97,8 @@ public class JdReservation extends JdRes
return retVal;
}
+ // Return the number of slices inuse for this JdReservation.
+
public Long getSlicesInuse() {
String location = "getSlicesInuse";
ConcurrentHashMap<DuccId, SizeBytes> map = getMap();
@@ -95,6 +107,8 @@ public class JdReservation extends JdRes
return retVal;
}
+ // Return the number of slices not inuse for this JdReservation.
+
public Long getSlicesAvailable() {
String location = "getSlicesAvailable";
Long retVal = getSlicesTotal() - getSlicesInuse();
@@ -102,11 +116,15 @@ public class JdReservation extends JdRes
return retVal;
}
+ // Return true if all slices for this JdReservation are inuse.
+
public boolean isFull() {
boolean retVal = (getSlicesTotal() <= getSlicesInuse());
return retVal;
}
+ // Return true if all slices for this JdReservation are not inuse.
+
public boolean isEmpty() {
boolean retVal = (getSlicesInuse() == 0);
return retVal;
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java?rev=1711115&r1=1711114&r2=1711115&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/jd/scheduler/JdScheduler.java Wed Oct 28 20:16:43 2015
@@ -67,17 +67,28 @@ public class JdScheduler {
private AtomicBoolean requestPending = new AtomicBoolean(false);
private AtomicBoolean changes = new AtomicBoolean(false);
+ // Manage the allocation of JD slices, which comprises making reservations,
+ // subdividing said reservations into slices, one per JD, and returning
+ // unused reservations.
+
public JdScheduler() {
}
+ // Auto-manage true is nominal.
+
public void setAutomanage() {
autoManage.set(true);
}
+ // Auto-manage false is for testing only.
+
public void resetAutomanage() {
autoManage.set(false);
}
+ // Save current slice allocations within each Reservation comprising
+ // the Orchestrator's checkpoint map.
+
public void ckpt() {
String location = "ckpt";
if(changes.get()) {
@@ -108,6 +119,9 @@ public class JdScheduler {
}
}
+ // Restore current slice allocations within each Reservation comprising
+ // the Orchestrator's checkpoint map.
+
public void restore() {
String location = "restore";
try {
@@ -128,6 +142,8 @@ public class JdScheduler {
}
}
+ // Return the number of Reservations allocated for JDs.
+
public int getReservationCount() {
int count = 0;
for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
@@ -143,6 +159,8 @@ public class JdScheduler {
return count;
}
+ // Process an OR publication.
+
public void handle(IDuccWorkMap dwm) {
String location = "handle";
try {
@@ -162,6 +180,8 @@ public class JdScheduler {
}
}
+ // Account for state changes for JD Reservations.
+
private void resourceAccounting(IDuccWorkMap dwm, JdHostProperties jdHostProperties) {
String location = "resourceAccounting";
String jdHostClass = jdHostProperties.getHostClass();
@@ -226,16 +246,20 @@ public class JdScheduler {
return slicesReserveActual;
}
+ // Determine if at least one JD Reservation can be unreserved.
+
private boolean isReservationDivestable(IDuccWorkMap dwm, JdHostProperties jdHostProperties) {
boolean retVal = false;
long slicesReserveDesired = getSlicesReserveDesired(jdHostProperties);
long slicesReserveActual = getSlicesReserveActual();
if(map.size() > 1) {
- if(slicesReserveActual > (2 * slicesReserveDesired)) {
- synchronized(map) {
- for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
- JdReservation jdReservation = entry.getValue();
- if(jdReservation.isEmpty()) {
+ synchronized(map) {
+ for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
+ JdReservation jdReservation = entry.getValue();
+ if(jdReservation.isEmpty()) {
+ long slicesToRelease = jdReservation.getSlicesTotal();
+ long slicesReserveAfterRelease = slicesReserveActual - slicesToRelease;
+ if(slicesReserveAfterRelease > slicesReserveDesired) {
retVal = true;
break;
}
@@ -246,6 +270,8 @@ public class JdScheduler {
return retVal;
}
+ // Acquire or divest JD Reservations based upon need.
+
private void resourceAdjustment(IDuccWorkMap dwm, JdHostProperties jdHostProperties) {
String location = "resourceAdjustment";
if(autoManage.get()) {
@@ -281,6 +307,8 @@ public class JdScheduler {
logger.debug(location, jobid, "actual: "+slicesReserveActual+" "+"desired: "+slicesReserveDesired);
}
+ // Request a new JD Reservation.
+
private void reservationAcquire(IDuccWorkMap dwm, JdHostProperties jdHostProperties) {
String location = "reservationAcquire";
CommonConfiguration common = null;
@@ -323,6 +351,8 @@ public class JdScheduler {
logger.debug(location, duccId, "actual: "+slicesReserveActual+" "+"desired: "+slicesReserveDesired);
}
+ // Return an unused JD Reservation.
+
private void reservationDivest(IDuccWorkMap dwm, JdHostProperties jdHostProperties) {
String location = "reservationDivest";
DuccId jdReservationDuccId = null;
@@ -354,6 +384,8 @@ public class JdScheduler {
logger.debug(location, jobid, "actual: "+slicesReserveActual+" "+"desired: "+slicesReserveDesired);
}
+ // Nothing to do.
+
private void reservationNoChange(IDuccWorkMap dwm, JdHostProperties jdHostProperties) {
String location = "reservationNoChange";
long slicesReserveDesired = getSlicesReserveDesired(jdHostProperties);
@@ -361,6 +393,8 @@ public class JdScheduler {
logger.trace(location, jobid, "actual: "+slicesReserveActual+" "+"desired: "+slicesReserveDesired);
}
+ // Update a list of JDs (DuccId's) allocated on a JD Reservation.
+
private void setJdReservationBeanList(List<JdReservationBean> jdReservationBeanList) {
if(jdReservationBeanList != null) {
for(JdReservationBean entry : jdReservationBeanList) {
@@ -371,6 +405,8 @@ public class JdScheduler {
}
}
+ // Return a list of JDs (DuccId's) allocated on a JD Reservation.
+
public List<JdReservationBean> getJdReservationBeanList(DuccId jdReservationDuccId) {
String location = "getJdReservationBeanList";
List<JdReservationBean> jdReservationBeanList = new ArrayList<JdReservationBean>();
@@ -385,11 +421,15 @@ public class JdScheduler {
return jdReservationBeanList;
}
+ // Return the number of JD Reservations.
+
public int countReservationsTotal() {
int count = map.size();
return count;
}
+ // Return the number of JD Reservations that are "up" (e.g. in Assigned state).
+
public int countReservationsUp() {
int count = 0;
for(Entry<DuccId, JdReservation> entry : map.entrySet()) {
@@ -401,6 +441,8 @@ public class JdScheduler {
return count;
}
+ // Handle a JD Reservation that has become available.
+
private void reservationUp(IDuccWorkReservation dwr, JdHostProperties jdHostProperties) {
String location = "reservationUp";
DuccId duccId = dwr.getDuccId();
@@ -427,6 +469,8 @@ public class JdScheduler {
}
}
+ // Handle a JD Reservation that has become unavailable.
+
private void reservationDown(IDuccWorkReservation dwr) {
String location = "reservationDown";
DuccId duccId = dwr.getDuccId();
@@ -446,6 +490,8 @@ public class JdScheduler {
}
}
+ // Handle unexpected state for a JD Reservation.
+
private void reservationOther(IDuccWorkReservation dwr, JdHostProperties jdHostProperties) {
String location = " reservationOther";
DuccId duccId = dwr.getDuccId();
@@ -463,6 +509,8 @@ public class JdScheduler {
logger.trace(location, duccId, "total: "+countReservationsTotal()+" "+"up: "+countReservationsUp());
}
+ // Handle a JD Reservation that has disappeared for the Orchestrator publication.
+
private void reservationVanished(DuccId jdReservationDuccId) {
String location = "reservationVanished";
List<JdReservation> list = new ArrayList<JdReservation>();
@@ -480,6 +528,8 @@ public class JdScheduler {
}
}
+ // Handle a list of JD Reservations that are no longer viable.
+
private void defunct(List<JdReservation> list) {
if(list != null) {
if(!list.isEmpty()) {
@@ -490,6 +540,8 @@ public class JdScheduler {
}
}
+ // Handle an individual JD Reservation that is no longer viable.
+
private void defunct(JdReservation jdReservation) {
String location = "defunct";
//TODO phase I = kill Job
@@ -500,6 +552,8 @@ public class JdScheduler {
}
}
+ // Get a slice, if one is available.
+
public NodeIdentity allocate(DuccId jdId, DuccId jobId) {
String location = "allocate";
NodeIdentity nodeIdentity = null;
@@ -523,6 +577,8 @@ public class JdScheduler {
return nodeIdentity;
}
+ // Return a slice.
+
public void deallocate(DuccId jdId, DuccId jobId) {
String location = "deallocate";
NodeIdentity nodeIdentity = null;
@@ -548,6 +604,8 @@ public class JdScheduler {
}
}
+ // Return the number of slices total for the specified JD Reservation.
+
public int countSlicesTotal(DuccId duccId) {
String location = "countSlicesTotal";
int count = 0;
@@ -559,6 +617,8 @@ public class JdScheduler {
return count;
}
+ // Return the number of slices inuse for the specified JD Reservation.
+
public int countSlicesInuse(DuccId duccId) {
String location = "countSlicesInuse";
int count = 0;
@@ -570,6 +630,8 @@ public class JdScheduler {
return count;
}
+ // Return the number of slices available for the specified JD Reservation.
+
public int countSlicesAvailable(DuccId duccId) {
String location = "countSlicesAvailable";
int count = 0;
@@ -581,6 +643,8 @@ public class JdScheduler {
return count;
}
+ // Return the number of slices total (for all JD Reservations).
+
public int countSlicesTotal() {
String location = "countSlicesTotal";
int count = 0;
@@ -592,6 +656,8 @@ public class JdScheduler {
return count;
}
+ // Return the number of slices inuse (for all JD Reservations).
+
public int countSlicesInuse() {
String location = "countSlicesInuse";
int count = 0;
@@ -603,6 +669,8 @@ public class JdScheduler {
return count;
}
+ // Return the number of slices available (for all JD Reservations).
+
public int countSlicesAvailable() {
String location = "countSlicesAvailable";
int count = 0;
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java?rev=1711115&r1=1711114&r2=1711115&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/test/java/org/apache/uima/ducc/orchestrator/jd/scheduler/test/TestSuite.java Wed Oct 28 20:16:43 2015
@@ -272,7 +272,9 @@ public class TestSuite {
assertTrue(jdScheduler.countSlicesInuse() == 0);
assertTrue(jdScheduler.countSlicesTotal() > 0);
//
- for(int i=0; i < 1000; i++) {
+ int allocations = 0;
+ int slicesPerReservation = 38;
+ while(allocations < 100) {
DuccId jdId = TestHelper.getJdId();
DuccId jdProcessDuccId = (DuccId) jdId;
map.put(jdId, jdId);
@@ -283,17 +285,33 @@ public class TestSuite {
}
//assertTrue(nodeIdentity != null);
randomPublication(jdScheduler, dwm);
+ if(nodeIdentity != null) {
+ allocations += 1;
+ long reservationsTotal = jdScheduler.countReservationsTotal();
+ long slicesTotal = jdScheduler.countSlicesTotal();
+ long slicesAvailable = jdScheduler.countSlicesAvailable();
+ long slicesInuse = jdScheduler.countSlicesInuse();
+ assertTrue(slicesTotal == (slicesAvailable+slicesInuse));
+ assertTrue(slicesTotal == (reservationsTotal*slicesPerReservation));
+ }
}
for(Entry<DuccId, DuccId> entry : map.entrySet()) {
DuccId jdId = entry.getKey();
DuccId jdProcessDuccId = (DuccId) jdId;
jdScheduler.deallocate(jdProcessDuccId, jobId);
randomPublication(jdScheduler, dwm);
+ long reservationsTotal = jdScheduler.countReservationsTotal();
+ long slicesTotal = jdScheduler.countSlicesTotal();
+ long slicesAvailable = jdScheduler.countSlicesAvailable();
+ long slicesInuse = jdScheduler.countSlicesInuse();
+ assertTrue(slicesTotal == (slicesAvailable+slicesInuse));
+ assertTrue(slicesTotal == (reservationsTotal*slicesPerReservation));
}
publication(jdScheduler, dwm);
assertTrue(jdScheduler.countSlicesInuse() == 0);
assertTrue(jdScheduler.countSlicesTotal() > 0);
assertTrue(jdScheduler.countSlicesAvailable() > 0);
+ assertTrue(jdScheduler.countReservationsTotal() == 1);
}
catch(Exception e) {
e.printStackTrace();