Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acceptor Dynamic Session Templates #607

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0ac7ecc
Merge pull request #1 from connamara/master
pvkv1799 Jun 18, 2020
1c0d3a6
Logout can be received when not logged on.
LittleAlexey Jan 19, 2018
4a32702
Redirected stderr to stdout (nul) to avoid confusing message "'pwsh' …
pvkv1799 Jun 18, 2020
31e4cd7
comment about where pwsh comes from
gbirchmeier Jun 24, 2020
1aa5da1
fix some typos
gbirchmeier Jun 24, 2020
ab6d8c8
don't use "./", don't auto-upload nugets
gbirchmeier Jun 25, 2020
cabb0b8
restore RELEASE-README.md... again
gbirchmeier Jun 25, 2020
37e4e3d
fix formatting of RELEASE_README
gbirchmeier Jun 25, 2020
ce6691d
Bump NUnit3TestAdapter from 3.16.1 to 3.17.0
dependabot-preview[bot] Jul 13, 2020
7bce47e
incremented version on release notes
gbirchmeier Jul 13, 2020
0ff6970
Don't reflect on non-QF/n assemblies
gbirchmeier Jul 13, 2020
5137896
forgot to own it
gbirchmeier Jul 13, 2020
f92bc9f
corrections for ruby 2.5+; some script annotations
gbirchmeier Jul 21, 2020
505907a
remove old unused C++ build
gbirchmeier Jul 21, 2020
45dbc5d
use ruby 2.7 on appveyor
gbirchmeier Jul 21, 2020
9ae84bf
some debugging for ruby on appveyor
gbirchmeier Jul 21, 2020
ba756a2
more debugging
gbirchmeier Jul 21, 2020
737b728
change to ruby 2.6, since appveyor's being weird
gbirchmeier Jul 21, 2020
243ddc4
ignore .vscode/
gbirchmeier Jul 22, 2020
a0bdc64
add 1156 (ApplExtId) to FIXT11.xml
gbirchmeier Jul 28, 2020
edfffa3
stupid copy/paste error in previous commit
gbirchmeier Jul 28, 2020
143da50
Added "AcceptorTemplate" parameter
pvkv1799 Jun 1, 2020
e3579b7
Comment
pvkv1799 Jun 1, 2020
dc82d51
Added SessionID wildcards handling to FileLog
pvkv1799 Jun 1, 2020
d296fcb
Added FileLog unit tests for wildcards
pvkv1799 Jun 1, 2020
acd35de
Refactored ThreadedSocketAcceptor unit tests: changed to pass configu…
pvkv1799 Jun 1, 2020
d0a14ee
Added SessionID wildcards handling to FileStore;
pvkv1799 Jun 2, 2020
622c395
Bug fix: validation of BeginString regardless of Connection Type
pvkv1799 Jun 3, 2020
782dfe3
Bug fix in test: wildcards are valid only for acceptor
pvkv1799 Jun 3, 2020
1eab2e4
Added logic to create the new session from a template upon receiving …
pvkv1799 Jun 3, 2020
52144b3
Added unit tests for dynamic session templates
pvkv1799 Jun 3, 2020
56e5584
Removed unused AcceptorTemplate constant
pvkv1799 Jun 3, 2020
176dce3
Documentation comments for GetSession
pvkv1799 Jun 3, 2020
6af399a
Removed TODO from GetSession
pvkv1799 Jun 10, 2020
3bb2a51
Added check for null _acceptor in CreateFromTemplate
pvkv1799 Jun 10, 2020
9059892
Improved explanations in comments
pvkv1799 Jun 10, 2020
628b77a
Using the new Session constructor with isInitiator
pvkv1799 Jun 18, 2020
50005cb
Removed commented ACCEPTOR_TEMPLATE constant
pvkv1799 Jun 18, 2020
83f1b83
Renamed GetSession to LookupOrCreateDynamicSession
pvkv1799 Jun 18, 2020
2f54fe5
Removed commented-out irrelevant code
pvkv1799 Jun 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ upload_to_s3.rb
*~
*.suo
.vs/
.vscode/

# ReSharper is a .NET coding add-in
_ReSharper*/
Expand Down
1 change: 0 additions & 1 deletion AcceptanceTest/at_xml_to_nunit_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class Fixture
attr_accessor :name, :total, :errors, :failures, :cases

def self.create_from_acceptance_test_xml xml_filename
require 'rubygems'
require 'nokogiri'

fixture = Fixture.new
Expand Down
Binary file removed AcceptanceTest/debug/at/quickfix_net.dll
Binary file not shown.
Binary file removed AcceptanceTest/debug/at/quickfix_net.pdb
Binary file not shown.
Binary file removed AcceptanceTest/debug/at/quickfix_net_messages.dll
Binary file not shown.
Binary file removed AcceptanceTest/debug/at/quickfix_net_messages.pdb
Binary file not shown.
Binary file removed AcceptanceTest/debug/pt/quickfix_net.dll
Binary file not shown.
Binary file removed AcceptanceTest/debug/pt/quickfix_net.pdb
Binary file not shown.
Binary file removed AcceptanceTest/debug/pt/quickfix_net_messages.dll
Binary file not shown.
Binary file removed AcceptanceTest/debug/pt/quickfix_net_messages.pdb
Binary file not shown.
1 change: 1 addition & 0 deletions AcceptanceTest/runat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ AppDataDictionary=..\spec\fix\FIX50SP1.xml
"@ | Out-File 'cfg\at.cfg' -Encoding utf8

# Start the acceptor...
# (this runs the exe or dll in AcceptanceTest/bin/)
$AtProcess = Start-Process -FilePath dotnet.exe -ArgumentList "run -c $Configuration -f $Framework --no-build --no-restore -- $Conf" -NoNewWindow -PassThru

if ($UseWsl -and $UseWsl.IsPresent) {
Expand Down
56 changes: 28 additions & 28 deletions New-Release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Write-Host "`nTag Version: $TagVersion`n"
if ($UseWslRuby -and $UseWslRuby.IsPresent) {
wsl ruby scripts\update_assembly_version.rb $TagVersion QuickFIXn\QuickFix.csproj Messages\FIX40\QuickFix.FIX40.csproj Messages\FIX41\QuickFix.FIX41.csproj Messages\FIX42\QuickFix.FIX42.csproj Messages\FIX43\QuickFix.FIX43.csproj Messages\FIX44\QuickFix.FIX44.csproj Messages\FIX50\QuickFix.FIX50.csproj Messages\FIX50SP1\QuickFix.FIX50SP1.csproj Messages\FIX50SP2\QuickFix.FIX50SP2.csproj
} else {
.\ruby scripts\update_assembly_version.rb $TagVersion QuickFIXn\QuickFix.csproj Messages\FIX40\QuickFix.FIX40.csproj Messages\FIX41\QuickFix.FIX41.csproj Messages\FIX42\QuickFix.FIX42.csproj Messages\FIX43\QuickFix.FIX43.csproj Messages\FIX44\QuickFix.FIX44.csproj Messages\FIX50\QuickFix.FIX50.csproj Messages\FIX50SP1\QuickFix.FIX50SP1.csproj Messages\FIX50SP2\QuickFix.FIX50SP2.csproj
ruby scripts\update_assembly_version.rb $TagVersion QuickFIXn\QuickFix.csproj Messages\FIX40\QuickFix.FIX40.csproj Messages\FIX41\QuickFix.FIX41.csproj Messages\FIX42\QuickFix.FIX42.csproj Messages\FIX43\QuickFix.FIX43.csproj Messages\FIX44\QuickFix.FIX44.csproj Messages\FIX50\QuickFix.FIX50.csproj Messages\FIX50SP1\QuickFix.FIX50SP1.csproj Messages\FIX50SP2\QuickFix.FIX50SP2.csproj
}

$ExitCode = $LASTEXITCODE
Expand All @@ -38,22 +38,22 @@ if ($ExitCode -eq 0) {
Exit $ExitCode
}

.\git add QuickFIXn\QuickFix.csproj
.\git add Messages\FIX40\QuickFix.FIX40.csproj
.\git add Messages\FIX41\QuickFix.FIX41.csproj
.\git add Messages\FIX42\QuickFix.FIX42.csproj
.\git add Messages\FIX43\QuickFix.FIX43.csproj
.\git add Messages\FIX44\QuickFix.FIX44.csproj
.\git add Messages\FIX50\QuickFix.FIX50.csproj
.\git add Messages\FIX50SP1\QuickFix.FIX50SP1.csproj
.\git add Messages\FIX50SP2\QuickFix.FIX50SP2.csproj
.\git commit -m "version number for version %TAG_VERSION%"
git add QuickFIXn\QuickFix.csproj
git add Messages\FIX40\QuickFix.FIX40.csproj
git add Messages\FIX41\QuickFix.FIX41.csproj
git add Messages\FIX42\QuickFix.FIX42.csproj
git add Messages\FIX43\QuickFix.FIX43.csproj
git add Messages\FIX44\QuickFix.FIX44.csproj
git add Messages\FIX50\QuickFix.FIX50.csproj
git add Messages\FIX50SP1\QuickFix.FIX50SP1.csproj
git add Messages\FIX50SP2\QuickFix.FIX50SP2.csproj
git commit -m "version number for version %TAG_VERSION%"
Write-Host '* Version number committed.'

.\git tag -a $TagVersion -m 'Release version $TagVersion'
git tag -a $TagVersion -m 'Release version $TagVersion'
Write-Host '* Created tag.'

.\git checkout $TagVersion
git checkout $TagVersion
$ExitCode = $LASTEXITCODE
if ($ExitCode -eq 0) {
Write-Host "* Checked out tag $TagVersion"
Expand All @@ -65,7 +65,7 @@ if ($ExitCode -eq 0) {
if ($UsWslRuby -and $UseWslRuby.IsPresent) {
wsl ruby generator/generate.rb
} else {
.\ruby generator/generate.rb
ruby generator/generate.rb
}

$ExitCode = $LASTEXITCODE
Expand All @@ -91,17 +91,17 @@ if ($ExitCode -eq 0) {

# DO NOT remove quotes around *.nupkg. Due to a bug in older versions of the .NET SDK,
# without the surrounding quotes, only the first package will be pushed.
if ($BuildTarget -ieq 'pack') {
dotnet nuget push '*.nupkg' -s 'https://api.nuget.org/v3/index.json' -k $NuGetApiKey 'tmp\NuGet'
}

$ExitCode = $LASTEXITCODE
if ($ExitCode -eq 0) {
Write-Host '* Pushed QuickFIX/n NuGet packages to NuGet.org'
} else {
Write-Error 'A problem occurred while pushing NuGet packages to NuGet.org'
Exit $ExitCode
}
#if ($BuildTarget -ieq 'pack') {
# dotnet nuget push '*.nupkg' -s 'https://api.nuget.org/v3/index.json' -k $NuGetApiKey 'tmp\NuGet'
#}

#$ExitCode = $LASTEXITCODE
#if ($ExitCode -eq 0) {
# Write-Host '* Pushed QuickFIX/n NuGet packages to NuGet.org'
#} else {
# Write-Error 'A problem occurred while pushing NuGet packages to NuGet.org'
# Exit $ExitCode
#}

@(
$QFDir
Expand Down Expand Up @@ -140,7 +140,7 @@ Write-Host '* Created zip.'
if ($UseWslRuby -and $UseWslRuby.IsPresent) {
wsl ruby scripts\s3_upload.rb "$QFDir.zip" $AwsAccessKey $AwsSecretKey
} else {
.\ruby scripts\s3_upload.rb "$QFDir.zip" $AwsAccessKey $AwsSecretKey
ruby scripts\s3_upload.rb "$QFDir.zip" $AwsAccessKey $AwsSecretKey
}

$ExitCode = $LASTEXITCODE
Expand All @@ -154,7 +154,7 @@ if ($ExitCode -eq 0) {
Get-ChildItem -Path 'tmp' -Recurse | Remove-Item -Recurse -Force
Write-Host '* Removed ''tmp'' directory.'

.\git checkout master
git checkout master
Write-Host '* Changed back to master.'

Write-Host "`nSuccessfully created QuickFIX/n $TagVersion" -ForegroundColor Green
Expand All @@ -164,4 +164,4 @@ if ($NuGetApiKey) {
}
Write-Host "You must commit the new tag and deploy the website"

Exit 0
Exit 0
2 changes: 1 addition & 1 deletion QuickFIXn/DefaultMessageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static ICollection<Assembly> GetAppDomainAssemblies()
var assemblies = AppDomain
.CurrentDomain
.GetAssemblies()
.Where(assembly => !assembly.IsDynamic)
.Where(assembly => !assembly.IsDynamic && assembly.GetName().Name.StartsWith("QuickFix"))
.ToList();
return assemblies;
}
Expand Down
94 changes: 84 additions & 10 deletions QuickFIXn/FileLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,97 @@ private void Init(string fileLogPath, string prefix)
eventLog_.AutoFlush = true;
}

public const string WILDCARD_FILE_PREFIX = "DS_"; // Dynamic Session
public const string WILDCARD_REPLACEMENT = "(ANY)";
/// <summary>
/// Calculates unique filename prefix from SessionID.
/// Handles wildcards in SessionID fields
/// </summary>
/// <returns>Filename prefix unique for SessioID</returns>
public static string Prefix(SessionID sessionID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly (or all) the same as FileStore.Prefix(). That was fine when they were small, but now I think this common code should be unified. Perhaps a static class & function would be appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do - should I put the new calls in "Util" subfolder of the solution?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll work, or it could go in the same dir as FileLog/FileStore. Doesn't really matter to me.

{
System.Text.StringBuilder prefix = new System.Text.StringBuilder(sessionID.BeginString)
.Append('-').Append(sessionID.SenderCompID);

bool hasWildcard = false;

System.Text.StringBuilder prefix = new System.Text.StringBuilder();
if (Values.WILDCARD_VALUE.Equals(sessionID.BeginString))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT).Append('-');
}
else prefix.Append(sessionID.BeginString).Append('-');
if (Values.WILDCARD_VALUE.Equals(sessionID.SenderCompID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.SenderCompID);


if (SessionID.IsSet(sessionID.SenderSubID))
prefix.Append('_').Append(sessionID.SenderSubID);
{
prefix.Append('_');
if (Values.WILDCARD_VALUE.Equals(sessionID.SenderSubID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.SenderSubID);
}
if (SessionID.IsSet(sessionID.SenderLocationID))
prefix.Append('_').Append(sessionID.SenderLocationID);
prefix.Append('-').Append(sessionID.TargetCompID);
{
prefix.Append('_');
if (Values.WILDCARD_VALUE.Equals(sessionID.SenderLocationID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.SenderLocationID);
}
prefix.Append('-');
if (Values.WILDCARD_VALUE.Equals(sessionID.TargetCompID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.TargetCompID);

if (SessionID.IsSet(sessionID.TargetSubID))
prefix.Append('_').Append(sessionID.TargetSubID);
{
prefix.Append('_');
if (Values.WILDCARD_VALUE.Equals(sessionID.TargetSubID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.TargetSubID);
}
if (SessionID.IsSet(sessionID.TargetLocationID))
prefix.Append('_').Append(sessionID.TargetLocationID);

{
prefix.Append('_');
if (Values.WILDCARD_VALUE.Equals(sessionID.TargetLocationID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.TargetLocationID);
}
// SessionQualifier now is not allowed for acceptor, so cannot be a wildcard,
// still should not hurt to implement wildcard logic for it
if (SessionID.IsSet(sessionID.SessionQualifier))
prefix.Append('-').Append(sessionID.SessionQualifier);

{
prefix.Append('-');
if (Values.WILDCARD_VALUE.Equals(sessionID.SessionQualifier))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.SessionQualifier);
}
// To guarantee unique file name,
// even if someone uses WILDCARD_REPLACEMENT as a part if SessionID
if (hasWildcard) return WILDCARD_FILE_PREFIX + prefix.ToString();
// No wildcard(s) - no additional prefix
return prefix.ToString();
}

Expand Down
94 changes: 84 additions & 10 deletions QuickFIXn/FileStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,97 @@ public MsgDef(long index, int size)

System.Collections.Generic.Dictionary<int, MsgDef> offsets_ = new Dictionary<int, MsgDef>();

public const string WILDCARD_FILE_PREFIX = "DS_"; // Dynamic Session
public const string WILDCARD_REPLACEMENT = "(ANY)";
/// <summary>
/// Calculates unique filename prefix from SessionID.
/// Handles wildcards in SessionID fields
/// </summary>
/// <returns>Filename prefix unique for SessioID</returns>
public static string Prefix(SessionID sessionID)
{
System.Text.StringBuilder prefix = new System.Text.StringBuilder(sessionID.BeginString)
.Append('-').Append(sessionID.SenderCompID);

bool hasWildcard = false;

System.Text.StringBuilder prefix = new System.Text.StringBuilder();
if (Values.WILDCARD_VALUE.Equals(sessionID.BeginString))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT).Append('-');
}
else prefix.Append(sessionID.BeginString).Append('-');
if (Values.WILDCARD_VALUE.Equals(sessionID.SenderCompID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.SenderCompID);


if (SessionID.IsSet(sessionID.SenderSubID))
prefix.Append('_').Append(sessionID.SenderSubID);
{
prefix.Append('_');
if (Values.WILDCARD_VALUE.Equals(sessionID.SenderSubID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.SenderSubID);
}
if (SessionID.IsSet(sessionID.SenderLocationID))
prefix.Append('_').Append(sessionID.SenderLocationID);
prefix.Append('-').Append(sessionID.TargetCompID);
{
prefix.Append('_');
if (Values.WILDCARD_VALUE.Equals(sessionID.SenderLocationID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.SenderLocationID);
}
prefix.Append('-');
if (Values.WILDCARD_VALUE.Equals(sessionID.TargetCompID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.TargetCompID);

if (SessionID.IsSet(sessionID.TargetSubID))
prefix.Append('_').Append(sessionID.TargetSubID);
{
prefix.Append('_');
if (Values.WILDCARD_VALUE.Equals(sessionID.TargetSubID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.TargetSubID);
}
if (SessionID.IsSet(sessionID.TargetLocationID))
prefix.Append('_').Append(sessionID.TargetLocationID);

{
prefix.Append('_');
if (Values.WILDCARD_VALUE.Equals(sessionID.TargetLocationID))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.TargetLocationID);
}
// SessionQualifier now is not allowed for acceptor, so cannot be a wildcard,
// still should not hurt to implement wildcard logic for it
if (SessionID.IsSet(sessionID.SessionQualifier))
prefix.Append('-').Append(sessionID.SessionQualifier);

{
prefix.Append('-');
if (Values.WILDCARD_VALUE.Equals(sessionID.SessionQualifier))
{
hasWildcard = true;
prefix.Append(WILDCARD_REPLACEMENT);
}
else prefix.Append(sessionID.SessionQualifier);
}
// To guarantee unique file name,
// even if someone uses WILDCARD_REPLACEMENT as a part if SessionID
if (hasWildcard) return WILDCARD_FILE_PREFIX + prefix.ToString();
// No wildcard(s) - no additional prefix
return prefix.ToString();
}

Expand Down
Loading