|
8 | 8 | import com.github.dockerjava.api.model.*; |
9 | 9 | import com.github.dockerjava.core.command.ExecStartResultCallback; |
10 | 10 | import com.github.dockerjava.core.command.PullImageResultCallback; |
| 11 | +import com.google.common.annotations.VisibleForTesting; |
11 | 12 | import lombok.Synchronized; |
12 | 13 | import lombok.extern.slf4j.Slf4j; |
13 | 14 | import org.apache.commons.io.IOUtils; |
@@ -235,21 +236,24 @@ private <T> T runInsideDocker(DockerClient client, Consumer<CreateContainerCmd> |
235 | 236 | } |
236 | 237 | } |
237 | 238 | } |
238 | | - |
239 | | - private static class DiskSpaceUsage { |
240 | | - Optional<Integer> availableMB = Optional.empty(); |
| 239 | + |
| 240 | + @VisibleForTesting |
| 241 | + static class DiskSpaceUsage { |
| 242 | + Optional<Long> availableMB = Optional.empty(); |
241 | 243 | Optional<Integer> usedPercent = Optional.empty(); |
242 | 244 | } |
243 | | - |
244 | | - private DiskSpaceUsage parseAvailableDiskSpace(String dfOutput) { |
| 245 | + |
| 246 | + @VisibleForTesting |
| 247 | + DiskSpaceUsage parseAvailableDiskSpace(String dfOutput) { |
245 | 248 | DiskSpaceUsage df = new DiskSpaceUsage(); |
246 | 249 | String[] lines = dfOutput.split("\n"); |
247 | 250 | for (String line : lines) { |
248 | 251 | String[] fields = line.split("\\s+"); |
249 | 252 | if (fields.length > 5 && fields[5].equals("/")) { |
250 | | - int availableKB = Integer.valueOf(fields[3]); |
251 | | - df.availableMB = Optional.of(availableKB / 1024); |
| 253 | + long availableKB = Long.valueOf(fields[3]); |
| 254 | + df.availableMB = Optional.of(availableKB / 1024L); |
252 | 255 | df.usedPercent = Optional.of(Integer.valueOf(fields[4].replace("%", ""))); |
| 256 | + break; |
253 | 257 | } |
254 | 258 | } |
255 | 259 | return df; |
|
0 commit comments