فهرست منبع

Merge pull request #1279 from wangkx/gh-1277

Fix gh-1277 problems of Event Scheduler and deschedule

Reviewed-By: Gavin Halliday <ghalliday@hpccsystems.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 13 سال پیش
والد
کامیت
102e85046f

+ 2 - 2
ecl/schedulectrl/scheduleread.cpp

@@ -404,7 +404,7 @@ private:
 
 IScheduleReader * getScheduleReader(char const * serverName, char const * eventName)
 {
-    if(eventName)
+    if(eventName && *eventName)
         return new CBranchScheduleReader(serverName, eventName, false, NULL);
     else
         return new CRootScheduleReader(serverName, false, NULL);
@@ -412,7 +412,7 @@ IScheduleReader * getScheduleReader(char const * serverName, char const * eventN
 
 IScheduleReader * getSubscribingScheduleReader(char const * serverName, IScheduleSubscriber * subscriber, char const * eventName)
 {
-    if(eventName)
+    if(eventName && *eventName)
         return new CBranchScheduleReader(serverName, eventName, true, subscriber);
     else
         return new CRootScheduleReader(serverName, true, subscriber);

+ 34 - 0
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -750,6 +750,38 @@ void WsWuInfo::getRoxieCluster(IEspECLWorkunit &info, unsigned flags)
     }
 }
 
+void WsWuInfo::getEventScheduleFlag(IEspECLWorkunit &info)
+{
+    info.setEventSchedule(0);
+    if (info.getState() && !stricmp(info.getState(), "wait"))
+    {
+        info.setEventSchedule(2); //Can deschedule
+    }
+    else
+    {
+        Owned<IConstWorkflowItemIterator> it = cw->getWorkflowItems();
+        if (it)
+        {
+            ForEach(*it)
+            {
+                IConstWorkflowItem *r = it->query();
+                if (!r)
+                    continue;
+
+                IWorkflowEvent *wfevent = r->getScheduleEvent();
+                if (!wfevent)
+                    continue;
+
+                if (!r->hasScheduleCount() || (r->queryScheduleCountRemaining() > 0))
+                {
+                    info.setEventSchedule(1); //Can reschedule
+                    break;
+                }
+            }
+        }
+    }
+}
+
 void WsWuInfo::getCommon(IEspECLWorkunit &info, unsigned flags)
 {
     SCMStringBuffer s;
@@ -774,6 +806,8 @@ void WsWuInfo::getCommon(IEspECLWorkunit &info, unsigned flags)
     if (cw->isPausing())
         info.setIsPausing(true);
 
+    getEventScheduleFlag(info);
+
     if (version > 1.27)
     {
         StringBuffer totalThorTimeStr;

+ 1 - 0
esp/services/ws_workunits/ws_workunitsHelpers.hpp

@@ -172,6 +172,7 @@ public:
     void getWorkunitDll(MemoryBuffer& buf);
     void getWorkunitXml(const char* plainText, MemoryBuffer& buf);
     void getWorkunitCpp(const char* cppname, const char* description, const char* ipAddress, MemoryBuffer& buf);
+    void getEventScheduleFlag(IEspECLWorkunit &info);
 
 public:
     IEspContext &context;

+ 5 - 3
esp/services/ws_workunits/ws_workunitsService.cpp

@@ -392,6 +392,7 @@ void CWsWorkunitsEx::init(IPropertyTree *cfg, const char *process, const char *s
     wuActionTable.setValue("unprotect", ActionProtect);
     wuActionTable.setValue("restore", ActionRestore);
     wuActionTable.setValue("reschedule", ActionEventSchedule);
+    wuActionTable.setValue("deschedule", ActionEventDeschedule);
     wuActionTable.setValue("settofailed", ActionChangeState);
 
     awusCacheMinutes = AWUS_CACHE_MIN_DEFAULT;
@@ -2517,8 +2518,6 @@ bool CWsWorkunitsEx::onWUShowScheduled(IEspContext &context, IEspWUShowScheduled
         const char *eventName = req.getEventName();
 
         IArrayOf<IEspScheduledWU> results;
-        if(notEmpty(clusterName))
-            getScheduledWUs(context, clusterName, eventName, results);
         if(notEmpty(req.getPushEventName()))
             resp.setPushEventName(req.getPushEventName());
         if(notEmpty(req.getPushEventText()))
@@ -2541,9 +2540,12 @@ bool CWsWorkunitsEx::onWUShowScheduled(IEspContext &context, IEspWUShowScheduled
                 continue;
 
             if(isEmpty(clusterName))
-                getScheduledWUs(context, clusterName, eventName, results);
+                getScheduledWUs(context, iclusterName, eventName, results);
             else if (strieq(clusterName, iclusterName))
+            {
+                getScheduledWUs(context, clusterName, eventName, results);
                 resp.setClusterSelected(i+1);
+            }
 
             Owned<IEspServerInfo> server = createServerInfo("");
             server->setName(iclusterName);