예제 #1
0
  private synchronized void updateProgress(TransferEvent event) {
    long total = 0;
    long completed = 0;

    for (Map.Entry<TransferResource, Long> entry : downloads.entrySet()) {
      total += entry.getKey().getContentLength();
      completed += entry.getValue();
    }

    String url = event.getResource().getRepositoryUrl() + event.getResource().getResourceName();

    switch (event.getType()) {
      case INITIATED:
      case STARTED:
        updateStatus(String.format("Downloading %s...", url));
        break;
      case PROGRESSED:
        updateStatus(
            String.format(
                "Downloaded %s of %s...",
                getStatus(event.getTransferredBytes(), event.getResource().getContentLength()),
                url));
        break;
      case CORRUPTED:
        updateStatus(String.format("%s is corrupted.", url));
        break;
      case SUCCEEDED:
        updateStatus(String.format("Downloaded %s.", url));
        break;
    }
  }
예제 #2
0
    @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
                + ")");
      }
    }
  @Override
  public void transferFailed(TransferEvent event) {
    transferCompleted(event);

    if (!(event.getException() instanceof MetadataNotFoundException)) {
      logger.info(event.getException().getMessage());
    }
  }
예제 #4
0
 @Override
 public void transferFailed(TransferEvent event) {
   // Aether generates a lot of failed transfers while looking through repos. Only print error
   // list if the package load fails overall
   failedDownloads.add(
       event.getResource().getRepositoryUrl() + event.getResource().getResourceName());
   downloads.remove(event.getResource());
   updateProgress(event);
 }
예제 #5
0
    @Override
    public void transferInitiated(TransferEvent event) {
      String message =
          event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";

      log.debug(
          message
              + ": "
              + event.getResource().getRepositoryUrl()
              + event.getResource().getResourceName());
    }
예제 #6
0
    private void transferCompleted(TransferEvent event) {
      downloads.remove(event.getResource());

      StringBuilder buffer = new StringBuilder(64);
      pad(buffer, lastLength);
      buffer.append('\r');
      log.trace(buffer);
    }
예제 #7
0
    @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);
    }
예제 #8
0
 public void transferCorrupted(TransferEvent event) {
   log.debug(event.getException());
 }
예제 #9
0
 @Override
 public void transferFailed(TransferEvent event) {
   transferCompleted(event);
   log.warn(event.getException());
 }
예제 #10
0
 @Override
 public void transferSucceeded(TransferEvent event) {
   downloads.remove(event.getResource());
   updateProgress(event);
 }
예제 #11
0
 @Override
 public void transferProgressed(TransferEvent event) throws TransferCancelledException {
   downloads.put(event.getResource(), event.getTransferredBytes());
   updateProgress(event);
 }
 public void transferCorrupted(TransferEvent event) {
   logger.info(event.getException().getMessage());
 }