def _event_handler_1(self, partitionFiles, _timestamp, _source): '\n Method invoked when Master assigns work to this process\n ' time.sleep(2) self.myPrint('Received partition split files: ' + (str(partitionFiles))) outputFile = self.outputDir + (str(time.time()).replace('.', '')) + ('_output_') + (str(self._id._address[1])) + ('.txt') (result, countReduceCalls, countSkippedRecords) = self.Reduce(partitionFiles) self.myPrint('writing result to ' + (outputFile)) Utils.writeResult(result, outputFile, 'wb') if ((not testFaultTolerance) or (self._id._address[1] % (3) == 0)): self.send(('ReportReduceWork', outputFile, countReduceCalls, countSkippedRecords), _source)
def _event_handler_1(self, inputData, _timestamp, _source): '\n Method invoked when Master assigns work to this worker\n ' time.sleep(2) self.myPrint('Received input split: ' + (str(inputData))) outputFile = self.outputDir + (str(time.time()).replace('.', '')) + ('_output_') + (str(self._id._address[1])) + ('.txt') (listKeyValue, countMapCalls, countSkippedRecords) = self.Map(inputData) partitions = self.partitioner(listKeyValue) partitionOuputFiles = dict() for key in partitions.keys(): outputFile = self.outputDir + (str(self._id._address[1])) + ('_output_') + (str(key)) + ('.txt') self.myPrint('writing result to ' + (outputFile)) Utils.writeResult(partitions[key], outputFile, 'a+b') partitionOuputFiles[key] = outputFile if ((not testFaultTolerance) or (self._id._address[1] % (2) == 0)): self.send(('ReportMapWork', partitionOuputFiles, countMapCalls, countSkippedRecords), _source)