mirror of https://github.com/apache/jclouds.git
Issue 430: Fixed some junit tests and added some static final
defaults.
This commit is contained in:
parent
1c78722297
commit
f8364a428e
|
@ -62,15 +62,21 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg
|
|||
@Named(BlobStoreConstants.BLOBSTORE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@VisibleForTesting
|
||||
static final long DEFAULT_PART_SIZE = 33554432; // 32MB
|
||||
|
||||
@VisibleForTesting
|
||||
static final int DEFAULT_MAGNITUDE_BASE = 100;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named("jclouds.mpu.parts.size")
|
||||
@VisibleForTesting
|
||||
long DEFAULT_PART_SIZE = 33554432; // 32mb
|
||||
long defaultPartSize = DEFAULT_PART_SIZE;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named("jclouds.mpu.parts.magnitude")
|
||||
@VisibleForTesting
|
||||
int magnitudeBase = 100;
|
||||
int magnitudeBase = DEFAULT_MAGNITUDE_BASE;
|
||||
|
||||
private final AWSS3BlobStore ablobstore;
|
||||
private final PayloadSlicer slicer;
|
||||
|
@ -93,7 +99,7 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg
|
|||
|
||||
@VisibleForTesting
|
||||
protected long calculateChunkSize(long length) {
|
||||
long unitPartSize = DEFAULT_PART_SIZE; // first try with default part size
|
||||
long unitPartSize = defaultPartSize; // first try with default part size
|
||||
long parts = length / unitPartSize;
|
||||
long partSize = unitPartSize;
|
||||
int magnitude = (int) (parts / magnitudeBase);
|
||||
|
@ -134,6 +140,14 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg
|
|||
return this.chunkSize;
|
||||
}
|
||||
|
||||
public long getCopied() {
|
||||
return copied;
|
||||
}
|
||||
|
||||
public void setCopied(long copied) {
|
||||
this.copied = copied;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected long getParts() {
|
||||
return parts;
|
||||
|
|
|
@ -67,8 +67,8 @@ public class MpuGraphData {
|
|||
|
||||
SequentialMultipartUploadStrategy strategy = new SequentialMultipartUploadStrategy(ablobStore, slicer);
|
||||
foreach(1L,
|
||||
SequentialMultipartUploadStrategy.DEFAULT_PART_SIZE * SequentialMultipartUploadStrategy.magnitudeBase,
|
||||
MultipartUploadStrategy.MAX_PART_SIZE * SequentialMultipartUploadStrategy.magnitudeBase,
|
||||
strategy.defaultPartSize * strategy.magnitudeBase,
|
||||
MultipartUploadStrategy.MAX_PART_SIZE * strategy.magnitudeBase,
|
||||
MultipartUploadStrategy.MAX_PART_SIZE * MultipartUploadStrategy.MAX_NUMBER_OF_PARTS,
|
||||
strategy);
|
||||
|
||||
|
|
|
@ -95,11 +95,11 @@ public class MpuPartitioningAlgorithmTest {
|
|||
replay(slicer);
|
||||
|
||||
SequentialMultipartUploadStrategy strategy = new SequentialMultipartUploadStrategy(ablobStore, slicer);
|
||||
// upper limit while we still have exactly DEFAULT_PART_SIZE chunkSize
|
||||
long length = SequentialMultipartUploadStrategy.DEFAULT_PART_SIZE * SequentialMultipartUploadStrategy.magnitudeBase;
|
||||
// upper limit while we still have exactly defaultPartSize chunkSize
|
||||
long length = SequentialMultipartUploadStrategy.DEFAULT_PART_SIZE * SequentialMultipartUploadStrategy.DEFAULT_MAGNITUDE_BASE;
|
||||
long chunkSize = strategy.calculateChunkSize(length);
|
||||
assertEquals(chunkSize, SequentialMultipartUploadStrategy.DEFAULT_PART_SIZE);
|
||||
assertEquals(strategy.getParts(), SequentialMultipartUploadStrategy.magnitudeBase - 1);
|
||||
assertEquals(strategy.getParts(), SequentialMultipartUploadStrategy.DEFAULT_MAGNITUDE_BASE - 1);
|
||||
assertEquals(strategy.getRemaining(), SequentialMultipartUploadStrategy.DEFAULT_PART_SIZE);
|
||||
assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length);
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class MpuPartitioningAlgorithmTest {
|
|||
length += 1;
|
||||
chunkSize = strategy.calculateChunkSize(length);
|
||||
assertEquals(chunkSize, SequentialMultipartUploadStrategy.DEFAULT_PART_SIZE * 2);
|
||||
assertEquals(strategy.getParts(), SequentialMultipartUploadStrategy.magnitudeBase / 2);
|
||||
assertEquals(strategy.getParts(), SequentialMultipartUploadStrategy.DEFAULT_MAGNITUDE_BASE / 2);
|
||||
assertEquals(strategy.getRemaining(), 1);
|
||||
assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length);
|
||||
|
||||
|
@ -130,10 +130,10 @@ public class MpuPartitioningAlgorithmTest {
|
|||
|
||||
SequentialMultipartUploadStrategy strategy = new SequentialMultipartUploadStrategy(ablobStore, slicer);
|
||||
// upper limit while we still have exactly MAGNITUDE_BASE parts (together with the remaining)
|
||||
long length = MultipartUploadStrategy.MAX_PART_SIZE * SequentialMultipartUploadStrategy.magnitudeBase;
|
||||
long length = MultipartUploadStrategy.MAX_PART_SIZE * SequentialMultipartUploadStrategy.DEFAULT_MAGNITUDE_BASE;
|
||||
long chunkSize = strategy.calculateChunkSize(length);
|
||||
assertEquals(chunkSize, MultipartUploadStrategy.MAX_PART_SIZE);
|
||||
assertEquals(strategy.getParts(), SequentialMultipartUploadStrategy.magnitudeBase - 1);
|
||||
assertEquals(strategy.getParts(), SequentialMultipartUploadStrategy.DEFAULT_MAGNITUDE_BASE - 1);
|
||||
assertEquals(strategy.getRemaining(), MultipartUploadStrategy.MAX_PART_SIZE);
|
||||
assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length);
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class MpuPartitioningAlgorithmTest {
|
|||
length += 1;
|
||||
chunkSize = strategy.calculateChunkSize(length);
|
||||
assertEquals(chunkSize, MultipartUploadStrategy.MAX_PART_SIZE);
|
||||
assertEquals(strategy.getParts(), SequentialMultipartUploadStrategy.magnitudeBase);
|
||||
assertEquals(strategy.getParts(), SequentialMultipartUploadStrategy.DEFAULT_MAGNITUDE_BASE);
|
||||
assertEquals(strategy.getRemaining(), 1);
|
||||
assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length);
|
||||
|
||||
|
|
Loading…
Reference in New Issue