You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/09/06 11:39:29 UTC
[GitHub] [ignite] gurustron commented on a change in pull request #7992: IGNITE-7369 .NET: Thin Client Transactions
gurustron commented on a change in pull request #7992:
URL: https://github.com/apache/ignite/pull/7992#discussion_r464069966
##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Transactions/TransactionClient.cs
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.Client.Transactions
+{
+ using System;
+ using System.Globalization;
+ using Apache.Ignite.Core.Client.Transactions;
+ using Apache.Ignite.Core.Transactions;
+
+ /// <summary>
+ /// Ignite Thin Client transaction facade.
+ /// </summary>
+ internal class TransactionClient : ITransactionClient
+ {
+ /** Unique transaction ID.*/
+ private readonly int _id;
+
+ /** Ignite. */
+ private readonly IgniteClient _ignite;
+
+ /** Socket. */
+ private readonly ClientSocket _socket;
+
+ /** Transaction is closed. */
+ private bool _closed;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">ID.</param>
+ /// <param name="ignite">Ignite.</param>
+ /// <param name="socket">Socket.</param>
+ /// <param name="concurrency">Concurrency.</param>
+ /// <param name="isolation">Isolation.</param>
+ /// <param name="timeout">Timeout.</param>
+ /// <param name="label">Label.</param>
+ public TransactionClient(int id,
+ IgniteClient ignite,
+ ClientSocket socket,
+ TransactionConcurrency concurrency,
+ TransactionIsolation isolation,
+ TimeSpan timeout,
+ string label)
+ {
+ _id = id;
+ _ignite = ignite;
+ _socket = socket;
+ Concurrency = concurrency;
+ Isolation = isolation;
+ Timeout = timeout;
+ Label = label;
+ }
+
+ /** <inheritdoc /> */
+ public void Commit()
+ {
+ ThrowIfClosed();
+ Close(true);
+ }
+
+ /** <inheritdoc /> */
+ public void Rollback()
+ {
+ ThrowIfClosed();
+ Close(false);
+ }
+
+ /** <inheritdoc /> */
+ public TransactionConcurrency Concurrency { get; private set; }
+
+ /** <inheritdoc /> */
+ public TransactionIsolation Isolation { get; private set; }
+
+ /** <inheritdoc /> */
+ public TimeSpan Timeout { get; private set; }
+
+ /** <inheritdoc /> */
+ public string Label { get; private set; }
+
+ /** <inheritdoc /> */
+ public void Dispose()
+ {
+ try
+ {
+ Close(false);
+ }
+ finally
+ {
+ GC.SuppressFinalize(this);
+ }
+ }
+
+ /// <summary>
+ /// Transaction Id.
+ /// </summary>
+ public int Id
+ {
+ get { return _id; }
+ }
+
+ public ClientSocket Socket
+ {
+ get { return _socket; }
+ }
+
+ /// <summary>
+ /// Returns if transaction is closed.
+ /// </summary>
+ internal bool Closed
+ {
+ get { return _closed; }
+ }
+
+ /// <summary>
+ /// Closes the transaction.
+ /// </summary>
+ private void Close(bool commit)
+ {
+ if (!_closed)
+ {
+ try
+ {
+ _ignite.Socket.DoOutInOp<object>(ClientOp.TxEnd,
Review comment:
1. Fixed.
2. What exceptions should we cover?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org