Переглянути джерело

HPCC-8717 Revise based on review comments

Signed-off-by: Kevin Wang <kevin.wang@lexisnexis.com>
Kevin Wang 12 роки тому
батько
коміт
59bdefc0af

+ 8 - 9
common/workunit/wujobq.cpp

@@ -1143,9 +1143,8 @@ public:
     }
 
 
-    unsigned copyItems(sQueueData &qd,CJobQueueContents &dest)
+    unsigned copyItemsImpl(sQueueData &qd,CJobQueueContents &dest)
     {
-        Cconnlockblock block(this,false);
         unsigned ret=0;
         StringBuffer path;
         for (unsigned i=0;;i++) {
@@ -1158,19 +1157,19 @@ public:
         return ret;
     }
 
+    unsigned copyItems(sQueueData &qd,CJobQueueContents &dest)
+    {
+        Cconnlockblock block(this,false);
+        return copyItemsImpl(qd,dest);
+    }
+
     void copyItemsAndState(CJobQueueContents& contents, StringBuffer& state)
     {
         assertex(qdata);
         Cconnlockblock block(this,false);
         assertex(qdata->root);
 
-        StringBuffer path;
-        for (unsigned i=0;;i++) {
-            IPropertyTree *item = qdata->root->queryPropTree(getItemPath(path.clear(),i).str());
-            if (!item)
-                break;
-            contents.append(*new CJobQueueItem(item));
-        }
+        copyItemsImpl(*qdata,contents);
 
         const char *st = qdata->root->queryProp("@state");
         if (st&&*st)

+ 15 - 15
esp/services/ws_smc/ws_smcService.cpp

@@ -238,7 +238,7 @@ void addQueuedWorkUnits(const char *queueName, CJobQueueContents &contents, IArr
     }
 }
 
-void CWsSMCEx::getQueueState(int runningJobsInQueue, StringBuffer& queueState, int& colorType)
+void CWsSMCEx::getQueueState(int runningJobsInQueue, StringBuffer& queueState, BulletType& bulletType)
 {
     bool queuePausedOrStopped = false;
     if ((queueState.length() > 0) && (strieq(queueState.str(),"stopped") || strieq(queueState.str(),"paused")))
@@ -249,19 +249,19 @@ void CWsSMCEx::getQueueState(int runningJobsInQueue, StringBuffer& queueState, i
     if (NotFound == runningJobsInQueue)
     {
         if (queuePausedOrStopped)
-            colorType = 3; //show bullet_white.png
+            bulletType = bulletWhite; //show bullet_white.png
         else
-            colorType = 5; //show bullet_error.png
+            bulletType = bulletError; //show bullet_error.png
     }
     else if (runningJobsInQueue > 0)
     {
         if (queuePausedOrStopped)
-            colorType = 1; //show bullet_orange.png
+            bulletType = bulletOrange; //show bullet_orange.png
         else
-            colorType = 4; //show bullet_green.png
+            bulletType = bulletGreen; //show bullet_green.png
     }
     else if (queuePausedOrStopped)
-        colorType = 2; //show bullet_yellow.png
+        bulletType = bulletYellow; //show bullet_yellow.png
 
     return;
 }
@@ -510,13 +510,13 @@ bool CWsSMCEx::onActivity(IEspContext &context, IEspActivityRequest &req, IEspAc
                 queue->copyItemsAndState(contents, queueState);
                 addQueuedWorkUnits(queueName, contents, aws, context, "ThorMaster", NULL);
 
-                int colorType = 6; //show bullet_green.png
+                BulletType bulletType = bulletGreen; //show bullet_green.png
                 int serverID = runningQueueNames.find(queueName);
                 int numRunningJobsInQueue = (NotFound != serverID) ? runningJobsInQueue[serverID] : -1;
-                getQueueState(numRunningJobsInQueue, queueState, colorType);
+                getQueueState(numRunningJobsInQueue, queueState, bulletType);
                 returnCluster->setQueueStatus(queueState.str());
                 if (version > 1.06)
-                    returnCluster->setQueueStatus2(colorType);
+                    returnCluster->setQueueStatus2(bulletType);
                 if (version > 1.10)
                     returnCluster->setClusterSize(cluster.getSize());
 
@@ -540,12 +540,12 @@ bool CWsSMCEx::onActivity(IEspContext &context, IEspActivityRequest &req, IEspAc
                     queue->copyItemsAndState(contents, queueState);
                     addQueuedWorkUnits(queueName, contents, aws, context, "RoxieServer", NULL);
 
-                    int colorType = 6; //show bullet_green.png
+                    BulletType bulletType = bulletGreen; //show bullet_green.png
                     int serverID = runningQueueNames.find(queueName);
                     int numRunningJobsInQueue = (NotFound != serverID) ? runningJobsInQueue[serverID] : -1;
-                    getQueueState(numRunningJobsInQueue, queueState, colorType);
+                    getQueueState(numRunningJobsInQueue, queueState, bulletType);
                     returnCluster->setQueueStatus(queueState.str());
-                    returnCluster->setQueueStatus2(colorType);
+                    returnCluster->setQueueStatus2(bulletType);
                     if (version > 1.10)
                         returnCluster->setClusterSize(cluster.getSize());
 
@@ -567,12 +567,12 @@ bool CWsSMCEx::onActivity(IEspContext &context, IEspActivityRequest &req, IEspAc
                 queue->copyItemsAndState(contents, queueState);
                 addQueuedWorkUnits(queueName, contents, aws, context, "HThorServer", NULL);
 
-                int colorType = 6; //show bullet_green.png
+                BulletType bulletType = bulletGreen; //show bullet_green.png
                 int serverID = runningQueueNames.find(queueName);
                 int numRunningJobsInQueue = (NotFound != serverID) ? runningJobsInQueue[serverID] : -1;
-                getQueueState(numRunningJobsInQueue, queueState, colorType);
+                getQueueState(numRunningJobsInQueue, queueState, bulletType);
                 returnCluster->setQueueStatus(queueState.str());
-                returnCluster->setQueueStatus2(colorType);
+                returnCluster->setQueueStatus2(bulletType);
                 HThorClusters.append(*returnCluster);
             }
         }

+ 11 - 1
esp/services/ws_smc/ws_smcService.hpp

@@ -22,6 +22,16 @@
 #include "TpWrapper.hpp"
 #include "WUXMLInfo.hpp"
 
+enum BulletType
+{
+    NONE = 0,
+    bulletOrange = 1,
+    bulletYellow = 2,
+    bulletWhite = 3,
+    bulletGreen = 4,
+    bulletError = 5
+};
+
 class CWsSMCEx : public CWsSMC
 {
     long m_counter;
@@ -69,7 +79,7 @@ private:
     void addToRoxieClusterList(IArrayOf<IEspRoxieCluster>& clusters, IEspRoxieCluster* cluster, const char* sortBy, bool descending);
     void addServerJobQueue(IArrayOf<IEspServerJobQueue>& jobQueues, const char* queueName, const char* serverName, const char* serverType);
     void addServerJobQueue(IArrayOf<IEspServerJobQueue>& jobQueues, const char* queueName, const char* queueState, const char* serverName, const char* serverType);
-    void getQueueState(int runningJobsInQueue, StringBuffer& queueState, int& colorType);
+    void getQueueState(int runningJobsInQueue, StringBuffer& queueState, BulletType& colorType);
 };