/** * @deprecated Replaced by {@link #getBytesTransferred()} */ public long getBytesTransfered() { return getBytesTransferred(); }
/** * Returns a percentage of the number of bytes transferred out of the total * number of bytes to transfer. * * @return A percentage of the number of bytes transferred out of the total * number of bytes to transfer; or -1.0 if the total length is not known. */ public synchronized double getPercentTransferred() { if (getBytesTransferred() < 0) return 0; return totalBytesToTransfer < 0 ? -1.0 : ((double)bytesTransferred / (double)totalBytesToTransfer) * (double)100; }
public static void showTransferProgress(Transfer xfer) { // print the transfer's human-readable description System.out.println(xfer.getDescription()); // print an empty progress bar... printProgressBar(0.0); // update the progress bar while the xfer is ongoing. do { try { Thread.sleep(100); } catch (InterruptedException e) { return; } // Note: so_far and total aren't used, they're just for // documentation purposes. TransferProgress progress = xfer.getProgress(); long so_far = progress.getBytesTransferred(); long total = progress.getTotalBytesToTransfer(); double pct = progress.getPercentTransferred(); eraseProgressBar(); printProgressBar(pct); } while (xfer.isDone() == false); // print the final state of the transfer. TransferState xfer_state = xfer.getState(); System.out.println(": " + xfer_state); }
/** * @deprecated Replaced by {@link #getBytesTransferred()} */ public long getBytesTransfered() { return getBytesTransferred(); }
/** * Returns a percentage of the number of bytes transferred out of the total * number of bytes to transfer. * * @return A percentage of the number of bytes transferred out of the total * number of bytes to transfer; or -1.0 if the total length is not known. */ public synchronized double getPercentTransferred() { if (getBytesTransferred() < 0) return 0; return totalBytesToTransfer < 0 ? -1.0 : ((double)bytesTransferred / (double)totalBytesToTransfer) * (double)100; }
/** * Method to invoke after upload has completed. * This can handle race conditions in setup/teardown. * @return the number of bytes which were transferred after the notification */ public long uploadCompleted() { long delta = upload.getProgress().getBytesTransferred() - lastBytesTransferred; if (delta > 0) { LOG.debug("S3A write delta changed after finished: {} bytes", delta); fs.incrementPutProgressStatistics(key, delta); } return delta; }
/** * Logs transfer progress for an S3 file transfer operation. * * @param transferProgress the progress of an S3 transfer operation */ private void logTransferProgress(TransferProgress transferProgress) { // If the total bytes to transfer is set to 0, we do not log the transfer progress. if (LOGGER.isInfoEnabled() && transferProgress.getTotalBytesToTransfer() > 0) { NumberFormat formatter = new DecimalFormat("#0.0"); LOGGER.info("progressBytesTransferred={} totalBytesToTransfer={} progressPercentTransferred={}", transferProgress.getBytesTransferred(), transferProgress.getTotalBytesToTransfer(), formatter.format(transferProgress.getPercentTransferred())); } }
/** * Logs transfer progress for an S3 file transfer operation. * * @param transferProgress the progress of an S3 transfer operation */ private void logTransferProgress(TransferProgress transferProgress) { // If the total bytes to transfer is set to 0, we do not log the transfer progress. if (LOGGER.isInfoEnabled() && transferProgress.getTotalBytesToTransfer() > 0) { NumberFormat formatter = new DecimalFormat("#0.0"); LOGGER.info("progressBytesTransferred={} totalBytesToTransfer={} progressPercentTransferred={}", transferProgress.getBytesTransferred(), transferProgress.getTotalBytesToTransfer(), formatter.format(transferProgress.getPercentTransferred())); } }
private long doCopy(Mapper.Context context, FileStatus sourceFileStatus, S3UploadDescriptor uploadDescriptor) throws IOException { LOG.debug("Copying {} to {}", sourceFileStatus.getPath(), uploadDescriptor.getTargetPath()); final Path sourcePath = sourceFileStatus.getPath(); Transfer transfer = startTransfer(context, uploadDescriptor); transfer.addProgressListener(new UploadProgressListener(context, description)); try { AmazonClientException e = transfer.waitForException(); if (e != null) { throw new IOException(e); } } catch (InterruptedException e) { throw new RuntimeException("Unable to upload file " + sourcePath, e); } return transfer.getProgress().getBytesTransferred(); }
private long doCopy(Mapper.Context context, FileStatus sourceFileStatus, S3UploadDescriptor uploadDescriptor) throws IOException { LOG.debug("Copying {} to {}", sourceFileStatus.getPath(), uploadDescriptor.getTargetPath()); final Path sourcePath = sourceFileStatus.getPath(); Transfer transfer = startTransfer(context, uploadDescriptor); transfer.addProgressListener(new UploadProgressListener(context, description)); try { AmazonClientException e = transfer.waitForException(); if (e != null) { throw new IOException(e); } } catch (InterruptedException e) { throw new RuntimeException("Unable to upload file " + sourcePath, e); } return transfer.getProgress().getBytesTransferred(); }
@Override public void progressChanged(ProgressEvent progressEvent) { final ProgressEventType eventType = progressEvent.getEventType(); if (eventType == ProgressEventType.REQUEST_BYTE_TRANSFER_EVENT || eventType == ProgressEventType.TRANSFER_COMPLETED_EVENT) { long now = System.currentTimeMillis(); if (now > lastLogTime + LOG_INTERVAL_SECONDS * 1000 || eventType == ProgressEventType.TRANSFER_COMPLETED_EVENT) { TransferProgress transferProgress = upload.getProgress(); double durationSec = (now - beginTime) / 1000D; LOG.info("{} transferred {} of {} ({} percent), duration {}, speed {})", upload.getDescription(), human(transferProgress.getBytesTransferred(), "B"), human(transferProgress.getTotalBytesToTransfer(), "B"), transferProgress.getPercentTransferred(), human(durationSec, "s"), human(transferProgress.getBytesTransferred() / durationSec, "B/sec")); lastLogTime = now; } } else if (eventType == ProgressEventType.TRANSFER_FAILED_EVENT) { LOG.error("{}: TRANSFER FAILED.", upload.getDescription()); } } }
@Override public void progressChanged(ProgressEvent progressEvent) { final ProgressEventType eventType = progressEvent.getEventType(); if (eventType == ProgressEventType.REQUEST_BYTE_TRANSFER_EVENT || eventType == ProgressEventType.TRANSFER_COMPLETED_EVENT) { long now = System.currentTimeMillis(); if (now > lastLogTime + LOG_INTERVAL_SECONDS * 1000 || eventType == ProgressEventType.TRANSFER_COMPLETED_EVENT) { TransferProgress transferProgress = upload.getProgress(); double durationSec = (now - beginTime) / 1000D; LOG.info("{} transferred {} of {} ({} percent), duration {}, speed {})", upload.getDescription(), human(transferProgress.getBytesTransferred(), "B"), human(transferProgress.getTotalBytesToTransfer(), "B"), transferProgress.getPercentTransferred(), human(durationSec, "s"), human(transferProgress.getBytesTransferred() / durationSec, "B/sec")); lastLogTime = now; } } else if (eventType == ProgressEventType.TRANSFER_FAILED_EVENT) { LOG.error("{}: TRANSFER FAILED.", upload.getDescription()); } } }
+ String.format("%.2f", xProgress.getPercentTransferred()) + "% " + asNumber(xProgress.getBytesTransferred()) + "/" + asNumber(contentLen)
long delta = upload.getProgress().getBytesTransferred() - listener.getLastBytesTransferred(); if (statistics != null && delta != 0) { if (LOG.isDebugEnabled()) {
while (!upload.isDone()) { System.out.print(upload.getProgress() .getBytesTransferred() + "/" + upload.getProgress() .getBytesTransferred() + "/" + upload.getProgress()
@Override public void progressChanged(ProgressEvent progressEvent) { if (progress != null) { progress.progress(); } // There are 3 http ops here, but this should be close enough for now ProgressEventType pet = progressEvent.getEventType(); if (pet == TRANSFER_PART_STARTED_EVENT || pet == TRANSFER_COMPLETED_EVENT) { fs.incrementWriteOperations(); } long transferred = upload.getProgress().getBytesTransferred(); long delta = transferred - lastBytesTransferred; fs.incrementPutProgressStatistics(key, delta); lastBytesTransferred = transferred; }
long delta = upload.getProgress().getBytesTransferred() - listener.getLastBytesTransferred(); if (statistics != null && delta != 0) { if (LOG.isDebugEnabled()) {
getLog().debug("Transferring " + transfer.getProgress().getTotalBytesToTransfer() + " bytes..."); transfer.waitForCompletion(); getLog().info("Transferred " + transfer.getProgress().getBytesTransferred() + " bytes."); } catch (InterruptedException e) { return false;
public void progressChanged(ProgressEvent progressEvent) { if (progress != null) { progress.progress(); } // There are 3 http ops here, but this should be close enough for now if (progressEvent.getEventCode() == ProgressEvent.PART_STARTED_EVENT_CODE || progressEvent.getEventCode() == ProgressEvent.COMPLETED_EVENT_CODE) { statistics.incrementWriteOps(1); } long transferred = upload.getProgress().getBytesTransferred(); long delta = transferred - lastBytesTransferred; if (statistics != null && delta != 0) { statistics.incrementBytesWritten(delta); } lastBytesTransferred = transferred; }
public void progressChanged(ProgressEvent progressEvent) { if (progress != null) { progress.progress(); } // There are 3 http ops here, but this should be close enough for now if (progressEvent.getEventCode() == ProgressEvent.PART_STARTED_EVENT_CODE || progressEvent.getEventCode() == ProgressEvent.COMPLETED_EVENT_CODE) { statistics.incrementWriteOps(1); } long transferred = upload.getProgress().getBytesTransferred(); long delta = transferred - lastBytesTransferred; if (statistics != null && delta != 0) { statistics.incrementBytesWritten(delta); } lastBytesTransferred = transferred; }