NCBI C++ ToolKit
src
connect
services
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
36
#include <
connect/services/netschedule_api.hpp
>
37
38
#include <vector>
39
#include <list>
40
41
42
BEGIN_NCBI_SCOPE
43
44
45
// A namespace-like class
46
struct
CNetScheduleGetJob
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
{
57
eWorking
,
58
eRestarted
,
59
eStopped
60
};
61
62
enum
EResult
{
63
eJob
,
64
eAgain
,
65
eInterrupt
,
66
eNoJobs
67
};
68
69
struct
SEntry
70
{
71
SSocketAddress
server_address
;
72
CDeadline
deadline
;
73
bool
all_affinities_checked
;
74
bool
more_jobs
;
75
76
SEntry
(
const
SSocketAddress
&
a
,
bool
j =
true
) :
77
server_address
(
a
),
78
deadline
(0, 0),
79
all_affinities_checked
(
true
),
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>
92
class
CNetScheduleGetJobImpl
:
public
CNetScheduleGetJob
93
{
94
public
:
95
CNetScheduleGetJobImpl
(TImpl&
impl
) :
96
m_Impl
(
impl
),
97
m_DiscoveryAction
(
SSocketAddress
(0, 0),
false
)
98
{
99
m_ImmediateActions
.push_back(
m_DiscoveryAction
);
100
}
101
102
CNetScheduleGetJob::EResult
GetJob
(
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
();
118
void
ReturnNotFullyCheckedServers
();
119
120
TImpl&
m_Impl
;
121
list<SEntry>
m_ImmediateActions
,
m_ScheduledActions
;
122
SEntry
m_DiscoveryAction
;
123
};
124
125
126
END_NCBI_SCOPE
127
128
129
#endif
/* CONN_SERVICES___NETSCHEDULE_API_GETJOB__HPP */
CDeadline
CDeadline.
Definition:
ncbitime.hpp:1830
CNetScheduleGetJobImpl
Definition:
netschedule_api_getjob.hpp:93
CNetScheduleGetJobImpl::m_Impl
TImpl & m_Impl
Definition:
netschedule_api_getjob.hpp:120
CNetScheduleGetJobImpl::GetJobImpl
EResult GetJobImpl(const CDeadline &deadline, TJobHolder &holder)
CNetScheduleGetJobImpl::Restart
void Restart()
Definition:
netschedule_api_getjob.cpp:379
CNetScheduleGetJobImpl::m_ImmediateActions
list< SEntry > m_ImmediateActions
Definition:
netschedule_api_getjob.hpp:121
CNetScheduleGetJobImpl::NextDiscoveryIteration
void NextDiscoveryIteration()
Definition:
netschedule_api_getjob.cpp:412
CNetScheduleGetJobImpl::GetJobImmediately
EResult GetJobImmediately(TJobHolder &holder)
CNetScheduleGetJobImpl::MoveToImmediateActions
void MoveToImmediateActions(SNetServerImpl *server_impl)
Definition:
netschedule_api_getjob.cpp:388
CNetScheduleGetJobImpl::m_ScheduledActions
list< SEntry > m_ScheduledActions
Definition:
netschedule_api_getjob.hpp:121
CNetScheduleGetJobImpl::ReturnNotFullyCheckedServers
void ReturnNotFullyCheckedServers()
Definition:
netschedule_api_getjob.cpp:438
CNetScheduleGetJobImpl::CNetScheduleGetJobImpl
CNetScheduleGetJobImpl(TImpl &impl)
Definition:
netschedule_api_getjob.hpp:95
CNetScheduleGetJobImpl::GetJob
CNetScheduleGetJob::EResult GetJob(const CDeadline &deadline, CNetScheduleJob &job, CNetScheduleAPI::EJobStatus *job_status, bool any_affinity)
Definition:
netschedule_api_getjob.cpp:48
CNetScheduleGetJobImpl::m_DiscoveryAction
SEntry m_DiscoveryAction
Definition:
netschedule_api_getjob.hpp:122
true
#define true
Definition:
bool.h:35
false
#define false
Definition:
bool.h:36
CNetScheduleAPI::EJobStatus
EJobStatus
Job status codes.
Definition:
netschedule_api.hpp:161
END_NCBI_SCOPE
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition:
ncbistl.hpp:103
BEGIN_NCBI_SCOPE
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition:
ncbistl.hpp:100
impl
Definition:
dbapi_driver_conn_mgr.hpp:44
a
unsigned int a
Definition:
ncbi_localip.c:102
netschedule_api.hpp
NetSchedule client specs.
CNetScheduleGetJob::SEntry
Definition:
netschedule_api_getjob.hpp:70
CNetScheduleGetJob::SEntry::operator==
bool operator==(const SEntry &rhs) const
Definition:
netschedule_api_getjob.hpp:84
CNetScheduleGetJob::SEntry::more_jobs
bool more_jobs
Definition:
netschedule_api_getjob.hpp:74
CNetScheduleGetJob::SEntry::deadline
CDeadline deadline
Definition:
netschedule_api_getjob.hpp:72
CNetScheduleGetJob::SEntry::SEntry
SEntry(const SSocketAddress &a, bool j=true)
Definition:
netschedule_api_getjob.hpp:76
CNetScheduleGetJob::SEntry::server_address
SSocketAddress server_address
Definition:
netschedule_api_getjob.hpp:71
CNetScheduleGetJob::SEntry::all_affinities_checked
bool all_affinities_checked
Definition:
netschedule_api_getjob.hpp:73
CNetScheduleGetJob
Definition:
netschedule_api_getjob.hpp:47
CNetScheduleGetJob::eWorking
@ eWorking
Definition:
netschedule_api_getjob.hpp:57
CNetScheduleGetJob::eStopped
@ eStopped
Definition:
netschedule_api_getjob.hpp:59
CNetScheduleGetJob::eRestarted
@ eRestarted
Definition:
netschedule_api_getjob.hpp:58
CNetScheduleGetJob::TAffinityLadder
vector< pair< string, string > > TAffinityLadder
Definition:
netschedule_api_getjob.hpp:54
CNetScheduleGetJob::EResult
EResult
Definition:
netschedule_api_getjob.hpp:62
CNetScheduleGetJob::eInterrupt
@ eInterrupt
Definition:
netschedule_api_getjob.hpp:65
CNetScheduleGetJob::eAgain
@ eAgain
Definition:
netschedule_api_getjob.hpp:64
CNetScheduleGetJob::eJob
@ eJob
Definition:
netschedule_api_getjob.hpp:63
CNetScheduleGetJob::eNoJobs
@ eNoJobs
Definition:
netschedule_api_getjob.hpp:66
CNetScheduleJob
Job description.
Definition:
netschedule_api.hpp:343
EState
Definition:
bzlib_private.h:197
SNetServerImpl
Definition:
srv_connections_impl.hpp:251
SSocketAddress
Definition:
connect_misc.hpp:53
Generated by
1.9.0
Modified on Sun Jun 02 05:19:38 2024 by modify_doxy.py rev. 669887