use of com.hazelcast.mapreduce.TopologyChangedException in project hazelcast by hazelcast.
the class KeysAssignmentOperation method run.
@Override
public void run() throws Exception {
MapReduceService mapReduceService = getService();
JobSupervisor supervisor = mapReduceService.getJobSupervisor(getName(), getJobId());
if (supervisor == null) {
this.result = new KeysAssignmentResult(NO_SUPERVISOR, null);
return;
}
Map<Object, Address> assignment = new HashMap<Object, Address>();
// Precheck if still all members are available
if (!supervisor.checkAssignedMembersAvailable()) {
TopologyChangedStrategy tcs = supervisor.getConfiguration().getTopologyChangedStrategy();
if (tcs == CANCEL_RUNNING_OPERATION) {
Exception exception = new TopologyChangedException();
supervisor.cancelAndNotify(exception);
this.result = new KeysAssignmentResult(CHECK_STATE_FAILED, assignment);
return;
// TODO Not yet fully supported
/* } else if (tcs == DISCARD_AND_RESTART) {
* supervisor.cancelNotifyAndRestart();
*/
} else {
Exception exception = new TopologyChangedException("Unknown or unsupported TopologyChangedStrategy");
supervisor.cancelAndNotify(exception);
this.result = new KeysAssignmentResult(CHECK_STATE_FAILED, assignment);
return;
}
}
try {
for (Object key : keys) {
Address address = supervisor.assignKeyReducerAddress(key);
assignment.put(key, address);
}
this.result = new KeysAssignmentResult(SUCCESSFUL, assignment);
} catch (NoDataMemberInClusterException e) {
supervisor.cancelAndNotify(e);
this.result = new KeysAssignmentResult(CHECK_STATE_FAILED, assignment);
}
}
Aggregations