Browse Source

HPCC-18236 Filter Event Scheduled WUs by job name

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 7 years ago
parent
commit
1a385ddc22
2 changed files with 30 additions and 22 deletions
  1. 2 1
      esp/scm/ws_workunits.ecm
  2. 28 21
      esp/services/ws_workunits/ws_workunitsService.cpp

+ 2 - 1
esp/scm/ws_workunits.ecm

@@ -1215,6 +1215,7 @@ ESPrequest [nil_remove] WUShowScheduledRequest
     string PushEventName("");
     string PushEventText("");
     [min_ver("1.51")] string State("");
+    [min_ver("1.71")] string JobName("");
 };
 
 ESPStruct [nil_remove] ScheduledWU
@@ -1933,7 +1934,7 @@ ESPresponse [exceptions_inline, nil_remove] WUGetNumFileToCopyResponse
 
 ESPservice [
     auth_feature("DEFERRED"), //This declares that the method logic handles feature level authorization
-    version("1.70"), default_client_version("1.70"),
+    version("1.71"), default_client_version("1.71"),
     noforms,exceptions_inline("./smc_xslt/exceptions.xslt"),use_method_name] WsWorkunits
 {
     ESPmethod [cache_seconds(60), resp_xsl_default("/esp/xslt/workunits.xslt")]     WUQuery(WUQueryRequest, WUQueryResponse);

+ 28 - 21
esp/services/ws_workunits/ws_workunitsService.cpp

@@ -3614,7 +3614,7 @@ bool CWsWorkunitsEx::onWUResult(IEspContext &context, IEspWUResultRequest &req,
    return true;
 }
 
-void getScheduledWUs(IEspContext &context, const char *stateReq, const char *serverName, const char *eventName, IArrayOf<IEspScheduledWU> & results)
+void getScheduledWUs(IEspContext &context, const char *stateReq, const char *jobNameReq, const char *serverName, const char *eventName, IArrayOf<IEspScheduledWU> & results)
 {
     double version = context.getClientVersion();
     if (notEmpty(serverName))
@@ -3636,33 +3636,39 @@ void getScheduledWUs(IEspContext &context, const char *stateReq, const char *ser
                     it->getWuid(wuid);
                     if (wuid.length())
                     {
-                        bool match = false;
+                        bool match = true;
                         unsigned stateID = WUStateUnknown;
                         StringBuffer jobName, owner;
                         SCMStringBuffer state;
                         try
                         {
                             Owned<IConstWorkUnit> cw = factory->openWorkUnit(wuid.str());
-                            if (!cw && (!stateReq || !*stateReq))
-                            	match = true;
-                            else if (cw)
+                            if (cw)
                             {
-                                if ((cw->getState() == WUStateScheduled) && cw->aborting())
-                                {
-                                    stateID = WUStateAborting;
-                                    state.set("aborting");
-                                }
-                                else
-                                {
-                                    stateID = cw->getState();
-                                    state.set(cw->queryStateDesc());
-                                }
+                                jobName.set(cw->queryJobName());
+                                owner.set(cw->queryUser());
+                            }
 
-                                if (!stateReq || !*stateReq || strieq(stateReq, state.str()))
+                            if (!isEmptyString(jobNameReq) && (jobName.isEmpty() || !WildMatch(jobName.str(), jobNameReq, true)))
+                                match =  false;
+                            else if (!isEmptyString(stateReq))
+                            {
+                                if (!cw)
+                                    match =  false;
+                                else
                                 {
-                                    match = true;
-                                    jobName.set(cw->queryJobName());
-                                    owner.set(cw->queryUser());
+                                    if ((cw->getState() == WUStateScheduled) && cw->aborting())
+                                    {
+                                        stateID = WUStateAborting;
+                                        state.set("aborting");
+                                    }
+                                    else
+                                    {
+                                        stateID = cw->getState();
+                                        state.set(cw->queryStateDesc());
+                                    }
+                                    if (!strieq(stateReq, state.str()))
+                                        match =  false;
                                 }
                             }
                         }
@@ -3670,6 +3676,7 @@ void getScheduledWUs(IEspContext &context, const char *stateReq, const char *ser
                         {
                             EXCLOG(e, "Get scheduled WUs");
                             e->Release();
+                            match =  false;
                         }
                         if (!match)
                         {
@@ -3741,10 +3748,10 @@ bool CWsWorkunitsEx::onWUShowScheduled(IEspContext &context, IEspWUShowScheduled
                 continue;
 
             if(isEmpty(clusterName))
-                getScheduledWUs(context, state, iclusterName, eventName, results);
+                getScheduledWUs(context, state, req.getJobName(), iclusterName, eventName, results);
             else if (strieq(clusterName, iclusterName))
             {
-                getScheduledWUs(context, state, clusterName, eventName, results);
+                getScheduledWUs(context, state, req.getJobName(), clusterName, eventName, results);
                 resp.setClusterSelected(i+1);
             }