Search in sources :

Example 11 with TransferResource

use of org.eclipse.aether.transfer.TransferResource in project bnd by bndtools.

the class ConsoleTransferListener method transferSucceeded.

@Override
public void transferSucceeded(TransferEvent event) {
    transferCompleted(event);
    TransferResource resource = event.getResource();
    long contentLength = event.getTransferredBytes();
    if (contentLength >= 0) {
        String type = (event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded");
        String len = contentLength >= 1024 ? toKB(contentLength) + " KB" : contentLength + " B";
        String throughput = "";
        long duration = System.currentTimeMillis() - resource.getTransferStartTime();
        if (duration > 0) {
            long bytes = contentLength - resource.getResumeOffset();
            DecimalFormat format = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH));
            double kbPerSec = (bytes / 1024.0) / (duration / 1000.0);
            throughput = " at " + format.format(kbPerSec) + " KB/sec";
        }
        out.println(type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len + throughput + ")");
    }
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) TransferResource(org.eclipse.aether.transfer.TransferResource) DecimalFormat(java.text.DecimalFormat)

Example 12 with TransferResource

use of org.eclipse.aether.transfer.TransferResource in project liferay-ide by liferay.

the class ConsoleTransferListener method transferProgressed.

@Override
public void transferProgressed(TransferEvent event) {
    TransferResource resource = event.getResource();
    _downloads.put(resource, Long.valueOf(event.getTransferredBytes()));
    StringBuilder buffer = new StringBuilder(64);
    for (Map.Entry<TransferResource, Long> entry : _downloads.entrySet()) {
        long total = entry.getKey().getContentLength();
        long complete = entry.getValue().longValue();
        buffer.append(_getStatus(complete, total)).append("  ");
    }
    int pad = _lastLength - buffer.length();
    _lastLength = buffer.length();
    _pad(buffer, pad);
    buffer.append('\r');
    _out.print(buffer);
}
Also used : TransferResource(org.eclipse.aether.transfer.TransferResource) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 13 with TransferResource

use of org.eclipse.aether.transfer.TransferResource in project liferay-ide by liferay.

the class ConsoleTransferListener method transferSucceeded.

@Override
public void transferSucceeded(TransferEvent event) {
    _transferCompleted(event);
    TransferResource resource = event.getResource();
    long contentLength = event.getTransferredBytes();
    if (contentLength >= 0) {
        String type = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded";
        String len = contentLength >= 1024 ? toKB(contentLength) + " KB" : contentLength + " B";
        String throughput = "";
        long duration = System.currentTimeMillis() - resource.getTransferStartTime();
        if (duration > 0) {
        // long bytes = contentLength - resource.getResumeOffset();
        // DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols(
        // Locale.ENGLISH ) );
        // double kbPerSec = ( bytes / 1024.0 ) / ( duration / 1000.0 );
        // throughput = " at " + format.format( kbPerSec ) + " KB/sec";
        }
        String messeage = type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len + throughput + ")";
        _out.println(messeage);
    }
}
Also used : TransferResource(org.eclipse.aether.transfer.TransferResource)

Example 14 with TransferResource

use of org.eclipse.aether.transfer.TransferResource in project qpid-broker-j by apache.

the class ConsoleTransferListener method transferProgressed.

@Override
public void transferProgressed(TransferEvent event) {
    TransferResource resource = event.getResource();
    _downloads.put(resource, Long.valueOf(event.getTransferredBytes()));
    StringBuilder buffer = new StringBuilder(64);
    for (Map.Entry<TransferResource, Long> entry : _downloads.entrySet()) {
        long total = entry.getKey().getContentLength();
        long complete = entry.getValue().longValue();
        buffer.append(getStatus(complete, total)).append("  ");
    }
    int pad = _lastLength - buffer.length();
    _lastLength = buffer.length();
    pad(buffer, pad);
    buffer.append('\r');
    _out.print(buffer);
}
Also used : TransferResource(org.eclipse.aether.transfer.TransferResource) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 15 with TransferResource

use of org.eclipse.aether.transfer.TransferResource in project qpid-broker-j by apache.

the class ConsoleTransferListener method transferSucceeded.

@Override
public void transferSucceeded(TransferEvent event) {
    transferCompleted(event);
    TransferResource resource = event.getResource();
    long contentLength = event.getTransferredBytes();
    if (contentLength >= 0) {
        String type = (event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded");
        String len = contentLength >= 1024 ? toKB(contentLength) + " KB" : contentLength + " B";
        String throughput = "";
        long duration = System.currentTimeMillis() - resource.getTransferStartTime();
        if (duration > 0) {
            long bytes = contentLength - resource.getResumeOffset();
            DecimalFormat format = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH));
            double kbPerSec = (bytes / 1024.0) / (duration / 1000.0);
            throughput = " at " + format.format(kbPerSec) + " KB/sec";
        }
        _out.println(type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len + throughput + ")");
    }
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) TransferResource(org.eclipse.aether.transfer.TransferResource) DecimalFormat(java.text.DecimalFormat)

Aggregations

TransferResource (org.eclipse.aether.transfer.TransferResource)18 Map (java.util.Map)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 DecimalFormat (java.text.DecimalFormat)5 DecimalFormatSymbols (java.text.DecimalFormatSymbols)5 File (java.io.File)3 RemoteException (java.rmi.RemoteException)2 Jar (aQute.bnd.osgi.Jar)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 DigestInputStream (java.security.DigestInputStream)1 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)1 Artifact (org.eclipse.aether.artifact.Artifact)1 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)1 DeployRequest (org.eclipse.aether.deployment.DeployRequest)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1 AbstractTransferListener (org.eclipse.aether.transfer.AbstractTransferListener)1 TransferCancelledException (org.eclipse.aether.transfer.TransferCancelledException)1 TransferEvent (org.eclipse.aether.transfer.TransferEvent)1