当前位置: 首页>>代码示例>>Java>>正文


Java ProgressEvent类代码示例

本文整理汇总了Java中com.amazonaws.event.ProgressEvent的典型用法代码示例。如果您正苦于以下问题:Java ProgressEvent类的具体用法?Java ProgressEvent怎么用?Java ProgressEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProgressEvent类属于com.amazonaws.event包,在下文中一共展示了ProgressEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: progressChanged

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
@Override
public void progressChanged(ProgressEvent progressEvent) {
  StringBuilder message = new StringBuilder();
  switch (progressEvent.getEventType()) {
  case TRANSFER_STARTED_EVENT:
    message.append("Starting: ").append(description);
    break;
  case TRANSFER_COMPLETED_EVENT:
    message.append("Completed: ").append(description);
    break;
  case TRANSFER_FAILED_EVENT:
    message.append("Falied: ").append(description);
    break;
  default:
    break;
  }

  context.setStatus(message.toString());
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:20,代码来源:RetriableFileCopyCommand.java

示例2: progressChanged

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:S3AOutputStream.java

示例3: progressChanged

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
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) {
    statistics.incrementWriteOps(1);
  }

  long transferred = upload.getProgress().getBytesTransferred();
  long delta = transferred - lastBytesTransferred;
  if (statistics != null && delta != 0) {
    statistics.incrementBytesWritten(delta);
  }

  lastBytesTransferred = transferred;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:21,代码来源:S3AOutputStream.java

示例4: progressChanged

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
@Override
public void progressChanged(ProgressEvent event)
{
	if ( event.getEventType() == ProgressEventType.REQUEST_CONTENT_LENGTH_EVENT )
	{
		contentLength = event.getBytes();
		getLog().info("Content size: " + contentLength + " bytes");
	}
	else if ( event.getEventType() == ProgressEventType.REQUEST_BYTE_TRANSFER_EVENT )
	{
		contentSent += event.getBytesTransferred();
		double div = (double) (((double)contentSent/(double)contentLength));
		double mul = div*(double)100.0;
		int mod = (int)mul / 10;
		if ( mod > lastTenPct )
		{
			lastTenPct = mod;
			getLog().info("Uploaded " + (mod*10) + "% of " + (contentLength/(1024*1024)) + " MB");
		}
	}
}
 
开发者ID:ServerlessJavaMaven,项目名称:ServerlessJavaMaven,代码行数:22,代码来源:ServerlessDeployMojo.java

示例5: s3ProgressListener

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
@Bean
public S3ProgressListener s3ProgressListener() {
	return new S3ProgressListener() {

		@Override
		public void onPersistableTransfer(PersistableTransfer persistableTransfer) {

		}

		@Override
		public void progressChanged(ProgressEvent progressEvent) {
			if (ProgressEventType.TRANSFER_COMPLETED_EVENT.equals(progressEvent.getEventType())) {
				transferCompletedLatch().countDown();
			}
		}

	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:19,代码来源:AmazonS3SinkMockTests.java

示例6: createProgressListener

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
private ProgressListener createProgressListener(Transfer transfer)
{
    return new ProgressListener()
    {
        private ProgressEventType previousType;
        private double previousTransferred;

        @Override
        public synchronized void progressChanged(ProgressEvent progressEvent)
        {
            ProgressEventType eventType = progressEvent.getEventType();
            if (previousType != eventType) {
                log.debug("Upload progress event (%s/%s): %s", host, key, eventType);
                previousType = eventType;
            }

            double transferred = transfer.getProgress().getPercentTransferred();
            if (transferred >= (previousTransferred + 10.0)) {
                log.debug("Upload percentage (%s/%s): %.0f%%", host, key, transferred);
                previousTransferred = transferred;
            }
        }
    };
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:PrestoS3FileSystem.java

示例7: progressChanged

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
@Override
public void progressChanged(ProgressEvent progressEvent) {
    ProgressEventType type = progressEvent.getEventType();
    if (type.equals(TRANSFER_COMPLETED_EVENT) || type.equals(TRANSFER_STARTED_EVENT)) {
        out.println();
    }

    if (type.isByteCountEvent()) {
        long timeLeft = getTimeLeft();
        if (lastTimeLeft < 1 && timeLeft > 0) {
            // prime this value with a sane starting point
            lastTimeLeft = timeLeft;
        }

        // use an exponential moving average to smooth the estimate
        lastTimeLeft += 0.90 * (timeLeft - lastTimeLeft);

        out.print(String.format("\r%1$s  %2$s / %3$s  %4$s      ",
                generate(saturatedCast(round(completed + (progress.getPercentTransferred() * multiplier)))),
                humanReadableByteCount(progress.getBytesTransferred(), true),
                humanReadableByteCount(progress.getTotalBytesToTransfer(), true), fromSeconds(lastTimeLeft)));
        out.flush();
    }
}
 
开发者ID:rholder,项目名称:esthree,代码行数:25,代码来源:PrintingProgressListener.java

示例8: copyAndHash

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
public MessageDigest copyAndHash(InputStream input, long totalBytes, Progress progress)
        throws IOException, CloneNotSupportedException {

    // clone the current digest, such that it remains unchanged in this method
    MessageDigest computedDigest = (MessageDigest) currentDigest.clone();
    byte[] buffer = new byte[DEFAULT_BUF_SIZE];

    long count = 0;
    int n;
    while (-1 != (n = input.read(buffer))) {
        output.write(buffer, 0, n);
        if (progressListener != null) {
            progress.updateProgress(n);
            progressListener.progressChanged(new ProgressEvent(ProgressEventType.RESPONSE_BYTE_TRANSFER_EVENT, n));
        }
        computedDigest.update(buffer, 0, n);
        count += n;
    }

    // verify that at least this many bytes were read
    if (totalBytes != count) {
        throw new IOException(String.format("%d bytes downloaded instead of expected %d bytes", count, totalBytes));
    }
    return computedDigest;
}
 
开发者ID:rholder,项目名称:esthree,代码行数:26,代码来源:Get.java

示例9: copyAndHash

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
public MessageDigest copyAndHash(InputStream input, long totalBytes, Progress progress)
        throws IOException, CloneNotSupportedException {

    // clone the current digest, such that it remains unchanged in this method
    MessageDigest computedDigest = (MessageDigest) currentDigest.clone();
    byte[] buffer = new byte[DEFAULT_BUF_SIZE];

    long count = 0;
    int n;
    while (-1 != (n = input.read(buffer))) {
        output.write(buffer, 0, n);
        if (progressListener != null) {
            progress.updateProgress(n);
            progressListener.progressChanged(new ProgressEvent(ProgressEventType.REQUEST_BYTE_TRANSFER_EVENT, n));
        }
        computedDigest.update(buffer, 0, n);
        count += n;
    }

    // verify that at least this many bytes were read
    if (totalBytes != count) {
        throw new IOException(String.format("%d bytes downloaded instead of expected %d bytes", count, totalBytes));
    }
    return computedDigest;
}
 
开发者ID:rholder,项目名称:esthree,代码行数:26,代码来源:GetMultipart.java

示例10: copyFile

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
private void copyFile(String srcKey, String dstKey) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("copyFile " + srcKey + " -> " + dstKey);
  }

  ObjectMetadata srcom = s3.getObjectMetadata(bucket, srcKey);
  final ObjectMetadata dstom = srcom.clone();
  if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
    dstom.setServerSideEncryption(serverSideEncryptionAlgorithm);
  }
  CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucket, srcKey, bucket, dstKey);
  copyObjectRequest.setCannedAccessControlList(cannedACL);
  copyObjectRequest.setNewObjectMetadata(dstom);

  ProgressListener progressListener = new ProgressListener() {
    public void progressChanged(ProgressEvent progressEvent) {
      switch (progressEvent.getEventCode()) {
        case ProgressEvent.PART_COMPLETED_EVENT_CODE:
          statistics.incrementWriteOps(1);
          break;
        default:
          break;
      }
    }
  };

  Copy copy = transfers.copy(copyObjectRequest);
  copy.addProgressListener(progressListener);
  try {
    copy.waitForCopyResult();
    statistics.incrementWriteOps(1);
  } catch (InterruptedException e) {
    throw new IOException("Got interrupted, cancelling");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:S3AFileSystem.java

示例11: progressChanged

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
@Override
public void progressChanged(ProgressEvent progressEvent) {

    if (progressEvent.getEventType() == ProgressEventType.REQUEST_CONTENT_LENGTH_EVENT) {
        partSize = progressEvent.getBytes();
        ArchiveUploadHighLevel.this.log.info("Part size: " + partSize);
    }

    if (progressEvent.getEventType() == ProgressEventType.CLIENT_REQUEST_SUCCESS_EVENT) {
        counter += partSize;
        int percentage = (int)(counter * 100.0 / total);
        ArchiveUploadHighLevel.this.log.info("Successfully transferred: " + counter + " / " + total + " (" + percentage + "%)");
    }
}
 
开发者ID:arjuan,项目名称:simple-glacier-client,代码行数:15,代码来源:ArchiveUploadHighLevel.java

示例12: copyBaseTo

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
@Test
public void copyBaseTo() {
    final ProgressListener listener = new SyncProgressListener() {
        @Override
        public void progressChanged(ProgressEvent progressEvent) {
        }
    };
    final AWSCredentials credentials = new BasicAWSCredentials("accesskey",
            "accessid");
    final RequestMetricCollector collector = new RequestMetricCollector() {
        @Override
        public void collectMetrics(Request<?> request, Response<?> response) {
        }
    };

    final AmazonWebServiceRequest from = new AmazonWebServiceRequest() {
    };
    from.setGeneralProgressListener(listener);
    from.setRequestCredentials(credentials);
    from.setRequestMetricCollector(collector);
    from.putCustomRequestHeader("k1", "v1");
    from.putCustomRequestHeader("k2", "v2");
    from.putCustomQueryParameter("k1", "v1");
    from.putCustomQueryParameter("k2", "v2a");
    from.putCustomQueryParameter("k2", "v2b");
    from.getRequestClientOptions().setReadLimit(1234);

    final AmazonWebServiceRequest to = new AmazonWebServiceRequest() {
    };

    // Before copy
    RequestClientOptions toOptions;
    verifyBaseBeforeCopy(to);

    // After copy
    from.copyBaseTo(to);
    verifyBaseAfterCopy(listener, credentials, collector, from, to);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:39,代码来源:AmazonWebServiceRequestTest.java

示例13: progressChanged

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
@Override
public void progressChanged(ProgressEvent progressEvent) {
    ProgressEventType type = progressEvent.getEventType();
    if (type.isByteCountEvent())
        return;
    if (type != types[count]) {
        throw new AssertionError("Expect event type "
                + types[count] + " but got "
                + progressEvent.getEventType());
    }
    count++;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:13,代码来源:ProgressListenerWithEventCodeVerification.java

示例14: filter

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
@Override
public ProgressEvent filter(ProgressEvent progressEvent) {
    // Block COMPLETE events from the low-level GetObject operation,
    // but we still want to keep the BytesTransferred
    return progressEvent.getEventType() == ProgressEventType.TRANSFER_COMPLETED_EVENT
         ? null // discard this event
         : progressEvent
         ;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:10,代码来源:TransferCompletionFilter.java

示例15: copyFile

import com.amazonaws.event.ProgressEvent; //导入依赖的package包/类
private void copyFile(String srcKey, String dstKey) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("copyFile " + srcKey + " -> " + dstKey);
  }

  ObjectMetadata srcom = s3.getObjectMetadata(bucket, srcKey);
  final ObjectMetadata dstom = srcom.clone();
  if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
    dstom.setSSEAlgorithm(serverSideEncryptionAlgorithm);
  }
  CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucket, srcKey, bucket, dstKey);
  copyObjectRequest.setCannedAccessControlList(cannedACL);
  copyObjectRequest.setNewObjectMetadata(dstom);

  ProgressListener progressListener = new ProgressListener() {
    public void progressChanged(ProgressEvent progressEvent) {
      switch (progressEvent.getEventType()) {
        case TRANSFER_PART_COMPLETED_EVENT:
          statistics.incrementWriteOps(1);
          break;
        default:
          break;
      }
    }
  };

  Copy copy = transfers.copy(copyObjectRequest);
  copy.addProgressListener(progressListener);
  try {
    copy.waitForCopyResult();
    statistics.incrementWriteOps(1);
  } catch (InterruptedException e) {
    throw new IOException("Got interrupted, cancelling");
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:36,代码来源:S3AFileSystem.java


注:本文中的com.amazonaws.event.ProgressEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。