Support cache extension id in .NET
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/aaca59fd Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/aaca59fd Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/aaca59fd Branch: refs/heads/ignite-3199-1 Commit: aaca59fd5ae757d06012a5b05f7593bb10002995 Parents: 218bef7 Author: Pavel Tupitsyn <[email protected]> Authored: Tue Sep 13 14:42:03 2016 +0300 Committer: Pavel Tupitsyn <[email protected]> Committed: Tue Sep 13 14:42:03 2016 +0300 ---------------------------------------------------------------------- .../IgniteSessionStateStoreProvider.cs | 52 +++++++++++++------- .../Apache.Ignite.Core.csproj | 1 - .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 5 +- .../Impl/Cache/CacheInvokeOp.cs | 35 ------------- .../Impl/Cache/ICacheInternal.cs | 3 +- 5 files changed, 40 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/aaca59fd/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 a502450..a89dc84 100644 --- a/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs +++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/IgniteSessionStateStoreProvider.cs @@ -47,6 +47,21 @@ namespace Apache.Ignite.AspNet /// </summary> public class IgniteSessionStateStoreProvider : SessionStateStoreProviderBase { + /** Extension id */ + private const int ExtensionId = 1; + + /// <summary> + /// Op codes for <see cref="ICacheInternal.InvokeExtension{T}"/>. + /// </summary> + private enum Op + { + /** Lock the session data. */ + SessionLock = 1, + + /** Update and unlock the session data. */ + SessionSetAndUnlock = 2 + } + /** Application id config parameter. */ private const string ApplicationId = "applicationId"; @@ -431,11 +446,12 @@ namespace Apache.Ignite.AspNet /// </summary> private SessionStateLockResult LockItem(string key, long lockId) { - return ((ICacheInternal) Cache).InvokeExtension<SessionStateLockResult>(CacheInvokeOp.SessionLock, w => - { - w.WriteString(key); - WriteLockInfo(w, lockId, true); - }); + return ((ICacheInternal) Cache).InvokeExtension<SessionStateLockResult>(ExtensionId, (int) Op.SessionLock, + w => + { + w.WriteString(key); + WriteLockInfo(w, lockId, true); + }); } /// <summary> @@ -443,12 +459,13 @@ namespace Apache.Ignite.AspNet /// </summary> private void UnlockItem(string key, long lockId) { - ((ICacheInternal) Cache).InvokeExtension<object>(CacheInvokeOp.SessionSetAndUnlock, w => - { - w.WriteString(key); - w.WriteBoolean(false); // Only unlock. - WriteLockInfo(w, lockId); - }); + ((ICacheInternal) Cache).InvokeExtension<object>(ExtensionId, (int) Op.SessionSetAndUnlock, + w => + { + w.WriteString(key); + w.WriteBoolean(false); // Only unlock. + WriteLockInfo(w, lockId); + }); } /// <summary> @@ -460,12 +477,13 @@ namespace Apache.Ignite.AspNet var cache = _expiryCacheHolder.GetCacheWithExpiry(data.Timeout * 60); - ((ICacheInternal) cache).InvokeExtension<object>(CacheInvokeOp.SessionSetAndUnlock, w => - { - w.WriteString(key); - w.WriteBoolean(true); // Unlock and update. - w.WriteObject(data); - }); + ((ICacheInternal) cache).InvokeExtension<object>(ExtensionId, (int) Op.SessionSetAndUnlock, + w => + { + w.WriteString(key); + w.WriteBoolean(true); // Unlock and update. + w.WriteObject(data); + }); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/aaca59fd/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj index e565c5e..4be28ac 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj @@ -181,7 +181,6 @@ <Compile Include="Impl\Binary\UserSerializerProxy.cs" /> <Compile Include="Impl\Cache\Affinity\AffinityFunctionSerializer.cs" /> <Compile Include="Impl\Cache\Affinity\PlatformAffinityFunction.cs" /> - <Compile Include="Impl\Cache\CacheInvokeOp.cs" /> <Compile Include="Impl\Collections\KeyValueDirtyTrackedCollection.cs" /> <Compile Include="Impl\Common\ObjectInfoHolder.cs" /> <Compile Include="Impl\Common\Platform.cs" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/aaca59fd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs index 871b435..859e90d 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs @@ -873,11 +873,12 @@ namespace Apache.Ignite.Core.Impl.Cache } /** <inheritDoc /> */ - public T InvokeExtension<T>(CacheInvokeOp opCode, Action<IBinaryRawWriter> writeAction) + public T InvokeExtension<T>(int extensionId, int opCode, Action<IBinaryRawWriter> writeAction) { return DoOutInOpX((int) CacheOp.Extension, writer => { - writer.WriteInt((int) opCode); + writer.WriteInt(extensionId); + writer.WriteInt(opCode); writeAction(writer); }, (input, res) => res == True ? Marshaller.Unmarshal<T>(input) : default(T), ReadException); http://git-wip-us.apache.org/repos/asf/ignite/blob/aaca59fd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheInvokeOp.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheInvokeOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheInvokeOp.cs deleted file mode 100644 index 4b52d53..0000000 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheInvokeOp.cs +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.Impl.Cache -{ - /// <summary> - /// Op codes for <see cref="ICacheInternal.InvokeExtension{T}"/>. - /// </summary> - public enum CacheInvokeOp - { - /// <summary> - /// Lock the session data. - /// </summary> - SessionLock = 1, - - /// <summary> - /// Update and unlock the session data. - /// </summary> - SessionSetAndUnlock = 2 - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/aaca59fd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs index 43477e8..cd4922b 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs @@ -41,11 +41,12 @@ namespace Apache.Ignite.Core.Impl.Cache /// Invokes a cache extension. /// </summary> /// <typeparam name="T">The type of the result.</typeparam> + /// <param name="extensionId">The extension identifier.</param> /// <param name="opCode">The extension op code.</param> /// <param name="writeAction">The write action.</param> /// <returns> /// Result of the processing. /// </returns> - T InvokeExtension<T>(CacheInvokeOp opCode, Action<IBinaryRawWriter> writeAction); + T InvokeExtension<T>(int extensionId, int opCode, Action<IBinaryRawWriter> writeAction); } }
