266 lines
6.5 KiB
C++
266 lines
6.5 KiB
C++
// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
|
|
//
|
|
// This software owned by Onix Solutions Limited [OnixS] and is
|
|
// protected by copyright law and international copyright treaties.
|
|
//
|
|
// Access to and use of the software is governed by the terms of the applicable
|
|
// OnixS Software Services Agreement (the Agreement) and Customer end user license
|
|
// agreements granting a non-assignable, non-transferable and non-exclusive license
|
|
// to use the software for it's own data processing purposes under the terms defined
|
|
// in the Agreement.
|
|
//
|
|
// Except as otherwise granted within the terms of the Agreement, copying or
|
|
// reproduction of any part of this source code or associated reference material
|
|
// to any other location for further reproduction or redistribution, and any
|
|
// amendments to this copyright notice, are expressly prohibited.
|
|
//
|
|
// Any reproduction or redistribution for sale or hiring of the Software not in
|
|
// accordance with the terms of the Agreement is a violation of copyright law.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <OnixS/CME/MDH/Integral.h>
|
|
|
|
ONIXS_CMEMDH_NAMESPACE_BEGIN
|
|
|
|
/// TCP recovery service configuration settings.
|
|
ONIXS_CMEMDH_LTWT_CLASS
|
|
TcpRecoverySettings
|
|
{
|
|
public:
|
|
/// Initializes parameters with default values.
|
|
TcpRecoverySettings()
|
|
: username_()
|
|
, password_()
|
|
, reconnectAttempts_(3)
|
|
, reconnectInterval_(500)
|
|
, servingTimeout_(10)
|
|
, acquisitionTimeout_(500)
|
|
{
|
|
}
|
|
|
|
/// Cleans everything up.
|
|
~TcpRecoverySettings()
|
|
{
|
|
}
|
|
|
|
/// Username to identify a requester while
|
|
/// logging on to a TCP Recovery service.
|
|
const std::string& username() const
|
|
{
|
|
return username_;
|
|
}
|
|
|
|
/// Assigns username to identify a requester
|
|
/// while logging on to a TCP Recovery service.
|
|
void
|
|
username(
|
|
const std::string& username)
|
|
{
|
|
username_ = username;
|
|
}
|
|
|
|
/// Password to identify a requester while
|
|
/// logging on to TCP Recovery service.
|
|
const std::string& password() const
|
|
{
|
|
return password_;
|
|
}
|
|
|
|
/// Assigns password to identify a requester
|
|
/// while logging on to TCP Recovery service.
|
|
void
|
|
password(
|
|
const std::string& password)
|
|
{
|
|
password_ = password;
|
|
}
|
|
|
|
/// Number of attempts to receive missed
|
|
/// messages via the TCP recovery feed.
|
|
///
|
|
/// @note Default value is '3'.
|
|
UInt32 reconnectAttempts() const
|
|
{
|
|
return reconnectAttempts_;
|
|
}
|
|
|
|
/// Number of attempts to receive missed
|
|
/// messages via the TCP recovery feed.
|
|
void
|
|
reconnectAttempts(
|
|
UInt32 reconnectAttempts)
|
|
{
|
|
reconnectAttempts_ =
|
|
reconnectAttempts;
|
|
}
|
|
|
|
/// Interval between the attempts to receive
|
|
/// missed packets via the TCP recovery feed if
|
|
/// previous attempt either failed or was rejected.
|
|
///
|
|
/// Interval is measured in milliseconds.
|
|
///
|
|
/// @note Default value is '500'.
|
|
UInt32 reconnectInterval() const
|
|
{
|
|
return reconnectInterval_;
|
|
}
|
|
|
|
/// Interval between the attempts to receive
|
|
/// missed packets via the TCP recovery feed if
|
|
/// previous attempt either failed or was rejected.
|
|
///
|
|
/// Interval is measured in milliseconds.
|
|
void
|
|
reconnectInterval(
|
|
UInt32 reconnectInterval)
|
|
{
|
|
reconnectInterval_ =
|
|
reconnectInterval;
|
|
}
|
|
|
|
/// Amount of time allocated to process a
|
|
/// recovery request. TCP recovery service
|
|
/// interrupts request processing if it can't
|
|
/// be accomplished within given time frame.
|
|
///
|
|
/// Interval is measured in seconds.
|
|
///
|
|
/// @note Default value is '10'.
|
|
UInt32 servingTimeout() const
|
|
{
|
|
return servingTimeout_;
|
|
}
|
|
|
|
/// Amount of time allocated to process a
|
|
/// recovery request. TCP recovery service
|
|
/// interrupts request processing if it can't
|
|
/// be accomplished within given time frame.
|
|
///
|
|
/// Interval is measured in seconds.
|
|
void
|
|
servingTimeout(
|
|
UInt32 servingTimeout)
|
|
{
|
|
servingTimeout_ =
|
|
servingTimeout;
|
|
}
|
|
|
|
/// Timeout on a TCP recovery service acquisition.
|
|
///
|
|
/// TCP recovery service may process only
|
|
/// single request at a time. If TCP recovery
|
|
/// service can't be acquired within time defined
|
|
/// by given parameter, recovery request will be
|
|
/// rejected.
|
|
///
|
|
/// Timeout is measured in milliseconds.
|
|
///
|
|
/// @note Default value is '500'.
|
|
UInt32 acquisitionTimeout() const
|
|
{
|
|
return acquisitionTimeout_;
|
|
}
|
|
|
|
/// Timeout of request for shared TCP recovery service.
|
|
/// If shared TCP recovery service is used and another Handler
|
|
/// instance owned it for processing, this Handler instance
|
|
/// will wait for specified timeout and cancel TCP recovery request
|
|
/// if TCP Recovery service still not released.
|
|
///
|
|
/// Timeout is measured in milliseconds.
|
|
void
|
|
acquisitionTimeout(
|
|
UInt32 acquisitionTimeout)
|
|
{
|
|
acquisitionTimeout_ =
|
|
acquisitionTimeout;
|
|
}
|
|
|
|
private:
|
|
std::string username_;
|
|
std::string password_;
|
|
|
|
UInt32 reconnectAttempts_;
|
|
UInt32 reconnectInterval_;
|
|
|
|
UInt32 servingTimeout_;
|
|
UInt32 acquisitionTimeout_;
|
|
};
|
|
|
|
/// Serializes TCP recovery settings.
|
|
ONIXS_CMEMDH_EXPORTED
|
|
void
|
|
toStr(
|
|
std::string&,
|
|
const
|
|
TcpRecoverySettings&);
|
|
|
|
/// Serializes TCP recovery settings.
|
|
inline
|
|
std::string
|
|
toStr(
|
|
const
|
|
TcpRecoverySettings& settings)
|
|
{
|
|
std::string str;
|
|
|
|
toStr(str, settings);
|
|
|
|
return str;
|
|
}
|
|
|
|
ONIXS_CMEMDH_INTERNAL_CLASS_DECL
|
|
(
|
|
TcpRecoverySession
|
|
);
|
|
|
|
/// TCP Recovery Service.
|
|
ONIXS_CMEMDH_EXPORTED_CLASS
|
|
TcpRecoveryService
|
|
{
|
|
public:
|
|
/// Initializes instance according to given settings.
|
|
TcpRecoveryService(
|
|
const TcpRecoverySettings&);
|
|
|
|
/// Finalizes instance and cleans everything up.
|
|
~TcpRecoveryService();
|
|
|
|
/// Settings defining service behavior.
|
|
const
|
|
TcpRecoverySettings&
|
|
settings() const
|
|
{
|
|
return *settings_;
|
|
}
|
|
|
|
private:
|
|
friend
|
|
ONIXS_CMEMDH_INTERNAL_CLASS_DECL
|
|
(
|
|
TcpRecoverySession
|
|
);
|
|
|
|
// Shared details.
|
|
void* resource_;
|
|
|
|
// Settings of the service.
|
|
TcpRecoverySettings* settings_;
|
|
|
|
// Copying is not assumed.
|
|
|
|
TcpRecoveryService(
|
|
const TcpRecoveryService&);
|
|
|
|
TcpRecoveryService&
|
|
operator =(
|
|
const TcpRecoveryService&);
|
|
};
|
|
|
|
ONIXS_CMEMDH_NAMESPACE_END
|