/// Asynchronously attempt to commit the given multi-record transaction. First, the expected
/// record versions are sent to the server nodes for verification. If all nodes return success,
@@ -177,22 +190,23 @@ public void Commit(CommitListener listener, Txn txn)
}
///
- /// Asynchronously attempt to commit the given multi-record transaction.
- /// Create listener, call asynchronous put and return task monitor.
+ /// Asynchronously attempt to abort and rollback the given multi-record transaction.
+ /// Create listener, call asynchronous commit and return task monitor.
///
/// multi-record transaction
/// cancellation token
- public Task Commit(Txn txn, CancellationToken token)
+ public Task Abort(Txn txn, CancellationToken token)
{
- var listener = new CommitListenerAdapter(token);
- Commit(listener, txn);
+ var listener = new AbortListenerAdapter(token);
+ Abort(listener, txn);
return listener.Task;
}
+
///
/// Asynchronously abort and rollback the given multi-record transaction.
///
- /// Schedules the commit command with a channel selector and return.
+ /// Schedules the abort command with a channel selector and return.
/// Another thread will process the command and send the results to the listener.
///
/// Requires server version 8.0+
@@ -222,13 +236,6 @@ public void Abort(AbortListener listener, Txn txn)
}
}
- public Task Abort(Txn txn, CancellationToken token)
- {
- var listener = new AbortListenerAdapter(token);
- Abort(listener, txn);
- return listener.Task;
- }
-
//-------------------------------------------------------
// Write Record Operations
//-------------------------------------------------------
diff --git a/AerospikeClient/Async/AsyncQueryPartitionExecutor.cs b/AerospikeClient/Async/AsyncQueryPartitionExecutor.cs
index f308117a..68942fd1 100644
--- a/AerospikeClient/Async/AsyncQueryPartitionExecutor.cs
+++ b/AerospikeClient/Async/AsyncQueryPartitionExecutor.cs
@@ -14,8 +14,6 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-using System;
-using System.Collections.Generic;
namespace Aerospike.Client
{
diff --git a/AerospikeClient/Async/AsyncScanPartitionExecutor.cs b/AerospikeClient/Async/AsyncScanPartitionExecutor.cs
index 20cbc5c0..704e25d8 100644
--- a/AerospikeClient/Async/AsyncScanPartitionExecutor.cs
+++ b/AerospikeClient/Async/AsyncScanPartitionExecutor.cs
@@ -14,8 +14,6 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-using System;
-using System.Collections.Generic;
namespace Aerospike.Client
{
diff --git a/AerospikeClient/Async/IAsyncClient.cs b/AerospikeClient/Async/IAsyncClient.cs
index 47a709d6..ccbbb017 100644
--- a/AerospikeClient/Async/IAsyncClient.cs
+++ b/AerospikeClient/Async/IAsyncClient.cs
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2022 Aerospike, Inc.
+ * Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
@@ -41,14 +41,23 @@ public interface IAsyncClient : IAerospikeClient
// Multi-Record Transactions
//-------------------------------------------------------
+ ///
+ /// Asynchronously attempt to commit the given multi-record transaction.
+ /// Create listener, call asynchronous commit and return task monitor.
+ ///
+ /// multi-record transaction
+ /// cancellation token
+ public Task Commit(Txn txn, CancellationToken token);
+
///
/// Asynchronously attempt to commit the given multi-record transaction. First, the expected
- /// record versions are sent to the server nodes for verification.If all nodes return success,
+ /// record versions are sent to the server nodes for verification. If all nodes return success,
/// the transaction is committed. Otherwise, the transaction is aborted.
///
- /// This method registers the command with an event loop and returns.
- /// The event loop thread will process the command and send the results to the listener.
- ///
+ /// Schedules the commit command with a channel selector and return.
+ /// Another thread will process the command and send the results to the listener.
+ ///
+ ///
/// Requires server version 8.0+
///
///
@@ -56,17 +65,25 @@ public interface IAsyncClient : IAerospikeClient
/// multi-record transaction
void Commit(CommitListener listener, Txn txn);
+ ///
+ /// Asynchronously attempt to abort and rollback the given multi-record transaction.
+ /// Create listener, call asynchronous commit and return task monitor.
+ ///
+ /// multi-record transaction
+ /// cancellation token
+ public Task Abort(Txn txn, CancellationToken token);
+
///
/// Asynchronously abort and rollback the given multi-record transaction.
///
- /// This method registers the command with an event loop and returns.
- /// The event loop thread will process the command and send the results to the listener.
+ /// Schedules the abort command with a channel selector and return.
+ /// Another thread will process the command and send the results to the listener.
///
/// Requires server version 8.0+
///
///
- ///
- ///
+ /// where to send results
+ /// multi-record transaction
void Abort(AbortListener listener, Txn txn);
//-------------------------------------------------------
diff --git a/AerospikeClient/Cluster/NodeValidator.cs b/AerospikeClient/Cluster/NodeValidator.cs
index cf398ca7..d5599f61 100644
--- a/AerospikeClient/Cluster/NodeValidator.cs
+++ b/AerospikeClient/Cluster/NodeValidator.cs
@@ -100,6 +100,11 @@ public Node SeedNode(Cluster cluster, Host host, Peers peers)
private bool ValidatePeers(Peers peers, Node node)
{
+ if (peers == null)
+ {
+ return true;
+ }
+
try
{
peers.refreshCount = 0;
diff --git a/AerospikeClient/Command/Batch.cs b/AerospikeClient/Command/Batch.cs
index 16a1f68c..ac7d7b0a 100644
--- a/AerospikeClient/Command/Batch.cs
+++ b/AerospikeClient/Command/Batch.cs
@@ -536,7 +536,7 @@ protected internal override bool ParseRow()
BatchRecord record = records[batchIndex];
- if (resultCode == 0)
+ if (resultCode == ResultCode.OK)
{
record.resultCode = resultCode;
}
diff --git a/AerospikeClient/Command/Command.cs b/AerospikeClient/Command/Command.cs
index 1604955a..7c38a9e8 100644
--- a/AerospikeClient/Command/Command.cs
+++ b/AerospikeClient/Command/Command.cs
@@ -316,7 +316,7 @@ public void SetTxnMarkRollForward(Key key)
Begin();
int fieldCount = EstimateKeySize(key);
EstimateOperationSize(bin);
- SizeBuffer();
+ //SizeBuffer();
WriteTxnMonitor(key, 0, Command.INFO2_WRITE, fieldCount, 1);
WriteOperation(bin, Operation.Type.WRITE);
End();
@@ -462,7 +462,7 @@ public void SetTxnClose(Txn txn, Key key)
{
Begin();
int fieldCount = EstimateKeySize(key);
- SizeBuffer();
+ //SizeBuffer();
WriteTxnMonitor(key, 0, Command.INFO2_WRITE | Command.INFO2_DELETE | Command.INFO2_DURABLE_DELETE,
fieldCount, 0);
End();
@@ -470,6 +470,7 @@ public void SetTxnClose(Txn txn, Key key)
private void WriteTxnMonitor(Key key, int readAttr, int writeAttr, int fieldCount, int opCount)
{
+ SizeBuffer();
dataOffset += 8;
dataBuffer[dataOffset++] = MSG_REMAINING_HEADER_SIZE;
dataBuffer[dataOffset++] = (byte)readAttr;
diff --git a/AerospikeClient/Command/ExecuteCommand.cs b/AerospikeClient/Command/ExecuteCommand.cs
index da0db3ea..6637d24a 100644
--- a/AerospikeClient/Command/ExecuteCommand.cs
+++ b/AerospikeClient/Command/ExecuteCommand.cs
@@ -24,7 +24,7 @@ public sealed class ExecuteCommand : SyncWriteCommand
private readonly string packageName;
private readonly string functionName;
private readonly Value[] args;
- public Record Record { get; private set; }
+ public Record Record { get; private set; }
public ExecuteCommand
(
diff --git a/AerospikeClient/Command/OperateArgs.cs b/AerospikeClient/Command/OperateArgs.cs
index 8f983036..bdf42800 100644
--- a/AerospikeClient/Command/OperateArgs.cs
+++ b/AerospikeClient/Command/OperateArgs.cs
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2023 Aerospike, Inc.
+ * Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
diff --git a/AerospikeClient/Command/ReadCommand.cs b/AerospikeClient/Command/ReadCommand.cs
index 891e6d0c..28d40570 100644
--- a/AerospikeClient/Command/ReadCommand.cs
+++ b/AerospikeClient/Command/ReadCommand.cs
@@ -53,6 +53,7 @@ protected internal override void ParseResult(Connection conn)
{
ParseHeader(conn);
ParseFields(policy.Txn, key, false);
+
if (resultCode == ResultCode.OK)
{
this.record = policy.recordParser.ParseRecord(dataBuffer, ref dataOffset, opCount, generation, expiration, isOperation);
diff --git a/AerospikeClient/Listener/CommitListener.cs b/AerospikeClient/Listener/CommitListener.cs
index fdca6e2b..2629c7de 100644
--- a/AerospikeClient/Listener/CommitListener.cs
+++ b/AerospikeClient/Listener/CommitListener.cs
@@ -24,7 +24,7 @@ namespace Aerospike.Client
public interface CommitListener
{
///
- /// This method is called when the records are verified and the commit succeeds.
+ /// This method is called when the records are verified and the commit succeeded or will succeed.
///
void OnSuccess(CommitStatusType status);
diff --git a/AerospikeClient/Main/AerospikeClient.cs b/AerospikeClient/Main/AerospikeClient.cs
index daa5e954..ad09ad8d 100644
--- a/AerospikeClient/Main/AerospikeClient.cs
+++ b/AerospikeClient/Main/AerospikeClient.cs
@@ -90,7 +90,7 @@ public class AerospikeClient : IDisposable, IAerospikeClient
protected BatchDeletePolicy batchDeletePolicyDefault;
///
- /// Default user defined function policy used in batch UDF excecute commands.
+ /// Default user defined function policy used in batch UDF execute commands.
///
protected BatchUDFPolicy batchUDFPolicyDefault;
@@ -256,6 +256,7 @@ protected internal AerospikeClient(ClientPolicy policy)
///
/// Default read policy that is used when read command policy is null.
+ /// Get returns a copy of the read policy default to avoid problems if this shared instance is later modified.
///
public Policy ReadPolicyDefault
{
@@ -265,6 +266,7 @@ public Policy ReadPolicyDefault
///
/// Default write policy that is used when write command policy is null.
+ /// Get returns a copy of the write policy default to avoid problems if this shared instance is later modified.
///
public WritePolicy WritePolicyDefault
{
@@ -274,6 +276,7 @@ public WritePolicy WritePolicyDefault
///
/// Default scan policy that is used when scan command policy is null.
+ /// Get returns a copy of the scan policy default to avoid problems if this shared instance is later modified.
///
public ScanPolicy ScanPolicyDefault
{
@@ -283,6 +286,7 @@ public ScanPolicy ScanPolicyDefault
///
/// Default query policy that is used when query command policy is null.
+ /// Get returns a copy of the query policy default to avoid problems if this shared instance is later modified.
///
public QueryPolicy QueryPolicyDefault
{
@@ -291,8 +295,9 @@ public QueryPolicy QueryPolicyDefault
}
///
- /// Default parent policy used in batch read commands.Parent policy fields
+ /// Default parent policy used in batch read commands. Parent policy fields
/// include socketTimeout, totalTimeout, maxRetries, etc...
+ /// Get returns a copy of the batch header read policy default to avoid problems if this shared instance is later modified.
///
public BatchPolicy BatchPolicyDefault
{
@@ -303,6 +308,7 @@ public BatchPolicy BatchPolicyDefault
///
/// Default parent policy used in batch write commands. Parent policy fields
/// include socketTimeout, totalTimeout, maxRetries, etc...
+ /// Get returns a copy of the batch header write policy default to avoid problems if this shared instance is later modified.
///
public BatchPolicy BatchParentPolicyWriteDefault
{
@@ -313,6 +319,7 @@ public BatchPolicy BatchParentPolicyWriteDefault
///
/// Default write policy used in batch operate commands.
/// Write policy fields include generation, expiration, durableDelete, etc...
+ /// Get returns a copy of the batch detail write policy default to avoid problems if this shared instance is later modified.
///
public BatchWritePolicy BatchWritePolicyDefault
{
@@ -322,6 +329,7 @@ public BatchWritePolicy BatchWritePolicyDefault
///
/// Default delete policy used in batch delete commands.
+ /// Get returns a copy of the batch detail delete policy default to avoid problems if this shared instance is later modified.
///
public BatchDeletePolicy BatchDeletePolicyDefault
{
@@ -331,6 +339,7 @@ public BatchDeletePolicy BatchDeletePolicyDefault
///
/// Default user defined function policy used in batch UDF excecute commands.
+ /// Get returns a copy of the batch detail UDF policy default to avoid problems if this shared instance is later modified.
///
public BatchUDFPolicy BatchUDFPolicyDefault
{
@@ -338,8 +347,19 @@ public BatchUDFPolicy BatchUDFPolicyDefault
set { batchUDFPolicyDefault = value; }
}
+ ///
+ /// Default info policy that is used when info command policy is null.
+ /// Get returns a copy of the info command policy default to avoid problems if this shared instance is later modified.
+ ///
+ public InfoPolicy InfoPolicyDefault
+ {
+ get { return new InfoPolicy(infoPolicyDefault); }
+ set { infoPolicyDefault = value; }
+ }
+
///
/// Default multi-record transactions (MRT) policy when verifying record versions in a batch on a commit.
+ /// Get returns a copy of the txn verify policy default.
///
public TxnVerifyPolicy TxnVerifyPolicyDefault
{
@@ -350,6 +370,7 @@ public TxnVerifyPolicy TxnVerifyPolicyDefault
///
/// Default multi-record transactions (MRT) policy when rolling the transaction records forward (commit)
/// or back(abort) in a batch.
+ /// Get returns a copy of the txn roll policy default.
///
public TxnRollPolicy TxnRollPolicyDefault
{
@@ -357,15 +378,6 @@ public TxnRollPolicy TxnRollPolicyDefault
set { txnRollPolicyDefault = value; }
}
- ///
- /// Default info policy that is used when info command policy is null.
- ///
- public InfoPolicy InfoPolicyDefault
- {
- get { return infoPolicyDefault; }
- set { infoPolicyDefault = value; }
- }
-
//-------------------------------------------------------
// Cluster Connection Management
//-------------------------------------------------------
@@ -467,11 +479,13 @@ public ClusterStats GetClusterStats()
/// Attempt to commit the given multi-record transaction. First, the expected record versions are
/// sent to the server nodes for verification. If all nodes return success, the transaction is
/// committed. Otherwise, the transaction is aborted.
- ///
+ ///
/// Requires server version 8.0+
- ///
+ ///
///
/// multi-record transaction
+ /// status of the commit on success
+ /// if verify commit fails
public CommitStatus.CommitStatusType Commit(Txn txn)
{
TxnRoll tr = new(cluster, txn);
@@ -496,11 +510,12 @@ public CommitStatus.CommitStatusType Commit(Txn txn)
///
/// Abort and rollback the given multi-record transaction.
- ///
+ ///
/// Requires server version 8.0+
- ///
+ ///
///
/// multi-record transaction
+ /// statis of the abort
public AbortStatus.AbortStatusType Abort(Txn txn)
{
TxnRoll tr = new(cluster, txn);
@@ -1028,10 +1043,8 @@ public Record[] Get(BatchPolicy policy, Key[] keys)
policy = batchPolicyDefault;
}
-
policy.Txn?.PrepareRead(keys);
-
Record[] records = new Record[keys.Length];
try
@@ -1197,10 +1210,8 @@ public Record[] GetHeader(BatchPolicy policy, Key[] keys)
policy = batchPolicyDefault;
}
-
policy.Txn?.PrepareRead(keys);
-
Record[] records = new Record[keys.Length];
try
@@ -1304,11 +1315,10 @@ public Record Join(BatchPolicy policy, Key key, params Join[] joins)
public Record Operate(WritePolicy policy, Key key, params Operation[] operations)
{
OperateArgs args = new OperateArgs(policy, writePolicyDefault, operatePolicyReadDefault, operations);
-
+ policy = args.writePolicy;
+
if (args.hasWrite)
{
- policy = args.writePolicy;
-
if (policy.Txn != null)
{
TxnMonitor.AddKey(cluster, policy, key);
diff --git a/AerospikeClient/Main/AerospikeException.cs b/AerospikeClient/Main/AerospikeException.cs
index 27805b63..ed73da91 100644
--- a/AerospikeClient/Main/AerospikeException.cs
+++ b/AerospikeClient/Main/AerospikeException.cs
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2023 Aerospike, Inc.
+ * Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
@@ -16,8 +16,6 @@
*/
using System.Collections.ObjectModel;
using System.Text;
-using static Aerospike.Client.AbortStatus;
-using static Aerospike.Client.AerospikeException;
using static Aerospike.Client.CommitError;
namespace Aerospike.Client
@@ -498,7 +496,7 @@ public BatchRecordArray(BatchRecord[] records, Exception e)
this.records = records;
}
- public BatchRecordArray(BatchRecord[] records, String message, Exception e)
+ public BatchRecordArray(BatchRecord[] records, string message, Exception e)
: base(ResultCode.BATCH_FAILED, message, e)
{
this.records = records;
@@ -578,7 +576,7 @@ public Backoff(int resultCode) : base(resultCode)
}
///
- /// Exception thrown when fails.
+ /// Exception thrown when fails.
/// Commit Exception has similar behavior to AggregateException.
/// might be populated if mutliple exceptions contribute to the failure.
///
diff --git a/AerospikeClient/Main/BatchRecord.cs b/AerospikeClient/Main/BatchRecord.cs
index 9196404b..3d8a31d5 100644
--- a/AerospikeClient/Main/BatchRecord.cs
+++ b/AerospikeClient/Main/BatchRecord.cs
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2022 Aerospike, Inc.
+ * Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
diff --git a/AerospikeClient/Main/IAerospikeClient.cs b/AerospikeClient/Main/IAerospikeClient.cs
index c9c6ee2f..5a825919 100644
--- a/AerospikeClient/Main/IAerospikeClient.cs
+++ b/AerospikeClient/Main/IAerospikeClient.cs
@@ -26,68 +26,80 @@ public interface IAerospikeClient
///
/// Default read policy that is used when read command policy is null.
+ /// Get returns a copy of the read policy default to avoid problems if this shared instance is later modified.
///
Policy ReadPolicyDefault { get; set; }
///
/// Default write policy that is used when write command policy is null.
+ /// Get returns a copy of the write policy default to avoid problems if this shared instance is later modified.
///
WritePolicy WritePolicyDefault { get; set; }
///
/// Default scan policy that is used when scan command policy is null.
+ /// Get returns a copy of the scan policy default to avoid problems if this shared instance is later modified.
///
ScanPolicy ScanPolicyDefault { get; set; }
///
/// Default query policy that is used when query command policy is null.
+ /// Get returns a copy of the query policy default to avoid problems if this shared instance is later modified.
///
QueryPolicy QueryPolicyDefault { get; set; }
///
/// Default parent policy used in batch read commands.Parent policy fields
/// include socketTimeout, totalTimeout, maxRetries, etc...
+ /// Get returns a copy of the batch header read policy default to avoid problems if this shared instance is later modified.
///
BatchPolicy BatchPolicyDefault { get; set; }
///
/// Default parent policy used in batch write commands. Parent policy fields
/// include socketTimeout, totalTimeout, maxRetries, etc...
+ /// Get returns a copy of the batch header write policy default to avoid problems if this shared instance is later modified.
///
BatchPolicy BatchParentPolicyWriteDefault { get; set; }
///
/// Default write policy used in batch operate commands.
/// Write policy fields include generation, expiration, durableDelete, etc...
+ /// Get returns a copy of the batch detail write policy default to avoid problems if this shared instance is later modified.
///
BatchWritePolicy BatchWritePolicyDefault { get; set; }
///
/// Default delete policy used in batch delete commands.
+ /// Get returns a copy of the batch detail delete policy default to avoid problems if this shared instance is later modified.
///
BatchDeletePolicy BatchDeletePolicyDefault { get; set; }
///
- /// Default user defined function policy used in batch UDF excecute commands.
+ /// Default user defined function policy used in batch UDF execute commands.
+ /// Get returns a copy of the batch detail UDF policy default to avoid problems if this shared instance is later modified.
///
BatchUDFPolicy BatchUDFPolicyDefault { get; set; }
+ ///
+ /// Default info policy that is used when info command policy is null.
+ /// Get returns a copy of the info command policy default to avoid problems if this shared instance is later modified.
+ ///
+ InfoPolicy InfoPolicyDefault { get; set; }
+
///
/// Default multi-record transactions (MRT) policy when verifying record versions in a batch on a commit.
+ /// Get returns a copy of the txn verify policy default.
///
TxnVerifyPolicy TxnVerifyPolicyDefault { get; set; }
///
/// Default multi-record transactions (MRT) policy when rolling the transaction records forward (commit)
- /// or back(abort) in a batch.
+ /// or back(abort) in a batch.
+ /// Get returns a copy of the txn roll policy default.
///
TxnRollPolicy TxnRollPolicyDefault { get; set; }
- ///
- /// Default info policy that is used when info command policy is null.
- ///
- InfoPolicy InfoPolicyDefault { get; set; }
-
//-------------------------------------------------------
// Cluster Connection Management
//-------------------------------------------------------
@@ -134,22 +146,25 @@ public interface IAerospikeClient
///
/// Attempt to commit the given multi-record transaction. First, the expected record versions are
- /// sent to the server nodes for verification.If all nodes return success, the command is
+ /// sent to the server nodes for verification. If all nodes return success, the transaction is
/// committed. Otherwise, the transaction is aborted.
- ///
+ ///
/// Requires server version 8.0+
- ///
+ ///
///
/// multi-record transaction
+ /// status of the commit on success
+ /// if verify commit fails
CommitStatus.CommitStatusType Commit(Txn txn);
///
/// Abort and rollback the given multi-record transaction.
- ///
+ ///
/// Requires server version 8.0+
- ///
+ ///
///
/// multi-record transaction
+ /// statis of the abort
AbortStatus.AbortStatusType Abort(Txn txn);
//-------------------------------------------------------
diff --git a/AerospikeClient/Main/ResultCode.cs b/AerospikeClient/Main/ResultCode.cs
index bf060407..d66ab3cf 100644
--- a/AerospikeClient/Main/ResultCode.cs
+++ b/AerospikeClient/Main/ResultCode.cs
@@ -319,6 +319,12 @@ public sealed class ResultCode
///
public const int MRT_ABORTED = 34;
+ ///