def __init__(self, log, idleJTHandler, interval, limit, hadoopDir, javaHome, servInfoProvider): self.__log = log self.__idlenessLimit = limit self.__idleJobTrackerHandler = idleJTHandler self.__hadoopDir = hadoopDir hadoopPath = os.path.join(self.__hadoopDir, "bin", "hadoop") #hadoop directory can be from pkgs or a temp location like tarball. Verify once. if not os.path.exists(hadoopPath): raise Exception('Invalid Hadoop path specified: %s' % hadoopPath) self.__javaHome = javaHome # Note that when this object is created, we don't yet know the JT URL. # The service info provider will be polled until we get the URL. self.__serviceInfoProvider = servInfoProvider self.__jobCountRegExp = re.compile("([0-9]+) jobs currently running.*") self.__jobStatusRegExp = re.compile("(\S+)\s+(\d)\s+\d+\s+\S+$") self.__firstIdleTime = 0 self.__hadoop15Version = { 'major' : '0', 'minor' : '15' } #Assumption: we are not going to support versions older than 0.15 for Idle Job tracker. if not self.__isCompatibleHadoopVersion(self.__hadoop15Version): raise Exception('Incompatible Hadoop Version: Cannot check status') self.__stopFlag = False self.__jtURLFinderThread = func(name='JTURLFinderThread', functionRef=self.getJobTrackerURL) self.__jtMonitorThread = loop(name='JTMonitorThread', functionRef=self.monitorJobTracker, sleep=interval) self.__jobTrackerURL = None
def stopRM(self): """An XMLRPC call which will spawn a thread to stop the Ringmaster program.""" # We spawn a thread here because we want the XMLRPC call to return. Calling # stop directly from here will also stop the XMLRPC server. try: self.log.debug("inside xml-rpc call to stop ringmaster") rmStopperThread = func('RMStopper', self.rm.stop) rmStopperThread.start() self.log.debug("returning from xml-rpc call to stop ringmaster") return True except: self.log.debug("Exception in stop: %s" % get_exception_string()) return False
def stopRM(self): """An XMLRPC call which will spawn a thread to stop the Ringmaster program.""" # We spawn a thread here because we want the XMLRPC call to return. Calling # stop directly from here will also stop the XMLRPC server. try: self.log.debug("inside xml-rpc call to stop ringmaster") rmStopperThread = func("RMStopper", self.rm.stop) rmStopperThread.start() self.log.debug("returning from xml-rpc call to stop ringmaster") return True except: self.log.debug("Exception in stop: %s" % get_exception_string()) return False