-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
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?