Commits

Peter Rudenko  committed ce1b190

Kill job functionality

  • Participants
  • Parent commits e7e70a6

Comments (0)

Files changed (1)

File templeton.py

         response = urllib2.urlopen(req)
         return json.loads(response.read())
 
+    def delete(self, url, data=None):
+        """
+        Make DELETE query to templeton url.
+        """
+        if data is not None:
+            data['user.name'] = self.user
+        else:
+            data = {"user.name": self.user}
+        data = urllib.urlencode(data)
+        opener = urllib2.build_opener(urllib2.HTTPHandler)
+        req = urllib2.Request(TEMPLETON_URL + url + "?" + data)
+        req.get_method = lambda: 'DELETE'
+        response = opener.open(req)
+        return json.loads(response.read())
+
 
     def pig_query(self, execute=None, pig_file=None, statusdir=None, callback=None):
         """
         """
         return self.get("queue/%s" % job_id)
 
+    def kill_job(self, job_id):
+        return self.delete("queue/%s" % job_id)
+
 
 
 
 if __name__ == "__main__":
     t = Templeton()
-    pig_query = t.pig_query(user="hdfs", )
-    job = t.check_job(pig_query['id'])
-    print job
+    job = t.pig_query(pig_file="/tmp/hcat.pig", statusdir="/tmp/hcat_output/")
+    print "Started job %s " % job
+    print "Job status %s " % t.check_job(job['id'])
+    print "Killing job %s " % t.kill_job(job['id'])
+    #print t.delete("ddl/database/default/table/a3")
+