Skip to content

Commit

Permalink
Merge pull request connamara#1 from gbirchmeier/314
Browse files Browse the repository at this point in the history
update from latest master, fix some typos
  • Loading branch information
martinadams committed Jun 10, 2015
2 parents d8c635e + a8153fe commit 259441c
Show file tree
Hide file tree
Showing 32 changed files with 890 additions and 123 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ ChangeLog
AcceptanceTest/AcceptanceTests*.html
AcceptanceTest/AcceptanceTests*.xml
AcceptanceTest/TestResult.xml
AcceptanceTest/bin/Debug/*
AcceptanceTest/bin/Release/*
AcceptanceTest/bin/
AcceptanceTest/obj/
AcceptanceTest/log/
AcceptanceTest/store/
AcceptanceTest/cfg/at.cfg
Examples/Executor/bin/*
Examples/Executor/obj/*
Examples/Executor/log/
Expand Down
1 change: 0 additions & 1 deletion AcceptanceTest/cfg/.gitignore

This file was deleted.

14 changes: 1 addition & 13 deletions AcceptanceTest/cfg/at_44.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,5 @@ TargetCompID=TW
ResetOnLogon=Y
FileStorePath=store
[SESSION]
BeginString=FIX.4.0
DataDictionary=..\spec\fix\FIX40.xml
[SESSION]
BeginString=FIX.4.1
DataDictionary=..\spec\fix\FIX41.xml
[SESSION]
BeginString=FIX.4.2
DataDictionary=..\spec\fix\FIX42.xml
[SESSION]
BeginString=FIX.4.3
DataDictionary=..\spec\fix\FIX43.xml
[SESSION]
BeginString=FIX.4.4
DataDictionary=..\spec\fix\FIX44.xml
DataDictionary=..\spec\fix\FIX44.xml
15 changes: 15 additions & 0 deletions AcceptanceTest/cfg/at_44_noreset.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[DEFAULT]
Verbose=Y
FileLogPath=log
ConnectionType=acceptor
SocketAcceptPort=5005
SocketReuseAddress=Y
StartTime=00:00:00
EndTime=00:00:00
SenderCompID=ISLD
TargetCompID=TW
ResetOnLogon=N
FileStorePath=store
[SESSION]
BeginString=FIX.4.4
DataDictionary=..\spec\fix\FIX44.xml
17 changes: 1 addition & 16 deletions AcceptanceTest/cfg/at_50.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,8 @@ SenderCompID=ISLD
TargetCompID=TW
ResetOnLogon=Y
FileStorePath=store
[SESSION]
BeginString=FIX.4.0
DataDictionary=..\spec\fix\FIX40.xml
[SESSION]
BeginString=FIX.4.1
DataDictionary=..\spec\fix\FIX41.xml
[SESSION]
BeginString=FIX.4.2
DataDictionary=..\spec\fix\FIX42.xml
[SESSION]
BeginString=FIX.4.3
DataDictionary=..\spec\fix\FIX43.xml
[SESSION]
BeginString=FIX.4.4
DataDictionary=..\spec\fix\FIX44.xml
[SESSION]
BeginString=FIXT.1.1
DefaultApplVerID=FIX.5.0
AppDataDictionary=..\spec\fix\FIX50.xml
TransportDataDictionary=..\spec\fix\FIXT11.xml
TransportDataDictionary=..\spec\fix\FIXT11.xml
15 changes: 0 additions & 15 deletions AcceptanceTest/cfg/at_50_sp1.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@ SenderCompID=ISLD
TargetCompID=TW
ResetOnLogon=Y
FileStorePath=store
[SESSION]
BeginString=FIX.4.0
DataDictionary=..\spec\fix\FIX40.xml
[SESSION]
BeginString=FIX.4.1
DataDictionary=..\spec\fix\FIX41.xml
[SESSION]
BeginString=FIX.4.2
DataDictionary=..\spec\fix\FIX42.xml
[SESSION]
BeginString=FIX.4.3
DataDictionary=..\spec\fix\FIX43.xml
[SESSION]
BeginString=FIX.4.4
DataDictionary=..\spec\fix\FIX44.xml
[SESSION]
BeginString=FIXT.1.1
DefaultApplVerID=FIX.5.0SP1
Expand Down
15 changes: 0 additions & 15 deletions AcceptanceTest/cfg/at_50_sp2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@ SenderCompID=ISLD
TargetCompID=TW
ResetOnLogon=Y
FileStorePath=store
[SESSION]
BeginString=FIX.4.0
DataDictionary=..\spec\fix\FIX40.xml
[SESSION]
BeginString=FIX.4.1
DataDictionary=..\spec\fix\FIX41.xml
[SESSION]
BeginString=FIX.4.2
DataDictionary=..\spec\fix\FIX42.xml
[SESSION]
BeginString=FIX.4.3
DataDictionary=..\spec\fix\FIX43.xml
[SESSION]
BeginString=FIX.4.4
DataDictionary=..\spec\fix\FIX44.xml
[SESSION]
BeginString=FIXT.1.1
DefaultApplVerID=FIX.5.0SP2
Expand Down
4 changes: 2 additions & 2 deletions AcceptanceTest/definitions/server/fix44/SessionReset.def
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ E8=FIX.4.49=5535=034=249=ISLD52=<TIME>56=TW112=1
#send a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1
I8=FIX.4.435=A34=149=TW52=<TIME>56=ISLD98=0108=30141=Y
#Expect a response with a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1.
E8=FIX.4.49=6735=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=30141=Y10=0
E8=FIX.4.49=6135=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=3010=0

#Send TestRequest (MsgSeqNum = 2) expect to receive HeartBeat (MsgSeqNum = 2)
I8=FIX.4.435=134=249=TW52=<TIME>56=ISLD112=1
Expand All @@ -31,4 +31,4 @@ E8=FIX.4.49=5535=034=249=ISLD52=<TIME>56=TW112=1
I8=FIX.4.435=534=349=TW52=<TIME>56=ISLD
E8=FIX.4.49=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0

eDISCONNECT
eDISCONNECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Issue #80: logon with reset _after_disconnect_

iCONNECT
# logon with reset, because this config has ResetOnLogon=N
I8=FIX.4.435=A34=149=TW52=<TIME>56=ISLD98=0108=30141=Y
E8=FIX.4.49=6135=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=3010=0
I8=FIX.4.435=034=249=TW52=<TIME>56=ISLD
I8=FIX.4.435=034=349=TW52=<TIME>56=ISLD
I8=FIX.4.435=034=449=TW52=<TIME>56=ISLD
I8=FIX.4.435=034=549=TW52=<TIME>56=ISLD
I8=FIX.4.435=034=649=TW52=<TIME>56=ISLD
I8=FIX.4.435=034=749=TW52=<TIME>56=ISLD
I8=FIX.4.435=034=849=TW52=<TIME>56=ISLD
I8=FIX.4.435=034=949=TW52=<TIME>56=ISLD

#Send TestRequest, expect HeartBeat response
I8=FIX.4.435=134=1049=TW52=<TIME>56=ISLD112=1
E8=FIX.4.49=5535=034=249=ISLD52=<TIME>56=TW112=1

#Logout and response
I8=FIX.4.435=534=1149=TW52=<TIME>56=ISLD
E8=FIX.4.49=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0

eDISCONNECT
iCONNECT

#send a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1
I8=FIX.4.435=A34=149=TW52=<TIME>56=ISLD98=0108=30141=Y
#Expect a response with a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1.
E8=FIX.4.49=6135=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=3010=0

#Send TestRequest (MsgSeqNum = 2) expect to receive HeartBeat (MsgSeqNum = 2)
I8=FIX.4.435=134=249=TW52=<TIME>56=ISLD112=1
E8=FIX.4.49=5535=034=249=ISLD52=<TIME>56=TW112=1

# logout message and response
I8=FIX.4.435=534=349=TW52=<TIME>56=ISLD
E8=FIX.4.49=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0

eDISCONNECT
4 changes: 2 additions & 2 deletions AcceptanceTest/definitions/server/fix50/SessionReset.def
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ E8=FIXT.1.19=5535=034=249=ISLD52=<TIME>56=TW112=1
#send a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1
I8=FIXT.1.135=A34=149=TW52=<TIME>56=ISLD98=0108=30141=Y1137=7
#Expect a response with a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1.
E8=FIXT.1.19=7435=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=30141=Y1137=710=0
E8=FIXT.1.19=6835=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=301137=710=0

#Send TestRequest (MsgSeqNum = 2) expect to receive HeartBeat (MsgSeqNum = 2)
I8=FIXT.1.135=134=249=TW52=<TIME>56=ISLD112=1
Expand All @@ -31,4 +31,4 @@ E8=FIXT.1.19=5535=034=249=ISLD52=<TIME>56=TW112=1
I8=FIXT.1.135=534=349=TW52=<TIME>56=ISLD
E8=FIXT.1.19=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0

eDISCONNECT
eDISCONNECT
4 changes: 2 additions & 2 deletions AcceptanceTest/definitions/server/fix50sp1/SessionReset.def
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ E8=FIXT.1.19=5535=034=249=ISLD52=<TIME>56=TW112=1
#send a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1
I8=FIXT.1.135=A34=149=TW52=<TIME>56=ISLD98=0108=30141=Y1137=8
#Expect a response with a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1.
E8=FIXT.1.19=7435=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=30141=Y1137=810=0
E8=FIXT.1.19=6835=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=301137=810=0

#Send TestRequest (MsgSeqNum = 2) expect to receive HeartBeat (MsgSeqNum = 2)
I8=FIXT.1.135=134=249=TW52=<TIME>56=ISLD112=1
Expand All @@ -31,4 +31,4 @@ E8=FIXT.1.19=5535=034=249=ISLD52=<TIME>56=TW112=1
I8=FIXT.1.135=534=349=TW52=<TIME>56=ISLD
E8=FIXT.1.19=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0

eDISCONNECT
eDISCONNECT
4 changes: 2 additions & 2 deletions AcceptanceTest/definitions/server/fix50sp2/SessionReset.def
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ E8=FIXT.1.19=5535=034=249=ISLD52=<TIME>56=TW112=1
#send a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1
I8=FIXT.1.135=A34=149=TW52=<TIME>56=ISLD98=0108=30141=Y1137=9
#Expect a response with a Logon with ResetSeqNumFlag set to Y and with MsgSeqNum of 1.
E8=FIXT.1.19=7435=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=30141=Y1137=910=0
E8=FIXT.1.19=6835=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=301137=910=0

#Send TestRequest (MsgSeqNum = 2) expect to receive HeartBeat (MsgSeqNum = 2)
I8=FIXT.1.135=134=249=TW52=<TIME>56=ISLD112=1
Expand All @@ -31,4 +31,4 @@ E8=FIXT.1.19=5535=034=249=ISLD52=<TIME>56=TW112=1
I8=FIXT.1.135=534=349=TW52=<TIME>56=ISLD
E8=FIXT.1.19=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0

eDISCONNECT
eDISCONNECT
1 change: 0 additions & 1 deletion AcceptanceTest/obj/Debug/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion AcceptanceTest/obj/Release/.gitignore

This file was deleted.

5 changes: 4 additions & 1 deletion NEXT_VERSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ Changes since the last version (oldest first):
* (minor) #286 - FieldBase.Equals() and .GetHashcode() (steffanu)
* (patch) #287 - sync fix in Session class (steffanu)
* (patch) #275 - SessionID.IsSet() should be used instead of !=SessionID.NOT_SET (akamyshanov)

* (patch) #297 - revert #287
* (patch) #290 - support for RefreshOnLogon (martinadams)
* (patch) #80 - fixes to tag-141-related sequence resets (TomasVetrovsky,akamyshanov,gbirchmeier)
* (minor) #314 - New feature: add/remove sessions dynamically (martinadams)

99 changes: 82 additions & 17 deletions QuickFIXn/AbstractInitiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public abstract class AbstractInitiator : IInitiator
private HashSet<SessionID> disconnected_ = new HashSet<SessionID>();
private bool isStopped_ = true;
private Thread thread_;
private SessionFactory sessionFactory_ = null;

#region Properties

Expand Down Expand Up @@ -59,18 +60,11 @@ public void Start()
throw new System.ObjectDisposedException(this.GetType().Name);

// create all sessions
SessionFactory factory = new SessionFactory(_app, _storeFactory, _logFactory, _msgFactory);
sessionFactory_ = new SessionFactory(_app, _storeFactory, _logFactory, _msgFactory);
foreach (SessionID sessionID in _settings.GetSessions())
{
Dictionary dict = _settings.Get(sessionID);
string connectionType = dict.GetString(SessionSettings.CONNECTION_TYPE);

if ("initiator".Equals(connectionType))
{
sessionIDs_.Add(sessionID);
sessions_[sessionID] = factory.Create(sessionID, dict);
SetDisconnected(sessionID);
}
AddSession(sessionID, dict);
}

if (0 == sessions_.Count)
Expand All @@ -83,6 +77,65 @@ public void Start()
thread_.Start();
}

/// <summary>
/// Add new session, either at start-up or as an ad-hoc operation
/// </summary>
/// <param name="sessionID">ID of new session<param>
/// <param name="dict">config settings for new session</param></param>
/// <returns>true if session added successfully, false if session already exists or is not an initiator</returns>
public bool AddSession(SessionID sessionID, Dictionary dict)
{
if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID))
{
Session session = sessionFactory_.Create(sessionID, dict);
lock (sync_)
{
if (!_settings.Has(sessionID)) // session won't be in settings if ad-hoc creation after startup
_settings.Set(sessionID, dict);
sessionIDs_.Add(sessionID);
sessions_[sessionID] = session;
SetDisconnected(sessionID);
}
return true;
}
return false;
}

/// <summary>
/// Ad-hoc removal of an existing session
/// </summary>
/// <param name="sessionID">ID of session to be removed</param>
/// <param name="terminateActiveSession">if true, force disconnection and removal of session even if it has an active connection</param>
/// <returns>true if session removed or not already present; false if could not be removed due to an active connection</returns>
public bool RemoveSession(SessionID sessionID, bool terminateActiveSession)
{
Session session = null;
bool disconnectRequired = false;
lock (sync_)
{
if (sessionIDs_.Contains(sessionID))
{
session = sessions_[sessionID];
if (session.IsLoggedOn && !terminateActiveSession)
return false;

sessions_.Remove(sessionID);
_settings.Remove(sessionID);
disconnectRequired = IsConnected(sessionID) || IsPending(sessionID);
if (disconnectRequired)
SetDisconnected(sessionID);
disconnected_.Remove(sessionID);
sessionIDs_.Remove(sessionID);
OnRemove(sessionID);
}
}
if (disconnectRequired)
session.Disconnect("Dynamic session removal");
if (session != null)
session.Dispose();
return true;
}

/// <summary>
/// Logout existing session and close connection. Attempt graceful disconnect first.
/// </summary>
Expand Down Expand Up @@ -144,12 +197,13 @@ public void Stop(bool force)
{
foreach (Session s in sessions_.Values)
s.Dispose();

sessions_.Clear();
sessionIDs_.Clear();
pending_.Clear();
connected_.Clear();
disconnected_.Clear();
}
sessions_.Clear();
sessionIDs_.Clear();
pending_.Clear();
connected_.Clear();
disconnected_.Clear();
}

public bool IsLoggedOn
Expand Down Expand Up @@ -178,6 +232,14 @@ public bool IsLoggedOn
protected virtual void OnConfigure(SessionSettings settings)
{ }

/// <summary>
/// Implement this to provide custom reaction behavior to an ad-hoc session removal.
/// (This is called after the session is removed.)
/// </summary>
/// <param name="sessionID">ID of session that was removed</param>
protected virtual void OnRemove(SessionID sessionID)
{ }

[System.Obsolete("This method's intended purpose is unclear. Don't use it.")]
protected virtual void OnInitialize(SessionSettings settings)
{ }
Expand Down Expand Up @@ -254,9 +316,12 @@ protected void SetDisconnected(SessionID sessionID)
{
lock (sync_)
{
pending_.Remove(sessionID);
connected_.Remove(sessionID);
disconnected_.Add(sessionID);
if (sessionIDs_.Contains(sessionID))
{
pending_.Remove(sessionID);
connected_.Remove(sessionID);
disconnected_.Add(sessionID);
}
}
}

Expand Down
Loading

0 comments on commit 259441c

Please sign in to comment.