incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r1180226 - in /incubator/ambari/trunk: CHANGES.txt agent/src/main/python/ambari_agent/ActionQueue.py
Date Fri, 07 Oct 2011 20:50:22 GMT
Author: eyang
Date: Fri Oct  7 20:50:21 2011
New Revision: 1180226

URL: http://svn.apache.org/viewvc?rev=1180226&view=rev
Log:
AMBARI-46. Implemented preservation of cluster id, blueprint name and 
blueprint revision on agent. (Eric Yang)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1180226&r1=1180225&r2=1180226&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Fri Oct  7 20:50:21 2011
@@ -2,6 +2,9 @@ Ambari Change log
 
 Release 0.1.0 - unreleased
 
+  AMBARI-46. Implemented preservation of cluster id, blueprint name and
+  blueprint revision on agent. (Eric Yang)
+
   AMBARI-44. Implemented blueprint name and revision in heartbeat. (Eric Yang)
   
   AMBARI-39. Bridged cluster reference gap between REST API with State machine. (Eric Yang)

Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py?rev=1180226&r1=1180225&r2=1180226&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py Fri Oct  7 20:50:21
2011
@@ -24,19 +24,32 @@ import Queue
 import threading
 from FileUtil import writeFile
 from shell import shellRunner
+import json
+import os
 
 logger = logging.getLogger()
 
 class ActionQueue(threading.Thread):
-  global q, r, clusterId, bluePrintName, bluePrintRevision
+  global q, r, clusterId, bluePrintName, bluePrintRevision, checkFile
   q = Queue.Queue()
   r = Queue.Queue()
   clusterId = 'unknown'
   bluePrintName = 'unknown'
   bluePrintRevision = 'unknown'
+  checkFile = '/tmp/blueprint'
 
   def __init__(self):
+    global clusterId, bluePrintName, bluePrintRevision, checkFile
     threading.Thread.__init__(self)
+    if 'AMBARI_LOG_DIR' in os.environ:
+      checkFile = os.environ['AMBARI_LOG_DIR']+"/blueprint"
+    if os.path.exists(checkFile):
+      f = open(checkFile, 'r')
+      data = json.load(f)
+      clusterId = data['clusterId']
+      bluePrintName = data['bluePrintName']
+      bluePrintRevision = data['bluePrintRevision']
+      f.close()
     self.sh = shellRunner()
 
   def put(self, response):
@@ -56,9 +69,20 @@ class ActionQueue(threading.Thread):
                      'RUN_ACTION': self.runAction
                    }
         result = switches.get(action['kind'], self.unknownAction)(action)
-        clusterId = action['clusterId']
-        bluePrintName = action['bluePrintName']
-        bluePrintRevision = action['bluePrintRevision']
+        # Store the blue print check point file
+        if clusterId!=action['clusterId'] or bluePrintName!=action['bluePrintName'] or bluePrintRevision!=action['bluePrintRevision']:
+          clusterId = action['clusterId']
+          bluePrintName = action['bluePrintName']
+          bluePrintRevision = action['bluePrintRevision']
+          output = { 
+                     'clusterId' : clusterId,
+                     'bluePrintName' : bluePrintName,
+                     'bluePrintRevision' : bluePrintRevision
+                   }
+          data = json.dumps(output)
+          info = ['ambari-write-file',os.getuid(),os.getgid(),'0700','/tmp/blueprint',data]
+          writeFile(info)
+        # Update the result
         r.put(result)
 
   def result(self):



Mime
View raw message