public long timeTaken() { return watch.taken(); }
@After public void tearDown() throws Exception { long time = watch.taken();
@Override public void onDownloadComplete(String host, String file) { String prefix = resume ? "Resume downloading" : "Downloading"; String msg = prefix + " from host: " + host + " file: " + file + " completed"; if (transferredBytes > 0) { msg += " (size: " + StringHelper.humanReadableBytes(transferredBytes) + ")"; } long taken = watch.taken(); String time = TimeUtils.printDuration(taken); msg += " (took: " + time + ")"; doLog(msg); }
@Override public void onUploadComplete(String host, String file) { String msg = "Uploading to host: " + host + " file: " + file + " completed"; if (transferredBytes > 0) { msg += " (size: " + StringHelper.humanReadableBytes(transferredBytes) + ")"; } long taken = watch.taken(); String time = TimeUtils.printDuration(taken); msg += " (took: " + time + ")"; doLog(msg); }
@Override public void onUpload(String host, String file, long chunkSize, long totalChunkSize, long fileSize) { transferredBytes = totalChunkSize; String msg = "Uploading to host: " + host + " file: " + file + " chunk (" + chunkSize + "/" + totalChunkSize + " bytes)"; if (fileSize > 0) { float percent = ((float) totalChunkSize / (float) fileSize) * 100L; String num = String.format("%.1f", percent); // avoid 100.0 as its only done when we get the onUploadComplete if (totalChunkSize < fileSize && "100.0".equals(num)) { num = "99.9"; } String size = StringHelper.humanReadableBytes(totalChunkSize); msg += " (progress: " + size + "/" + num + "%)"; } else { // okay we do not know the total size, but then make what we have uploaded so-far human readable String size = StringHelper.humanReadableBytes(totalChunkSize); msg += " (uploaded: " + size + ")"; } // each chunk is verbose doLogVerbose(msg); // however if the operation is slow then log once in a while if (interval.taken() > endpoint.getTransferLoggingIntervalSeconds() * 1000) { doLog(msg); interval.restart(); } }
@Override public void onDownload(String host, String file, long chunkSize, long totalChunkSize, long fileSize) { totalChunkSize = totalChunkSize + resumeOffset; transferredBytes = totalChunkSize; String prefix = resume ? "Resume downloading" : "Downloading"; String msg = prefix + " from host: " + host + " file: " + file + " chunk (" + chunkSize + "/" + totalChunkSize + " bytes)"; if (fileSize > 0) { float percent = ((float) totalChunkSize / (float) fileSize) * 100L; String num = String.format("%.1f", percent); // avoid 100.0 as its only done when we get the onDownloadComplete if (totalChunkSize < fileSize && "100.0".equals(num)) { num = "99.9"; } String size = StringHelper.humanReadableBytes(totalChunkSize); msg += " (progress: " + size + "/" + num + "%)"; } else { // okay we do not know the total size, but then make what we have download so-far human readable String size = StringHelper.humanReadableBytes(totalChunkSize); msg += " (downloaded: " + size + ")"; } doLogVerbose(msg); // however if the operation is slow then log once in a while if (interval.taken() > endpoint.getTransferLoggingIntervalSeconds() * 1000) { doLog(msg); interval.restart(); } }
while (!futures.isEmpty() && watch.taken() < timeout) {
@ManagedAttribute(description = "Summary of last FTP activity (download only)") public String getLastFtpActivity() { FTPClient client = getOperations().getFtpClient(); FtpClientActivityListener listener = (FtpClientActivityListener) client.getCopyStreamListener(); if (listener != null) { String log = listener.getLastLogActivity(); if (log != null) { long since = listener.getLastLogActivityTimestamp(); if (since > 0) { StopWatch watch = new StopWatch(new Date(since)); long delta = watch.taken(); String human = TimeUtils.printDuration(delta); return log + " " + human + " ago"; } else { return log; } } } return null; }
@ManagedAttribute(description = "Summary of last FTP activity (all)") public String getLastFtpActivityVerbose() { FTPClient client = getOperations().getFtpClient(); FtpClientActivityListener listener = (FtpClientActivityListener) client.getCopyStreamListener(); if (listener != null) { String log = listener.getLastVerboseLogActivity(); if (log != null) { long since = listener.getLastVerboseLogActivityTimestamp(); if (since > 0) { StopWatch watch = new StopWatch(new Date(since)); long delta = watch.taken(); String human = TimeUtils.printDuration(delta); return log + " " + human + " ago"; } else { return log; } } } return null; }
long time = watch.taken(); log.debug("Took {} ({} millis) to store file: {} and FTP client returned: {}", new Object[]{TimeUtils.printDuration(time), time, targetName, answer});
long time = watch.taken(); LOG.debug("Took {} ({} millis) to store file: {} and FTP client returned: true", new Object[] {TimeUtils.printDuration(time), time, targetName});