File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
src/main/java/com/github/dockerjava/client Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 3434import com .github .dockerjava .client .command .ListContainersCmd ;
3535import com .github .dockerjava .client .command .ListImagesCmd ;
3636import com .github .dockerjava .client .command .LogContainerCmd ;
37+ import com .github .dockerjava .client .command .PingCmd ;
3738import com .github .dockerjava .client .command .PullImageCmd ;
3839import com .github .dockerjava .client .command .PushImageCmd ;
3940import com .github .dockerjava .client .command .RemoveContainerCmd ;
@@ -174,6 +175,10 @@ public AuthCmd authCmd() {
174175 public InfoCmd infoCmd () throws DockerException {
175176 return new InfoCmd ().withBaseResource (baseResource );
176177 }
178+
179+ public PingCmd pingCmd () {
180+ return new PingCmd ().withBaseResource (baseResource );
181+ }
177182
178183 public VersionCmd versionCmd () throws DockerException {
179184 return new VersionCmd ().withBaseResource (baseResource );
Original file line number Diff line number Diff line change 1+ package com .github .dockerjava .client .command ;
2+
3+ import org .slf4j .Logger ;
4+ import org .slf4j .LoggerFactory ;
5+
6+ import com .sun .jersey .api .client .ClientResponse ;
7+ import com .sun .jersey .api .client .UniformInterfaceException ;
8+ import com .sun .jersey .api .client .WebResource ;
9+
10+ /**
11+ * Ping the Docker server
12+ *
13+ */
14+ public class PingCmd extends AbstrDockerCmd <PingCmd , Integer > {
15+
16+ private static final Logger LOGGER = LoggerFactory .getLogger (PingCmd .class );
17+
18+ protected Integer impl () {
19+ WebResource webResource = baseResource .path ("/_ping" );
20+
21+ try {
22+ LOGGER .trace ("GET: {}" , webResource );
23+ ClientResponse resp = webResource .get (ClientResponse .class );
24+ return resp .getStatus ();
25+ } catch (UniformInterfaceException exception ) {
26+ return exception .getResponse ().getStatus ();
27+ }
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments