public static class ConnectionContext.MongoPrimary extends Object
| Modifier and Type | Field and Description |
|---|---|
private BiConsumer<String,Throwable> |
errorHandler |
private Supplier<com.mongodb.MongoClient> |
primaryConnectionSupplier |
private ReplicaSet |
replicaSet |
| Modifier | Constructor and Description |
|---|---|
protected |
MongoPrimary(ConnectionContext context,
ReplicaSet replicaSet,
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.
|
Set<String> |
databaseNames()
Use the primary to get the names of all the databases in the replica set.
|
void |
execute(String desc,
Consumer<com.mongodb.MongoClient> 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 BiConsumer<String,Throwable> errorHandler
protected MongoPrimary(ConnectionContext context, ReplicaSet replicaSet, 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 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 © 2016 JBoss by Red Hat. All rights reserved.