mirror of https://github.com/apache/jclouds.git
made name a mandatory parameter of newBlob
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2612 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
183342d7f0
commit
2d3c1b6019
|
@ -88,8 +88,10 @@ public class BaseAtmosBlobStore {
|
|||
.getClass().getName()));
|
||||
}
|
||||
|
||||
public Blob newBlob() {
|
||||
return blobFactory.create(null);
|
||||
public Blob newBlob(String name) {
|
||||
Blob blob = blobFactory.create(null);
|
||||
blob.getMetadata().setName(name);
|
||||
return blob;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class AtmosBlobStoreContextBuilderTest {
|
|||
assertEquals(context.getAsyncApi().getClass(), StubAtmosStorageAsyncClient.class);
|
||||
assertEquals(context.getAsyncBlobStore().getClass(), AtmosAsyncBlobStore.class);
|
||||
assertEquals(context.getAsyncApi().newObject().getClass(), AtmosObjectImpl.class);
|
||||
assertEquals(context.getAsyncBlobStore().newBlob().getClass(), BlobImpl.class);
|
||||
assertEquals(context.getAsyncBlobStore().newBlob(null).getClass(), BlobImpl.class);
|
||||
assertEquals(context.getAccount(), "id");
|
||||
assertEquals(context.getEndPoint(), URI.create("https://localhost/azurestub"));
|
||||
}
|
||||
|
|
|
@ -508,6 +508,55 @@ public interface InstanceClient {
|
|||
* {@link InstanceState#STOPPING} to {@link InstanceState#STOPPED}</li>
|
||||
* </ol>
|
||||
*
|
||||
* The {@code blockDeviceMapping} option takes a value in the following format:
|
||||
* <device-name>=<snapshot-id>[:<volume-size>[:<deleteOnTermination>]]
|
||||
* <ol>
|
||||
* <li>device-name - this is the device name as it should be exposed to the instance, for example
|
||||
* /dev/sdb. This is the same as the device field specified in the AttachVolume call today. This
|
||||
* field also serves as the key for the structure.</li>
|
||||
* <li>snapshot-id - the ID of the EBS snapshot to be used when creating the volume. This field
|
||||
* is optional. If it is not specified, the volume-size field must be present to create a blank
|
||||
* volume of the specified size.</li>
|
||||
* <li>volume-size - the size (GiBs) of the volume. This field is optional unless no snapshot-id
|
||||
* is present. If a snapshot-id is present, the size must be equal to or larger than the
|
||||
* snapshot's volume size.</li>
|
||||
* <li>delete-on-termination - this indicates whether the volume should be deleted on
|
||||
* termination. It defaults to ' true '.</li>
|
||||
* </ol>
|
||||
* <p/>
|
||||
* Note that the device names between Linux and Windows differ. For Linux, ensure that your
|
||||
* device name is in the form /dev/sd[a-z] . For example, /dev/sda , /dev/sdb and /dev/sdh are
|
||||
* all valid device names.
|
||||
* <p/>
|
||||
* For Windows, the root device is still referred to as /dev/sda1 . For other devices, ensure
|
||||
* that they are in the form /xvd[c-p] . For example, /xvde , /xvdf and /xvdp are all valid
|
||||
* Windows device names.
|
||||
* <p/>
|
||||
* Here are a few extra examples on how this functionality can be used.
|
||||
*
|
||||
* <ol>
|
||||
* <li>
|
||||
* resize the root volume: @{code /dev/sda1=:100}</li>
|
||||
* <li>
|
||||
* don't delete the root volume: {@code /dev/sda1=:100:false}</li>
|
||||
* <li>
|
||||
* TODO: unverified: create and attach an additional volume at launch: {@code
|
||||
* /dev/sdb=snap-e8a23d81,/dev/sdc=:200}
|
||||
* <p/>
|
||||
* The above example will create and attach the following EBS volumes at launch time:
|
||||
* <ol>
|
||||
* <li>
|
||||
* /dev/sdb - a 10 GiBs EBS volume containing an ext3 file system; this is an Amazon shared
|
||||
* snapshot.</li>
|
||||
* <li>
|
||||
* /dev/sdc - an empty 200 GiB EBS volume.</li>
|
||||
* </ol>
|
||||
* </li>
|
||||
* <li>
|
||||
* TODO: unverified: cresize the root partition of a Windows 2008 image and add an additional 100
|
||||
* GiB device: {@code /dev/sda1=:100,/dev/xvdc=:100}</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param region
|
||||
* Instances are tied to Availability Zones. However, the instance ID is tied to the
|
||||
* Region.
|
||||
|
|
|
@ -93,8 +93,10 @@ public class BaseS3BlobStore {
|
|||
.getClass().getName()));
|
||||
}
|
||||
|
||||
public Blob newBlob() {
|
||||
return blobFactory.create(null);
|
||||
public Blob newBlob(String name) {
|
||||
Blob blob = blobFactory.create(null);
|
||||
blob.getMetadata().setName(name);
|
||||
return blob;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class S3BlobStoreContextBuilderTest {
|
|||
assertEquals(context.getAsyncApi().getClass(), StubS3AsyncClient.class);
|
||||
assertEquals(context.getAsyncBlobStore().getClass(), S3AsyncBlobStore.class);
|
||||
assertEquals(context.getAsyncApi().newS3Object().getClass(), S3ObjectImpl.class);
|
||||
assertEquals(context.getAsyncBlobStore().newBlob().getClass(), BlobImpl.class);
|
||||
assertEquals(context.getAsyncBlobStore().newBlob(null).getClass(), BlobImpl.class);
|
||||
assertEquals(context.getAccount(), "id");
|
||||
assertEquals(context.getEndPoint(), URI.create("https://localhost/s3stub"));
|
||||
}
|
||||
|
|
|
@ -58,8 +58,7 @@ public class MainApp {
|
|||
BlobStore blobStore = context.getBlobStore();
|
||||
blobStore.createContainer(containerName);
|
||||
|
||||
Blob blob = blobStore.newBlob();
|
||||
blob.getMetadata().setName("test");
|
||||
Blob blob = blobStore.newBlob("test");
|
||||
blob.setPayload("testdata");
|
||||
blobStore.putBlob(containerName, blob);
|
||||
|
||||
|
|
|
@ -127,8 +127,7 @@ public class JCloudsS3ServiceLiveTest extends BaseBlobStoreIntegrationTest<S3Asy
|
|||
try {
|
||||
String objectKey = "key-testDeleteObjectImpl";
|
||||
String objectValue = "test";
|
||||
Blob blob = context.getAsyncBlobStore().newBlob();
|
||||
blob.getMetadata().setName(objectKey);
|
||||
Blob blob = context.getAsyncBlobStore().newBlob(objectKey);
|
||||
blob.setPayload(objectValue);
|
||||
addBlobToContainer(bucketName, blob);
|
||||
|
||||
|
@ -148,8 +147,7 @@ public class JCloudsS3ServiceLiveTest extends BaseBlobStoreIntegrationTest<S3Asy
|
|||
String metadataName = "metadata-name-1";
|
||||
String metadataValue = "metadata-value-1";
|
||||
|
||||
Blob blob = context.getAsyncBlobStore().newBlob();
|
||||
blob.getMetadata().setName(objectKey);
|
||||
Blob blob = context.getAsyncBlobStore().newBlob(objectKey);
|
||||
blob.setPayload(objectValue);
|
||||
blob.getMetadata().getUserMetadata().put(metadataName, metadataValue);
|
||||
addBlobToContainer(bucketName, blob);
|
||||
|
@ -175,8 +173,7 @@ public class JCloudsS3ServiceLiveTest extends BaseBlobStoreIntegrationTest<S3Asy
|
|||
String metadataName = "metadata-name-2";
|
||||
String metadataValue = "metadata-value-2";
|
||||
|
||||
Blob blob = context.getAsyncBlobStore().newBlob();
|
||||
blob.getMetadata().setName(objectKey);
|
||||
Blob blob = context.getAsyncBlobStore().newBlob(objectKey);
|
||||
blob.setPayload(objectValue);
|
||||
blob.getMetadata().getUserMetadata().put(metadataName, metadataValue);
|
||||
addBlobToContainer(bucketName, blob);
|
||||
|
@ -434,8 +431,7 @@ public class JCloudsS3ServiceLiveTest extends BaseBlobStoreIntegrationTest<S3Asy
|
|||
String sourceMetadataValue = "souce-metadata-value";
|
||||
String destinationMetadataValue = "destination-metadata-value";
|
||||
|
||||
Blob blob = context.getAsyncBlobStore().newBlob();
|
||||
blob.getMetadata().setName(sourceObjectKey);
|
||||
Blob blob = context.getAsyncBlobStore().newBlob(sourceObjectKey);
|
||||
blob.setPayload(data);
|
||||
blob.getMetadata().getUserMetadata().put(metadataName, sourceMetadataValue);
|
||||
addBlobToContainer(bucketName, blob);
|
||||
|
|
|
@ -66,9 +66,8 @@ public class BaseAzureBlobStore {
|
|||
ClearListStrategy clearContainerStrategy, BlobPropertiesToBlobMetadata object2BlobMd,
|
||||
AzureBlobToBlob object2Blob, BlobToAzureBlob blob2Object,
|
||||
ListOptionsToListBlobsOptions container2ContainerListOptions,
|
||||
BlobToHttpGetOptions blob2ObjectGetOptions,
|
||||
GetDirectoryStrategy getDirectoryStrategy, MkdirStrategy mkdirStrategy,
|
||||
ContainerToResourceMetadata container2ResourceMd,
|
||||
BlobToHttpGetOptions blob2ObjectGetOptions, GetDirectoryStrategy getDirectoryStrategy,
|
||||
MkdirStrategy mkdirStrategy, ContainerToResourceMetadata container2ResourceMd,
|
||||
ListBlobsResponseToResourceList container2ResourceList, ExecutorService service) {
|
||||
this.async = checkNotNull(async, "async");
|
||||
this.sync = checkNotNull(sync, "sync");
|
||||
|
@ -81,8 +80,7 @@ public class BaseAzureBlobStore {
|
|||
this.container2ContainerListOptions = checkNotNull(container2ContainerListOptions,
|
||||
"container2ContainerListOptions");
|
||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||
this.getDirectoryStrategy = checkNotNull(getDirectoryStrategy,
|
||||
"getDirectoryStrategy");
|
||||
this.getDirectoryStrategy = checkNotNull(getDirectoryStrategy, "getDirectoryStrategy");
|
||||
this.mkdirStrategy = checkNotNull(mkdirStrategy, "mkdirStrategy");
|
||||
this.container2ResourceMd = checkNotNull(container2ResourceMd, "container2ResourceMd");
|
||||
this.container2ResourceList = checkNotNull(container2ResourceList, "container2ResourceList");
|
||||
|
@ -94,8 +92,10 @@ public class BaseAzureBlobStore {
|
|||
.getClass().getName()));
|
||||
}
|
||||
|
||||
public Blob newBlob() {
|
||||
return blobFactory.create(null);
|
||||
public Blob newBlob(String name) {
|
||||
Blob blob = blobFactory.create(null);
|
||||
blob.getMetadata().setName(name);
|
||||
return blob;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,17 +56,16 @@ public class AzureBlobStoreContextBuilderTest {
|
|||
|
||||
public void testNewBuilder() {
|
||||
AzureBlobStoreContextBuilder builder = newBuilder();
|
||||
assertEquals(builder.getProperties().getProperty(PROPERTY_USER_METADATA_PREFIX),
|
||||
"x-ms-meta-");
|
||||
assertEquals(builder.getProperties().getProperty(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT),
|
||||
"id");
|
||||
assertEquals(builder.getProperties().getProperty(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY),
|
||||
"secret");
|
||||
assertEquals(builder.getProperties().getProperty(PROPERTY_USER_METADATA_PREFIX), "x-ms-meta-");
|
||||
assertEquals(builder.getProperties().getProperty(
|
||||
AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT), "id");
|
||||
assertEquals(builder.getProperties().getProperty(
|
||||
AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY), "secret");
|
||||
}
|
||||
|
||||
private AzureBlobStoreContextBuilder newBuilder() {
|
||||
return new AzureBlobStoreContextBuilder(new AzureBlobPropertiesBuilder("id",
|
||||
"secret").build()).withModules(new AzureBlobStubClientModule());
|
||||
return new AzureBlobStoreContextBuilder(new AzureBlobPropertiesBuilder("id", "secret")
|
||||
.build()).withModules(new AzureBlobStubClientModule());
|
||||
}
|
||||
|
||||
public void testBuildContext() {
|
||||
|
@ -75,15 +74,16 @@ public class AzureBlobStoreContextBuilderTest {
|
|||
assertEquals(context.getAsyncApi().getClass(), StubAzureBlobAsyncClient.class);
|
||||
assertEquals(context.getAsyncBlobStore().getClass(), AzureAsyncBlobStore.class);
|
||||
assertEquals(context.getAsyncApi().newBlob().getClass(), AzureBlobImpl.class);
|
||||
assertEquals(context.getAsyncBlobStore().newBlob().getClass(), BlobImpl.class);
|
||||
assertEquals(context.getAsyncBlobStore().newBlob(null).getClass(), BlobImpl.class);
|
||||
assertEquals(context.getAccount(), "id");
|
||||
assertEquals(context.getEndPoint(), URI.create("https://localhost/azurestub"));
|
||||
}
|
||||
|
||||
public void testBuildInjector() {
|
||||
Injector i = newBuilder().buildInjector();
|
||||
assert i.getInstance(Key.get(new TypeLiteral<BlobStoreContext<AzureBlobAsyncClient, AzureBlobClient>>() {
|
||||
})) != null;
|
||||
assert i.getInstance(Key
|
||||
.get(new TypeLiteral<BlobStoreContext<AzureBlobAsyncClient, AzureBlobClient>>() {
|
||||
})) != null;
|
||||
assert i.getInstance(AzureBlob.class) != null;
|
||||
assert i.getInstance(Blob.class) != null;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.jclouds.blobstore.options.ListContainerOptions;
|
|||
*/
|
||||
public interface AsyncBlobStore {
|
||||
|
||||
Blob newBlob();
|
||||
Blob newBlob(String name);
|
||||
|
||||
/**
|
||||
* Lists all root-level resources available to the account.
|
||||
|
|
|
@ -34,7 +34,7 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(BlobMapImpl.class)
|
||||
public interface BlobMap extends ListableMap<String, Blob> {
|
||||
|
||||
Blob newBlob();
|
||||
Blob newBlob(String name);
|
||||
|
||||
public static interface Factory {
|
||||
BlobMap create(String containerName, ListContainerOptions listOptions);
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.blobstore.options.ListContainerOptions;
|
|||
*/
|
||||
public interface BlobStore {
|
||||
|
||||
Blob newBlob();
|
||||
Blob newBlob(String name);
|
||||
|
||||
/**
|
||||
* Lists all root-level resources available to the account.
|
||||
|
|
|
@ -213,8 +213,8 @@ public class BlobMapImpl extends BaseBlobMap<Blob> implements BlobMap {
|
|||
});
|
||||
}
|
||||
|
||||
public Blob newBlob() {
|
||||
return connection.newBlob();
|
||||
public Blob newBlob(String name) {
|
||||
return connection.newBlob(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -225,8 +225,7 @@ public class InputStreamMapImpl extends BaseBlobMap<InputStream> implements Inpu
|
|||
try {
|
||||
Set<Future<String>> puts = Sets.newHashSet();
|
||||
for (Map.Entry<? extends String, ? extends Object> entry : map.entrySet()) {
|
||||
Blob object = connection.newBlob();
|
||||
object.getMetadata().setName(prefixer.apply(entry.getKey()));
|
||||
Blob object = connection.newBlob(prefixer.apply(entry.getKey()));
|
||||
object.setPayload(Payloads.newPayload(entry.getValue()));
|
||||
object.generateMD5();
|
||||
puts.add(connection.putBlob(containerName, object));
|
||||
|
@ -286,11 +285,10 @@ public class InputStreamMapImpl extends BaseBlobMap<InputStream> implements Inpu
|
|||
* @see S3Client#put(String, Blob)
|
||||
*/
|
||||
@VisibleForTesting
|
||||
InputStream putInternal(String s, Payload payload) {
|
||||
Blob object = connection.newBlob();
|
||||
object.getMetadata().setName(prefixer.apply(s));
|
||||
InputStream putInternal(String name, Payload payload) {
|
||||
Blob object = connection.newBlob(prefixer.apply(name));
|
||||
try {
|
||||
InputStream returnVal = containsKey(s) ? get(s) : null;
|
||||
InputStream returnVal = containsKey(name) ? get(name) : null;
|
||||
object.setPayload(payload);
|
||||
object.generateMD5();
|
||||
connection.putBlob(containerName, object).get(requestTimeoutMilliseconds,
|
||||
|
|
|
@ -58,8 +58,7 @@ public class MarkerFileMkdirStrategy implements MkdirStrategy {
|
|||
try {
|
||||
if (!connection.directoryExists(containerName, directory).get(requestTimeoutMilliseconds,
|
||||
TimeUnit.MILLISECONDS)) {
|
||||
Blob blob = connection.newBlob();
|
||||
blob.getMetadata().setName(directory + directorySuffix);
|
||||
Blob blob = connection.newBlob(directory + directorySuffix);
|
||||
blob.setPayload("");
|
||||
blob.getMetadata().setContentType("application/directory");
|
||||
connection.putBlob(containerName, blob).get(requestTimeoutMilliseconds,
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.jclouds.util.Utils;
|
|||
public class BlobStoreUtils {
|
||||
|
||||
public static Blob newBlob(BlobStore blobStore, ResourceMetadata blobMeta) {
|
||||
Blob blob = blobStore.newBlob();
|
||||
Blob blob = blobStore.newBlob(blobMeta.getName());
|
||||
if (blobMeta instanceof BlobMetadata) {
|
||||
blob.getMetadata().setContentMD5(((BlobMetadata) blobMeta).getContentMD5());
|
||||
blob.getMetadata().setContentType(((BlobMetadata) blobMeta).getContentType());
|
||||
|
@ -46,17 +46,10 @@ public class BlobStoreUtils {
|
|||
blob.getMetadata().setId(blobMeta.getId());
|
||||
blob.getMetadata().setLastModified(blobMeta.getLastModified());
|
||||
blob.getMetadata().setLocation(blobMeta.getLocation());
|
||||
blob.getMetadata().setName(blobMeta.getName());
|
||||
blob.getMetadata().setUserMetadata(blobMeta.getUserMetadata());
|
||||
return blob;
|
||||
}
|
||||
|
||||
public static Blob newBlob(BlobStore blobStore, String name) {
|
||||
Blob blob = blobStore.newBlob();
|
||||
blob.getMetadata().setName(name);
|
||||
return blob;
|
||||
}
|
||||
|
||||
public static String parseContainerFromPath(String path) {
|
||||
String container = path;
|
||||
if (path.indexOf('/') != -1)
|
||||
|
|
|
@ -296,7 +296,7 @@ public class BaseBlobIntegrationTest<A, S> extends BaseBlobStoreIntegrationTest<
|
|||
@Test(groups = { "integration", "live" }, dataProvider = "putTests")
|
||||
public void testPutObject(String key, String type, Object content, Object realObject)
|
||||
throws InterruptedException, IOException {
|
||||
Blob object = newBlob(key);
|
||||
Blob object = context.getBlobStore().newBlob(key);
|
||||
object.getMetadata().setContentType(type);
|
||||
object.setPayload(Payloads.newPayload(content));
|
||||
if (content instanceof InputStream) {
|
||||
|
@ -318,7 +318,7 @@ public class BaseBlobIntegrationTest<A, S> extends BaseBlobStoreIntegrationTest<
|
|||
public void testMetadata() throws InterruptedException {
|
||||
String key = "hello";
|
||||
|
||||
Blob object = newBlob(key);
|
||||
Blob object = context.getBlobStore().newBlob(key);
|
||||
object.setPayload(TEST_STRING);
|
||||
object.getMetadata().setContentType("text/plain");
|
||||
object.getMetadata().setSize(new Long(TEST_STRING.length()));
|
||||
|
|
|
@ -65,7 +65,7 @@ public class BaseBlobLiveTest<A, S> extends BaseBlobStoreIntegrationTest<A, S> {
|
|||
int length = connection.getContentLength();
|
||||
InputStream input = connection.getInputStream();
|
||||
|
||||
Blob object = newBlob(key);
|
||||
Blob object = context.getBlobStore().newBlob(key);
|
||||
object.setPayload(input);
|
||||
object.setContentLength(length);
|
||||
object.getMetadata().setContentMD5(md5);
|
||||
|
|
|
@ -129,7 +129,7 @@ public class BaseBlobMapIntegrationTest<A, S> extends BaseMapIntegrationTest<A,
|
|||
try {
|
||||
Map<String, Blob> map = createMap(context, bucketName);
|
||||
putStringWithMD5(map, "one", "apple");
|
||||
Blob object = newBlob("one");
|
||||
Blob object = context.getBlobStore().newBlob("one");
|
||||
object.setPayload("apple");
|
||||
object.generateMD5();
|
||||
assertConsistencyAwareContainsValue(map, object);
|
||||
|
@ -157,7 +157,7 @@ public class BaseBlobMapIntegrationTest<A, S> extends BaseMapIntegrationTest<A,
|
|||
String bucketName = getContainerName();
|
||||
try {
|
||||
Map<String, Blob> map = createMap(context, bucketName);
|
||||
Blob object = newBlob("one");
|
||||
Blob object = context.getBlobStore().newBlob("one");
|
||||
object.setPayload(Utils.toInputStream("apple"));
|
||||
object.generateMD5();
|
||||
Blob old = map.put(object.getMetadata().getName(), object);
|
||||
|
@ -178,7 +178,7 @@ public class BaseBlobMapIntegrationTest<A, S> extends BaseMapIntegrationTest<A,
|
|||
Map<String, Blob> map = createMap(context, bucketName);
|
||||
Map<String, Blob> newMap = new HashMap<String, Blob>();
|
||||
for (String key : fiveInputs.keySet()) {
|
||||
Blob object = newBlob(key);
|
||||
Blob object = context.getBlobStore().newBlob(key);
|
||||
object.setPayload(fiveInputs.get(key));
|
||||
object.setContentLength(new Long(fiveBytes.get(key).length));
|
||||
newMap.put(key, object);
|
||||
|
@ -194,7 +194,7 @@ public class BaseBlobMapIntegrationTest<A, S> extends BaseMapIntegrationTest<A,
|
|||
|
||||
@Override
|
||||
protected void putStringWithMD5(Map<String, Blob> map, String key, String value) {
|
||||
Blob object = newBlob(key);
|
||||
Blob object = context.getBlobStore().newBlob(key);
|
||||
object.setPayload(value);
|
||||
object.generateMD5();
|
||||
map.put(key, object);
|
||||
|
@ -203,7 +203,7 @@ public class BaseBlobMapIntegrationTest<A, S> extends BaseMapIntegrationTest<A,
|
|||
protected void putFiveStrings(Map<String, Blob> map) {
|
||||
Map<String, Blob> newMap = new HashMap<String, Blob>();
|
||||
for (Map.Entry<String, String> entry : fiveStrings.entrySet()) {
|
||||
Blob object = newBlob(entry.getKey());
|
||||
Blob object = context.getBlobStore().newBlob(entry.getKey());
|
||||
object.setPayload(entry.getValue());
|
||||
newMap.put(entry.getKey(), object);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ public class BaseBlobMapIntegrationTest<A, S> extends BaseMapIntegrationTest<A,
|
|||
protected void putFiveStringsUnderPath(Map<String, Blob> map) {
|
||||
Map<String, Blob> newMap = new HashMap<String, Blob>();
|
||||
for (Map.Entry<String, String> entry : fiveStringsUnderPath.entrySet()) {
|
||||
Blob object = newBlob(entry.getKey());
|
||||
Blob object = context.getBlobStore().newBlob(entry.getKey());
|
||||
object.setPayload(entry.getValue());
|
||||
newMap.put(entry.getKey(), object);
|
||||
}
|
||||
|
|
|
@ -125,12 +125,6 @@ public class BaseBlobStoreIntegrationTest<A, S> {
|
|||
|
||||
private static volatile boolean initialized = false;
|
||||
|
||||
protected Blob newBlob(String key) {
|
||||
Blob object = context.getBlobStore().newBlob();
|
||||
object.getMetadata().setName(key);
|
||||
return object;
|
||||
}
|
||||
|
||||
protected void createContainersSharedByAllThreads(BlobStoreContext<A, S> context,
|
||||
ITestContext testContext) throws Exception {
|
||||
while (!initialized) {
|
||||
|
@ -256,7 +250,7 @@ public class BaseBlobStoreIntegrationTest<A, S> {
|
|||
}
|
||||
|
||||
protected String addBlobToContainer(String sourceContainer, String key) {
|
||||
Blob sourceObject = newBlob(key);
|
||||
Blob sourceObject = context.getBlobStore().newBlob(key);
|
||||
sourceObject.getMetadata().setContentType("text/xml");
|
||||
sourceObject.setPayload(TEST_STRING);
|
||||
return addBlobToContainer(sourceContainer, sourceObject);
|
||||
|
@ -265,7 +259,7 @@ public class BaseBlobStoreIntegrationTest<A, S> {
|
|||
protected void add5BlobsUnderPathAnd5UnderRootToContainer(String sourceContainer) {
|
||||
for (Entry<String, String> entry : Iterables.concat(fiveStrings.entrySet(),
|
||||
fiveStringsUnderPath.entrySet())) {
|
||||
Blob sourceObject = newBlob(entry.getKey());
|
||||
Blob sourceObject = context.getBlobStore().newBlob(entry.getKey());
|
||||
sourceObject.getMetadata().setContentType("text/xml");
|
||||
sourceObject.setPayload(entry.getValue());
|
||||
addBlobToContainer(sourceContainer, sourceObject);
|
||||
|
|
|
@ -197,7 +197,7 @@ public class BaseContainerIntegrationTest<A, S> extends BaseBlobStoreIntegration
|
|||
|
||||
protected void addAlphabetUnderRoot(String containerName) throws InterruptedException {
|
||||
for (char letter = 'a'; letter <= 'z'; letter++) {
|
||||
Blob blob = newBlob(letter + "");
|
||||
Blob blob = context.getBlobStore().newBlob(letter + "");
|
||||
blob.setPayload(letter + "content");
|
||||
context.getBlobStore().putBlob(containerName, blob);
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ public class BaseContainerIntegrationTest<A, S> extends BaseBlobStoreIntegration
|
|||
|
||||
protected void add15UnderRoot(String containerName) throws InterruptedException {
|
||||
for (int i = 0; i < 15; i++) {
|
||||
Blob blob = newBlob(i + "");
|
||||
Blob blob = context.getBlobStore().newBlob(i + "");
|
||||
blob.setPayload(i + "content");
|
||||
context.getBlobStore().putBlob(containerName, blob);
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ public class BaseContainerIntegrationTest<A, S> extends BaseBlobStoreIntegration
|
|||
protected void addTenObjectsUnderPrefix(String containerName, String prefix)
|
||||
throws InterruptedException {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Blob blob = newBlob(prefix + "/" + i);
|
||||
Blob blob = context.getBlobStore().newBlob(prefix + "/" + i);
|
||||
blob.setPayload(i + "content");
|
||||
context.getBlobStore().putBlob(containerName, blob);
|
||||
}
|
||||
|
|
|
@ -681,8 +681,10 @@ public class StubAsyncBlobStore implements AsyncBlobStore {
|
|||
});
|
||||
}
|
||||
|
||||
public Blob newBlob() {
|
||||
return blobProvider.create(null);
|
||||
public Blob newBlob(String name) {
|
||||
Blob blob = blobProvider.create(null);
|
||||
blob.getMetadata().setName(name);
|
||||
return blob;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,9 +61,8 @@ public class StoreTweetsController extends HttpServlet {
|
|||
}
|
||||
|
||||
public Blob apply(Status from) {
|
||||
Blob to = map.newBlob();
|
||||
Blob to = map.newBlob(from.getId() + "");
|
||||
to.getMetadata().setContentType(MediaType.TEXT_PLAIN);
|
||||
to.getMetadata().setName(from.getId() + "");
|
||||
to.setPayload(from.getText());
|
||||
to.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME,
|
||||
from.getUser().getScreenName());
|
||||
|
|
|
@ -54,8 +54,7 @@ public class AddTweetsControllerTest {
|
|||
BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder()
|
||||
.buildContext();
|
||||
context.getAsyncBlobStore().createContainer(container).get();
|
||||
Blob blob = context.getAsyncBlobStore().newBlob();
|
||||
blob.getMetadata().setName("1");
|
||||
Blob blob = context.getAsyncBlobStore().newBlob("1");
|
||||
blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank");
|
||||
blob.setPayload("I love beans!");
|
||||
context.getAsyncBlobStore().putBlob(container, blob).get();
|
||||
|
|
|
@ -50,8 +50,7 @@ public class KeyToStoredTweetStatusTest {
|
|||
|
||||
public void testStoreTweets() throws IOException, InterruptedException, ExecutionException {
|
||||
BlobMap map = createMap();
|
||||
Blob blob = map.newBlob();
|
||||
blob.getMetadata().setName("1");
|
||||
Blob blob = map.newBlob("1");
|
||||
blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank");
|
||||
blob.setPayload("I love beans!");
|
||||
map.put("1", blob);
|
||||
|
|
|
@ -51,8 +51,7 @@ public class ServiceToStoredTweetStatusesTest {
|
|||
BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder()
|
||||
.buildContext();
|
||||
context.getAsyncBlobStore().createContainer(container).get();
|
||||
Blob blob = context.getAsyncBlobStore().newBlob();
|
||||
blob.getMetadata().setName("1");
|
||||
Blob blob = context.getAsyncBlobStore().newBlob("1");
|
||||
blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank");
|
||||
blob.setPayload("I love beans!");
|
||||
context.getAsyncBlobStore().putBlob(container, blob).get();
|
||||
|
|
|
@ -81,8 +81,7 @@ public class BaseCloudFilesBlobStore {
|
|||
this.container2ContainerListOptions = checkNotNull(container2ContainerListOptions,
|
||||
"container2ContainerListOptions");
|
||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||
this.getDirectoryStrategy = checkNotNull(getDirectoryStrategy,
|
||||
"getDirectoryStrategy");
|
||||
this.getDirectoryStrategy = checkNotNull(getDirectoryStrategy, "getDirectoryStrategy");
|
||||
this.mkdirStrategy = checkNotNull(mkdirStrategy, "mkdirStrategy");
|
||||
this.container2ResourceMd = checkNotNull(container2ResourceMd, "container2ResourceMd");
|
||||
this.container2ResourceList = checkNotNull(container2ResourceList, "container2ResourceList");
|
||||
|
@ -94,8 +93,10 @@ public class BaseCloudFilesBlobStore {
|
|||
.getClass().getName()));
|
||||
}
|
||||
|
||||
public Blob newBlob() {
|
||||
return blobFactory.create(null);
|
||||
public Blob newBlob(String name) {
|
||||
Blob blob = blobFactory.create(null);
|
||||
blob.getMetadata().setName(name);
|
||||
return blob;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class CloudFilesBlobStoreContextBuilderTest {
|
|||
assertEquals(context.getAsyncApi().getClass(), StubCloudFilesAsyncClient.class);
|
||||
assertEquals(context.getAsyncBlobStore().getClass(), CloudFilesAsyncBlobStore.class);
|
||||
assertEquals(context.getAsyncApi().newCFObject().getClass(), CFObjectImpl.class);
|
||||
assertEquals(context.getAsyncBlobStore().newBlob().getClass(), BlobImpl.class);
|
||||
assertEquals(context.getAsyncBlobStore().newBlob(null).getClass(), BlobImpl.class);
|
||||
assertEquals(context.getAccount(), "id");
|
||||
assertEquals(context.getEndPoint(), URI.create("http://localhost/rackspacestub/cloudfiles"));
|
||||
}
|
||||
|
|
|
@ -246,8 +246,8 @@ public class BlobStoreFileObject extends AbstractFileObject {
|
|||
return new BlobStoreOutputStream(file, getBlobStore(), BlobStoreUtils.newBlob(
|
||||
getBlobStore(), metadata));
|
||||
} else {
|
||||
return new BlobStoreOutputStream(file, getBlobStore(), BlobStoreUtils.newBlob(
|
||||
getBlobStore(), getNameTrimLeadingSlashes()));
|
||||
return new BlobStoreOutputStream(file, getBlobStore(), getBlobStore().newBlob(
|
||||
getNameTrimLeadingSlashes()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue