public static class ConnectionContext.MongoPrimary extends Object
| Modifier and Type | Field and Description |
|---|---|
private BiConsumer<String,Throwable> |
errorHandler |
private Filters |
filters |
private Supplier<com.mongodb.MongoClient> |
primaryConnectionSupplier |
private ReplicaSet |
replicaSet |
| Modifier | Constructor and Description |
|---|---|
protected |
MongoPrimary(ConnectionContext context,
ReplicaSet replicaSet,
Filters filters,
BiConsumer<String,Throwable> errorHandler) |
| Modifier and Type | Method and Description |
|---|---|
com.mongodb.ServerAddress |
address()
Get the address of the primary node, if there is one.
|
List<CollectionId> |
collections()
Use the primary to get the identifiers of all the collections in the replica set, applying the current
collection filter configuration.
|
Set<String> |
databaseNames()
Use the primary to get the names of all the databases in the replica set, applying the current database
filter configuration.
|
void |
execute(String desc,
Consumer<com.mongodb.MongoClient> operation)
Execute the supplied operation using the primary, blocking until a primary is available.
|
<T> T |
execute(String desc,
Function<com.mongodb.MongoClient,T> operation)
Execute the supplied operation using the primary, blocking until a primary is available.
|
void |
executeBlocking(String desc,
BlockingConsumer<com.mongodb.MongoClient> operation)
Execute the supplied operation using the primary, blocking until a primary is available.
|
ReplicaSet |
replicaSet()
Get the replica set.
|
private final ReplicaSet replicaSet
private final Supplier<com.mongodb.MongoClient> primaryConnectionSupplier
private final Filters filters
private final BiConsumer<String,Throwable> errorHandler
protected MongoPrimary(ConnectionContext context, ReplicaSet replicaSet, Filters filters, BiConsumer<String,Throwable> errorHandler)
public ReplicaSet replicaSet()
public com.mongodb.ServerAddress address()
null if there is currently no primarypublic void execute(String desc, Consumer<com.mongodb.MongoClient> operation)
desc - the description of the operation, for logging purposesoperation - the operation to be performed on the primary.public <T> T execute(String desc, Function<com.mongodb.MongoClient,T> operation)
desc - the description of the operation, for logging purposesoperation - the operation to be performed on the primarypublic void executeBlocking(String desc, BlockingConsumer<com.mongodb.MongoClient> operation) throws InterruptedException
desc - the description of the operation, for logging purposesoperation - the operation to be performed on the primary.InterruptedException - if the operation was interruptedpublic Set<String> databaseNames()
public List<CollectionId> collections()
Copyright © 2018 JBoss by Red Hat. All rights reserved.