OnixS C++ CME iLink 3 Binary Order Entry Handler  1.9.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:
63  virtual ~SessionSchedulerListener() ONIXS_ILINK3_DEFAULT
64 };
65 
66 /// Scheduler options.
68 {
69 public:
71 
73 
75 
76  /// \return the path to the scheduler configuration file.
77  const std::string & configurationFile() const;
78 
79  /// Sets the path to the scheduler configuration file.
80  SessionSchedulerOptions &configurationFile(const std::string &file);
81 
82  /// \return the event listener.
83  SessionSchedulerListener * eventListener() const;
84 
85  /// Sets the event listener.
86  SessionSchedulerOptions &eventListener(SessionSchedulerListener *listener);
87 
88  SessionSchedulerOptions & operator = (const SessionSchedulerOptions & other);
89 
90 private:
91  std::string * configurationFile_;
92  SessionSchedulerListener * eventListener_;
93 };
94 
95 /// Session Scheduler.
97 {
98 public:
100 
101  /// Performs the graceful shutdown of scheduling sessions.
102  ~SessionScheduler();
103 
104  /// Looks for the predefined session schedule associated with the given id
105  /// that was specified in Scheduler's configuration file.
106  ///
107  /// \return `NULL` if no schedule is available for the given id.
108  const SessionSchedule * findSchedule(const SessionScheduleId & id) const;
109 
110  /// Looks for the predefined session connection settings associated with the given id
111  /// that was specified in Scheduler's configuration file.
112  ///
113  /// \return `NULL` if no settings is available for the given id.
114  const SessionConnectionSettings * findConnectionSettings(const SessionConnectionSettingsId & id) const;
115 
116  /// Adds the session to the automatic connection management.
117  ///
118  /// - If the session is being added during the active time frame, it will be connected immediately.
119  /// - If the session is being registered during the inactive time frame and is in the active state, it will be disconnected.
120  /// - If the session is already registered, and exception will be thrown.
121  ///
122  /// \param session the instance of the session to be maintained.
123  /// \param schedule Session's schedule.
124  /// \param connection Session's connection settings.
125  SessionScheduler& add(Session *session, const SessionSchedule &schedule, const SessionConnectionSettings &connection);
126 
127  /// Adds the session to the automatic connection management.
128  ///
129  /// - If the session is being added during the active time frame, it will be connected immediately.
130  /// - If the session is being registered during the inactive time frame and is in the active state, it will be disconnected.
131  /// - If the session is already registered, and exception will be thrown.
132  ///
133  /// \param session the instance of the session to be maintained.
134  /// \param scheduleId the ID of the predefined schedule.
135  /// \param connectionId the ID of the predefined connection settings.
136  SessionScheduler &add(Session *session, const SessionScheduleId &scheduleId, const SessionConnectionSettingsId &connectionId);
137 
138  /// Removes the session from еру automatic connection management services.
139  SessionScheduler &remove(Session *session);
140 
141  /// Sets the CPU affinity for the Scheduler service thread.
142  SessionScheduler &serviceThreadAffinity(const OnixS::CME::iLink3::CpuIndexes &cpuIndexes);
143 
144  /// \return the CPU affinity for the Scheduler service thread.
145  const OnixS::CME::iLink3::CpuIndexes &serviceThreadAffinity() const;
146 
147  /// Sets the number of logon attempts in case of a logon failure.
148  SessionScheduler &reconnectAttempts(int value);
149 
150  /// \return the number of logon attempts in case of a logon failure.
151  ///
152  /// The default value is `3`.
153  int reconnectAttempts() const;
154 
155  /// Sets the time interval between the logon attempts in case of a logon failure (in seconds).
156  SessionScheduler &reconnectInterval(int value);
157 
158  /// \return the time interval between the logon attempts in case of a logon failure (in seconds).
159  ///
160  /// The default value is `180` seconds.
161  int reconnectInterval() const;
162 
163  /// Activates the UTC usage.
164  SessionScheduler &utcTimeUsage(bool value);
165 
166  /// \return `true` if the UTC is used, otherwise - `false`.
167  ///
168  /// The default value is `false`.
169  bool utcTimeUsage() const;
170 
171 private:
172  class Impl;
173  Impl * impl_;
174 };
175 }
176 }
177 }
178 }
An iLink 3 Session.
Definition: Session.h:38
std::set< CpuIndex > CpuIndexes
Definition: Defines.h:74
Definition: Defines.h:40
#define ONIXS_ILINK3_EXPORTED
Definition: Compiler.h:162