HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_Scheduler.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  */
8 
9 #ifndef __PDG_SCHEDULER_H__
10 #define __PDG_SCHEDULER_H__
11 
12 #include "PDG_API.h"
13 
14 #include "PDG_AttributeFile.h"
15 #include "PDG_AttributePrimitive.h"
16 #include "PDG_BatchWorkItem.h"
17 #include "PDG_CookOptions.h"
18 #include "PDG_EventEmitter.h"
19 #include "PDG_EventTypes.h"
20 #include "PDG_File.h"
21 #include "PDG_FileUtils.h"
22 #include "PDG_NodeInterface.h"
23 #include "PDG_SchedulerTypes.h"
24 #include "PDG_WorkItemSort.h"
25 
26 #include <PDGT/PDGT_ValueArgs.h>
27 
28 #include <UT/UT_Array.h>
31 #include <UT/UT_ConcurrentQueue.h>
32 #include <UT/UT_ConcurrentSet.h>
33 #include <UT/UT_Map.h>
34 #include <UT/UT_Options.h>
35 #include <UT/UT_StringArray.h>
36 #include <UT/UT_StringHolder.h>
37 #include <UT/UT_TBBSpinLock.h>
38 
39 #include <time.h>
40 
41 class PDG_CookState;
42 class PDG_GraphContext;
43 class PDG_Node;
44 class PDG_Service;
45 class PDG_SchedulerType;
46 class PDG_WorkItem;
47 
48 class UT_JSONValue;
49 class UT_JSONWriter;
50 
51 namespace PDGN
52 {
53 class PDGN_PollingClientNNG;
54 }
55 
56 /*
57  * Base class for scheduler nodes, which process work items and run them
58  * either in process or out of process
59  */
61  public PDG_EventEmitter,
62  public PDG_TypeInstance,
64 {
65 public:
66  /*
67  * Enumeration of possible return values from onScheduler callback
68  */
70  {
71  /// The work item was cooked, and should be marked as canceled
73 
74  /// The work item was cooked, and should be marked as failed
76 
77  /// The work item was cooked, and should be marked as succeeded
79 
80  /// The call to schedule the work item failed
82 
83  /// The call to schedule the work item succeeded
85 
86  /// The scheduler cannot handle the work item at this time
88 
89  /// The scheduler cannot handle any work items at this time, and
90  /// all further scheduling requests will be deferred
91  eFullDeferred
92  };
93 
94  /*
95  * Enumeration of possible return values from onTick callback
96  */
98  {
99  /// The scheduler is ready to accept work items
101 
102  /// The scheduler is busy, and cannot process additional work items
104 
105  /// The scheduler has encountered some sort of fatal error or request
106  /// to cancel, and will not longer accept work items for the remainder
107  /// of the cook.
108  eSchedulerCancelCook
109  };
110 
111  /*
112  * Enumeration of possible return values from onAcceptWorkItem callback
113  */
115  {
116  /// The scheduler is able to handle the specified work item
118 
119  /// The scheduler is not able to handle the specified work item
121 
122  /// The scheduler cannot tell if can/can't schedule the specified
123  /// work item, and the default logic for checking should be used
124  /// instead
125  eSchedulerDefault
126  };
127 
128  /*
129  * Enumeration of work item data transfer modes
130  */
132  {
133  /// Work item data is transfered to the farm using a shared
134  /// drive, by writing it to .json file on disk.
136 
137  /// Work item data is transfered via RPC
138  eSourceRPCMessage
139  };
140 
141  /*
142  * Enumeration of temp dir cleanup options
143  */
145  {
146  /// The temp file dir is not cleaned up automatically
148 
149  /// The temp file dir is cleaned up when the scheduler is removed or
150  /// the session shuts down
152 
153  /// The temp file dir is cleaned up after the scheduler finishes
154  /// cooking
155  eCleanupCook
156  };
157 
158 public:
160  const PDG_BaseType* type,
161  const PDGT_ValueArgs& extra_args,
162  const UT_StringHolder& name);
163  ~PDG_Scheduler() override;
164 
165  /// Returns the list of supported event types
166  const PDG_EventFilter& supportedEventTypes() const override;
167 
168  int64 getMemoryUsage(bool inclusive) const override;
169 
170  /// Debug name method, required by PDGE_DependencyOwner
171  UT_StringHolder debugName() const override
172  { return name(); }
173 
174  /// Resets the dependency owner
175  void resetOwner() override;
176 
177  /// Returns the is cooked dep for this scheduler
179  { return &myIsCookedDep; }
180 
181  /// Returns the is cooked dep for this scheduler
183  { return &myIsSetupDep; }
184 
185  /// Returns the name of the shceudler
186  const UT_StringHolder& name() const
187  { return myName; }
188 
189  /// Called when the type object should reload itself because of a change
190  /// to the underlying Python module
191  bool reloadInstance(UT_WorkBuffer& errors) override;
192 
193  /// Returns the node interface/template that describes the default
194  /// parameters and connections for the scheduler
195  const PDG_NodeInterface* templateInterface() const override;
196 
197  /// Returns the type object that defines the scheduler
198  const PDG_SchedulerType* typeObject() const;
199 
200  /// Returns true if the scheduler is able to queue the specified work item,
201  /// else false.
202  bool canSchedule(const PDG_WorkItem* work_item);
203 
204  /// Called when the scheduler should process a static dependency graph
205  virtual void onScheduleStatic(
206  const PDG_WorkItemMap& dependencies,
207  const PDG_WorkItemMap& dependents,
208  const PDG_WorkItemArray& ready_items) = 0;
209 
210  /// Called whenever the scheduler should schedule a work item. This is a
211  /// required callback.
212  virtual ScheduleResult onSchedule(PDG_WorkItem* work_item) = 0;
213 
214  /// Called when a specific work item should be canceled
215  virtual void onCancelWorkItems(
216  const PDG_WorkItemArray& work_item,
217  PDG_Node* node) = 0;
218 
219  /// Called when the scheduler is first started, should be used to initialize
220  /// scheduler state, threads, etc. This is an optional callback.
221  virtual bool onStart() = 0;
222 
223  /// Called when the scheduler is stopped, to clean up any resources held
224  /// by the scheduler (sockets, threads, etc). Optional callback.
225  virtual bool onStop() = 0;
226 
227  /// Called when cooking begins
228  virtual bool onStartCook(
229  bool static_cook,
230  const PDG_NodeSet&) = 0;
231 
232  /// Called when cooking completes or is canceled
233  virtual bool onStopCook(bool cancel) = 0;
234 
235  /// Called once at the start of the cook, to allow the scheduler to
236  /// set any custom cook options
237  virtual void onConfigureCook(
238  PDG_CookOptions* cook_ptions) = 0;
239 
240  /// Called at the before cooking on the background thread to setup
241  /// anything needed for a cook.
242  virtual bool onSetupCook() = 0;
243 
244  /// Called periodically during cooking to update state
245  virtual TickResult onTick() = 0;
246 
247  /// Returns an enum indicating whether or not the scheduler accepts the
248  /// specified work item
249  virtual AcceptResult onAcceptWorkItem(
250  const PDG_WorkItem* work_item) = 0;
251 
252  /// Custom file transfer logic, implemented per-scheduler
253  virtual bool onTransferFile(
254  const UT_StringHolder& file_path);
255 
256  /// Transfers a file for a work item that uses this scheduler, using the
257  /// transfer settings on the scheduler itself.
258  bool transferFile(
259  const PDG_WorkItem* work_item,
260  const PDG_File& file,
261  PDG_FileUtils::TransferType default_type,
262  bool check_type,
263  UT_WorkBuffer& errors) const;
264 
265  /// Transfers a file from the local machine to the machine that will be
266  /// executing processor tasks, e.g. a remote machine on the farm.
267  bool transferFile(
268  const UT_StringHolder& file_path,
269  PDG_FileUtils::TransferType default_type,
270  bool check_type,
271  UT_WorkBuffer& errors) const;
272 
273  /// Transfers a file from the local machine to the machine that will be
274  /// executing processor tasks, e.g. a remote machine on the farm. This
275  /// variant of the method preserves the directory structure relative to
276  /// the specified root directory
277  bool transferFile(
278  const UT_StringHolder& root_path,
279  const UT_StringHolder& file_path,
280  const UT_StringHolder& sub_path,
281  PDG_FileUtils::TransferType default_type,
282  bool check_type,
283  UT_WorkBuffer& errors) const;
284 
285  /// Returns the path on the scheduler that a local file will be copied
286  /// to, using the standard file transfer mechanism
287  UT_StringHolder formatTransferPath(
288  const UT_StringHolder& local_path,
289  PDG_FileUtils::TransferType default_type,
290  bool local,
291  bool check_type) const;
292 
293  /// Returns the path on the scheduler that a local file will be copied
294  /// to. Unlike the above method, this method preserves the directory
295  /// structure relative to the specified root directory
296  UT_StringHolder formatTransferPath(
297  const UT_StringHolder& root_path,
298  const UT_StringHolder& local_path,
299  const UT_StringHolder& sub_path,
300  PDG_FileUtils::TransferType default_type,
301  bool local,
302  bool check_type) const;
303 
304  /// Returns the local version of the given path.
305  UT_StringHolder localizePath(
306  const UT_StringHolder& deloc_path) const;
307 
308  /// Returns the delocalized (remote) version of the given local path.
309  UT_StringHolder delocalizePath(
310  const UT_StringHolder& local_path) const;
311 
312  /// Returns the job name for the specified work item
313  UT_StringHolder jobName(const PDG_WorkItem* work_item) const;
314 
315  /// Expands special tokens in the command string
316  virtual UT_StringHolder expandCommandTokens(
317  const UT_StringHolder& command,
318  const PDG_WorkItem* work_item) = 0;
319 
320  /// cook the output node in the graph context of the given file as a single job
321  virtual UT_StringHolder submitAsJob(
322  const UT_StringHolder& graph_file,
323  const UT_StringHolder& node_name) = 0;
324 
325  /// set the working directory local and network path, equivalent
326  /// to the __PDG_DIR__
327  void setWorkingDir(
328  const UT_StringHolder& local_path,
329  const UT_StringHolder& remote_path);
330  /// set the temp directory local and network path, equivalent
331  /// to the __PDG_TEMP__
332  void setTempDir(
333  const UT_StringHolder& local_path,
334  const UT_StringHolder& remote_path);
335  /// set the script directory local and network path, equivalent
336  /// to the __PDG_SCRIPTDIR__
337  void setScriptDir(
338  const UT_StringHolder& local_path,
339  const UT_StringHolder& remote_path);
340 
341  /// sets whether or not the scheduler accepts in-process work items
342  void setAcceptInProcess(bool in_process);
343 
344  /// returns the working directory (network) path, equivalent
345  /// to the __PDG_DIR__ command token when local is false.
346  /// When local is true, returns the absolute path to the shared root
347  /// on the local file system
348  UT_StringHolder workingDir(bool local) const;
349 
350  /// returns the temp directory (network) path, equivalent
351  /// to the __PDG_TEMP__ command token when local is false.
352  /// When local is true, returns the absolute path to the shared temp
353  /// on the local file system
354  UT_StringHolder tempDir(bool local) const;
355 
356  /// returns the temp script directory (network) path, equivalent
357  /// to the __PDG_SCRIPTDIR__ command token when local is false.
358  /// When local is true, returns the absolute path to the temp
359  /// script on the local file system
360  UT_StringHolder scriptDir(bool local) const;
361 
362  /// Returns the path to the directory where log files generated during the
363  /// cook should be written.
364  /// When local is true, returns the aboslute path on the local file system.
365  UT_StringHolder logDir(bool local) const;
366 
367  /// Returns the path to the directory where work items are serialized
368  /// before their commands are executed.
369  /// When local is true, returns the aboslute path on the local file system.
370  UT_StringHolder dataDir(bool local) const;
371 
372  /// Returns the path to an application for the given name, for example
373  /// "python", "hython"
374  virtual UT_StringHolder applicationBin(
375  const UT_StringHolder& name,
376  const PDG_WorkItem* work_item);
377 
378  /// returns the server endpoint for work item results, in format <HOST>:<PORT>,
379  /// equivalent to the __PDG_RESULT_SERVER__ command token
380  virtual UT_StringHolder workItemResultServerAddr() = 0;
381 
382  /// returns a URI for the workitem cook log (text file)
383  virtual UT_StringHolder getLogURI(const PDG_WorkItem* work_item) = 0;
384 
385  /// returns a URI for the workitem status page if relevant
386  virtual UT_StringHolder getStatusURI(const PDG_WorkItem* work_item) = 0;
387 
388  /// Terminate the give shared server
389  virtual bool endSharedServer(
390  const UT_StringHolder& sharedserver_name) = 0;
391  /// Clears metadata associated with the given shared server name
392  virtual void clearSharedServerInfo(
393  const UT_StringHolder &sharedserver_name);
394  /// Sets metadata associated with the given shared server name, returns full name
395  virtual UT_StringHolder setSharedServerInfo(
396  const UT_StringHolder &sharedserver_name,
397  const PDGT_ValueArgs& info);
398  /// Gets metadata associated with the given shared server name
399  PDGT_ValueArgs getSharedServerInfo(
400  const UT_StringHolder &sharedserver_name);
401  /// Gets the list of shared servers
402  UT_StringArray getSharedServers();
403 
404  /// Delete the temporary directory and all its contents
405  virtual void cleanTempDirectory();
406 
407  /// Called to stop the scheduler
408  void stop(bool exiting);
409 
410  /// Called when a cook begins with the cook state data for that cook
411  bool startCook(PDG_CookState& cook_state);
412 
413  /// Called when a cook stops
414  void stopCook();
415 
416  /// Cancels an active cook
417  void cancelCook(bool pause);
418 
419  /// Ticks the scheduler
420  bool tick(PDG_Scheduler::TickResult& tick_result);
421 
422  /// Cooks a specific work item using it's internal cook method
423  bool cookWorkItem(PDG_WorkItem* work_item);
424 
425 
426  /// Submits a static cook with this scheduler
427  void submitStatic();
428 
429 
430  /// Queues a work item and returns a state that represents the result of
431  /// the operation
432  virtual PDG_WorkItemState queueWorkItem(PDG_WorkItem* work_item);
433 
434  /// Removes a work item from any internal tracking lists
435  void removeWorkItem(const PDG_WorkItem* work_item);
436 
437 
438  /// Cancels a cook for a specific work tiem
439  bool cancelWorkItem(PDG_WorkItem* work_item);
440 
441  /// Cancels a cook for a specific node
442  void cancelNode(PDG_Node* node);
443 
444  void onWorkItemPriorityChanged(
445  PDG_WorkItem* work_item);
446  void process(bool skip_ready_items);
447 
448  bool isRunning(int count=0);
449  bool isRunning(const PDG_WorkItem* work_item);
450  bool isDefault();
451 
452  bool isWaitForFailures() const;
453  bool isValidateOutputFiles() const;
454  bool isCheckExpectedOutputFiles() const;
455  bool isCompressWorkItemData() const;
456  virtual PDGN::PDGN_PollingClientNNG*
457  getPollingClient() { return nullptr; }
458 
459  WorkItemDataSource workItemDataSource() const;
460 
461  int numRunningItems() const;
462  int numFailedItems() const;
463  int numQueuedItems() const;
464 
465  void setContext(PDG_GraphContext* context);
466  PDG_GraphContext* context() const;
467 
468  void dependencyGraph(
469  PDG_WorkItemMap& dependencies,
470  PDG_WorkItemMap& dependents,
471  PDG_WorkItemArray& ready,
472  bool expand);
473 
474  /// Starts a service using this scheduler
475  virtual bool startService(
476  UT_WorkBuffer& errors,
477  PDG_Service* service)
478  { return false; }
479 
480  /// Stops a service that was started with this scheduler
481  virtual bool stopService(
482  UT_WorkBuffer& errors,
483  PDG_Service* service,
484  bool cancel)
485  { return false; }
486 
487  /// Starts a job for the specified service client
488  virtual bool startServiceClient(
489  UT_WorkBuffer& errors,
490  PDG_Service* service,
491  PDG_ServiceClient* client)
492  { return false; }
493 
494  /// Stops the job associated with a specific client process
495  virtual bool stopServiceClient(
496  UT_WorkBuffer& errors,
497  PDG_Service* service,
498  PDG_ServiceClient* client)
499  { return false; }
500 
501  template <typename T, typename D=T>
503  T& result,
504  PDG_NodeInterface* node,
505  const UT_StringHolder& prefix,
506  const UT_StringHolder& parm,
507  PDG_WorkItem* work_item,
508  const D& default_value,
509  UT_WorkBuffer& errors) const
510  {
511  UT_WorkBuffer parm_name;
512  UT_WorkBuffer toggle_name;
513 
514  if (prefix.isstring() && prefix.length() > 0)
515  {
516  toggle_name.format("{}_override_toggle", templateName());
517  parm_name.format("{}_{}", prefix, parm);
518  }
519  else
520  {
521  parm_name.append(parm);
522  }
523 
524  // If the user supplied us with a batch item, evaluate against the first
525  // sub item instead
526  PDG_WorkItem* eval_work_item = work_item;
527  if (work_item && work_item->isBatch())
528  {
529  auto batch_item =
530  static_cast<PDG_BatchWorkItem*>(work_item);
531  if (batch_item->batchSize() > 0)
532  eval_work_item = batch_item->batchItems()[0];
533  }
534 
535  result = default_value;
536  PDG_Port* port = parameter(parm_name.buffer());
537  if (port)
538  {
539  if (!port->evaluate(0, result, eval_work_item, errors))
540  return false;
541  }
542 
543  if (!node)
544  return true;
545 
546  port = node->parameter(toggle_name.buffer());
547 
548  if (port)
549  {
550  exint toggle_result;
551  port->evaluate(0, toggle_result, eval_work_item, errors);
552 
553  if (toggle_result < 1)
554  return true;
555  }
556 
557  port = node->parameter(parm_name.buffer());
558  if (port)
559  {
560  if (!port->evaluate(0, result, eval_work_item, errors))
561  return false;
562  }
563 
564  return true;
565  }
566 
567 
568  void onWorkItemSetStringArray(
569  PDG_WorkItemID work_item_id,
570  int index,
571  const UT_StringHolder& attribute_name,
573  void onWorkItemSetFloatArray(
574  PDG_WorkItemID work_item_id,
575  int index,
576  const UT_StringHolder& attribute_name,
578  void onWorkItemSetIntArray(
579  PDG_WorkItemID work_item_id,
580  int index,
581  const UT_StringHolder& attribute_name,
583  void onWorkItemSetFileArray(
584  PDG_WorkItemID work_item_id,
585  int index,
586  const UT_StringHolder& attribute_name,
588  void onWorkItemSetDictArray(
589  PDG_WorkItemID work_item_id,
590  int index,
591  const UT_StringHolder& attribute_name,
593 
594  void onWorkItemSetPyObject(
595  PDG_WorkItemID work_item_id,
596  int index,
597  const UT_StringHolder& attribute_name,
598  const UT_StringHolder& pyobject_repr);
599  void onWorkItemSetString(
600  PDG_WorkItemID work_item_id,
601  int index,
602  const UT_StringHolder& attribute_name,
603  const UT_StringHolder& value,
604  int attrib_index);
605  void onWorkItemSetFloat(
606  PDG_WorkItemID work_item_id,
607  int index,
608  const UT_StringHolder& attribute_name,
609  fpreal value,
610  int attrib_index);
611  void onWorkItemSetInt(
612  PDG_WorkItemID work_item_id,
613  int index,
614  const UT_StringHolder& attribute_name,
615  exint value,
616  int attrib_index);
617  void onWorkItemSetFile(
618  PDG_WorkItemID work_item_id,
619  int index,
620  const UT_StringHolder& attribute_name,
622  int attrib_index);
623  void onWorkItemSetDict(
624  PDG_WorkItemID work_item_id,
625  int index,
626  const UT_StringHolder& attribute_name,
627  const UT_OptionsHolder& dict_repr,
628  int attrib_index);
629 
630  void onWorkItemAddOutput(
631  PDG_WorkItemID work_item_id,
632  int index,
633  const UT_StringHolder& path,
634  const UT_StringHolder& tag,
635  PDG_File::Hash hash_code,
636  bool active_only);
637  void onWorkItemAddOutputs(
638  PDG_WorkItemID work_item_id,
639  int index,
640  const UT_StringArray& paths,
641  const UT_StringHolder& tags,
642  const PDG_File::HashArray& hashes,
643  bool active_only);
644  void onWorkItemAddOutputs(
645  PDG_WorkItemID work_item_id,
646  int index,
647  const UT_StringArray& paths,
648  const UT_StringArray& tags,
649  const PDG_File::HashArray& hashes,
650  bool active_only);
651  void onWorkItemInvalidateCache(
652  PDG_WorkItemID work_item_id,
653  int index);
654 
655  void onWorkItemSucceeded(
656  PDG_WorkItemID work_item_id,
657  int index,
658  fpreal cook_duration);
659  void onWorkItemFailed(
660  PDG_WorkItemID work_item_id,
661  int index);
662  void onWorkItemCanceled(
663  PDG_WorkItemID work_item_id,
664  int index);
665  void onWorkItemStartCook(
666  PDG_WorkItemID work_item_id,
667  int index,
668  bool clear_outputs);
669 
670  void onWorkItemSetCustomState(
671  PDG_WorkItemID work_item_id,
672  int index,
673  const UT_StringHolder& custom_state);
674  void onWorkItemSetCookPercent(
675  PDG_WorkItemID work_item_id,
676  int index,
677  fpreal &cook_percent);
678  void onWorkItemAppendLog(
679  PDG_WorkItemID work_item_id,
680  int index,
681  const UT_StringHolder& log_data,
682  PDG_WorkItemLogType log_type);
683 
684  PDG_WorkItemEvalState isWorkItemReady(
685  PDG_WorkItemID work_item_id,
686  int index);
687 
688  /// Emits errors or warnings from the scheduler as PDG_Events
689  void addError(
690  const UT_StringHolder& message) const override;
691  void addWarning(
692  const UT_StringHolder& message) const override;
693 
694  /// Writes the current parameter value configuration of this scheduler
695  /// to JSON
696  bool asJSON(
697  UT_JSONWriter& writer,
698  bool skip_defaults) const;
699 
700  /// Reads and constructs a scheduler from JSON and returns the instance
701  static PDG_Scheduler* fromJSON(
702  const UT_JSONValue* value,
703  PDG_GraphContext* context,
704  UT_WorkBuffer& errors);
705 
706  virtual fpreal tickPeriod() const;
707  virtual int maxItemsPerTick() const;
708  virtual int maxConcurrentTasks() const;
709 
710  PDG_PathMappingMode mapMode() const;
711 
712  PDG_FileTransferType transferType() const;
713  UT_StringHolder transferRoot() const;
714 
715 protected:
716  /// Find the workitem and report error if not found
717  PDG_WorkItem* workItemChecked(
718  PDG_WorkItemID work_item_id,
719  int index);
720 
722  PDGE_Resolutions& resolutions,
723  const PDGE_Evaluator& evaluator,
724  PDGE_Dependency* dependency) override;
725 
726 private:
727  struct Result
728  {
729  PDG_WorkItemState myState;
730  PDG_WorkItemID myId;
731  fpreal myDuration;
732  int myIndex;
733  bool myUnresolve;
734  };
735 
736  using ResultMap = UT_Map<PDG_WorkItemID, Result>;
737  using ResultQueue = UT_ConcurrentQueue<Result>;
738 
739  using PriorityQueue =
742  using WorkItemSet = UT_ConcurrentSet<PDG_WorkItemID>;
743  using NodeSet = UT_ConcurrentSet<PDG_Node*>;
744  using SharedServerInfoMap =
746 
747  /// The key for the name of the scheduler when writing it to JSON
748  static const UT_StringHolder theNameKey;
749 
750  /// The key for the type of the scheduler when writing it to JSON
751  static const UT_StringHolder theTypeKey;
752 
753  /// The key for the parameters of the scheduler when writing them to JSON
754  static const UT_StringHolder theParametersKey;
755 
756 private:
757  ScheduleResult schedule(
758  PDG_WorkItem* work_item,
759  UT_Array<Result>& pending);
760  int markCompleted(
761  const Result& result,
762  UT_Array<Result>& pending);
763  PDG_WorkItem* workItem(
764  PDG_WorkItemID work_item_id,
765  int index);
766  void updateDefaultDirectories();
767 
768 private:
769  PDGE_Dependency myIsCookedDep;
770  PDGE_Dependency myIsSetupDep;
771 
772  PriorityQueue myScheduleQueue;
773  ResultQueue myScheduleResults;
774  ResultMap myPauseResults;
775  SharedServerInfoMap mySharedServerInfo;
776  PDG_WorkItemIDSet myPausedItems;
777 
778  WorkItemSet myRunningItems;
779  WorkItemSet myFailedItems;
780  WorkItemSet myLongRunningItems;
781 
782  WorkItemSet myCanceledItems;
783  NodeSet myCanceledNodes;
784 
785  UT_StringHolder myName;
786  UT_StringHolder myLocalWorkingDir;
787  UT_StringHolder myLocalTempDir;
788  UT_StringHolder myLocalScriptDir;
789  UT_StringHolder myRemoteWorkingDir;
790  UT_StringHolder myRemoteTempDir;
791  UT_StringHolder myRemoteScriptDir;
792 
793  PDG_GraphContext* myContext;
794  const PDG_SchedulerType* myTypeObject;
795 
796  time_t myLastTick;
797  WorkItemDataSource myDataSource;
798  TempDirCleanup myTempDirCleanup;
799 
800  UT_TBBSpinLock myProcessLock;
801 
802  bool myCancelingFlag;
803  bool myPausingFlag;
804  bool myStaticCook;
805  bool myInProcess;
806 
807  bool myIsWaitForFailures;
808  bool myIsValidateOutputFiles;
809  bool myIsCheckExpectedOutputFiles;
810  bool myIsCompressWorkItemData;
811 };
812 
813 #endif /* __PDG_SCHEDULER_H__ */
exint PDG_WorkItemID
Type defs for unique work item IDs.
The work item was cooked, and should be marked as succeeded.
Definition: PDG_Scheduler.h:78
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
bool isDefault(const cgltf_texture_view &tv)
const UT_StringHolder & name() const
Returns the name of the shceudler.
virtual bool startService(UT_WorkBuffer &errors, PDG_Service *service)
Starts a service using this scheduler.
The scheduler is able to handle the specified work item.
GLsizei const GLfloat * value
Definition: glcorearb.h:824
PDGE_Dependency * isSetupDep()
Returns the is cooked dep for this scheduler.
Comparator< PriorityComparator, Reverse > Priority
Functor that compares two work item references or pointers by priority.
#define PDG_API
Definition: PDG_API.h:23
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
The scheduler is not able to handle the specified work item.
int64 exint
Definition: SYS_Types.h:125
SYS_FORCE_INLINE const char * buffer() const
The call to schedule the work item succeeded.
Definition: PDG_Scheduler.h:84
The temp file dir is not cleaned up automatically.
The work item was cooked, and should be marked as failed.
Definition: PDG_Scheduler.h:75
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:39
**But if you need a result
Definition: thread.h:622
bool evaluateOverride(T &result, PDG_NodeInterface *node, const UT_StringHolder &prefix, const UT_StringHolder &parm, PDG_WorkItem *work_item, const D &default_value, UT_WorkBuffer &errors) const
virtual void addWarning(const UT_StringHolder &message) const
Adds a warning to the node interface – implemented in subclasses.
PDG_WorkItemEvalState
virtual bool reloadInstance(UT_WorkBuffer &errors)
The call to schedule the work item failed.
Definition: PDG_Scheduler.h:81
virtual PDGN::PDGN_PollingClientNNG * getPollingClient()
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
int64 Hash
The file hash/modtime type.
Definition: PDG_File.h:39
exint length() const
The work item was cooked, and should be marked as canceled.
Definition: PDG_Scheduler.h:72
bool isBatch() const
Returns true if the work tiem is a batch.
PDG_WorkItemState
Enum of possible work item states.
virtual bool stopServiceClient(UT_WorkBuffer &errors, PDG_Service *service, PDG_ServiceClient *client)
Stops the job associated with a specific client process.
PDG_FileTransferType
const UT_StringHolder & templateName() const
virtual void addError(const UT_StringHolder &message) const
Adds an error to the node interface – implemented in subclasses.
long long int64
Definition: SYS_Types.h:116
tbb::concurrent_hash_map< K, T, H, A > UT_ConcurrentHashMap
virtual int64 getMemoryUsage(bool inclusive) const
Returns the memory usage of this owner instance.
PDG_PathMappingMode
Enumeration of path mapping modes available on the scheduler.
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual const PDG_NodeInterface * templateInterface() const
virtual bool startServiceClient(UT_WorkBuffer &errors, PDG_Service *service, PDG_ServiceClient *client)
Starts a job for the specified service client.
PDG_WorkItemLogType
Enumeration of work item log message types.
size_t format(const char *fmt, const Args &...args)
TransferType
Enumeration of file transfer destination paths.
Definition: PDG_FileUtils.h:84
PDG_Port * parameter(const UT_StringHolder &name, int multi=-1) const
fpreal64 fpreal
Definition: SYS_Types.h:283
The scheduler cannot handle the work item at this time.
Definition: PDG_Scheduler.h:87
GLuint index
Definition: glcorearb.h:786
The scheduler is busy, and cannot process additional work items.
SYS_FORCE_INLINE void append(char character)
UT_StringHolder debugName() const override
Debug name method, required by PDGE_DependencyOwner.
The scheduler is ready to accept work items.
virtual PDGE_Dependency::State evalResolve(PDGE_Resolutions &, const PDGE_Evaluator &, PDGE_Dependency *)
Called when a dependency owned by this object is resolved.
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:99
void pause(int delay) noexcept
Definition: thread.h:103
bool process(T &func, UT_WorkBuffer &fullpath, exint fullpath_len, const UT_StringArray &paths, const UT_Array< FS_Stat > &stats)
Utility function to process the contents of the traverse() function.
Definition: FS_Traverse.h:24
#define UT_ConcurrentPriorityQueue
bool evaluate(int index, fpreal &result, const PDG_WorkItem *work_item, UT_WorkBuffer &errors) const
virtual bool stopService(UT_WorkBuffer &errors, PDG_Service *service, bool cancel)
Stops a service that was started with this scheduler.
PDGE_Dependency * isCookedDep()
Returns the is cooked dep for this scheduler.
virtual void resetOwner()
Resets the owner.
tbb::concurrent_unordered_set< K, H, P, A > UT_ConcurrentSet
GLint GLsizei count
Definition: glcorearb.h:405
SYS_FORCE_INLINE bool isstring() const
virtual const PDG_EventFilter & supportedEventTypes() const =0
Returns the list of supported event types for this emitter.