Przeglądaj źródła

Merge pull request #4050 from ghalliday/issue8901

HPCC-8901 Add priorityValue to the workunit information

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 12 lat temu
rodzic
commit
524ef820f9

+ 10 - 4
common/workunit/workunit.cpp

@@ -1765,7 +1765,7 @@ static int getEnum(const char *v, mapEnums *map)
     return 0;
 }
 
-static int getEnum(IPropertyTree *p, const char *propname, mapEnums *map) 
+static int getEnum(const IPropertyTree *p, const char *propname, mapEnums *map)
 {
     return getEnum(p->queryProp(propname),map);
 }
@@ -3909,10 +3909,9 @@ int CLocalWorkUnit::getPriorityLevel() const
     return p->getPropInt("PriorityFlag"); 
 }
 
-int CLocalWorkUnit::getPriorityValue() const 
+int calcPriorityValue(const IPropertyTree * p)
 {
-    CriticalBlock block(crit);
-    int priority = p->getPropInt("PriorityFlag"); 
+    int priority = p->getPropInt("PriorityFlag");
     switch((WUPriorityClass) getEnum(p, "@priorityClass", priorityClasses))
     {
     case PriorityClassLow:
@@ -3925,6 +3924,13 @@ int CLocalWorkUnit::getPriorityValue() const
     return priority;
 }
 
+
+int CLocalWorkUnit::getPriorityValue() const 
+{
+    CriticalBlock block(crit);
+    return calcPriorityValue(p);
+}
+
 void CLocalWorkUnit::setRescheduleFlag(bool value) 
 {
     CriticalBlock block(crit);

+ 1 - 0
common/workunit/workunit.hpp

@@ -1210,6 +1210,7 @@ enum WUQueryActivationOptions
     MAKE_ACTIVATE_LOAD_DATA_ONLY = 5
 };
 
+extern WORKUNIT_API int calcPriorityValue(const IPropertyTree * p);  // Calls to this should really go through the workunit interface.
 
 extern WORKUNIT_API IPropertyTree * addNamedQuery(IPropertyTree * queryRegistry, const char * name, const char * wuid, const char * dll, bool library, const char *userid);       // result not linked
 extern WORKUNIT_API void removeNamedQuery(IPropertyTree * queryRegistry, const char * id);

+ 22 - 0
ecl/regress/issue8901.ecl

@@ -0,0 +1,22 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+import std.system.Workunit as wu;
+#workunit('priority', 1);
+#workunit('priority', 'high');
+output(wu.workunitlist(Workunit));
+

+ 1 - 0
plugins/workunitservices/workunitservices.cpp

@@ -67,6 +67,7 @@ static const char * EclDefinition =
                             " string job{maxlength(256)};"
                             " string10 state;"
                             " string7 priority;"
+                            " integer2 priorityvalue;"
                             " string20 created;"
                             " string20 modified;"
                             " boolean online;"

+ 4 - 0
plugins/workunitservices/workunitservices.ipp

@@ -57,6 +57,7 @@ inline void varAppend(MemoryBuffer &mb,unsigned w,IPropertyTree &pt,const char *
 
 inline bool serializeWUSrow(IPropertyTree &pt,MemoryBuffer &mb, bool isonline)
 {
+    mb.setEndian(__LITTLE_ENDIAN);
     fixedAppend(mb,24,pt.queryName());
     varAppend(mb,64,pt,"@submitID");
     varAppend(mb,64,pt,"@clusterName");
@@ -64,6 +65,9 @@ inline bool serializeWUSrow(IPropertyTree &pt,MemoryBuffer &mb, bool isonline)
     varAppend(mb,256,pt,"@jobName");
     fixedAppend(mb,10,pt,"@state");
     fixedAppend(mb,7,pt,"@priorityClass");
+    short int prioritylevel = calcPriorityValue(&pt);
+    mb.appendEndian(sizeof(prioritylevel), &prioritylevel);
+
     const char *mod = "TimeStamps/TimeStamp[@application=\"workunit\"]/Modified";
     const char *crt = "TimeStamps/TimeStamp[@application=\"workunit\"]/Created";
     fixedAppend(mb,20,pt,crt);