Skip to content

Allow to suspend/resume RestClient #645

Open
@christophstrobl

Description

@christophstrobl

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions