private boolean assignGreedily(Mapping m, Task task, List<ConsistentHash<ExecutorChunk>> hashes, int i) { if (i==hashes.size()) return true; // fully assigned String key = task.getAffinityKey() + (i>0 ? String.valueOf(i) : ""); for (ExecutorChunk ec : hashes.get(i).list(key)) { // let's attempt this assignment m.assign(i,ec); if (m.isPartiallyValid() && assignGreedily(m,task,hashes,i+1)) return true; // successful greedily allocation // otherwise 'ec' wasn't a good fit for us. try next. } // every attempt failed m.assign(i,null); return false; } };
private boolean assignGreedily(Mapping m, Task task, List<ConsistentHash<ExecutorChunk>> hashes, int i) { if (i==hashes.size()) return true; // fully assigned String key = task.getFullDisplayName() + (i>0 ? String.valueOf(i) : ""); for (ExecutorChunk ec : hashes.get(i).list(key)) { // let's attempt this assignment m.assign(i,ec); if (m.isPartiallyValid() && assignGreedily(m,task,hashes,i+1)) return true; // successful greedily allocation // otherwise 'ec' wasn't a good fit for us. try next. } // every attempt failed m.assign(i,null); return false; } };
private boolean assignGreedily(Mapping m, Task task, List<ConsistentHash<ExecutorChunk>> hashes, int i) { if (i==hashes.size()) return true; // fully assigned String key = task.getFullDisplayName() + (i>0 ? String.valueOf(i) : ""); for (ExecutorChunk ec : hashes.get(i).list(key)) { // let's attempt this assignment m.assign(i,ec); if (m.isPartiallyValid() && assignGreedily(m,task,hashes,i+1)) return true; // successful greedily allocation // otherwise 'ec' wasn't a good fit for us. try next. } // every attempt failed m.assign(i,null); return false; } };
private boolean assignGreedily(Mapping m, Task task, List<ConsistentHash<ExecutorChunk>> hashes, int i) { if (i == hashes.size()) { return true; // fully assigned } String key = task.getFullDisplayName() + (i > 0 ? String.valueOf(i) : ""); for (ExecutorChunk ec : hashes.get(i).list(key)) { // let's attempt this assignment m.assign(i, ec); if (m.isPartiallyValid() && assignGreedily(m, task, hashes, i + 1)) { return true; // successful greedily allocation } // otherwise 'ec' wasn't a good fit for us. try next. } // every attempt failed m.assign(i, null); return false; } };
private boolean assignGreedily(Mapping m, Task task, List<ConsistentHash<ExecutorChunk>> hashes, int i) { if (i==hashes.size()) return true; // fully assigned String key = task.getFullDisplayName() + (i>0 ? String.valueOf(i) : ""); for (ExecutorChunk ec : hashes.get(i).list(key)) { // let's attempt this assignment m.assign(i,ec); if (m.isPartiallyValid() && assignGreedily(m,task,hashes,i+1)) return true; // successful greedily allocation // otherwise 'ec' wasn't a good fit for us. try next. } // every attempt failed m.assign(i,null); return false; } };
private boolean assignGreedily(Mapping m, Task task, List<ConsistentHash<ExecutorChunk>> hashes, int i) { if (i==hashes.size()) return true; // fully assigned String key = task.getFullDisplayName() + (i>0 ? String.valueOf(i) : ""); for (ExecutorChunk ec : hashes.get(i).list(key)) { // let's attempt this assignment m.assign(i,ec); if (m.isPartiallyValid() && assignGreedily(m,task,hashes,i+1)) return true; // successful greedily allocation // otherwise 'ec' wasn't a good fit for us. try next. } // every attempt failed m.assign(i,null); return false; } };
/** * Makes sure that all the assignments are made and it is within the constraints. */ public boolean isCompletelyValid() { for (ExecutorChunk ec : mapping) if (ec==null) return false; // unassigned return isPartiallyValid(); }
/** * Makes sure that all the assignments are made and it is within the constraints. */ public boolean isCompletelyValid() { for (ExecutorChunk ec : mapping) if (ec==null) return false; // unassigned return isPartiallyValid(); }
/** * Makes sure that all the assignments are made and it is within the constraints. */ public boolean isCompletelyValid() { for (ExecutorChunk ec : mapping) if (ec==null) return false; // unassigned return isPartiallyValid(); }
/** * Makes sure that all the assignments are made and it is within the constraints. */ public boolean isCompletelyValid() { for (ExecutorChunk ec : mapping) if (ec==null) return false; // unassigned return isPartiallyValid(); }
/** * Makes sure that all the assignments are made and it is within the * constraints. */ public boolean isCompletelyValid() { for (ExecutorChunk ec : mapping) { if (ec == null) { return false; // unassigned } } return isPartiallyValid(); }
/** * Makes sure that all the assignments are made and it is within the constraints. */ public boolean isCompletelyValid() { for (ExecutorChunk ec : mapping) if (ec==null) return false; // unassigned return isPartiallyValid(); }