Class Binding
Represents a particular named binding.
Binding type defines a protocol by implementing a transport instance management strategy
that support particular technology, such as blocking TCP or async ZeroMQ.
Binding instance retains state/config information about all transports
and has logic for Node's host:service resolution.
Bindings are services, meaning - they can have state/threads that
manage transport channels that operate under binding
Inheritance
System.Object
Binding
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: NFX.dll
Syntax
public abstract class Binding : GlueComponentService, IApplicationComponent, IDisposable, IService, INamed, IConfigurable, ILocalizedTimeProvider, IInstrumentable, IExternallyParameterized
Constructors
Binding(IGlueImplementation, String, Provider)
Declaration
protected Binding(IGlueImplementation glue, string name = null, Provider provider = null)
Parameters
Binding(String)
Declaration
protected Binding(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Fields
ATTR_PATH
Declaration
public const string ATTR_PATH = "$"
Field Value
Type |
Description |
System.String |
|
ATTR_SLASH_PATH
Declaration
public const string ATTR_SLASH_PATH = "/$"
Field Value
Type |
Description |
System.String |
|
CLIENT_TRANSPORT_COUNT_WAIT_THRESHOLD_DEFAULT
Declaration
public const int CLIENT_TRANSPORT_COUNT_WAIT_THRESHOLD_DEFAULT = 8
Field Value
Type |
Description |
System.Int32 |
|
CLIENT_TRANSPORT_EXISTING_ACQUISITION_TIMEOUT_MS_DEFAULT
Declaration
public const int CLIENT_TRANSPORT_EXISTING_ACQUISITION_TIMEOUT_MS_DEFAULT = 100
Field Value
Type |
Description |
System.Int32 |
|
CLIENT_TRANSPORT_IDLE_TIMEOUT_MS_DEFAULT
Declaration
public const int CLIENT_TRANSPORT_IDLE_TIMEOUT_MS_DEFAULT = 120000
Field Value
Type |
Description |
System.Int32 |
|
CLIENT_TRANSPORT_MAX_COUNT_DEFAULT
Declaration
public const int CLIENT_TRANSPORT_MAX_COUNT_DEFAULT = 0
Field Value
Type |
Description |
System.Int32 |
|
CLIENT_TRANSPORT_MAX_EXISTING_ACQUISITION_TIMEOUT_MS_DEFAULT
Declaration
public const int CLIENT_TRANSPORT_MAX_EXISTING_ACQUISITION_TIMEOUT_MS_DEFAULT = 15000
Field Value
Type |
Description |
System.Int32 |
|
CONFIG_CLIENT_DUMP_ATTR
Declaration
public const string CONFIG_CLIENT_DUMP_ATTR = "client-dump"
Field Value
Type |
Description |
System.String |
|
CONFIG_CLIENT_TRANSPORT_COUNT_WAIT_THRESHOLD_ATTR
Declaration
public const string CONFIG_CLIENT_TRANSPORT_COUNT_WAIT_THRESHOLD_ATTR = "count-wait-threshold"
Field Value
Type |
Description |
System.String |
|
CONFIG_CLIENT_TRANSPORT_EXISTING_ACQUISITION_TIMEOUT_MS_ATTR
Declaration
public const string CONFIG_CLIENT_TRANSPORT_EXISTING_ACQUISITION_TIMEOUT_MS_ATTR = "existing-acquisition-timeout-ms"
Field Value
Type |
Description |
System.String |
|
CONFIG_CLIENT_TRANSPORT_MAX_COUNT_ATTR
Declaration
public const string CONFIG_CLIENT_TRANSPORT_MAX_COUNT_ATTR = "max-count"
Field Value
Type |
Description |
System.String |
|
CONFIG_CLIENT_TRANSPORT_MAX_EXISTING_ACQUISITION_TIMEOUT_MS_ATTR
Declaration
public const string CONFIG_CLIENT_TRANSPORT_MAX_EXISTING_ACQUISITION_TIMEOUT_MS_ATTR = "max-existing-acquisition-timeout-ms"
Field Value
Type |
Description |
System.String |
|
CONFIG_CLIENT_TRANSPORT_SECTION
Declaration
public const string CONFIG_CLIENT_TRANSPORT_SECTION = "client-transport"
Field Value
Type |
Description |
System.String |
|
Declaration
public const string CONFIG_DUMP_FORMAT_ATTR = "dump-format"
Field Value
Type |
Description |
System.String |
|
CONFIG_DUMP_PATH_ATTR
Declaration
public const string CONFIG_DUMP_PATH_ATTR = "dump-path"
Field Value
Type |
Description |
System.String |
|
CONFIG_INSTRUMENT_TRANSPORT_STAT_ATTR
Declaration
public const string CONFIG_INSTRUMENT_TRANSPORT_STAT_ATTR = "instrument-transport-stat"
Field Value
Type |
Description |
System.String |
|
CONFIG_SERVER_DUMP_ATTR
Declaration
public const string CONFIG_SERVER_DUMP_ATTR = "server-dump"
Field Value
Type |
Description |
System.String |
|
CONFIG_SERVER_TRANSPORT_SECTION
Declaration
public const string CONFIG_SERVER_TRANSPORT_SECTION = "server-transport"
Field Value
Type |
Description |
System.String |
|
CONFIG_STAT_TIMES_EMA_FACTOR_ATTR
Declaration
public const string CONFIG_STAT_TIMES_EMA_FACTOR_ATTR = "stat-times-ema-factor"
Field Value
Type |
Description |
System.String |
|
CONFIG_TRANSPORT_IDLE_TIMEOUT_MS_ATTR
Declaration
public const string CONFIG_TRANSPORT_IDLE_TIMEOUT_MS_ATTR = "idle-timeout-ms"
Field Value
Type |
Description |
System.String |
|
DEFAULT_STAT_TIMES_EMA_FACTOR
Defines how much smoothing the timing statistics filter does - the lower the number the more smoothing is done.
Smoothing makes stat times insensitive to some seldom delays that may happen every now and then
Declaration
public const double DEFAULT_STAT_TIMES_EMA_FACTOR = 0.04
Field Value
Type |
Description |
System.Double |
|
m_ClientTransportAllocatorLocks
Hash table of locks used during new transport allocation, must be prime size
Declaration
protected object[] m_ClientTransportAllocatorLocks
Field Value
Type |
Description |
System.Object[] |
|
m_Provider
Declaration
protected Provider m_Provider
Field Value
MAX_STAT_TIMES_EMA_FACTOR
Declaration
public const double MAX_STAT_TIMES_EMA_FACTOR = 0.999
Field Value
Type |
Description |
System.Double |
|
MIN_STAT_TIMES_EMA_FACTOR
Declaration
public const double MIN_STAT_TIMES_EMA_FACTOR = 0.0001
Field Value
Type |
Description |
System.Double |
|
SERVER_TRANSPORT_IDLE_TIMEOUT_MS_DEFAULT
Declaration
public const int SERVER_TRANSPORT_IDLE_TIMEOUT_MS_DEFAULT = 600000
Field Value
Type |
Description |
System.Int32 |
|
Properties
ClientDump
Turns on/off client message dumping to disk. Turning on dumping has negative effect on performance and consumes resources
Declaration
[Config("$client-dump", DumpDetail.None)]
[ExternalParameter(new string[]{"glue", "instrumentation"})]
public DumpDetail ClientDump { get; set; }
Property Value
ClientMsgInspectors
Returns client message inspectors for this instance
Declaration
public OrderedRegistry<IClientMsgInspector> ClientMsgInspectors { get; }
Property Value
ClientTransportCountWaitThreshold
Sets the threshold, expressed as the number of active client transports per remote address, below which binding will always allocate a new instance
of client transport without trying/waiting to acquire an existing one. When this number is exceeded then binding will try to acquire an existing
client transport instance for up to ClientTransportExistingAcquisitionTimeoutMs milliseconds.
For more info, see 'NFX.Glue: Client Call Concurrency' topic in manual/blog
Declaration
[Config("client-transport/$count-wait-threshold", 8)]
[ExternalParameter(new string[]{"glue"})]
public int ClientTransportCountWaitThreshold { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
ClientTransportExistingAcquisitionTimeoutMs
Sets the length of interval for the binding trying to acquire existing client transport instance to make a call.
When this interval is exhausted then binding tries to allocate a new client transport per remote address, unless
other limits prohibit (max transport count). The value has to be greater or equal to zero.
NOTE: this property works in conjunction with ClientTransportCoutWaitThreshold, if the number of active client transports
is below ClientTransportCoutWaitThreshold, then binding does not wait and allocates a new client transport right away until
ClientTransportCoutWaitThreshold limit is reached, then binding will try to acquire existing transport for ClientTransportExistingAcquisitionTimeoutMs milliseconds.
For more info, see 'NFX.Glue: Client Call Concurrency' topic in manual/blog
Declaration
[Config("client-transport/$existing-acquisition-timeout-ms", 100)]
[ExternalParameter(new string[]{"glue"})]
public int ClientTransportExistingAcquisitionTimeoutMs { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
ClientTransportIdleTimeoutMs
Specifies when client transports get auto-closed. Interval is measured in ms. Zero means indefinite/never closed transport.
For more info, see 'NFX.Glue: Client Call Concurrency' topic in manual/blog
Declaration
[Config("client-transport/$idle-timeout-ms", 120000)]
[ExternalParameter(new string[]{"glue"})]
public int ClientTransportIdleTimeoutMs { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
ClientTransportMaxCount
Imposes a limit on number of active client transports per remote address. Once this limit is reached the binding will block until it can acquire
an existing transport instance. Set value to zero to remove the limit.
For more info, see 'NFX.Glue: Client Call Concurrency' topic in manual/blog
Declaration
[Config("client-transport/$max-count", 0)]
[ExternalParameter(new string[]{"glue"})]
public int ClientTransportMaxCount { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
ClientTransportMaxExistingAcquisitionTimeoutMs
Imposes a timeout for binding trying to get an existing transport instance per remote address.
Binding throws ClientCallException when this timeout is exceeded. A value of zero removes the limit
Declaration
[Config("client-transport/$max-existing-acquisition-timeout-ms", 15000)]
[ExternalParameter(new string[]{"glue"})]
public int ClientTransportMaxExistingAcquisitionTimeoutMs { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
ClientTransports
Returns all client transports in the binding stack
Declaration
public IEnumerable<ClientTransport> ClientTransports { get; }
Property Value
ConfigNode
Returns configuration node for this named instance
Declaration
public IConfigSectionNode ConfigNode { get; }
Property Value
Set the format for message dumping
Declaration
[Config("$dump-format", DumpFormat.Binary)]
[ExternalParameter(new string[]{"glue", "instrumentation"})]
public DumpFormat DumpMsgFormat { get; set; }
Property Value
DumpPath
Set the path for message dumping. Must be an existing navigable path
Declaration
[Config("$dump-path")]
[ExternalParameter(new string[]{"glue", "instrumentation"})]
public string DumpPath { get; set; }
Property Value
Type |
Description |
System.String |
|
Returns name of msg format encoding
Declaration
public abstract string EncodingFormat { get; }
Property Value
Type |
Description |
System.String |
|
InstrumentClientTransportStat
Defines whether client transport statistics is periodically dumped into instrumentation
Declaration
[Config("client-transport/$instrument-transport-stat")]
[ExternalParameter(new string[]{"glue", "instrumentation"})]
public bool InstrumentClientTransportStat { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
InstrumentServerTransportStat
Defines whether server transport statistics is periodically dumped into instrumentation
Declaration
[Config("server-transport/$instrument-transport-stat")]
[ExternalParameter(new string[]{"glue", "instrumentation"})]
public bool InstrumentServerTransportStat { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
MeasureStatTimes
Defines whether message processing latency should be measured - i.e. messages time-stamped on arrival
Declaration
[Config]
[ExternalParameter(new string[]{"glue", "instrumentation"})]
public bool MeasureStatTimes { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
OperationFlow
Returns sync/async flow that this binding provides
Declaration
public abstract OperationFlow OperationFlow { get; }
Property Value
Provider
Declaration
public Provider Provider { get; }
Property Value
ServerDump
Turns on/off server message dumping to disk. Turning on dumping has negative effect on performance and consumes resources
Declaration
[Config("$server-dump", DumpDetail.None)]
[ExternalParameter(new string[]{"glue", "instrumentation"})]
public DumpDetail ServerDump { get; set; }
Property Value
ServerMsgInspectors
Returns server message inspectors for this instance
Declaration
public OrderedRegistry<IServerMsgInspector> ServerMsgInspectors { get; }
Property Value
ServerTransportIdleTimeoutMs
Specifies when server transports get auto-closed. Interval is measured in ms. Zero means indefinite/never closed transport.
For more info, see 'NFX.Glue: Client Call Concurrency' topic in manual/blog
Declaration
[Config("server-transport/$idle-timeout-ms", 600000)]
[ExternalParameter(new string[]{"glue"})]
public int ServerTransportIdleTimeoutMs { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
ServerTransports
Returns all server transports in the binding stack
Declaration
public IEnumerable<ServerTransport> ServerTransports { get; }
Property Value
StatTimesEMAFactor
Defines how much smoothing the timing statistics filter does - the lower the number the more smoothing is done.
Smoothing makes stat times insensitive to some seldom delays that may happen every now and then
Declaration
[Config("stat-times-ema-factor", 0.04)]
[ExternalParameter(new string[]{"glue", "instrumentation"})]
public double StatTimesEMAFactor { get; set; }
Property Value
Type |
Description |
System.Double |
|
StatTimeTicks
Returns current time in system frequency-dependent ticks.
This property is used to measure accurate times and depends on MeasureStatTimes set to true, otherwise 0 is returned
Declaration
public long StatTimeTicks { get; }
Property Value
Type |
Description |
System.Int64 |
|
Transports
Returns all transports in the binding stack
Declaration
public IEnumerable<Transport> Transports { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<Transport> |
|
Methods
_Register(Transport)
Declaration
protected void _Register(Transport transport)
Parameters
_Unregister(Transport)
Declaration
protected void _Unregister(Transport transport)
Parameters
AcquireClientTransportForCall(ClientEndPoint, RequestMsg)
Returns an instance of transport suitable for a call. The implementation may return existing transport or allocate a new instance.
The call is thread-safe
Declaration
protected virtual ClientTransport AcquireClientTransportForCall(ClientEndPoint client, RequestMsg request)
Parameters
Returns
AreNodesIdentical(Node, Node)
Returns true when two nodes represent the same binding, host and service identities.
The implementation depends on binding, for example some binding may recognize an optional parameter as part of host segment, however
that parameter does not change the identity of the node instance
Declaration
public abstract bool AreNodesIdentical(Node left, Node right)
Parameters
Type |
Name |
Description |
Node |
left |
|
Node |
right |
|
Returns
Type |
Description |
System.Boolean |
|
CheckRunningState(Boolean)
Ensures that application and binding runtime are running or throws otherwise
Declaration
public void CheckRunningState(bool client = true)
Parameters
Type |
Name |
Description |
System.Boolean |
client |
|
CloseServerEndpoint(ServerEndPoint)
Declaration
protected abstract void CloseServerEndpoint(ServerEndPoint epoint)
Parameters
Override to perform custom transport preparation and launch
Declaration
protected virtual void ConfigureAndStartNewClientTransport(ClientTransport transport)
Parameters
Destructor()
Declaration
protected override void Destructor()
Overrides
DispatchCall(ClientEndPoint, RequestMsg)
Dispatches a call allocating new or re-using existing transport if needed. The strategy depends on particular Binding implementation.
This call is thread-safe
Declaration
public CallSlot DispatchCall(ClientEndPoint client, RequestMsg request)
Parameters
Returns
DoAcceptManagerVisit(Object, DateTime)
Declaration
protected override void DoAcceptManagerVisit(object manager, DateTime managerNow)
Parameters
Type |
Name |
Description |
System.Object |
manager |
|
System.DateTime |
managerNow |
|
Overrides
Declaration
protected override void DoConfigure(IConfigSectionNode node)
Parameters
Overrides
DoSignalStop()
Declaration
protected override void DoSignalStop()
Overrides
DoWaitForCompleteStop()
Declaration
protected override void DoWaitForCompleteStop()
Overrides
DumpMsg(Boolean, Msg, ArraySegment<Byte>)
Conditionally dumps message to disk
Declaration
protected void DumpMsg(bool server, Msg msg, ArraySegment<byte> data)
Parameters
Type |
Name |
Description |
System.Boolean |
server |
True for server-side message
|
Msg |
msg |
Message that was deserialized/serialized. If null then error happened while deserializing
|
System.ArraySegment<System.Byte> |
data |
Data
|
DumpMsg(Boolean, Msg, Byte[], Int32, Int32)
Conditionally dumps message to disk
Declaration
protected void DumpMsg(bool server, Msg msg, byte[] buffer, int offset, int count)
Parameters
Type |
Name |
Description |
System.Boolean |
server |
True for server-side message
|
Msg |
msg |
Message that was deserialized/serialized. If null then error happened while deserializing
|
System.Byte[] |
buffer |
Message body
|
System.Int32 |
offset |
Start index in buffer
|
System.Int32 |
count |
Byte size of message body
|
DumpMsg(Boolean, Msg, Func<ArraySegment<Byte>>)
Conditionally dumps message to disk where the data is lazily obtained by calling dataFun
Declaration
protected void DumpMsg(bool server, Msg msg, Func<ArraySegment<byte>> dataFun)
Parameters
Type |
Name |
Description |
System.Boolean |
server |
|
Msg |
msg |
|
System.Func<System.ArraySegment<System.Byte>> |
dataFun |
|
GetClientCallStatTimeKey(ClientEndPoint, RequestMsg)
Extracts necessary information from client:request pair that characterizes the particular call
for the purpose of call timing
Declaration
public virtual string GetClientCallStatTimeKey(ClientEndPoint client, RequestMsg request)
Parameters
Returns
Type |
Description |
System.String |
|
MakeNewClientTransport(ClientEndPoint)
Factory method - Override to make an instance of a new client transport suitable for particular binding type
Declaration
protected abstract ClientTransport MakeNewClientTransport(ClientEndPoint client)
Parameters
Returns
OpenServerEndpoint(ServerEndPoint)
Declaration
protected abstract ServerTransport OpenServerEndpoint(ServerEndPoint epoint)
Parameters
Returns
ReleaseClientTransportAfterCall(ClientTransport)
Releases a transport instance that was acquired for call.
The implementation may return this instance back to the pool of available transports or deallocate it.
The default implementation releases the instance back to the pool
Declaration
protected virtual void ReleaseClientTransportAfterCall(ClientTransport transport)
Parameters
TryGetExistingAcquiredTransportPerRemoteNode(Node)
Tries to acquire an available client transport to make a call.
This method respects binding/transport settings that impose a limit on the number of
open concurrent transports and timeouts for acqusition waiting
Declaration
protected virtual ClientTransport TryGetExistingAcquiredTransportPerRemoteNode(Node remoteNode)
Parameters
Type |
Name |
Description |
Node |
remoteNode |
remote node to connect to
|
Returns
Implements
System.IDisposable
Extension Methods