You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2016/09/13 16:15:47 UTC
ignite git commit: Merge SessionStateData class
Repository: ignite
Updated Branches:
refs/heads/ignite-3199-1 9213a5c8f -> 815cde40c
Merge SessionStateData class
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/815cde40
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/815cde40
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/815cde40
Branch: refs/heads/ignite-3199-1
Commit: 815cde40c8cfea1734f1e94c6b64d10af5411f7f
Parents: 9213a5c
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Tue Sep 13 19:15:32 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Tue Sep 13 19:15:32 2016 +0300
----------------------------------------------------------------------
.../websession/PlatformDotnetSessionData.java | 20 ++--
.../Apache.Ignite.AspNet.csproj | 1 -
.../IgniteSessionStateStoreProvider.cs | 32 +++---
.../Impl/IgniteSessionStateItemCollection.cs | 9 ++
.../Impl/IgniteSessionStateStoreData.cs | 81 +++++++--------
.../Impl/SessionStateData.cs | 101 -------------------
.../Impl/SessionStateLockResult.cs | 6 +-
.../Apache.Ignite.Core.Tests.csproj | 1 -
.../BinarizableSessionStateStoreDataTest.cs | 95 -----------------
.../AspNet/IgniteSessionStateStoreDataTest.cs | 71 +++++++++++--
10 files changed, 143 insertions(+), 274 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java
index 2a3a52e..bf0804d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/PlatformDotnetSessionData.java
@@ -221,11 +221,6 @@ public class PlatformDotnetSessionData implements Binarylizable {
* @param writer Binary writer.
*/
public void writeBinary(BinaryRawWriter writer) {
- writer.writeInt(timeout);
- writer.writeUuid(lockNodeId);
- writer.writeLong(lockId);
- writer.writeTimestamp(lockTime);
-
writer.writeBoolean(isDiff);
writer.writeInt(items.size());
@@ -235,6 +230,11 @@ public class PlatformDotnetSessionData implements Binarylizable {
}
writer.writeByteArray(staticObjects);
+
+ writer.writeInt(timeout);
+ writer.writeUuid(lockNodeId);
+ writer.writeLong(lockId);
+ writer.writeTimestamp(lockTime);
}
/** {@inheritDoc} */
@@ -250,11 +250,6 @@ public class PlatformDotnetSessionData implements Binarylizable {
* @param reader Reader.
*/
public void readBinary(BinaryRawReader reader) {
- timeout = reader.readInt();
- lockNodeId = reader.readUuid();
- lockId = reader.readLong();
- lockTime = reader.readTimestamp();
-
items = new TreeMap<>();
isDiff = reader.readBoolean();
int count = reader.readInt();
@@ -263,6 +258,11 @@ public class PlatformDotnetSessionData implements Binarylizable {
items.put(reader.readString(), reader.readByteArray());
staticObjects = reader.readByteArray();
+
+ timeout = reader.readInt();
+ lockNodeId = reader.readUuid();
+ lockId = reader.readLong();
+ lockTime = reader.readTimestamp();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.csproj b/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.csproj
index 40aab55..b17c9f3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.csproj
@@ -54,7 +54,6 @@
<Compile Include="Impl\IgniteSessionStateItemCollection.cs" />
<Compile Include="Impl\IgniteSessionStateStoreData.cs" />
<Compile Include="Impl\KeyValueDirtyTrackedCollection.cs" />
- <Compile Include="Impl\SessionStateData.cs" />
<Compile Include="Impl\SessionStateLockResult.cs" />
<Compile Include="Package-Info.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
index 1f04b5d..7cf892a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs
@@ -77,7 +77,7 @@ namespace Apache.Ignite.AspNet
private volatile string _applicationId;
/** */
- private volatile ExpiryCacheHolder<string, SessionStateData> _expiryCacheHolder;
+ private volatile ExpiryCacheHolder<string, IgniteSessionStateStoreData> _expiryCacheHolder;
/** */
private volatile ILogger _log;
@@ -96,9 +96,9 @@ namespace Apache.Ignite.AspNet
{
base.Initialize(name, config);
- var cache = ConfigUtil.InitializeCache<string, SessionStateData>(config, GetType());
+ var cache = ConfigUtil.InitializeCache<string, IgniteSessionStateStoreData>(config, GetType());
- _expiryCacheHolder = new ExpiryCacheHolder<string, SessionStateData>(cache);
+ _expiryCacheHolder = new ExpiryCacheHolder<string, IgniteSessionStateStoreData>(cache);
_applicationId = config[ApplicationId];
@@ -188,7 +188,7 @@ namespace Apache.Ignite.AspNet
{
Log("GetItem session store data found", id, context);
- return new IgniteSessionStateStoreData(data);
+ return data;
}
Log("GetItem session store data locked", id, context);
@@ -270,7 +270,7 @@ namespace Apache.Ignite.AspNet
locked = false;
- return new IgniteSessionStateStoreData(lockResult.Data);
+ return lockResult.Data;
}
/// <summary>
@@ -305,11 +305,9 @@ namespace Apache.Ignite.AspNet
Debug.Assert(item != null);
- var data = ((IgniteSessionStateStoreData) item).Data;
-
var key = GetKey(id);
- SetAndUnlockItem(key, data);
+ SetAndUnlockItem(key, (IgniteSessionStateStoreData) item);
}
/// <summary>
@@ -373,7 +371,7 @@ namespace Apache.Ignite.AspNet
var key = GetKey(id);
- var data = new SessionStateData { Timeout = timeout };
+ var data = new IgniteSessionStateStoreData(new HttpStaticObjectsCollection(), timeout);
PutItem(key, data, cache);
}
@@ -390,7 +388,7 @@ namespace Apache.Ignite.AspNet
/// <summary>
/// Gets the cache.
/// </summary>
- private ICache<string, SessionStateData> Cache
+ private ICache<string, IgniteSessionStateStoreData> Cache
{
get
{
@@ -480,9 +478,9 @@ namespace Apache.Ignite.AspNet
/// <summary>
/// Sets and unlocks the item.
/// </summary>
- private void SetAndUnlockItem(string key, SessionStateData data)
+ private void SetAndUnlockItem(string key, IgniteSessionStateStoreData data)
{
- data.Items.WriteChangesOnly = true; // Write diff.
+ data.WriteChangesOnly = true; // Write diff.
var cache = _expiryCacheHolder.GetCacheWithExpiry(data.Timeout * 60);
@@ -497,7 +495,7 @@ namespace Apache.Ignite.AspNet
/// <summary>
/// Puts the item.
/// </summary>
- private void PutItem(string key, SessionStateData data, ICache<string, SessionStateData> cache)
+ private void PutItem(string key, IgniteSessionStateStoreData data, ICache<string, IgniteSessionStateStoreData> cache)
{
OutOp(Op.Put, w =>
{
@@ -509,9 +507,9 @@ namespace Apache.Ignite.AspNet
/// <summary>
/// Gets the item.
/// </summary>
- private SessionStateData GetItem(string key)
+ private IgniteSessionStateStoreData GetItem(string key)
{
- return OutInOp(Op.Get, w => w.WriteString(key), r => new SessionStateData(r));
+ return OutInOp(Op.Get, w => w.WriteString(key), r => new IgniteSessionStateStoreData(r));
}
/// <summary>
@@ -526,7 +524,7 @@ namespace Apache.Ignite.AspNet
/// Invokes the extension operation.
/// </summary>
private void OutOp(Op op, Action<IBinaryRawWriter> writeAction,
- ICache<string, SessionStateData> cache = null)
+ ICache<string, IgniteSessionStateStoreData> cache = null)
{
OutInOp<object>(op, writeAction, null, cache);
}
@@ -535,7 +533,7 @@ namespace Apache.Ignite.AspNet
/// Invokes the extension operation.
/// </summary>
private T OutInOp<T>(Op op, Action<IBinaryRawWriter> writeAction, Func<IBinaryRawReader, T> readFunc,
- ICache<string, SessionStateData> cache = null)
+ ICache<string, IgniteSessionStateStoreData> cache = null)
{
cache = cache ?? Cache;
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateItemCollection.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateItemCollection.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateItemCollection.cs
index 273b6d6..946e277 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateItemCollection.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateItemCollection.cs
@@ -40,9 +40,18 @@ namespace Apache.Ignite.AspNet.Impl
{
Debug.Assert(collection != null);
+ // TODO: Merge classes
_collection = collection;
}
+ /// <summary>
+ /// Gets the collection.
+ /// </summary>
+ public KeyValueDirtyTrackedCollection Collection
+ {
+ get { return _collection; }
+ }
+
/** <inheritdoc /> */
public IEnumerator GetEnumerator()
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateStoreData.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateStoreData.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateStoreData.cs
index 5bf58e2..bdd619c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateStoreData.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/IgniteSessionStateStoreData.cs
@@ -17,77 +17,78 @@
namespace Apache.Ignite.AspNet.Impl
{
+ using System;
using System.IO;
using System.Web;
using System.Web.SessionState;
+ using Apache.Ignite.Core.Binary;
/// <summary>
- /// Wrapper for <see cref="SessionStateData"/>.
+ /// Ignite <see cref="SessionStateStoreData"/> implementation.
/// </summary>
internal class IgniteSessionStateStoreData : SessionStateStoreData
{
- /** */
- private readonly SessionStateData _data;
-
- /** */
- private readonly IgniteSessionStateItemCollection _items;
-
/// <summary>
/// Initializes a new instance of the <see cref="IgniteSessionStateStoreData"/> class.
/// </summary>
- /// <param name="data">The data.</param>
- public IgniteSessionStateStoreData(SessionStateData data)
- : base(null, DeserializeStaticObjects(data.StaticObjects), 0)
+ /// <param name="reader">The reader.</param>
+ public IgniteSessionStateStoreData(IBinaryRawReader reader) : base(
+ new IgniteSessionStateItemCollection(new KeyValueDirtyTrackedCollection(reader)),
+ DeserializeStaticObjects(reader.ReadByteArray()), reader.ReadInt())
{
- _data = data;
- _items = new IgniteSessionStateItemCollection(_data.Items);
+ LockNodeId = reader.ReadGuid();
+ LockId = reader.ReadLong();
+ LockTime = reader.ReadTimestamp();
}
/// <summary>
- /// Initializes a new instance of the <see cref="IgniteSessionStateStoreData"/> class.
+ /// Writes this object to the given writer.
/// </summary>
- /// <param name="staticObjects">The static objects.</param>
- /// <param name="timeout">The timeout.</param>
- public IgniteSessionStateStoreData(HttpStaticObjectsCollection staticObjects, int timeout)
- : base(null, staticObjects, 0)
+ /// <param name="writer">Writer.</param>
+ public void WriteBinary(IBinaryRawWriter writer)
{
- _data = new SessionStateData
- {
- Timeout = timeout
- };
+ ((IgniteSessionStateItemCollection)Items).Collection.WriteBinary(writer);
+ writer.WriteByteArray(SerializeStaticObjects());
+ writer.WriteInt(Timeout);
- _items = new IgniteSessionStateItemCollection(_data.Items);
+ writer.WriteGuid(LockNodeId);
+ writer.WriteLong(LockId);
+ writer.WriteTimestamp(LockTime);
}
/// <summary>
- /// The session variables and values for the current session.
+ /// Gets or sets the lock node id. Null means not locked.
/// </summary>
- public override ISessionStateItemCollection Items
- {
- get { return _items; }
- }
+ public Guid? LockNodeId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the lock id.
+ /// </summary>
+ public long LockId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the lock time.
+ /// </summary>
+ public DateTime? LockTime { get; set; }
/// <summary>
- /// Gets and sets the amount of time, in minutes, allowed between requests before the session-state
- /// provider terminates the session.
+ /// Gets or sets a value indicating whether only dirty changed things should be serialized.
/// </summary>
- public override int Timeout
+ public bool WriteChangesOnly
{
- get { return _data.Timeout; }
- set { _data.Timeout = value; }
+ get { return ((IgniteSessionStateItemCollection) Items).Collection.WriteChangesOnly; }
+ set { ((IgniteSessionStateItemCollection) Items).Collection.WriteChangesOnly = value; }
}
/// <summary>
- /// Gets the data.
+ /// Initializes a new instance of the <see cref="IgniteSessionStateStoreData"/> class.
/// </summary>
- public SessionStateData Data
+ /// <param name="staticObjects">The static objects.</param>
+ /// <param name="timeout">The timeout.</param>
+ public IgniteSessionStateStoreData(HttpStaticObjectsCollection staticObjects, int timeout)
+ : base(new IgniteSessionStateItemCollection(new KeyValueDirtyTrackedCollection()), staticObjects, timeout)
{
- get
- {
- _data.StaticObjects = SerializeStaticObjects();
-
- return _data;
- }
+ // No-op.
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/SessionStateData.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/SessionStateData.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/SessionStateData.cs
deleted file mode 100644
index adad69c..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/SessionStateData.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-\ufeff/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.AspNet.Impl
-{
- using System;
- using Apache.Ignite.Core.Binary;
-
- /// <summary>
- /// Binarizable SessionStateStoreData.
- /// Does not override System.Web.SessionState.SessionStateStoreData to avoid dependency on System.Web.
- /// </summary>
- internal class SessionStateData
- {
- /** Items. */
- private readonly KeyValueDirtyTrackedCollection _items;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="SessionStateData"/> class.
- /// </summary>
- /// <param name="reader">The reader.</param>
- public SessionStateData(IBinaryRawReader reader)
- {
- Timeout = reader.ReadInt();
- LockNodeId = reader.ReadGuid();
- LockId = reader.ReadLong();
- LockTime = reader.ReadTimestamp();
- _items = new KeyValueDirtyTrackedCollection(reader);
- StaticObjects = reader.ReadByteArray();
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="SessionStateData"/> class.
- /// </summary>
- public SessionStateData()
- {
- _items = new KeyValueDirtyTrackedCollection();
- }
-
- /// <summary>
- /// Gets the items.
- /// </summary>
- public KeyValueDirtyTrackedCollection Items
- {
- get { return _items; }
- }
-
- /// <summary>
- /// Gets or sets the static objects.
- /// </summary>
- public byte[] StaticObjects { get; set; }
-
- /// <summary>
- /// Gets or sets the timeout.
- /// </summary>
- public int Timeout { get; set; }
-
- /// <summary>
- /// Gets or sets the lock node id. Null means not locked.
- /// </summary>
- public Guid? LockNodeId { get; set; }
-
- /// <summary>
- /// Gets or sets the lock id.
- /// </summary>
- public long LockId { get; set; }
-
- /// <summary>
- /// Gets or sets the lock time.
- /// </summary>
- public DateTime? LockTime { get; set; }
-
- /// <summary>
- /// Writes this object to the given writer.
- /// </summary>
- /// <param name="writer">Writer.</param>
- public void WriteBinary(IBinaryRawWriter writer)
- {
- writer.WriteInt(Timeout);
- writer.WriteGuid(LockNodeId);
- writer.WriteLong(LockId);
- writer.WriteTimestamp(LockTime);
- Items.WriteBinary(writer);
- writer.WriteByteArray(StaticObjects);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/SessionStateLockResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/SessionStateLockResult.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/SessionStateLockResult.cs
index 100fc18..6fb9ace 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/SessionStateLockResult.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/SessionStateLockResult.cs
@@ -31,7 +31,7 @@ namespace Apache.Ignite.AspNet.Impl
private readonly bool _success;
/** Session state data. */
- private readonly SessionStateData _data;
+ private readonly IgniteSessionStateStoreData _data;
/** Lock time. */
private readonly DateTime? _lockTime;
@@ -45,7 +45,7 @@ namespace Apache.Ignite.AspNet.Impl
_success = reader.ReadBoolean();
if (_success)
- _data = new SessionStateData(reader);
+ _data = new IgniteSessionStateStoreData(reader);
_lockTime = reader.ReadTimestamp();
@@ -64,7 +64,7 @@ namespace Apache.Ignite.AspNet.Impl
/// <summary>
/// Gets the data. Null when <see cref="Success"/> is <c>false</c>.
/// </summary>
- public SessionStateData Data
+ public IgniteSessionStateStoreData Data
{
get { return _data; }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index bc628b4..5e54115 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -59,7 +59,6 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
- <Compile Include="AspNet\BinarizableSessionStateStoreDataTest.cs" />
<Compile Include="AspNet\ExpiryCacheHolderTest.cs" />
<Compile Include="AspNet\IgniteSessionStateItemCollectionTest.cs" />
<Compile Include="AspNet\IgniteSessionStateStoreDataTest.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/BinarizableSessionStateStoreDataTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/BinarizableSessionStateStoreDataTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/BinarizableSessionStateStoreDataTest.cs
deleted file mode 100644
index 929f0e4..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/BinarizableSessionStateStoreDataTest.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-\ufeff/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.AspNet
-{
- using System;
- using System.IO;
- using Apache.Ignite.AspNet.Impl;
- using Apache.Ignite.Core.Impl.Binary;
- using Apache.Ignite.Core.Impl.Binary.IO;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for <see cref="SessionStateData"/>.
- /// </summary>
- public class BinarizableSessionStateStoreDataTest
- {
- /// <summary>
- /// Tests the empty data.
- /// </summary>
- [Test]
- public void TestEmpty()
- {
- var data = new SessionStateData();
-
- Assert.AreEqual(0, data.LockId);
- Assert.AreEqual(0, data.Items.Count);
- Assert.AreEqual(0, data.Timeout);
- Assert.IsNull(data.LockNodeId);
- Assert.IsNull(data.LockTime);
- Assert.IsNull(data.StaticObjects);
- }
-
- /// <summary>
- /// Tests the serialization.
- /// </summary>
- [Test]
- public void TestSerialization()
- {
- var data = new SessionStateData
- {
- Timeout = 97,
- LockId = 11,
- LockNodeId = Guid.NewGuid(),
- LockTime = DateTime.UtcNow.AddHours(-1),
- StaticObjects = new byte[] {1, 2, 3}
- };
-
- data.Items["key1"] = 1;
- data.Items["key2"] = 2;
-
- var data0 = SerializeDeserialize(data);
-
- Assert.AreEqual(data.Timeout, data0.Timeout);
- Assert.AreEqual(data.LockId, data0.LockId);
- Assert.AreEqual(data.LockNodeId, data0.LockNodeId);
- Assert.AreEqual(data.LockTime, data0.LockTime);
- Assert.AreEqual(data.StaticObjects, data0.StaticObjects);
- Assert.AreEqual(data.Items.GetKeys(), data0.Items.GetKeys());
- }
-
- /// <summary>
- /// Serializes and deserializes back an instance.
- /// </summary>
- private static SessionStateData SerializeDeserialize(SessionStateData data)
- {
- var marsh = BinaryUtils.Marshaller;
-
- using (var stream = new BinaryHeapStream(128))
- {
- var writer = marsh.StartMarshal(stream);
-
- data.WriteBinary(writer.GetRawWriter());
-
- stream.Seek(0, SeekOrigin.Begin);
-
- return new SessionStateData(marsh.StartUnmarshal(stream));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/815cde40/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreDataTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreDataTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreDataTest.cs
index a9520cb..c3f9262 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreDataTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreDataTest.cs
@@ -17,9 +17,13 @@
namespace Apache.Ignite.Core.Tests.AspNet
{
+ using System;
+ using System.IO;
using System.Reflection;
using System.Web;
using Apache.Ignite.AspNet.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Binary.IO;
using NUnit.Framework;
/// <summary>
@@ -46,13 +50,68 @@ namespace Apache.Ignite.Core.Tests.AspNet
Assert.AreEqual(1, data.StaticObjects.Count);
Assert.AreEqual(0, data.StaticObjects["int"]);
Assert.AreEqual("val", data.Items["key"]);
+ }
+
+ /// <summary>
+ /// Tests the empty data.
+ /// </summary>
+ [Test]
+ public void TestEmpty()
+ {
+ var data = new IgniteSessionStateStoreData(null, 0);
+
+ Assert.AreEqual(0, data.LockId);
+ Assert.AreEqual(0, data.Items.Count);
+ Assert.AreEqual(0, data.Timeout);
+ Assert.IsNull(data.LockNodeId);
+ Assert.IsNull(data.LockTime);
+ Assert.IsNull(data.StaticObjects);
+ }
+
+ /// <summary>
+ /// Tests the serialization.
+ /// </summary>
+ [Test]
+ public void TestSerialization()
+ {
+ var data = new IgniteSessionStateStoreData(null, 96)
+ {
+ Timeout = 97,
+ LockId = 11,
+ LockNodeId = Guid.NewGuid(),
+ LockTime = DateTime.UtcNow.AddHours(-1),
+ };
+
+ data.Items["key1"] = 1;
+ data.Items["key2"] = 2;
+
+ var data0 = SerializeDeserialize(data);
+
+ Assert.AreEqual(data.Timeout, data0.Timeout);
+ Assert.AreEqual(data.LockId, data0.LockId);
+ Assert.AreEqual(data.LockNodeId, data0.LockNodeId);
+ Assert.AreEqual(data.LockTime, data0.LockTime);
+ Assert.AreEqual(data.Items.Keys, data0.Items.Keys);
+ }
+
+
+ /// <summary>
+ /// Serializes and deserializes back an instance.
+ /// </summary>
+ private static IgniteSessionStateStoreData SerializeDeserialize(IgniteSessionStateStoreData data)
+ {
+ var marsh = BinaryUtils.Marshaller;
+
+ using (var stream = new BinaryHeapStream(128))
+ {
+ var writer = marsh.StartMarshal(stream);
+
+ data.WriteBinary(writer.GetRawWriter());
+
+ stream.Seek(0, SeekOrigin.Begin);
- // Clone.
- var data1 = new IgniteSessionStateStoreData(data.Data);
- Assert.AreEqual(44, data1.Timeout);
- Assert.AreEqual(1, data1.StaticObjects.Count);
- Assert.AreEqual(0, data1.StaticObjects["int"]);
- Assert.AreEqual("val", data1.Items["key"]);
+ return new IgniteSessionStateStoreData(marsh.StartUnmarshal(stream));
+ }
}
}
}