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

Allow to suspend/resume MongoClient

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Unknown Unknown
    • None
    • None
    • 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?

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: