Skip to content

Commit

Permalink
Port to 1.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JPWatson committed Dec 18, 2018
1 parent cc1bb4c commit ced5898
Show file tree
Hide file tree
Showing 33 changed files with 833 additions and 556 deletions.
4 changes: 2 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### Port
Aeron.NET has been ported against Java version:
- Agrona: 0.9.22
- Aeron: 1.10.4
- Agrona: 0.9.28
- Aeron: 1.13.0
2 changes: 1 addition & 1 deletion driver/Aeron.Driver.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Aeron.Driver</id>
<version>1.12.0</version>
<version>1.13.0</version>
<title>Aeron Driver</title>
<authors>Adaptive Financial Consulting Ltd.</authors>
<owners>Adaptive Financial Consulting Ltd.</owners>
Expand Down
Binary file modified driver/media-driver.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion driver/version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Driver source:
https://repo1.maven.org/maven2/io/aeron/aeron-all/1.12.0/aeron-all-1.12.0.jar
https://repo1.maven.org/maven2/io/aeron/aeron-all/1.13.0/aeron-all-1.13.0.jar
2 changes: 1 addition & 1 deletion src/Adaptive.Aeron/Adaptive.Aeron.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<PackageId>Aeron.Client</PackageId>
<VersionPrefix>1.12.0</VersionPrefix>
<VersionPrefix>1.13.0</VersionPrefix>
<Authors>Adaptive Financial Consulting Ltd.</Authors>
<Company>Adaptive Financial Consulting Ltd.</Company>
<Product>Aeron Client</Product>
Expand Down
12 changes: 11 additions & 1 deletion src/Adaptive.Aeron/Aeron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,21 @@ public class Context : IDisposable
/// </summary>
public const string TAGS_PARAM_NAME = "tags";

/// <summary>
/// Qualifier for a value which is a tag for reference. This prefix is use in the param value.
/// </summary>
public const string TAG_PREFIX = "tag:";

/// <summary>
/// Parameter name for channel URI param to indicate if term buffers should be sparse. Value is boolean.
/// </summary>
public const string SPARSE_PARAM_NAME = "sparse";


/// <summary>
/// Parameter name for channel URI param to indicate an alias for the given URI. Value not interpreted by Aeron.
/// </summary>
public const string ALIAS_PARAM_NAME = "alias";

/// <summary>
/// Get the default directory name to be used if <seealso cref="AeronDirectoryName(String)"/> is not set. This will take
/// the <seealso cref="AERON_DIR_PROP_NAME"/> if set and if not then <seealso cref="AERON_DIR_PROP_DEFAULT"/>.
Expand Down
131 changes: 70 additions & 61 deletions src/Adaptive.Aeron/ChannelUri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private enum State
private string _prefix;
private string _media;
private readonly IDictionary<string, string> _params;
private string[] _tags;
private readonly string[] _tags;

/// <summary>
/// Construct with the components provided to avoid parsing.
Expand All @@ -62,7 +62,6 @@ public ChannelUri(string prefix, string media, IDictionary<string, string> @para
_prefix = prefix;
_media = media;
_params = @params;

_tags = SplitTags(_params.GetOrDefault(Aeron.Context.TAGS_PARAM_NAME));
}

Expand Down Expand Up @@ -185,27 +184,31 @@ public string Remove(string key)
/// </summary>
/// <param name="key"> to be lookup. </param>
/// <returns> true if the key has a value otherwise false. </returns>
/// <see cref="Aeron.Context.TAGS_PARAM_NAME"/>
/// <see cref="Aeron.Context.TAG_PREFIX"/>
public bool ContainsKey(string key)
{
return _params.ContainsKey(key);
}

/// <summary>
/// Get the channel tag.
/// Get the channel tag, if it exists, that refers to an another channel.
/// </summary>
/// <returns> channel tag. </returns>
/// <returns> channel tag if it exists or null if not in this URI. </returns>
public string ChannelTag()
{
return (_tags.Length > CHANNEL_TAG_INDEX) ? _tags[CHANNEL_TAG_INDEX] : null;
return (null != _tags && _tags.Length > CHANNEL_TAG_INDEX) ? _tags[CHANNEL_TAG_INDEX] : null;
}

/// <summary>
/// Get the entity tag.
/// Get the entity tag, if it exists, that refers to an entity such as subscription or publication.
/// </summary>
/// <returns> entity tag. </returns>
/// <returns> entity tag if it exists or null if not in this URI. </returns>
/// <see cref="Aeron.Context.TAGS_PARAM_NAME"/>
/// <see cref="Aeron.Context.TAG_PREFIX"/>
public string EntityTag()
{
return (_tags.Length > ENTITY_TAG_INDEX) ? _tags[ENTITY_TAG_INDEX] : null;
return (null != _tags && _tags.Length > ENTITY_TAG_INDEX) ? _tags[ENTITY_TAG_INDEX] : null;
}

/// <summary>
Expand Down Expand Up @@ -275,7 +278,7 @@ public static ChannelUri Parse(string cs)
{
int position = 0;
string prefix;
if (StartsWith(cs, Aeron.Context.SPY_PREFIX))
if (StartsWith(cs, 0, Aeron.Context.SPY_PREFIX))
{
prefix = SPY_QUALIFIER;
position = Aeron.Context.SPY_PREFIX.Length;
Expand Down Expand Up @@ -326,33 +329,28 @@ public static ChannelUri Parse(string cs)
break;

case State.PARAMS_KEY:
switch (c)
if (c == '=')
{
case '=':
key = builder.ToString();
builder.Length = 0;
state = State.PARAMS_VALUE;
break;

default:
builder.Append(c);
break;
key = builder.ToString();
builder.Length = 0;
state = State.PARAMS_VALUE;
}
else
{
builder.Append(c);
}

break;

case State.PARAMS_VALUE:
switch (c)
if (c == '|')
{
case '|':
@params[key] = builder.ToString();
builder.Length = 0;
state = State.PARAMS_KEY;
break;

default:
builder.Append(c);
break;
@params[key] = builder.ToString();
builder.Length = 0;
state = State.PARAMS_KEY;
}
else
{
builder.Append(c);
}

break;
Expand Down Expand Up @@ -394,20 +392,24 @@ public static string AddSessionId(string channel, int sessionId)
}

/// <summary>
/// Is the param tagged? (starts with the "tag:" prefix)
/// Is the param value tagged? (starts with the "tag:" prefix)
/// </summary>
/// <param name="paramValue"> to check if tagged. </param>
/// <returns> true if tagged or false if not. </returns>
/// <see cref="Aeron.Context.TAGS_PARAM_NAME"/>
/// <see cref="Aeron.Context.TAG_PREFIX"/>
public static bool IsTagged(string paramValue)
{
return StartsWith(paramValue, "tag:");
return StartsWith(paramValue, 0, Aeron.Context.TAG_PREFIX);
}

/// <summary>
/// Get the value of the tag from a given parameter.
/// Get the value of the tag from a given parameter value.
/// </summary>
/// <param name="paramValue"> to extract the tag value from. </param>
/// <returns> the value of the tag or <seealso cref="INVALID_TAG"/> if not tagged. </returns>
/// <see cref="Aeron.Context.TAGS_PARAM_NAME"/>
/// <see cref="Aeron.Context.TAG_PREFIX"/>
public static long GetTag(string paramValue)
{
return IsTagged(paramValue) ? long.Parse(paramValue.Substring(4, paramValue.Length - 4)) : INVALID_TAG;
Expand All @@ -430,49 +432,56 @@ private static bool StartsWith(string input, int position, string prefix)

return true;
}

private static bool StartsWith(string input, string prefix)
{
return StartsWith(input, 0, prefix);
}

private static string[] SplitTags(string tags)
private static string[] SplitTags(string tagsValue)
{
string[] stringArray = new string[0];
string[] tags = ArrayUtil.EMPTY_STRING_ARRAY;

if (null != tags)
if (null != tagsValue)
{
int currentStartIndex = 0;
int tagIndex = 0;
stringArray = new string[2];
int length = tags.Length;

for (int i = 0; i < length; i++)
int tagCount = CountTags(tagsValue);
if (tagCount == 1)
{
if (tags[i] == ',')
{
string tag = null;
tags = new[]{tagsValue};
}
else
{
int tagStartPosition = 0;
int tagIndex = 0;
tags = new string[tagCount];

if (i - currentStartIndex > 0)
for (int i = 0, length = tagsValue.Length; i < length; i++)
{
if (tagsValue[i] == ',')
{
tag = tags.Substring(currentStartIndex, i - currentStartIndex);
currentStartIndex = i + 1;
}
tags[tagIndex++] = tagsValue.Substring(tagStartPosition, i - tagStartPosition);
tagStartPosition = i + 1;

stringArray = ArrayUtil.EnsureCapacity(stringArray, tagIndex + 1);
stringArray[tagIndex] = tag;
tagIndex++;
if (tagIndex >= (tagCount - 1))
{
tags[tagIndex] = tagsValue.Substring(tagStartPosition, length - tagStartPosition);
}
}
}
}
}

if ((length - currentStartIndex) > 0)
return tags;
}

private static int CountTags(string tags)
{
int count = 1;

for (int i = 0, length = tags.Length; i < length; i++)
{
if (tags[i] == ',')
{
stringArray = ArrayUtil.EnsureCapacity(stringArray, tagIndex + 1);
stringArray[tagIndex] = tags.Substring(currentStartIndex, length - currentStartIndex);
++count;
}
}

return stringArray;
return count;
}
}
}
Loading

0 comments on commit ced5898

Please sign in to comment.