Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
94 changes: 0 additions & 94 deletions driver-core/src/main/com/mongodb/ClientEncryptionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

package com.mongodb;

import com.mongodb.annotations.Alpha;
import com.mongodb.annotations.NotThreadSafe;
import com.mongodb.annotations.Reason;
import com.mongodb.lang.Nullable;

import javax.net.ssl.SSLContext;
Expand All @@ -29,9 +27,7 @@

import static com.mongodb.assertions.Assertions.assertTrue;
import static com.mongodb.assertions.Assertions.notNull;
import static com.mongodb.internal.TimeoutSettings.convertAndValidateTimeout;
import static java.util.Collections.unmodifiableMap;
import static java.util.concurrent.TimeUnit.MILLISECONDS;

/**
* The client-side settings for data key creation and explicit encryption.
Expand All @@ -52,8 +48,6 @@ public final class ClientEncryptionSettings {
@Nullable
private final KmsConnectCallback kmsConnectCallback;
@Nullable
private final Long timeoutMS;
@Nullable
private final Long keyExpirationMS;

/**
Expand All @@ -70,8 +64,6 @@ public static final class Builder {
@Nullable
private KmsConnectCallback kmsConnectCallback;
@Nullable
private Long timeoutMS;
@Nullable
private Long keyExpirationMS;

/**
Expand Down Expand Up @@ -172,48 +164,6 @@ public Builder keyExpiration(@Nullable final Long keyExpiration, final TimeUnit
return this;
}

/**
* Sets the time limit for the full execution of an operation.
*
* <ul>
* <li>{@code null} means that the timeout mechanism for operations will defer to using:
* <ul>
* <li>{@code waitQueueTimeoutMS}: The maximum wait time in milliseconds that a thread may wait for a connection to become
* available</li>
* <li>{@code socketTimeoutMS}: How long a send or receive on a socket can take before timing out.</li>
* <li>{@code wTimeoutMS}: How long the server will wait for the write concern to be fulfilled before timing out.</li>
* <li>{@code maxTimeMS}: The cumulative time limit for processing operations on a cursor.
* See: <a href="https://docs.mongodb.com/manual/reference/method/cursor.maxTimeMS">cursor.maxTimeMS</a>.</li>
* <li>{@code maxCommitTimeMS}: The maximum amount of time to allow a single {@code commitTransaction} command to execute.
* See: {@link TransactionOptions#getMaxCommitTime}.</li>
* </ul>
* </li>
* <li>{@code 0} means infinite timeout.</li>
* <li>{@code > 0} The time limit to use for the full execution of an operation.</li>
* </ul>
*
* <p>Note:
* <ul>
* <li>The timeout set through this method overrides the timeout defined in the key vault client settings
* specified in {@link #keyVaultMongoClientSettings(MongoClientSettings)}.
* Essentially, for operations that require accessing the key vault, the remaining timeout from the initial operation
* determines the duration allowed for key vault access.</li>
* <li>When using synchronous API, this timeout does not limit socket writes, therefore there is a possibility that the
* operation might not be timed out when expected. This limitation does not apply to the reactive streams API.</li>
* </ul>
*
* @param timeout the timeout
* @param timeUnit the time unit
* @return this
* @since 5.2
* @see #getTimeout
*/
@Alpha(Reason.CLIENT)
public ClientEncryptionSettings.Builder timeout(final long timeout, final TimeUnit timeUnit) {
this.timeoutMS = convertAndValidateTimeout(timeout, timeUnit);
return this;
}

/**
* Build an instance of {@code ClientEncryptionSettings}.
*
Expand Down Expand Up @@ -381,57 +331,13 @@ public Long getKeyExpiration(final TimeUnit timeUnit) {
return keyExpirationMS == null ? null : timeUnit.convert(keyExpirationMS, TimeUnit.MILLISECONDS);
}

/**
* The time limit for the full execution of an operation.
*
* <p>If set the following deprecated options will be ignored:
* {@code waitQueueTimeoutMS}, {@code socketTimeoutMS}, {@code wTimeoutMS}, {@code maxTimeMS} and {@code maxCommitTimeMS}</p>
*
* <ul>
* <li>{@code null} means that the timeout mechanism for operations will defer to using:
* <ul>
* <li>{@code waitQueueTimeoutMS}: The maximum wait time in milliseconds that a thread may wait for a connection to become
* available</li>
* <li>{@code socketTimeoutMS}: How long a send or receive on a socket can take before timing out.</li>
* <li>{@code wTimeoutMS}: How long the server will wait for the write concern to be fulfilled before timing out.</li>
* <li>{@code maxTimeMS}: The cumulative time limit for processing operations on a cursor.
* See: <a href="https://docs.mongodb.com/manual/reference/method/cursor.maxTimeMS">cursor.maxTimeMS</a>.</li>
* <li>{@code maxCommitTimeMS}: The maximum amount of time to allow a single {@code commitTransaction} command to execute.
* See: {@link TransactionOptions#getMaxCommitTime}.</li>
* </ul>
* </li>
* <li>{@code 0} means infinite timeout.</li>
* <li>{@code > 0} The time limit to use for the full execution of an operation.</li>
* </ul>
*
* <p>Note:
* <ul>
* <li>The timeout set through this method overrides the timeout defined in the key vault client settings
* specified in {@link Builder#keyVaultMongoClientSettings(MongoClientSettings)}.
* Essentially, for operations that require accessing the key vault, the remaining timeout from the initial operation
* determines the duration allowed for key vault access.</li>
* <li>When using synchronous API, this timeout does not limit socket writes, therefore there is a possibility that the
* operation might not be timed out when expected. This limitation does not apply to the reactive streams API.</li>
* </ul>
*
* @param timeUnit the time unit
* @return the timeout in the given time unit
* @since 5.2
*/
@Alpha(Reason.CLIENT)
@Nullable
public Long getTimeout(final TimeUnit timeUnit) {
return timeoutMS == null ? null : timeUnit.convert(timeoutMS, MILLISECONDS);
}

private ClientEncryptionSettings(final Builder builder) {
this.keyVaultMongoClientSettings = notNull("keyVaultMongoClientSettings", builder.keyVaultMongoClientSettings);
this.keyVaultNamespace = notNull("keyVaultNamespace", builder.keyVaultNamespace);
this.kmsProviders = notNull("kmsProviders", builder.kmsProviders);
this.kmsProviderPropertySuppliers = notNull("kmsProviderPropertySuppliers", builder.kmsProviderPropertySuppliers);
this.kmsProviderSslContextMap = notNull("kmsProviderSslContextMap", builder.kmsProviderSslContextMap);
this.kmsConnectCallback = builder.kmsConnectCallback;
this.timeoutMS = builder.timeoutMS;
this.keyExpirationMS = builder.keyExpirationMS;
}

Expand Down
63 changes: 1 addition & 62 deletions driver-core/src/main/com/mongodb/ClientSessionOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@

package com.mongodb;

import com.mongodb.annotations.Alpha;
import com.mongodb.annotations.Immutable;
import com.mongodb.annotations.NotThreadSafe;
import com.mongodb.annotations.Reason;
import com.mongodb.lang.Nullable;
import com.mongodb.session.ClientSession;

import java.util.Objects;
import java.util.concurrent.TimeUnit;

import static com.mongodb.assertions.Assertions.notNull;
import static com.mongodb.internal.TimeoutSettings.convertAndValidateTimeout;
import static java.util.concurrent.TimeUnit.MILLISECONDS;

/**
* The options to apply to a {@code ClientSession}.
Expand All @@ -43,7 +38,6 @@ public final class ClientSessionOptions {

private final Boolean causallyConsistent;
private final Boolean snapshot;
private final Long defaultTimeoutMS;
private final TransactionOptions defaultTransactionOptions;

/**
Expand Down Expand Up @@ -83,30 +77,6 @@ public TransactionOptions getDefaultTransactionOptions() {
return defaultTransactionOptions;
}

/**
* Gets the default time limit for the following operations executed on the session:
*
* <ul>
* <li>{@code commitTransaction}</li>
* <li>{@code abortTransaction}</li>
* <li>{@code withTransaction}</li>
* <li>{@code close}</li>
* </ul>
*
* <p>Note: When using synchronous API, this timeout does not limit socket writes, therefore
* there is a possibility that the operation might not be timed out when expected. This limitation does not
* apply to the reactive streams API.
*
* @param timeUnit the time unit
* @return the default timeout
* @since 5.2
*/
@Alpha(Reason.CLIENT)
@Nullable
public Long getDefaultTimeout(final TimeUnit timeUnit) {
return defaultTimeoutMS == null ? null : timeUnit.convert(defaultTimeoutMS, MILLISECONDS);
}

@Override
public boolean equals(final Object o) {
if (this == o) {
Expand All @@ -118,21 +88,19 @@ public boolean equals(final Object o) {
final ClientSessionOptions that = (ClientSessionOptions) o;
return Objects.equals(causallyConsistent, that.causallyConsistent)
&& Objects.equals(snapshot, that.snapshot)
&& Objects.equals(defaultTimeoutMS, that.defaultTimeoutMS)
&& Objects.equals(defaultTransactionOptions, that.defaultTransactionOptions);
}

@Override
public int hashCode() {
return Objects.hash(causallyConsistent, snapshot, defaultTimeoutMS, defaultTransactionOptions);
return Objects.hash(causallyConsistent, snapshot, defaultTransactionOptions);
}

@Override
public String toString() {
return "ClientSessionOptions{"
+ "causallyConsistent=" + causallyConsistent
+ ", snapshot=" + snapshot
+ ", defaultTimeoutMS=" + defaultTimeoutMS
+ ", defaultTransactionOptions=" + defaultTransactionOptions
+ '}';
}
Expand All @@ -159,7 +127,6 @@ public static Builder builder(final ClientSessionOptions options) {
builder.causallyConsistent = options.isCausallyConsistent();
builder.snapshot = options.isSnapshot();
builder.defaultTransactionOptions = options.getDefaultTransactionOptions();
builder.defaultTimeoutMS = options.defaultTimeoutMS;
return builder;
}

Expand All @@ -170,7 +137,6 @@ public static Builder builder(final ClientSessionOptions options) {
public static final class Builder {
private Boolean causallyConsistent;
private Boolean snapshot;
private Long defaultTimeoutMS;
private TransactionOptions defaultTransactionOptions = TransactionOptions.builder().build();

/**
Expand Down Expand Up @@ -219,32 +185,6 @@ public Builder defaultTransactionOptions(final TransactionOptions defaultTransac
return this;
}

/**
* Sets the default time limit for the following operations executed on the session:
*
* <ul>
* <li>{@code commitTransaction}</li>
* <li>{@code abortTransaction}</li>
* <li>{@code withTransaction}</li>
* <li>{@code close}</li>
* </ul>
*
* <p>Note: When using synchronous API, this timeout does not limit socket writes, therefore
* there is a possibility that the operation might not be timed out when expected. This limitation does not
* apply to the reactive streams API.
*
* @param defaultTimeout the timeout
* @param timeUnit the time unit
* @return this
* @since 5.2
* @see #getDefaultTimeout
*/
@Alpha(Reason.CLIENT)
public Builder defaultTimeout(final long defaultTimeout, final TimeUnit timeUnit) {
this.defaultTimeoutMS = convertAndValidateTimeout(defaultTimeout, timeUnit, "defaultTimeout");
return this;
}

/**
* Build the session options instance.
*
Expand All @@ -267,6 +207,5 @@ private ClientSessionOptions(final Builder builder) {
: Boolean.valueOf(!builder.snapshot);
this.snapshot = builder.snapshot;
this.defaultTransactionOptions = builder.defaultTransactionOptions;
this.defaultTimeoutMS = builder.defaultTimeoutMS;
}
}
Loading