}
// Move partitions
Map<ParticipantId, SortedSet<Integer>> newAssignment = Maps.newHashMap();
for (Map.Entry<ParticipantId, SortedSet<Integer>> e : origAssignment.entrySet()) {
ParticipantId instance = e.getKey();
SortedSet<Integer> partitions = e.getValue();
Integer instanceId = instanceMap.get(instance);
if (instanceId != null) {
for (int p : partitions) {
// Determine for each partition if there have been failures with the current assignment
// strategy, and if so, force a shift in assignment for that partition only
int shiftValue = getNumInstancesToShift(jobCfg, jobCtx, instances, p);
int newInstanceId = (instanceId + shiftValue) % instances.size();
ParticipantId newInstance = instanceMap.inverse().get(newInstanceId);
if (newInstance == null) {
newInstance = instance;
}
if (!newAssignment.containsKey(newInstance)) {
newAssignment.put(newInstance, new TreeSet<Integer>());