Brooklyn

brooklyn.entity.nosql.mongodb
[Java] Class MongoClientSupport

java.lang.Object
  brooklyn.entity.nosql.mongodb.MongoClientSupport
All Implemented Interfaces:
java.io.Closeable

public class MongoClientSupport

Manages connections to standalone MongoDB servers.

See Also:


Constructor Summary
MongoClientSupport(ServerAddress standalone)

 
Method Summary
boolean addMemberToReplicaSet(MongoDBServer secondary, java.lang.Integer id)

Reconfigures the replica set that this client is the primary member of to include a new member.

void close()

static MongoClientSupport forServer(MongoDBServer standalone)

Creates a MongoClientSupport instance in standalone mode.

BSONObject getReplicaSetConfig()

Java equivalent of calling rs.conf() in the console.

BasicBSONObject getReplicaSetStatus()

Runs replSetGetStatus on the admin database.

BasicBSONObject getServerStatus()

boolean initializeReplicaSet(java.lang.String replicaSetName, java.lang.Integer id)

boolean removeMemberFromReplicaSet(MongoDBServer server)

Reconfigures the replica set that this client is the primary member of to remove the given server.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Constructor Detail

MongoClientSupport

public MongoClientSupport(ServerAddress standalone)


 
Method Detail

addMemberToReplicaSet

public boolean addMemberToReplicaSet(MongoDBServer secondary, java.lang.Integer id)
Reconfigures the replica set that this client is the primary member of to include a new member.

Note that this can cause long downtime (typically 10-20s, even up to a minute).

Parameters:
secondary - New member of the set.
id - The id for the new set member. Must be unique within the set.
Returns:
True if successful


close

client.close();
public void close()


forServer

public static MongoClientSupport forServer(MongoDBServer standalone)
Creates a MongoClientSupport instance in standalone mode. Returns com.google.common.base.Optional#absent if the server's host and port are unknown.


getReplicaSetConfig

public BSONObject getReplicaSetConfig()
Java equivalent of calling rs.conf() in the console.


getReplicaSetStatus

public BasicBSONObject getReplicaSetStatus()
Runs replSetGetStatus on the admin database.
Returns:
The result of replSetGetStatus, or an empty BasicBSONObject if the command threw an exception (e.g. if the connection was reset) or if the resultant CommandResult#ok#ok was false.
See Also:


getServerStatus

public BasicBSONObject getServerStatus()


initializeReplicaSet

public boolean initializeReplicaSet(java.lang.String replicaSetName, java.lang.Integer id)


removeMemberFromReplicaSet

public boolean removeMemberFromReplicaSet(MongoDBServer server)
Reconfigures the replica set that this client is the primary member of to remove the given server.
Parameters:
server - The server to remove
Returns:
True if successful


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.