@java.lang.SuppressWarnings("all") public com.github.dockerjava.api.command.StatsCmd statsCmd(final java.lang.String arg0) { return this.wrappedClient.statsCmd(arg0); }
@Override public StatsCmd statsCmd(String arg0) { return getDelegate().statsCmd(arg0); }
public Optional<Statistics> getContainerStats(String containerId) { StatsCmd statsCmd = dockerClient.statsCmd(containerId); CountDownLatch countDownLatch = new CountDownLatch(1); StatsCallback stats = new StatsCallback(countDownLatch); try (StatsCallback statscallback = statsCmd.exec(stats)) { countDownLatch.await(5, TimeUnit.SECONDS); } catch (InterruptedException | IOException e) { LoggingService.logWarning(MODULE_NAME, e.getMessage()); } return Optional.ofNullable(stats.getStats()); }
public Statistics statsContainer(String id) throws IOException { this.readWriteLock.readLock().lock(); try { StatsCmd statsCmd = this.dockerClient.statsCmd(id); CountDownLatch countDownLatch = new CountDownLatch(1); StatsLogsResultCallback statslogs = new StatsLogsResultCallback(countDownLatch); try { StatsLogsResultCallback statscallback = statsCmd.exec(statslogs); countDownLatch.await(5, TimeUnit.SECONDS); statscallback.close(); } catch (InterruptedException e) { throw new IOException(e); } return statslogs.getStatistics(); } finally { this.readWriteLock.readLock().unlock(); } }
public Statistics statsContainer(String id) throws IOException { this.readWriteLock.readLock().lock(); try { StatsCmd statsCmd = this.dockerClient.statsCmd(id); CountDownLatch countDownLatch = new CountDownLatch(1); StatsLogsResultCallback statslogs = new StatsLogsResultCallback(countDownLatch); try { StatsLogsResultCallback statscallback = statsCmd.exec(statslogs); countDownLatch.await(5, TimeUnit.SECONDS); statscallback.close(); } catch (InterruptedException e) { throw new IOException(e); } return statslogs.getStatistics(); } finally { this.readWriteLock.readLock().unlock(); } }
public Statistics getStatistics(String containerId) { FirstObjectResultCallback<Statistics> resultCallback = new FirstObjectResultCallback<>(); try { return getClient().statsCmd(containerId).exec(resultCallback).waitForObject(); } catch (InterruptedException e) { throw new KurentoException("Interrupted while waiting for statistics"); } }
public Statistics getStatistics(String containerId) { FirstObjectResultCallback<Statistics> resultCallback = new FirstObjectResultCallback<>(); try { return getClient().statsCmd(containerId).exec(resultCallback).waitForObject(); } catch (InterruptedException e) { throw new KurentoException("Interrupted while waiting for statistics"); } }
@Override protected void doStart() throws Exception { String containerId = DockerHelper.getProperty(DockerConstants.DOCKER_CONTAINER_ID, endpoint.getConfiguration(), null, String.class); this.statsCmd = DockerClientFactory.getDockerClient(component, endpoint.getConfiguration(), null).statsCmd(containerId); this.statsCmd.exec(new StatsCallback()); super.doStart(); }
@Override public Optional<ContainerStats> getContainerStats(ContainerName containerName) { try { DockerStatsCallback statsCallback = dockerClient.statsCmd(containerName.asString()).exec(new DockerStatsCallback()); statsCallback.awaitCompletion(5, TimeUnit.SECONDS); return statsCallback.stats.map(stats -> new ContainerStats( stats.getNetworks(), stats.getCpuStats(), stats.getMemoryStats(), stats.getBlkioStats())); } catch (NotFoundException ignored) { return Optional.empty(); } catch (RuntimeException | InterruptedException e) { numberOfDockerDaemonFails.add(); throw new DockerException("Failed to get stats for container '" + containerName.asString() + "'", e); } }
private void statsContainer(String id, URI clusterUri, Statistics preStats) { if (this.isStopping()) { return; } if (isStopContainer(id)) { return; } schedule(() -> { CountDownLatch countDownLatch = new CountDownLatch(this.statsBatch); StatsContainerCallback statsCallback = null; try { statsCallback = dockerClient.statsCmd(id).exec(new StatsContainerCallback(this, clusterUri, id, countDownLatch, preStats)); } catch (com.github.dockerjava.api.exception.ConflictException | com.github.dockerjava.api.exception.NotFoundException e) { return; } try { countDownLatch.await(this.statsCallBackTimeout, TimeUnit.SECONDS); } catch (InterruptedException e) { } finally { try { statsCallback.close(); } catch (IOException e) { } statsContainer(id, clusterUri, statsCallback.getPreStat()); } }, this.statsPeriod, TimeUnit.SECONDS); }