Exemplo n.º 1
0
 def _parseEquals(self, list):
     return parseEquals(list)
Exemplo n.º 2
0
 def _parseEquals(self, list):
   return parseEquals(list)
Exemplo n.º 3
0
  def __check_jobtracker(self, desc, id, pkgdir):
    # Check jobtracker status. Return properly if it is ready to accept jobs.
    # Currently Checks for Jetty to come up, the last thing that can be checked
    # before JT completes initialisation. To be perfectly reliable, we need 
    # hadoop support
    name = desc.getName()
    if name == 'jobtracker':
      # Yes I am the Jobtracker
      self.log.debug("Waiting for jobtracker to initialise")
      version = desc.getVersion()
      self.log.debug("jobtracker version : %s" % version)
      hadoopCmd = self.getRunningValues()[id]
      attrs = hadoopCmd.getFilledInKeyValues()
      attrs = parseEquals(attrs)
      jobTrackerAddr = attrs['mapred.job.tracker']
      self.log.debug("jobtracker rpc server : %s" % jobTrackerAddr)
      if version < 16:
        jettyAddr = jobTrackerAddr.split(':')[0] + ':' + \
                              attrs['mapred.job.tracker.info.port']
      else:
        jettyAddr = attrs['mapred.job.tracker.http.address']
      self.log.debug("Jobtracker jetty : %s" % jettyAddr)

      # Check for Jetty to come up
      # For this do a http head, and then look at the status
      defaultTimeout = socket.getdefaulttimeout()
      # socket timeout isn`t exposed at httplib level. Setting explicitly.
      socket.setdefaulttimeout(1)
      sleepTime = 0.5
      jettyStatus = False
      jettyStatusmsg = ""
      while sleepTime <= 32:
        # There is a possibility that the command might fail after a while.
        # This code will check if the command failed so that a better
        # error message can be returned to the user.
        if not hadoopCmd.getCommandStatus():
          self.log.critical('Hadoop command found to have failed when ' \
                            'checking for jobtracker status')
          hadoopCmd.handleFailedCommand()
          addnInfo = ""
          if hadoopCmd.stdErrContents is not "":
            addnInfo = " Information from stderr of the command:\n%s" \
                                        % (hadoopCmd.stdErrContents)
          raise Exception("Could not launch the %s using %s/bin/hadoop.%s" \
                                        % (desc.getName(), pkgdir, addnInfo))
          
        try:
          jettyConn = httplib.HTTPConnection(jettyAddr)
          jettyConn.request("HEAD", "/jobtracker.jsp")
          # httplib inherently retries the following till socket timeout
          resp = jettyConn.getresponse()
          if resp.status != 200:
            # Some problem?
            jettyStatus = False
            jettyStatusmsg = "Jetty gave a non-200 response to a HTTP-HEAD" +\
                             " request. HTTP Status (Code, Msg): (%s, %s)" % \
                             ( resp.status, resp.reason )
            break
          else:
            self.log.info("Jetty returned a 200 status (%s)" % resp.reason)
            self.log.info("JobTracker successfully initialised")
            return
        except socket.error:
          self.log.debug("Jetty gave a socket error. Sleeping for %s" \
                                                                  % sleepTime)
          time.sleep(sleepTime)
          sleepTime = sleepTime * 2
        except Exception, e:
          jettyStatus = False
          jettyStatusmsg = ("Process(possibly other than jetty) running on" + \
                  " port assigned to jetty is returning invalid http response")
          break
      socket.setdefaulttimeout(defaultTimeout)
      if not jettyStatus:
        self.log.critical("Jobtracker failed to initialise.")
        if jettyStatusmsg:
          self.log.critical( "Reason: %s" % jettyStatusmsg )
        else: self.log.critical( "Reason: Jetty failed to give response")
        raise Exception("JobTracker failed to initialise")
Exemplo n.º 4
0
    def __check_jobtracker(self, desc, id, pkgdir):
        # Check jobtracker status. Return properly if it is ready to accept jobs.
        # Currently Checks for Jetty to come up, the last thing that can be checked
        # before JT completes initialisation. To be perfectly reliable, we need
        # hadoop support
        name = desc.getName()
        if name == 'jobtracker':
            # Yes I am the Jobtracker
            self.log.debug("Waiting for jobtracker to initialise")
            version = desc.getVersion()
            self.log.debug("jobtracker version : %s" % version)
            hadoopCmd = self.getRunningValues()[id]
            attrs = hadoopCmd.getFilledInKeyValues()
            attrs = parseEquals(attrs)
            jobTrackerAddr = attrs['mapred.job.tracker']
            self.log.debug("jobtracker rpc server : %s" % jobTrackerAddr)
            if version < 16:
                jettyAddr = jobTrackerAddr.split(':')[0] + ':' + \
                                      attrs['mapred.job.tracker.info.port']
            else:
                jettyAddr = attrs['mapred.job.tracker.http.address']
            self.log.debug("Jobtracker jetty : %s" % jettyAddr)

            # Check for Jetty to come up
            # For this do a http head, and then look at the status
            defaultTimeout = socket.getdefaulttimeout()
            # socket timeout isn`t exposed at httplib level. Setting explicitly.
            socket.setdefaulttimeout(1)
            sleepTime = 0.5
            jettyStatus = False
            jettyStatusmsg = ""
            while sleepTime <= 32:
                # There is a possibility that the command might fail after a while.
                # This code will check if the command failed so that a better
                # error message can be returned to the user.
                if not hadoopCmd.getCommandStatus():
                    self.log.critical('Hadoop command found to have failed when ' \
                                      'checking for jobtracker status')
                    hadoopCmd.handleFailedCommand()
                    addnInfo = ""
                    if hadoopCmd.stdErrContents is not "":
                        addnInfo = " Information from stderr of the command:\n%s" \
                                                    % (hadoopCmd.stdErrContents)
                    raise Exception("Could not launch the %s using %s/bin/hadoop.%s" \
                                                  % (desc.getName(), pkgdir, addnInfo))

                try:
                    jettyConn = httplib.HTTPConnection(jettyAddr)
                    jettyConn.request("HEAD", "/jobtracker.jsp")
                    # httplib inherently retries the following till socket timeout
                    resp = jettyConn.getresponse()
                    if resp.status != 200:
                        # Some problem?
                        jettyStatus = False
                        jettyStatusmsg = "Jetty gave a non-200 response to a HTTP-HEAD" +\
                                         " request. HTTP Status (Code, Msg): (%s, %s)" % \
                                         ( resp.status, resp.reason )
                        break
                    else:
                        self.log.info("Jetty returned a 200 status (%s)" %
                                      resp.reason)
                        self.log.info("JobTracker successfully initialised")
                        return
                except socket.error:
                    self.log.debug("Jetty gave a socket error. Sleeping for %s" \
                                                                            % sleepTime)
                    time.sleep(sleepTime)
                    sleepTime = sleepTime * 2
                except Exception, e:
                    jettyStatus = False
                    jettyStatusmsg = ("Process(possibly other than jetty) running on" + \
                            " port assigned to jetty is returning invalid http response")
                    break
            socket.setdefaulttimeout(defaultTimeout)
            if not jettyStatus:
                self.log.critical("Jobtracker failed to initialise.")
                if jettyStatusmsg:
                    self.log.critical("Reason: %s" % jettyStatusmsg)
                else:
                    self.log.critical("Reason: Jetty failed to give response")
                raise Exception("JobTracker failed to initialise")