def testInterrupt(self): """ HOD should raise HodInterruptException when interrupted""" def interrupt(testClass): testClass.assertRaises(HodInterruptException, client.testing) serverPort = ServiceUtil.getUniqRandomPort(h='localhost',low=40000,high=50000) client = hodXRClient('http://localhost:' + str(serverPort)) myThread = threading.Thread(name='testinterrupt', target=interrupt,args=(self,)) # Set the global interrupt hodInterrupt.setFlag() myThread.start() myThread.join() pass
def testInterrupt(self): """ HOD should raise HodInterruptException when interrupted""" def interrupt(testClass): testClass.assertRaises(HodInterruptException, client.testing) serverPort = ServiceUtil.getUniqRandomPort(h='localhost', low=40000, high=50000) client = hodXRClient('http://localhost:' + str(serverPort)) myThread = threading.Thread(name='testinterrupt', target=interrupt, args=(self, )) # Set the global interrupt hodInterrupt.setFlag() myThread.start() myThread.join() pass
time.sleep(self.__cfg['hod']['script-wait-time']) self.__log.debug('Slept for %d time. Now going to run the script' % self.__cfg['hod']['script-wait-time']) if hodInterrupt.isSet(): self.__log.debug('Hod interrupted - not executing script') else: scriptRunner = hadoopScript(clusterDir, self.__cfg['hod']['original-dir']) self.__opCode = scriptRunner.run(script) scriptRet = self.__opCode self.__log.info("Exit code from running the script: %d" % self.__opCode) else: self.__log.critical("Error %d in allocating the cluster. Cannot run the script." % self.__opCode) if hodInterrupt.isSet(): # Got interrupt while executing script. Unsetting it for deallocating hodInterrupt.setFlag(False) if self._is_cluster_allocated(clusterDir): self._op_deallocate(('deallocate', clusterDir)) except HodInterruptException, h: self.__log.critical("Script failed because of a process interrupt.") self.__opCode = HOD_INTERRUPTED_CODE except: self.__log.critical("script: %s failed: %s" % (script, get_exception_error_string())) self.__log.debug(get_exception_string()) self.__cleanup() self.handle_script_exit_code(scriptRet, clusterDir) return self.__opCode
self.__log.debug('Hod interrupted - not executing script') else: scriptRunner = hadoopScript( clusterDir, self.__cfg['hod']['original-dir']) self.__opCode = scriptRunner.run(script) scriptRet = self.__opCode self.__log.info("Exit code from running the script: %d" % self.__opCode) else: self.__log.critical( "Error %d in allocating the cluster. Cannot run the script." % self.__opCode) if hodInterrupt.isSet(): # Got interrupt while executing script. Unsetting it for deallocating hodInterrupt.setFlag(False) if self._is_cluster_allocated(clusterDir): self._op_deallocate(('deallocate', clusterDir)) except HodInterruptException, h: self.__log.critical( "Script failed because of a process interrupt.") self.__opCode = HOD_INTERRUPTED_CODE except: self.__log.critical("script: %s failed: %s" % (script, get_exception_error_string())) self.__log.debug(get_exception_string()) self.__cleanup() self.handle_script_exit_code(scriptRet, clusterDir)