Fix static access of MultipartUpload members.

This commit is contained in:
Diwaker Gupta 2013-02-20 11:23:53 -08:00
parent e16c7ba40c
commit c37d3103e7
2 changed files with 19 additions and 18 deletions

View File

@ -18,20 +18,20 @@
*/ */
package org.jclouds.aws.s3.blobstore.strategy.internal; package org.jclouds.aws.s3.blobstore.strategy.internal;
import org.jclouds.aws.s3.blobstore.strategy.MultipartUploadStrategy; import org.jclouds.aws.s3.blobstore.strategy.MultipartUpload;
/** /**
* Print out on the console some graph data regarding the partitioning algorithm. * Print out on the console some graph data regarding the partitioning algorithm.
* *
* @author Tibor Kiss * @author Tibor Kiss
*/ */
public class MpuGraphData { public class MpuGraphData {
private static void calculate(long length, MultipartUploadSlicingAlgorithm algorithm) { private static void calculate(long length, MultipartUploadSlicingAlgorithm algorithm) {
System.out.println("" + length + " " + algorithm.getParts() + " " System.out.println("" + length + " " + algorithm.getParts() + " "
+ algorithm.calculateChunkSize(length) + " " + + algorithm.getRemaining()); + algorithm.calculateChunkSize(length) + " " + + algorithm.getRemaining());
} }
private static void foreach(long from, long to1, long to2, long to3, MultipartUploadSlicingAlgorithm algorithm) { private static void foreach(long from, long to1, long to2, long to3, MultipartUploadSlicingAlgorithm algorithm) {
long i = 0L, step = 1L; long i = 0L, step = 1L;
System.out.println("=== {" + from + "," + to1 + "} ==="); System.out.println("=== {" + from + "," + to1 + "} ===");
@ -53,10 +53,10 @@ public class MpuGraphData {
public static void main(String[] args) { public static void main(String[] args) {
MultipartUploadSlicingAlgorithm algorithm = new MultipartUploadSlicingAlgorithm(); MultipartUploadSlicingAlgorithm algorithm = new MultipartUploadSlicingAlgorithm();
foreach(1L, foreach(1L,
algorithm.defaultPartSize * algorithm.magnitudeBase, algorithm.defaultPartSize * algorithm.magnitudeBase,
MultipartUploadStrategy.MAX_PART_SIZE * algorithm.magnitudeBase, MultipartUpload.MAX_PART_SIZE * algorithm.magnitudeBase,
MultipartUploadStrategy.MAX_PART_SIZE * MultipartUploadStrategy.MAX_NUMBER_OF_PARTS, MultipartUpload.MAX_PART_SIZE * MultipartUpload.MAX_NUMBER_OF_PARTS,
algorithm); algorithm);
} }

View File

@ -20,6 +20,7 @@ package org.jclouds.aws.s3.blobstore.strategy.internal;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.aws.s3.blobstore.strategy.MultipartUpload;
import org.jclouds.aws.s3.blobstore.strategy.MultipartUploadStrategy; import org.jclouds.aws.s3.blobstore.strategy.MultipartUploadStrategy;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -42,7 +43,7 @@ public class MpuPartitioningAlgorithmTest {
MultipartUploadSlicingAlgorithm strategy = new MultipartUploadSlicingAlgorithm(); MultipartUploadSlicingAlgorithm strategy = new MultipartUploadSlicingAlgorithm();
// exactly the MIN_PART_SIZE // exactly the MIN_PART_SIZE
long length = MultipartUploadStrategy.MIN_PART_SIZE; long length = MultipartUpload.MIN_PART_SIZE;
long chunkSize = strategy.calculateChunkSize(length); long chunkSize = strategy.calculateChunkSize(length);
assertEquals(chunkSize, MultipartUploadSlicingAlgorithm.DEFAULT_PART_SIZE); assertEquals(chunkSize, MultipartUploadSlicingAlgorithm.DEFAULT_PART_SIZE);
assertEquals(strategy.getParts(), 0); assertEquals(strategy.getParts(), 0);
@ -100,17 +101,17 @@ public class MpuPartitioningAlgorithmTest {
public void testWhenPartsHasToStartGrowingFromMagnitudeBase() { public void testWhenPartsHasToStartGrowingFromMagnitudeBase() {
MultipartUploadSlicingAlgorithm strategy = new MultipartUploadSlicingAlgorithm(); MultipartUploadSlicingAlgorithm strategy = new MultipartUploadSlicingAlgorithm();
// upper limit while we still have exactly MAGNITUDE_BASE parts (together with the remaining) // upper limit while we still have exactly MAGNITUDE_BASE parts (together with the remaining)
long length = MultipartUploadStrategy.MAX_PART_SIZE * MultipartUploadSlicingAlgorithm.DEFAULT_MAGNITUDE_BASE; long length = MultipartUpload.MAX_PART_SIZE * MultipartUploadSlicingAlgorithm.DEFAULT_MAGNITUDE_BASE;
long chunkSize = strategy.calculateChunkSize(length); long chunkSize = strategy.calculateChunkSize(length);
assertEquals(chunkSize, MultipartUploadStrategy.MAX_PART_SIZE); assertEquals(chunkSize, MultipartUpload.MAX_PART_SIZE);
assertEquals(strategy.getParts(), MultipartUploadSlicingAlgorithm.DEFAULT_MAGNITUDE_BASE - 1); assertEquals(strategy.getParts(), MultipartUploadSlicingAlgorithm.DEFAULT_MAGNITUDE_BASE - 1);
assertEquals(strategy.getRemaining(), MultipartUploadStrategy.MAX_PART_SIZE); assertEquals(strategy.getRemaining(), MultipartUpload.MAX_PART_SIZE);
assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length); assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length);
// then the number of parts is increasing // then the number of parts is increasing
length += 1; length += 1;
chunkSize = strategy.calculateChunkSize(length); chunkSize = strategy.calculateChunkSize(length);
assertEquals(chunkSize, MultipartUploadStrategy.MAX_PART_SIZE); assertEquals(chunkSize, MultipartUpload.MAX_PART_SIZE);
assertEquals(strategy.getParts(), MultipartUploadSlicingAlgorithm.DEFAULT_MAGNITUDE_BASE); assertEquals(strategy.getParts(), MultipartUploadSlicingAlgorithm.DEFAULT_MAGNITUDE_BASE);
assertEquals(strategy.getRemaining(), 1); assertEquals(strategy.getRemaining(), 1);
assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length); assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length);
@ -125,18 +126,18 @@ public class MpuPartitioningAlgorithmTest {
public void testWhenPartsExceedsMaxNumberOfParts() { public void testWhenPartsExceedsMaxNumberOfParts() {
MultipartUploadSlicingAlgorithm strategy = new MultipartUploadSlicingAlgorithm(); MultipartUploadSlicingAlgorithm strategy = new MultipartUploadSlicingAlgorithm();
// upper limit while we still have exactly MAX_NUMBER_OF_PARTS parts (together with the remaining) // upper limit while we still have exactly MAX_NUMBER_OF_PARTS parts (together with the remaining)
long length = MultipartUploadStrategy.MAX_PART_SIZE * MultipartUploadStrategy.MAX_NUMBER_OF_PARTS; long length = MultipartUpload.MAX_PART_SIZE * MultipartUpload.MAX_NUMBER_OF_PARTS;
long chunkSize = strategy.calculateChunkSize(length); long chunkSize = strategy.calculateChunkSize(length);
assertEquals(chunkSize, MultipartUploadStrategy.MAX_PART_SIZE); assertEquals(chunkSize, MultipartUpload.MAX_PART_SIZE);
assertEquals(strategy.getParts(), MultipartUploadStrategy.MAX_NUMBER_OF_PARTS - 1); assertEquals(strategy.getParts(), MultipartUpload.MAX_NUMBER_OF_PARTS - 1);
assertEquals(strategy.getRemaining(), MultipartUploadStrategy.MAX_PART_SIZE); assertEquals(strategy.getRemaining(), MultipartUpload.MAX_PART_SIZE);
assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length); assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length);
// then the number of parts is increasing // then the number of parts is increasing
length += 1; length += 1;
chunkSize = strategy.calculateChunkSize(length); chunkSize = strategy.calculateChunkSize(length);
assertEquals(chunkSize, MultipartUploadStrategy.MAX_PART_SIZE); assertEquals(chunkSize, MultipartUpload.MAX_PART_SIZE);
assertEquals(strategy.getParts(), MultipartUploadStrategy.MAX_NUMBER_OF_PARTS); assertEquals(strategy.getParts(), MultipartUpload.MAX_NUMBER_OF_PARTS);
assertEquals(strategy.getRemaining(), 1); assertEquals(strategy.getRemaining(), 1);
assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length); assertEquals(chunkSize * strategy.getParts() + strategy.getRemaining(), length);
} }