NCBI C++ ToolKit
netschedule_api_getjob.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CONN_SERVICES___NETSCHEDULE_API_GETJOB__HPP
2 #define CONN_SERVICES___NETSCHEDULE_API_GETJOB__HPP
3 
4 /* $Id: netschedule_api_getjob.hpp 90047 2020-05-06 16:16:59Z sadyrovr $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Rafael Sadyrov
30  *
31  * File Description:
32  * NetSchedule API get/read job implementation.
33  *
34  */
35 
37 
38 #include <vector>
39 #include <list>
40 
41 
43 
44 
45 // A namespace-like class
47 {
48  // Vector of priority-ordered pairs of affinities and
49  // corresponding priority-ordered comma-separated affinity lists.
50  // E.g., for "a, b, c" it would be:
51  // { "a", "a" },
52  // { "b", "a, b" },
53  // { "c", "a, b, c" }
54  typedef vector<pair<string, string> > TAffinityLadder;
55 
56  enum EState {
59  eStopped
60  };
61 
62  enum EResult {
66  eNoJobs
67  };
68 
69  struct SEntry
70  {
74  bool more_jobs;
75 
76  SEntry(const SSocketAddress& a, bool j = true) :
78  deadline(0, 0),
80  more_jobs(j)
81  {
82  }
83 
84  bool operator==(const SEntry& rhs) const
85  {
86  return server_address == rhs.server_address;
87  }
88  };
89 };
90 
91 template <class TImpl>
93 {
94 public:
96  m_Impl(impl),
98  {
100  }
101 
103  const CDeadline& deadline,
104  CNetScheduleJob& job,
105  CNetScheduleAPI::EJobStatus* job_status,
106  bool any_affinity);
107 
108 private:
109  template <class TJobHolder>
110  EResult GetJobImmediately(TJobHolder& holder);
111 
112  template <class TJobHolder>
113  EResult GetJobImpl(const CDeadline& deadline, TJobHolder& holder);
114 
115  void Restart();
116  void MoveToImmediateActions(SNetServerImpl* server_impl);
117  void NextDiscoveryIteration();
119 
120  TImpl& m_Impl;
123 };
124 
125 
127 
128 
129 #endif /* CONN_SERVICES___NETSCHEDULE_API_GETJOB__HPP */
CDeadline.
Definition: ncbitime.hpp:1830
EResult GetJobImpl(const CDeadline &deadline, TJobHolder &holder)
EResult GetJobImmediately(TJobHolder &holder)
void MoveToImmediateActions(SNetServerImpl *server_impl)
CNetScheduleGetJob::EResult GetJob(const CDeadline &deadline, CNetScheduleJob &job, CNetScheduleAPI::EJobStatus *job_status, bool any_affinity)
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
EJobStatus
Job status codes.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
unsigned int a
Definition: ncbi_localip.c:102
NetSchedule client specs.
bool operator==(const SEntry &rhs) const
SEntry(const SSocketAddress &a, bool j=true)
vector< pair< string, string > > TAffinityLadder
Job description.
Modified on Sun Jun 02 05:19:38 2024 by modify_doxy.py rev. 669887