mirror of https://github.com/apache/jclouds.git
JCLOUDS-1337: Azure putBlob portable storage tiers
This commit is contained in:
parent
6158b60954
commit
152ca564b5
|
@ -39,6 +39,7 @@ import org.jclouds.azureblob.blobstore.functions.BlobToAzureBlob;
|
|||
import org.jclouds.azureblob.blobstore.functions.ContainerToResourceMetadata;
|
||||
import org.jclouds.azureblob.blobstore.functions.ListBlobsResponseToResourceList;
|
||||
import org.jclouds.azureblob.blobstore.functions.ListOptionsToListBlobsOptions;
|
||||
import org.jclouds.azureblob.domain.AccessTier;
|
||||
import org.jclouds.azureblob.domain.AzureBlob;
|
||||
import org.jclouds.azureblob.domain.BlobBlockProperties;
|
||||
import org.jclouds.azureblob.domain.BlobProperties;
|
||||
|
@ -59,6 +60,7 @@ import org.jclouds.blobstore.domain.MultipartPart;
|
|||
import org.jclouds.blobstore.domain.MultipartUpload;
|
||||
import org.jclouds.blobstore.domain.PageSet;
|
||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||
import org.jclouds.blobstore.domain.Tier;
|
||||
import org.jclouds.blobstore.domain.internal.PageSetImpl;
|
||||
import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
|
||||
import org.jclouds.blobstore.internal.BaseBlobStore;
|
||||
|
@ -215,7 +217,7 @@ public class AzureBlobStore extends BaseBlobStore {
|
|||
*/
|
||||
@Override
|
||||
public String putBlob(String container, Blob blob) {
|
||||
return sync.putBlob(container, blob2AzureBlob.apply(blob));
|
||||
return putBlob(container, blob, new PutOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,10 +233,17 @@ public class AzureBlobStore extends BaseBlobStore {
|
|||
if (options.getBlobAccess() != BlobAccess.PRIVATE) {
|
||||
throw new UnsupportedOperationException("blob access not supported by Azure");
|
||||
}
|
||||
String eTag;
|
||||
if (options.isMultipart()) {
|
||||
return putMultipartBlob(container, blob, options);
|
||||
eTag = putMultipartBlob(container, blob, options);
|
||||
} else {
|
||||
eTag = sync.putBlob(container, blob2AzureBlob.apply(blob));
|
||||
}
|
||||
return putBlob(container, blob);
|
||||
Tier tier = blob.getMetadata().getTier();
|
||||
if (tier != Tier.STANDARD) {
|
||||
sync.setBlobTier(container, blob.getMetadata().getName(), AccessTier.fromTier(tier));
|
||||
}
|
||||
return eTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,6 +21,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.azureblob.domain.AccessTier;
|
||||
import org.jclouds.azureblob.domain.BlobProperties;
|
||||
import org.jclouds.azureblob.domain.PublicAccess;
|
||||
import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
||||
|
@ -67,6 +68,8 @@ public class BlobPropertiesToBlobMetadata implements Function<BlobProperties, Mu
|
|||
to.setType(StorageType.BLOB);
|
||||
}
|
||||
to.setSize(from.getContentMetadata().getContentLength());
|
||||
AccessTier tier = from.getTier();
|
||||
to.setTier((tier != null ? tier : AccessTier.HOT).toTier());
|
||||
return to;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,20 @@ package org.jclouds.azureblob.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.blobstore.domain.Tier;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
public enum AccessTier {
|
||||
HOT,
|
||||
COOL,
|
||||
ARCHIVE;
|
||||
HOT(Tier.STANDARD),
|
||||
COOL(Tier.INFREQUENT),
|
||||
ARCHIVE(Tier.ARCHIVE);
|
||||
|
||||
private final Tier tier;
|
||||
|
||||
private AccessTier(Tier tier) {
|
||||
this.tier = checkNotNull(tier);
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||
|
@ -34,7 +42,21 @@ public enum AccessTier {
|
|||
return value();
|
||||
}
|
||||
|
||||
// TODO: call valueOf instead like GCS?
|
||||
public static AccessTier fromValue(String tier) {
|
||||
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(tier, "tier")));
|
||||
}
|
||||
|
||||
public static AccessTier fromTier(Tier tier) {
|
||||
switch (tier) {
|
||||
case STANDARD: return AccessTier.HOT;
|
||||
case INFREQUENT: return AccessTier.COOL;
|
||||
case ARCHIVE: return AccessTier.ARCHIVE;
|
||||
}
|
||||
throw new IllegalArgumentException("invalid tier: " + tier);
|
||||
}
|
||||
|
||||
public Tier toTier() {
|
||||
return tier;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue