Ejemplo n.º 1
0
    def sendResult(self, allids):
        response = {"id": allids["onavjobid"], "jobID":allids["hadoopjobid"]}
        #print response
        propertyObj = ConfigProperties()
        onavurl = propertyObj.apisendurl()
        #url = 'http://localhost:8000/job/create/?'
        for key, value in response.iteritems():
            onavurl += '%s=%s&' % (key, value)
            onavurl = onavurl[:-1]

        requests.get(onavurl)
Ejemplo n.º 2
0
    def  retrieveJobID (self,iterationnumber):

        propertyObj = ConfigProperties()
        subcommand = propertyObj.localsubprocess()
        proc = subprocess.Popen(subcommand, stdout=subprocess.PIPE)        #checks for running jobs
        alljobs, err = proc.communicate()                               #captures running jobs in alljobs
        linecount = alljobs.count('\n')                                 #counts the number of lines in alljobs
        lines = alljobs.splitlines()                                    #list of lines for a running job
        jobline = lines[linecount-1]                                    #selects the line that has job id, usually the last line
        jobIDIndex = jobline.find("job_")                               #finds out the starting index of job id using pattern
        self.hadoopjobid.append(jobline[jobIDIndex:jobIDIndex+21])      #stores the job id using job id length

        return {'onavjobid':self.onavjobid[iterationnumber], 'hadoopjobid':self.hadoopjobid[iterationnumber]}   #retuns dict of job ids
Ejemplo n.º 3
0
    def processQuery(self, querylist,flag):

        propertyObj = ConfigProperties()
        hostname = propertyObj.localhivehost()
        portnumber = propertyObj.localhiveport()
        authentication = propertyObj.localhiveauthentication()
        username = propertyObj.localhiveuser()
        userpassword = propertyObj.localuserpassword()
        databasename = propertyObj.localhivedatabase()


        conn = pyhs2.connect(host=hostname, port = portnumber, authMechanism = authentication, user=username, password=userpassword, database = databasename)
        cur = conn.cursor()

        cur.execute(querylist['createdb'])
        cur.execute(querylist['workdb'])
        cur.execute(querylist['droptable1'])
        cur.execute(querylist['createtable1'])
        cur.execute(querylist['testcode'])
        cur.execute(querylist['droptable2'])
        cur.execute(querylist['createtable2'])

        if flag == 0:
            cur.close()
            conn.close()
Ejemplo n.º 4
0
    def getResponse(self):

        propertyObj = ConfigProperties()
        onavurl = propertyObj.apicallurl()

        try:
            self.response = requests.get(onavurl)

            if self.response.get('errors'):
                logging.warn("API error response")
                return {'request_error': 'api_error_response'}
        except requests.exceptions.ConnectionError:
            logging.warn('ConnectionError')
            return {'request_error': 'ConnectionTimeout'}
        except requests.exceptions.Timeout:
            logging.warn('API request timed out')
            return {'request_error': 'Timeout'}
        except Exception, ex:
            logging.warn("API request exception: %s", ex)
            return {'request_error':ex}