Package de.bwaldvogel.mongo
Class MongoServer
java.lang.Object
de.bwaldvogel.mongo.MongoServer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbind()Starts and binds the server on a local random portvoidvoidbind(SocketAddress socketAddress) voidbind(SocketAddress socketAddress, int numberOfBossThreads, int numberOfWorkerThreads) starts and binds the server on a local random portvoidcloseCursors(List<Long> cursorIds) Use this method to simulate closing of cursors by the server, for instance due to timeout.voidvoidenableSsl(PrivateKey key, String keyPassword, X509Certificate... keyCertChain) voidshutdown()Stop accepting new clients.voidStops accepting new clients, closes all clients and finally shuts down the server In contrast toshutdown(), this method should not block.voidCloses the server socket.toString()
-
Constructor Details
-
MongoServer
-
-
Method Details
-
enableOplog
public void enableOplog() -
enableSsl
-
bind
-
bind
-
bind
-
bind
Starts and binds the server on a local random portNote: For modern clients you probably want to use
bindAndGetConnectionString()instead!- Returns:
- the random local address the server was bound to
-
bindAndGetConnectionString
starts and binds the server on a local random port- Returns:
- the MongoDB connection string to connect to this server. Example: mongodb://localhost:12345
-
getLocalAddress
- Returns:
- the local address the server was bound or null if the server is not listening
-
getConnectionString
- Returns:
- the MongoDB connection string to connect to this server. Example: mongodb://localhost:12345
-
shutdown
public void shutdown()Stop accepting new clients. Wait until all resources (such as client connection) are closed and then shutdown. This method blocks until all clients are finished. UseshutdownNow()if the shutdown should be forced. -
stopListening
public void stopListening()Closes the server socket. No new clients are accepted afterwards. -
shutdownNow
public void shutdownNow()Stops accepting new clients, closes all clients and finally shuts down the server In contrast toshutdown(), this method should not block. -
toString
-
closeCursors
Use this method to simulate closing of cursors by the server, for instance due to timeout.
-