Package de.bwaldvogel.mongo
Class MongoServer
java.lang.Object
de.bwaldvogel.mongo.MongoServer
public class MongoServer
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description MongoServer(MongoBackend backend) -
Method Summary
Modifier and Type Method Description java.net.InetSocketAddressbind()starts and binds the server on a local random portvoidbind(java.lang.String hostname, int port)voidbind(java.net.SocketAddress socketAddress)voidbind(java.net.SocketAddress socketAddress, int numberOfBossThreads, int numberOfWorkerThreads)voidcloseCursors(MongoKillCursors killCursors)Use this method to simulate closing of cursors by the server, for instance due to timeout.voidenableOplog()voidenableSsl(java.security.PrivateKey key, java.lang.String keyPassword, java.security.cert.X509Certificate... keyCertChain)java.net.InetSocketAddressgetLocalAddress()voidshutdown()Stop accepting new clients.voidshutdownNow()Stops accepting new clients, closes all clients and finally shuts down the server In contrast toshutdown(), this method should not block.voidstopListening()Closes the server socket.java.lang.StringtoString()
-
Constructor Details
-
Method Details
-
enableOplog
public void enableOplog() -
enableSsl
public void enableSsl(java.security.PrivateKey key, java.lang.String keyPassword, java.security.cert.X509Certificate... keyCertChain) -
bind
public void bind(java.lang.String hostname, int port) -
bind
public void bind(java.net.SocketAddress socketAddress) -
bind
public void bind(java.net.SocketAddress socketAddress, int numberOfBossThreads, int numberOfWorkerThreads) -
bind
public java.net.InetSocketAddress bind()starts and binds the server on a local random port- Returns:
- the random local address the server was bound to
-
getLocalAddress
public java.net.InetSocketAddress getLocalAddress()- Returns:
- the local address the server was bound or null if the server is not listening
-
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
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
closeCursors
Use this method to simulate closing of cursors by the server, for instance due to timeout.
-