org.eclipse.aether.transfer.TransferEvent Java Examples

The following examples show how to use org.eclipse.aether.transfer.TransferEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FailureReportingTransferListener.java    From thorntail with Apache License 2.0 6 votes vote down vote up
public String failuresAsString() {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<String, List<TransferEvent>> entry : this.transfers.entrySet()) {
        final String resourceName = entry.getKey();
        for (TransferEvent event : entry.getValue()) {
            sb.append("Failed")
                    .append(event.getRequestType() == TransferEvent.RequestType.PUT ? " uploading " : " downloading ")
                    .append(resourceName)
                    .append(event.getRequestType() == TransferEvent.RequestType.PUT ? " into " : " from ")
                    .append(event.getResource().getRepositoryUrl()).append(". ");
            if (event.getException() != null) {
                sb.append("Reason: \n").append(event.getException());
            }
            sb.append('\n');
        }
    }

    return sb.toString();
}
 
Example #2
Source File: JULMavenTransferListener.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
@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)
      {
         DecimalFormat format = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH));
         double kbPerSec = (contentLength / 1024.0) / (duration / 1000.0);
         throughput = " at " + format.format(kbPerSec) + " KB/sec";
      }

      out.info(type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len
               + throughput + ")");
   }
}
 
Example #3
Source File: LogTransferListener.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
@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)
      {
         DecimalFormat format = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH));
         double kbPerSec = (contentLength / 1024.0) / (duration / 1000.0);
         throughput = " at " + format.format(kbPerSec) + " KB/sec";
      }

      out.println(type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len
               + throughput + ")");
   }
}
 
Example #4
Source File: ProgressTransferListener.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void transferStarted(TransferEvent te) throws TransferCancelledException {
    ProgressContributor c = contrib;
    if (c == null || handle == null) {
        return;
    }
    TransferResource res = te.getResource();
    int total = (int)Math.min((long)Integer.MAX_VALUE, res.getContentLength());
    if (total < 0) {
        c.start(0);
    } else {
        c.start(total);
    }
    length = total;
    c.progress(TXT_Started(getResourceName(res)));
}
 
Example #5
Source File: ProgressTransferListener.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages({
    "# {0} - transferring resource name",
    "TXT_Transferring={0} - Transferring...",
    "# {0} - transferring resource name",
    "# {1} - transferred amount",
    "TXT_Transferred={0} - Transferred {1}"
})
@Override
public void transferProgressed(TransferEvent te) throws TransferCancelledException {
    checkCancel();
    ProgressContributor c = contrib;
    if (c == null) {
        return;
    }
    long cnt = te.getTransferredBytes();
    cnt = Math.min((long)Integer.MAX_VALUE, cnt);
    if (length < 0) {
        c.progress(TXT_Transferring(getResourceName(te.getResource())));
    } else {
        cnt = Math.min(cnt, (long)length);
        c.progress(TXT_Transferred(getResourceName(te.getResource()), cnt), (int)cnt);
    }
}
 
Example #6
Source File: ConsoleTransferListener.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #7
Source File: ConsoleTransferListener.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
@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 + ")");
	}
}
 
Example #8
Source File: ConsoleTransferListener.java    From jenkins-build-monitor-plugin with MIT License 6 votes vote down vote up
@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 + ")");
    }
}
 
Example #9
Source File: ConsoleTransferListener.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #10
Source File: ConsoleTransferListener.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
@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 + ")");
    }
}
 
Example #11
Source File: ConsoleTransferListener.java    From jenkins-build-monitor-plugin with MIT License 6 votes vote down vote up
@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);
}
 
Example #12
Source File: MavenUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@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) {
            DecimalFormat format = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH));
            double kbPerSec = (contentLength / 1024.0) / (duration / 1000.0);
            throughput = " at " + format.format(kbPerSec) + " KB/sec";
        }

        log.debug(type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len + throughput
                + ")");
    }
}
 
Example #13
Source File: MavenUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@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');
    log.trace(buffer);
}
 
Example #14
Source File: LoggingTransferListener.java    From maven-repository-tools with Eclipse Public License 1.0 6 votes vote down vote up
@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";
        }

        logger.info( type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len
            + throughput + ")" );
    }
}
 
Example #15
Source File: FailureReportingTransferListener.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
public String failuresAsString() {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<String, List<TransferEvent>> entry : this.transfers.entrySet()) {
        final String resourceName = entry.getKey();
        for (TransferEvent event : entry.getValue()) {
            sb.append("Failed")
                    .append(event.getRequestType() == TransferEvent.RequestType.PUT ? " uploading " : " downloading ")
                    .append(resourceName)
                    .append(event.getRequestType() == TransferEvent.RequestType.PUT ? " into " : " from ")
                    .append(event.getResource().getRepositoryUrl()).append(". ");
            if (event.getException() != null) {
                sb.append("Reason: \n").append(event.getException());
            }
            sb.append('\n');
        }
    }

    return sb.toString();
}
 
Example #16
Source File: LogTransferListener.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
private void transferCompleted(TransferEvent event)
{
   downloads.remove(event.getResource());

   StringBuilder buffer = new StringBuilder(64);
   pad(buffer, lastLength);
   buffer.append('\r');
   out.print(buffer.toString());
}
 
Example #17
Source File: LogTransferListener.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void transferProgressed(TransferEvent event)
         throws TransferCancelledException
{
   TransferResource resource = event.getResource();
   downloads.put(resource, event.getTransferredBytes());

   StringBuilder buffer = new StringBuilder(64);

   for (Map.Entry<TransferResource, Long> entry : downloads.entrySet())
   {
      long total = entry.getKey().getContentLength();
      Long complete = entry.getValue();
      // NOTE: This null check guards against http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6312056
      if (complete != null)
      {
         buffer.append(getStatus(complete.longValue(), total)).append("  ");
      }
   }

   int pad = lastLength - buffer.length();
   lastLength = buffer.length();
   pad(buffer, pad);
   buffer.append('\r');

   out.print(buffer.toString());
}
 
Example #18
Source File: JULMavenTransferListener.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
private void transferCompleted(TransferEvent event)
{
   downloads.remove(event.getResource());

   StringBuilder buffer = new StringBuilder(64);
   pad(buffer, lastLength);
   buffer.append('\r');
   out.info(buffer.toString());
}
 
Example #19
Source File: LogTransferListener.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void transferCorrupted(TransferEvent event)
         throws TransferCancelledException
{
   TransferResource resource = event.getResource();

   out.println("[WARNING] " + event.getException().getMessage() + " for " + resource.getRepositoryUrl()
            + resource.getResourceName());
}
 
Example #20
Source File: LogTransferListener.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void transferInitiated(TransferEvent event)
{
   String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";

   out.println(message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName());
}
 
Example #21
Source File: ConsoleTransferListener.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void transferFailed(TransferEvent event) {
	transferCompleted(event);

	if (!(event.getException() instanceof MetadataNotFoundException)) {
		event.getException().printStackTrace(out);
	}
}
 
Example #22
Source File: ConsoleTransferListener.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private void transferCompleted(TransferEvent event) {
	downloads.remove(event.getResource());

	StringBuilder buffer = new StringBuilder(64);
	pad(buffer, lastLength);
	buffer.append('\r');
	out.print(buffer);
}
 
Example #23
Source File: ConsoleTransferListener.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
private void transferCompleted(TransferEvent event) {
    downloads.remove(event.getResource());

    StringBuilder buffer = new StringBuilder(64);
    pad(buffer, lastLength);
    buffer.append('\r');
    out.print(buffer);
}
 
Example #24
Source File: MavenUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void transferCompleted(TransferEvent event) {
    downloads.remove(event.getResource());

    StringBuilder buffer = new StringBuilder(64);
    pad(buffer, lastLength);
    buffer.append('\r');
    log.trace(buffer);

}
 
Example #25
Source File: JULMavenTransferListener.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void transferCorrupted(TransferEvent event)
         throws TransferCancelledException
{
   TransferResource resource = event.getResource();

   out.warning(event.getException().getMessage() + " for " + resource.getRepositoryUrl()
            + resource.getResourceName());
}
 
Example #26
Source File: LoggingTransferListener.java    From maven-repository-tools with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void transferFailed( TransferEvent event )
{
    transferCompleted( event );

    if ( !( event.getException() instanceof MetadataNotFoundException ) )
    {
        logger.info( event.getException().getMessage() );
    }
}
 
Example #27
Source File: JULMavenTransferListener.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void transferProgressed(TransferEvent event)
         throws TransferCancelledException
{
   TransferResource resource = event.getResource();
   downloads.put(resource, event.getTransferredBytes());

   StringBuilder buffer = new StringBuilder(64);

   for (Map.Entry<TransferResource, Long> entry : downloads.entrySet())
   {
      long total = entry.getKey().getContentLength();
      Long complete = entry.getValue();
      // NOTE: This null check guards against http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6312056
      if (complete != null)
      {
         buffer.append(getStatus(complete.longValue(), total)).append("  ");
      }
   }

   int pad = lastLength - buffer.length();
   lastLength = buffer.length();
   pad(buffer, pad);
   buffer.append('\r');

   out.info(buffer.toString());
}
 
Example #28
Source File: LoggingTransferListener.java    From maven-repository-tools with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void transferInitiated( TransferEvent event )
{
    String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";

    logger.info( message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
}
 
Example #29
Source File: FailureReportingTransferListener.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public void transferFailed(final TransferEvent event) {
    final String resourceName = event.getResource().getResourceName();
    List<TransferEvent> events = this.transfers.get(resourceName);
    if (events == null) {
        events = new ArrayList<>();
        this.transfers.put(resourceName, events);
    }
    events.add(event);
}
 
Example #30
Source File: JULMavenTransferListener.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void transferInitiated(TransferEvent event)
{
   String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";

   out.info(message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName());
}