Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to suspend/resume RestClient #645

Open
christophstrobl opened this issue Aug 3, 2023 · 0 comments
Open

Allow to suspend/resume RestClient #645

christophstrobl opened this issue Aug 3, 2023 · 0 comments
Labels
Category: Enhancement New feature or request

Comments

@christophstrobl
Copy link

Description

In order to create and resume from a checkpoint using CRaC it is required that all sockets are closed before taking the snapshot.
HttpAsyncClientBuilder used by the RestClientBuilder allows to set a NHttpClientConnectionManager which id defaulted to a PoolingNHttpClientConnectionManager. The pool will keep connections open for a given timeout which leads to an error when invoking jcmd ... JDK.checkpoint.
However, NHttpClientConnectionManager would allow to explicitly closeExpiredConnections() as well as closeIdleConnections which will make sure the requirements for capturing a snapshot are met.

Is there a way to provide an API on RestClient that would allow to evict open connections?

class RestClientResource implements org.crac.Resource {
    
    RestClient client;
    // ...
 
    @Override
    public void beforeCheckpoint(Context<? extends Resource> context) throws Exception {
        // client -> httpAsyncClient -> connmgr -> connmgr.closeExpiredConnections() & connmgr.closeIdleConnections(0, MILLISECONDS);
        client.evicConnections(); 
    }
    @Override
    public void afterRestore(Context<? extends Resource> context) throws Exception {
        // nothing to do
    }
}

In doing so existing references to the RestClient instances will remain valid, which would not be the case if the client was closed before the checkpoint and recreated from captured settings in the afterRestore method.

@l-trotta l-trotta added the Category: Enhancement New feature or request label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants