Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5034

Allow to suspend/resume MongoClient

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      In order to create a checkpoint using CRaC it is required that all sockets are closed before taking the snapshot.

      JAVA-3928 already introduced ways to suspend the ConnectionPool via invalidate(...) and resume if afterwards via `ready`.

      Is there a way to access the ConnectionPool to invoke those methods or maybe even provide some public API as outlined below

      class MongoClientResource implements org.crac.Resource {
      	
      	MongoClient mongoClient;
      	// ...
      
      	@Override
      	public void beforeCheckpoint(Context<? extends Resource> context) throws Exception {
      		// mongoClient -> delegate -> cluster -> server -> connectionPool.invalidate(...)
      		client.suspend(); 
      	}
      	@Override
      	public void afterRestore(Context<? extends Resource> context) throws Exception {
      		// mongoClient -> delegate -> cluster -> server -> connectionPool.ready()
      		client.resume();
      	}
      }
      

      In doing so existing references to the MongoClient as well as obtained MongoDatabase, MongoCollection instances will remain valid, which would not be the case if the client was closed before the checkpoint and recreated from captured MongoClientSettings in the afterRestore method.

            Assignee:
            Unassigned Unassigned
            Reporter:
            cstrobl@vmware.com Christoph Strobl
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: