public class ReplicaSetConfig
extends java.lang.Object
{ "_id" : "replica-set-name", "version" : 3, "members" : [ { "_id" : 0, "host" : "Sams.local:27017" }, { "_id" : 1, "host" : "Sams.local:27018" }, { "_id" : 2, "host" : "Sams.local:27019" } ] }To add or remove servers to a replica set you must redefine this configuration (run
replSetReconfig
on the primary) with the new members
list and the version
updated.Constructor and Description |
---|
ReplicaSetConfig(java.lang.String name) |
ReplicaSetConfig(java.lang.String name,
org.bson.types.BasicBSONList existingMembers) |
Modifier and Type | Method and Description |
---|---|
org.bson.BasicBSONObject |
build() |
static ReplicaSetConfig |
builder(java.lang.String name)
Creates a configuration with the given name.
|
static ReplicaSetConfig |
fromExistingConfig(org.bson.BSONObject config)
Creates a configuration from an existing configuration.
|
ReplicaSetConfig |
member(HostAndPort address,
java.lang.Integer id)
Adds a new member to the replica set config using the given
HostAndPort for hostname and port. |
ReplicaSetConfig |
member(MongoDBServer server,
java.lang.Integer id)
Adds a new member to the replica set config using
SoftwareProcess.HOSTNAME and AbstractMongoDBServer.PORT
for hostname and port. |
ReplicaSetConfig |
member(java.lang.String hostname,
java.lang.Integer port,
java.lang.Integer id)
Adds a new member to the replica set config with the given hostname, port and id.
|
ReplicaSetConfig |
primary(HostAndPort primary)
Notes the primary member of the replica.
|
ReplicaSetConfig |
remove(HostAndPort address)
Removes the first entity with host and port matching the given address.
|
ReplicaSetConfig |
remove(MongoDBServer server)
Removes the first entity using
SoftwareProcess.HOSTNAME and AbstractMongoDBServer.PORT . |
ReplicaSetConfig |
remove(java.lang.String hostname,
java.lang.Integer port)
Removes the first entity with the given hostname and port from the list of members
|
ReplicaSetConfig |
version(java.lang.Integer version)
Sets the version of the configuration.
|
public ReplicaSetConfig(java.lang.String name)
public ReplicaSetConfig(java.lang.String name, org.bson.types.BasicBSONList existingMembers)
public static ReplicaSetConfig builder(java.lang.String name)
public static ReplicaSetConfig fromExistingConfig(org.bson.BSONObject config)
public ReplicaSetConfig version(java.lang.Integer version)
public ReplicaSetConfig primary(HostAndPort primary)
public ReplicaSetConfig member(MongoDBServer server, java.lang.Integer id)
SoftwareProcess.HOSTNAME
and AbstractMongoDBServer.PORT
for hostname and port. Doesn't attempt to check that the id is free.public ReplicaSetConfig member(HostAndPort address, java.lang.Integer id)
HostAndPort
for hostname and port.
Doesn't attempt to check that the id is free.public ReplicaSetConfig member(java.lang.String hostname, java.lang.Integer port, java.lang.Integer id)
public ReplicaSetConfig remove(MongoDBServer server)
SoftwareProcess.HOSTNAME
and AbstractMongoDBServer.PORT
.public ReplicaSetConfig remove(HostAndPort address)
public ReplicaSetConfig remove(java.lang.String hostname, java.lang.Integer port)
public org.bson.BasicBSONObject build()
BasicBSONObject
representing the configuration that is suitable for a MongoDB server.