Search in sources :

Example 1 with AsyncClusterBinding

use of com.mongodb.internal.binding.AsyncClusterBinding in project mongo-java-driver by mongodb.

the class ClusterFixture method getAsyncBinding.

public static AsyncReadWriteBinding getAsyncBinding(final Cluster cluster, final ReadPreference readPreference) {
    if (!asyncBindingMap.containsKey(readPreference)) {
        AsyncReadWriteBinding binding = new AsyncClusterBinding(cluster, readPreference, ReadConcern.DEFAULT, getServerApi(), IgnorableRequestContext.INSTANCE);
        if (serverVersionAtLeast(3, 6)) {
            binding = new AsyncSessionBinding(binding);
        }
        asyncBindingMap.put(readPreference, binding);
    }
    return asyncBindingMap.get(readPreference);
}
Also used : AsyncReadWriteBinding(com.mongodb.internal.binding.AsyncReadWriteBinding) AsyncClusterBinding(com.mongodb.internal.binding.AsyncClusterBinding) AsyncSessionBinding(com.mongodb.internal.binding.AsyncSessionBinding)

Example 2 with AsyncClusterBinding

use of com.mongodb.internal.binding.AsyncClusterBinding in project mongo-java-driver by mongodb.

the class OperationExecutorImpl method getReadWriteBinding.

private AsyncReadWriteBinding getReadWriteBinding(final RequestContext requestContext, final ReadPreference readPreference, final ReadConcern readConcern, @Nullable final ClientSession session, final boolean ownsSession) {
    notNull("readPreference", readPreference);
    AsyncClusterAwareReadWriteBinding readWriteBinding = new AsyncClusterBinding(mongoClient.getCluster(), getReadPreferenceForBinding(readPreference, session), readConcern, mongoClient.getSettings().getServerApi(), requestContext);
    Crypt crypt = mongoClient.getCrypt();
    if (crypt != null) {
        readWriteBinding = new CryptBinding(readWriteBinding, crypt);
    }
    final AsyncClusterAwareReadWriteBinding asyncReadWriteBinding = readWriteBinding;
    if (session != null) {
        return new ClientSessionBinding(session.getWrapped(), ownsSession, asyncReadWriteBinding);
    } else {
        return asyncReadWriteBinding;
    }
}
Also used : AsyncClusterBinding(com.mongodb.internal.binding.AsyncClusterBinding) Crypt(com.mongodb.reactivestreams.client.internal.crypt.Crypt) CryptBinding(com.mongodb.reactivestreams.client.internal.crypt.CryptBinding) AsyncClusterAwareReadWriteBinding(com.mongodb.internal.binding.AsyncClusterAwareReadWriteBinding) ClientSessionBinding(com.mongodb.internal.async.client.ClientSessionBinding)

Aggregations

AsyncClusterBinding (com.mongodb.internal.binding.AsyncClusterBinding)2 ClientSessionBinding (com.mongodb.internal.async.client.ClientSessionBinding)1 AsyncClusterAwareReadWriteBinding (com.mongodb.internal.binding.AsyncClusterAwareReadWriteBinding)1 AsyncReadWriteBinding (com.mongodb.internal.binding.AsyncReadWriteBinding)1 AsyncSessionBinding (com.mongodb.internal.binding.AsyncSessionBinding)1 Crypt (com.mongodb.reactivestreams.client.internal.crypt.Crypt)1 CryptBinding (com.mongodb.reactivestreams.client.internal.crypt.CryptBinding)1