From c2a954665cd8542b90e9525c4cfb378bca40741f Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Mon, 20 Jun 2016 13:52:19 +0000
Subject: [PATCH] Task #8392: fix in redirecting jobs to lexar3/4

---
 LTA/LTAIngest/ingest_config.py.in | 2 +-
 LTA/LTAIngest/master.py           | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/LTA/LTAIngest/ingest_config.py.in b/LTA/LTAIngest/ingest_config.py.in
index 87d9043bb41..3ae0d647c5a 100644
--- a/LTA/LTAIngest/ingest_config.py.in
+++ b/LTA/LTAIngest/ingest_config.py.in
@@ -21,7 +21,7 @@ ltaClient    = None
 host      = socket.gethostname()
 ## Using netifaces module or something similar would be nicer, but it doesn't want to install in a custom dir
 ## So we use this hack
-if 'lexar001' in host or 'lexar002' in host:
+if 'lexar00' in host:
   host = host + '.offline.lofar'
 if 'gridftp01.target.rug.nl' in host:
   host = 'lotar2.staging.lofar'
diff --git a/LTA/LTAIngest/master.py b/LTA/LTAIngest/master.py
index ed52c927b3a..55e2b5c1eed 100755
--- a/LTA/LTAIngest/master.py
+++ b/LTA/LTAIngest/master.py
@@ -205,7 +205,9 @@ class jobHandler(Process):
           self.update_job_msg.put((job, job['Status'], JobProducing, None))
           job['Status'] = JobProducing
           self.active[job['ExportID']] = job
-          self.manager.get(job.get('slave_hosts')).put(job) ## sends it to the slave with the shortest queue of the possible slave_hosts
+          job_slave_hosts = job.get('slave_hosts')
+          slave_for_job = self.manager.get(job_slave_hosts)
+          slave_for_job.put(job) ## sends it to the slave with the shortest queue of the possible slave_hosts
           self.logger.debug("Job's started: %s (%i)" % (job['ExportID'], len(self.active)))
           first = True
         except Empty: pass
@@ -263,8 +265,9 @@ class queueHandler(Process):
       job['destination'] = self.job_groups[job['job_group']].get_destination()
 
       sourcehost = job['Location'].split(':')[0]
+      self.logger.info("job: %s sourcehost=%s" % (fileName, sourcehost))
       if 'cep4' in sourcehost.lower():
-          job['slave_hosts'] = ['lexar003.lexar.control.lofar', 'lexar004.lexar.control.lofar']
+          job['slave_hosts'] = ['lexar003.offline.lofar', 'lexar004.offline.lofar']
 
       self.scheduled.put(job)
 #      self.talker.put(job) ## Tell MoM we've done something
@@ -376,7 +379,7 @@ class ltaMaster():
 
     result = None
     length = sys.maxint
-    for k in self.slaves.keys():
+    for k in slave_hosts:
       size = self.slaves[k].qsize()
       if length > size:
         result = self.slaves[k]
-- 
GitLab