Skip to content

Commit

Permalink
Add Clone method to policies, changes to result codes for MRT
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonklaus committed Dec 3, 2024
1 parent 8cfec04 commit d31e0bd
Show file tree
Hide file tree
Showing 26 changed files with 305 additions and 160 deletions.
5 changes: 0 additions & 5 deletions AerospikeClient/Async/AsyncTxnAddKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ protected internal override bool PrepareRetry(bool timeout)
return true;
}

protected internal override void OnInDoubt()
{
policy.Txn.SetMonitorInDoubt();
}

protected internal override void OnSuccess()
{
if (listener != null)
Expand Down
4 changes: 2 additions & 2 deletions AerospikeClient/Async/AsyncTxnRoll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private void Roll(BatchRecordArrayListener rollListener, int txnAttr)

private void CloseOnCommit(bool verified)
{
if (!txn.MonitorMightExist())
if (!txn.CloseMonitor())
{
if (verified)
{
Expand Down Expand Up @@ -227,7 +227,7 @@ private void CloseOnCommit(bool verified)

private void CloseOnAbort()
{
if (!txn.MonitorMightExist())
if (!txn.CloseMonitor())
{
// There is no MRT monitor record to remove.
NotifyAbortSuccess(AbortStatusType.OK);
Expand Down
5 changes: 0 additions & 5 deletions AerospikeClient/Command/TxnAddKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,5 @@ protected internal override void ParseResult(Connection conn)

throw new AerospikeException(resultCode);
}

protected internal override void OnInDoubt()
{
policy.Txn.SetMonitorInDoubt();
}
}
}
6 changes: 3 additions & 3 deletions AerospikeClient/Command/TxnRoll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void Verify(BatchPolicy verifyPolicy, BatchPolicy rollPolicy)
throw CreateCommitException(CommitErrorType.VERIFY_FAIL_ABORT_ABANDONED, e, e2);
}

if (txn.MonitorMightExist())
if (txn.CloseMonitor())
{
try
{
Expand Down Expand Up @@ -142,7 +142,7 @@ public CommitStatusType Commit(BatchPolicy rollPolicy)
}
}

if (txn.MonitorMightExist())
if (txn.CloseMonitor())
{
// Remove MRT monitor.
try
Expand Down Expand Up @@ -206,7 +206,7 @@ public AbortStatusType Abort(BatchPolicy rollPolicy)
return AbortStatusType.ROLL_BACK_ABANDONED;
}

if (txn.MonitorMightExist())
if (txn.CloseMonitor())
{
try
{
Expand Down
60 changes: 36 additions & 24 deletions AerospikeClient/Main/AerospikeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,125 +256,137 @@ protected internal AerospikeClient(ClientPolicy policy)

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="Policy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public Policy ReadPolicyDefault
{
get { return new Policy(readPolicyDefault); }
get { return readPolicyDefault; }
set { readPolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="WritePolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public WritePolicy WritePolicyDefault
{
get { return new WritePolicy(writePolicyDefault); }
get { return writePolicyDefault; }
set { writePolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="ScanPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public ScanPolicy ScanPolicyDefault
{
get { return new ScanPolicy(scanPolicyDefault); }
get { return scanPolicyDefault; }
set { scanPolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="QueryPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public QueryPolicy QueryPolicyDefault
{
get { return new QueryPolicy(queryPolicyDefault); }
get { return queryPolicyDefault; }
set { queryPolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public BatchPolicy BatchPolicyDefault
{
get { return new BatchPolicy(batchPolicyDefault); }
get { return batchPolicyDefault; }
set { batchPolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public BatchPolicy BatchParentPolicyWriteDefault
{
get { return new BatchPolicy(batchParentPolicyWriteDefault); }
get { return batchParentPolicyWriteDefault; }
set { batchParentPolicyWriteDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchWritePolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public BatchWritePolicy BatchWritePolicyDefault
{
get { return new BatchWritePolicy(batchWritePolicyDefault); }
get { return batchWritePolicyDefault; }
set { batchWritePolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchDeletePolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public BatchDeletePolicy BatchDeletePolicyDefault
{
get { return new BatchDeletePolicy(batchDeletePolicyDefault); }
get { return batchDeletePolicyDefault; }
set { batchDeletePolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchUDFPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.er modified.
/// </summary>
public BatchUDFPolicy BatchUDFPolicyDefault
{
get { return new BatchUDFPolicy(batchUDFPolicyDefault); }
get { return batchUDFPolicyDefault; }
set { batchUDFPolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="InfoPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public InfoPolicy InfoPolicyDefault
{
get { return new InfoPolicy(infoPolicyDefault); }
get { return infoPolicyDefault; }
set { infoPolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="TxnVerifyPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public TxnVerifyPolicy TxnVerifyPolicyDefault
{
get { return new TxnVerifyPolicy(txnVerifyPolicyDefault); }
get { return txnVerifyPolicyDefault; }
set { txnVerifyPolicyDefault = value; }
}

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="TxnRollPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
public TxnRollPolicy TxnRollPolicyDefault
{
get { return new TxnRollPolicy(txnRollPolicyDefault); }
get { return txnRollPolicyDefault; }
set { txnRollPolicyDefault = value; }
}

Expand Down
2 changes: 1 addition & 1 deletion AerospikeClient/Main/AerospikeException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ public Backoff(int resultCode) : base(resultCode)
}

/// <summary>
/// Exception thrown when <see cref="AerospikeClient.Commit(Txn)"/> fails.
/// Exception thrown when a multi-record transaction commit fails.
/// Commit Exception has similar behavior to AggregateException.
/// <see cref="InnerExceptions"/> might be populated if mutliple exceptions contribute to the failure.
/// </summary>
Expand Down
36 changes: 24 additions & 12 deletions AerospikeClient/Main/IAerospikeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,77 +26,89 @@ public interface IAerospikeClient

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="Policy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
Policy ReadPolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="WritePolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
WritePolicy WritePolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="ScanPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
ScanPolicy ScanPolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="QueryPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
QueryPolicy QueryPolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
BatchPolicy BatchPolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
BatchPolicy BatchParentPolicyWriteDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchWritePolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
BatchWritePolicy BatchWritePolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchDeletePolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
BatchDeletePolicy BatchDeletePolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="BatchUDFPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
BatchUDFPolicy BatchUDFPolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="InfoPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
InfoPolicy InfoPolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="TxnVerifyPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
TxnVerifyPolicy TxnVerifyPolicyDefault { get; set; }

/// <summary>
/// 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.
/// Use when the policy will not be modified. Use <see cref="TxnRollPolicy.Clone()"/>
/// when the policy will be modified for use in a specific command.
/// </summary>
TxnRollPolicy TxnRollPolicyDefault { get; set; }

Expand Down
Loading

0 comments on commit d31e0bd

Please sign in to comment.