Skip to content

Instantly share code, notes, and snippets.

@Romeh
Created December 18, 2017 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Romeh/841ebc0a972f1b771f97d12fdf43ea4b to your computer and use it in GitHub Desktop.
Save Romeh/841ebc0a972f1b771f97d12fdf43ea4b to your computer and use it in GitHub Desktop.
/**
* sample service for how to call map reduce jobs in parallel asynchronous with fail fast reducer
*/
@Service
public class ComputeService {
private static final Logger logger = LoggerFactory.getLogger(AlertsService.class);
private final DataGridCompute dataGridCompute;
@Autowired
private FailFastReducer failFastReducer;
@Autowired
public ComputeService(DataGridCompute dataGridCompute) {
this.dataGridCompute = dataGridCompute;
}
/**
* call to ignite compute grid with list if jobs in parallel asynchronous
*/
public void validateWithAllServicesInParallelAsync(List<IgniteCallable<ServiceResponse>> jobs){
// execute the jobs with the fail fast reducer in parallel and async the just log the final aggregated response
dataGridCompute.executeMapReduceFailFast(jobs,failFastReducer,
mapReduceResponse -> logger.debug(mapReduceResponse.toString()));
}
/**
* call to ignite compute grid with list if jobs in parallel synchronous
*/
public MapReduceResponse validateWithAllServicesInParallelSync(List<IgniteCallable<ServiceResponse>> jobs){
// execute the jobs with the fail fast reducer in parallel and sync the just log the final aggregated response
return dataGridCompute.executeMapReduceFailFastSync(jobs,failFastReducer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment