use of com.hazelcast.mapreduce.TopologyChangedStrategy in project hazelcast by hazelcast.
the class AbstractMapReduceTask method getTopologyChangedStrategyOrConfigTopologyChangedStrategy.
private TopologyChangedStrategy getTopologyChangedStrategyOrConfigTopologyChangedStrategy(JobTrackerConfig config) {
String topologyChangedStrategyStr = getTopologyChangedStrategy();
TopologyChangedStrategy topologyChangedStrategy;
if (topologyChangedStrategyStr == null) {
topologyChangedStrategy = config.getTopologyChangedStrategy();
} else {
topologyChangedStrategy = TopologyChangedStrategy.valueOf(topologyChangedStrategyStr.toUpperCase(LOCALE_INTERNAL));
}
return topologyChangedStrategy;
}
use of com.hazelcast.mapreduce.TopologyChangedStrategy in project hazelcast by hazelcast.
the class AbstractMapReduceTask method startSupervisionTask.
private void startSupervisionTask(JobTracker jobTracker) {
final MapReduceService mapReduceService = getService(MapReduceService.SERVICE_NAME);
final JobTrackerConfig config = ((AbstractJobTracker) jobTracker).getJobTrackerConfig();
final boolean communicateStats = config.isCommunicateStats();
final int chunkSize = getChunkSizeOrConfigChunkSize(config);
final TopologyChangedStrategy topologyChangedStrategy = getTopologyChangedStrategyOrConfigTopologyChangedStrategy(config);
final String name = getDistributedObjectName();
final String jobId = getJobId();
final KeyValueSource keyValueSource = getKeyValueSource();
final Mapper mapper = getMapper();
final CombinerFactory combinerFactory = getCombinerFactory();
final ReducerFactory reducerFactory = getReducerFactory();
final Collection keys = getKeys();
final Collection<Object> keyObjects = getKeyObjects(keys);
final KeyPredicate predicate = getPredicate();
final ClusterService clusterService = nodeEngine.getClusterService();
for (Member member : clusterService.getMembers(KeyValueJobOperation.MEMBER_SELECTOR)) {
Operation operation = new KeyValueJobOperation(name, jobId, chunkSize, keyValueSource, mapper, combinerFactory, reducerFactory, communicateStats, topologyChangedStrategy);
executeOperation(operation, member.getAddress(), mapReduceService, nodeEngine);
}
// After we prepared all the remote systems we can now start the processing
for (Member member : clusterService.getMembers(DATA_MEMBER_SELECTOR)) {
Operation operation = new StartProcessingJobOperation(name, jobId, keyObjects, predicate);
executeOperation(operation, member.getAddress(), mapReduceService, nodeEngine);
}
}
use of com.hazelcast.mapreduce.TopologyChangedStrategy 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);
}
}
use of com.hazelcast.mapreduce.TopologyChangedStrategy in project hazelcast by hazelcast.
the class XmlConfigBuilder method handleJobTracker.
private void handleJobTracker(Node node) {
Node attName = node.getAttributes().getNamedItem("name");
String name = getTextContent(attName);
JobTrackerConfig jConfig = new JobTrackerConfig();
jConfig.setName(name);
for (Node n : childElements(node)) {
String nodeName = cleanNodeName(n);
String value = getTextContent(n).trim();
if ("max-thread-size".equals(nodeName)) {
jConfig.setMaxThreadSize(getIntegerValue("max-thread-size", value));
} else if ("queue-size".equals(nodeName)) {
jConfig.setQueueSize(getIntegerValue("queue-size", value));
} else if ("retry-count".equals(nodeName)) {
jConfig.setRetryCount(getIntegerValue("retry-count", value));
} else if ("chunk-size".equals(nodeName)) {
jConfig.setChunkSize(getIntegerValue("chunk-size", value));
} else if ("communicate-stats".equals(nodeName)) {
jConfig.setCommunicateStats(value == null || value.length() == 0 ? JobTrackerConfig.DEFAULT_COMMUNICATE_STATS : parseBoolean(value));
} else if ("topology-changed-stategy".equals(nodeName)) {
TopologyChangedStrategy topologyChangedStrategy = JobTrackerConfig.DEFAULT_TOPOLOGY_CHANGED_STRATEGY;
for (TopologyChangedStrategy temp : TopologyChangedStrategy.values()) {
if (temp.name().equals(value)) {
topologyChangedStrategy = temp;
}
}
jConfig.setTopologyChangedStrategy(topologyChangedStrategy);
}
}
config.addJobTrackerConfig(jConfig);
}
Aggregations