List of usage examples for org.apache.maven.repository ArtifactTransferResource getTransferStartTime
long getTransferStartTime();
From source file:org.commonjava.emb.boot.log.BatchTransferListener.java
License:Apache License
protected void doCompleted(final ArtifactTransferEvent transferEvent) { final ArtifactTransferResource artifact = transferEvent.getResource(); final long contentLength = transferEvent.getTransferredBytes(); if (contentLength >= 0) { final String type = (transferEvent.getRequestType() == ArtifactTransferEvent.REQUEST_PUT ? "Uploaded" : "Downloaded"); final String len = contentLength >= 1024 ? toKB(contentLength) + " KB" : contentLength + " B"; String throughput = ""; final long duration = System.currentTimeMillis() - artifact.getTransferStartTime(); if (duration > 0) { final DecimalFormat format = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH)); final double kbPerSec = (contentLength / 1024.0) / (duration / 1000.0); throughput = " at " + format.format(kbPerSec) + " KB/sec"; }//from w w w . j a v a 2 s . c om out.println(type + ": " + artifact.getUrl() + " (" + len + throughput + ")"); } }