OnixS C++ CME iLink 3 Binary Order Entry Handler  1.18.9
API Documentation
SessionScheduler.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable OnixS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
22 #include <OnixS/CME/iLink3/ABI.h>
27 
28 #include <set>
29 #include <string>
30 
31 namespace OnixS {
32 namespace CME {
33 namespace iLink3 {
34 namespace Scheduling {
35 
37 
38 typedef std::string SessionScheduleId;
39 typedef std::string SessionConnectionSettingsId;
40 
41 /// SessionScheduler events notifications.
43 {
44 public:
45  /// Notifies that the session is about to be closed.
46  ///
47  /// \param scheduler the instance the of session
48  /// scheduler that is about to close the session.
49  ///
50  /// \param session the session that is about to be closed.
51  ///
52  /// \param allowLogout indicates whether the scheduler must perform the logout.
53  /// To prohibit the logout set this parameter to `false`.
54  virtual void onLoggingOut(const SessionScheduler & scheduler, Session * session, bool * allowLogout) = 0;
55 
56  /// Notifies about a non-critical issue.
57  virtual void onWarning(const SessionScheduler & scheduler, Session * session, const std::string & warningReason) = 0;
58 
59  /// Notifies about an error.
60  virtual void onError(const SessionScheduler & scheduler, Session * session, const std::string & errorReason) = 0;
61 
62 protected:
64 };
65 
66 /// Scheduler options.
68 {
69 public:
71 
73 
74  /// \return the path to the scheduler configuration file.
75  const std::string & configurationFile() const ONIXS_ILINK3_NOTHROW;
76 
77  /// Sets the path to the scheduler configuration file.
78  SessionSchedulerOptions &configurationFile(const std::string &file);
79 
80  /// \return the event listener.
81  SessionSchedulerListener * eventListener() const ONIXS_ILINK3_NOTHROW;
82 
83  /// Sets the event listener.
85 
86 private:
87  std::string * configurationFile_;
88  SessionSchedulerListener * eventListener_;
89 };
90 
91 /// Session Scheduler.
93 {
94 public:
95  static const size_t TimeResolutionMs = 10;
96 
98 
99  /// Performs the graceful shutdown of scheduling sessions.
100  ~SessionScheduler();
101 
102  /// Looks for the predefined session schedule associated with the given id
103  /// that was specified in Scheduler's configuration file.
104  ///
105  /// \return `NULL` if no schedule is available for the given id.
106  const SessionSchedule * findSchedule(const SessionScheduleId & id) const;
107 
108  /// Looks for the predefined session connection settings associated with the given id
109  /// that was specified in Scheduler's configuration file.
110  ///
111  /// \return `NULL` if no settings are available for the given id.
112  const SessionConnectionSettings * findConnectionSettings(const SessionConnectionSettingsId & id) const;
113 
114  /// Adds the session to the automatic connection management.
115  ///
116  /// - If the session is being added during the active time frame, it will be connected immediately.
117  /// - If the session is being registered during the inactive time frame and is in the active state, it will be disconnected.
118  /// - If the session is already registered, an exception will be thrown.
119  ///
120  /// \param session the instance of the session to be maintained.
121  /// \param schedule Session's schedule.
122  /// \param connection Session's connection settings.
123  SessionScheduler& add(Session *session, const SessionSchedule &schedule, const SessionConnectionSettings &connection);
124 
125  /// Adds the session to the automatic connection management.
126  ///
127  /// - If the session is being added during the active time frame, it will be connected immediately.
128  /// - If the session is being registered during the inactive time frame and is in the active state, it will be disconnected.
129  /// - If the session is already registered, and exception will be thrown.
130  ///
131  /// \param session the instance of the session to be maintained.
132  /// \param scheduleId the ID of the predefined schedule.
133  /// \param connectionId the ID of the predefined connection settings.
134  SessionScheduler &add(Session *session, const SessionScheduleId &scheduleId, const SessionConnectionSettingsId &connectionId);
135 
136  /// Removes the session from the automatic connection management services.
137  SessionScheduler &remove(Session *session);
138 
139  /// Sets the CPU affinity for the Scheduler service thread.
140  SessionScheduler &serviceThreadAffinity(const OnixS::CME::iLink3::CpuIndexes &cpuIndexes);
141 
142  /// \return the CPU affinity for the Scheduler service thread.
143  const OnixS::CME::iLink3::CpuIndexes &serviceThreadAffinity() const ONIXS_ILINK3_NOTHROW;
144 
145  /// Sets the number of logon attempts in case of a logon failure.
146  SessionScheduler &reconnectAttempts(int value);
147 
148  /// \return the number of logon attempts in case of a logon failure.
149  ///
150  /// The default value is `3`.
151  int reconnectAttempts() const;
152 
153  /// Sets the time interval between the logon attempts in case of a logon failure (in seconds).
154  SessionScheduler &reconnectInterval(int value);
155 
156  /// \return the time interval between the logon attempts in case of a logon failure (in seconds).
157  ///
158  /// The default value is `180` seconds.
159  int reconnectInterval() const;
160 
161  /// Activates the UTC usage.
162  SessionScheduler &utcTimeUsage(bool value);
163 
164  /// \return `true` if the UTC is used, otherwise - `false`.
165  ///
166  /// The default value is `false`.
167  bool utcTimeUsage() const;
168 
169 private:
170  class Impl;
171  Impl * impl_;
172 };
173 }
174 }
175 }
176 }
An iLink 3 Session.
Definition: Session.h:47
std::set< CpuIndex > CpuIndexes
Definition: Defines.h:73
Definition: Defines.h:40
#define ONIXS_ILINK3_DEFAULT
Definition: Compiler.h:202
#define ONIXS_ILINK3_EXPORTED
Definition: Compiler.h:175
#define ONIXS_ILINK3_NOTHROW
Definition: Compiler.h:176