OnixS C++ CME iLink 3 Binary Order Entry Handler  1.18.0
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:
96 
97  /// Performs the graceful shutdown of scheduling sessions.
99 
100  /// Looks for the predefined session schedule associated with the given id
101  /// that was specified in Scheduler's configuration file.
102  ///
103  /// \return `NULL` if no schedule is available for the given id.
104  const SessionSchedule * findSchedule(const SessionScheduleId & id) const;
105 
106  /// Looks for the predefined session connection settings associated with the given id
107  /// that was specified in Scheduler's configuration file.
108  ///
109  /// \return `NULL` if no settings are available for the given id.
110  const SessionConnectionSettings * findConnectionSettings(const SessionConnectionSettingsId & id) const;
111 
112  /// Adds the session to the automatic connection management.
113  ///
114  /// - If the session is being added during the active time frame, it will be connected immediately.
115  /// - If the session is being registered during the inactive time frame and is in the active state, it will be disconnected.
116  /// - If the session is already registered, an exception will be thrown.
117  ///
118  /// \param session the instance of the session to be maintained.
119  /// \param schedule Session's schedule.
120  /// \param connection Session's connection settings.
121  SessionScheduler& add(Session *session, const SessionSchedule &schedule, const SessionConnectionSettings &connection);
122 
123  /// Adds the session to the automatic connection management.
124  ///
125  /// - If the session is being added during the active time frame, it will be connected immediately.
126  /// - If the session is being registered during the inactive time frame and is in the active state, it will be disconnected.
127  /// - If the session is already registered, and exception will be thrown.
128  ///
129  /// \param session the instance of the session to be maintained.
130  /// \param scheduleId the ID of the predefined schedule.
131  /// \param connectionId the ID of the predefined connection settings.
132  SessionScheduler &add(Session *session, const SessionScheduleId &scheduleId, const SessionConnectionSettingsId &connectionId);
133 
134  /// Removes the session from the automatic connection management services.
135  SessionScheduler &remove(Session *session);
136 
137  /// Sets the CPU affinity for the Scheduler service thread.
138  SessionScheduler &serviceThreadAffinity(const OnixS::CME::iLink3::CpuIndexes &cpuIndexes);
139 
140  /// \return the CPU affinity for the Scheduler service thread.
141  const OnixS::CME::iLink3::CpuIndexes &serviceThreadAffinity() const ONIXS_ILINK3_NOTHROW;
142 
143  /// Sets the number of logon attempts in case of a logon failure.
144  SessionScheduler &reconnectAttempts(int value);
145 
146  /// \return the number of logon attempts in case of a logon failure.
147  ///
148  /// The default value is `3`.
149  int reconnectAttempts() const;
150 
151  /// Sets the time interval between the logon attempts in case of a logon failure (in seconds).
152  SessionScheduler &reconnectInterval(int value);
153 
154  /// \return the time interval between the logon attempts in case of a logon failure (in seconds).
155  ///
156  /// The default value is `180` seconds.
157  int reconnectInterval() const;
158 
159  /// Activates the UTC usage.
160  SessionScheduler &utcTimeUsage(bool value);
161 
162  /// \return `true` if the UTC is used, otherwise - `false`.
163  ///
164  /// The default value is `false`.
165  bool utcTimeUsage() const;
166 
167 private:
168  class Impl;
169  Impl * impl_;
170 };
171 }
172 }
173 }
174 }
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