X Tutup
Skip to content

Failed to get a live stream (/stats) from docker remote api #230

@bengong2015

Description

@bengong2015

I tried to add an function to get the containers' state base on resource usage (docker remote api: minion ip:port/containers/{container id}/stats):

public class StatsContainerCmdExec extends AbstrDockerCmdExec<StatsContainerCmd, StatsContainerResponse> implements StatsContainerCmd.Exec{

private static final Logger LOGGER = LoggerFactory.getLogger(StatsContainerCmdExec.class);

public StatsContainerCmdExec(WebTarget baseResource) {
    super(baseResource);
}

protected StatsContainerResponse execute(StatsContainerCmd command) {
    WebTarget webResource = getBaseResource().path("/containers/{id}/stats")
    .resolveTemplate("id", command.getContainerId());
    LOGGER.trace("GET: {}", webResource);
    Builder builder = webResource.request();
    Builder a = builder.accept(MediaType.APPLICATION_JSON);
    StatsContainerResponse rp=a.get(StatsContainerResponse.class);  
    return rp;
} 

I set breakpoints and found the progress 'hang-up' at 'a.get(StatsContainerResponse.class)', When I tried to print the data of 'a.get()', java expose Exception said 'the connection still be allocated', need to release. I guess it is caused by the jersey api cannot solve the live stream (doesn't release the http connection after search once, it seems does not use the release method of httpclient). How can I fix it? Or rebuild the function by using 'getConnection()' and 'releaseConnection()' of httpclient JAR directly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup