本文整理汇总了Java中org.jclouds.blobstore.domain.BlobMetadata类的典型用法代码示例。如果您正苦于以下问题:Java BlobMetadata类的具体用法?Java BlobMetadata怎么用?Java BlobMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlobMetadata类属于org.jclouds.blobstore.domain包,在下文中一共展示了BlobMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CloudAclFileAttributes
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
/**
* <p>
* This constructor can only discern some very basic permissions. It assumes that because you have access
* to this container then you have all CRUD operation access. This may not be true. More sophisticated
* implementations should be able to tell the exact permissions.
* </p>
* <p>
* There is a lone {@link CloudAclEntry} created which has the default permissions. It is of type
* {@link PublicPrivateCloudPermissionsPrincipal}.
* </p>
* <p>
* Subclasses may implement different permissions.
* </p>
*/
public CloudAclFileAttributes(CloudAclEntryConflictChecker conflictChecker, BlobMetadata blobMetadata, BlobAccess blobAccess) {
super(blobMetadata);
aclSet = new CloudAclEntrySet(AnonymousUserPrincipal.INSTANCE, conflictChecker);
CloudAclEntry<PublicPrivateCloudPermissionsPrincipal> entry =
new CloudAclEntryBuilder<>(PublicPrivateCloudPermissionsPrincipal.class)
.addPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA, AclEntryPermission.APPEND_DATA,
AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY,
AclEntryPermission.DELETE, AclEntryPermission.DELETE_CHILD, AclEntryPermission.LIST_DIRECTORY,
AclEntryPermission.READ_ACL, AclEntryPermission.WRITE_ACL,
AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.READ_ATTRIBUTES)
.setType(AclEntryType.ALLOW)
.setPrincipal(new PublicPrivateCloudPermissionsPrincipal(blobAccess))
.build();
addAcl(AnonymousUserPrincipal.INSTANCE, entry);
}
示例2: readInternalAclFileAttributes
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
/**
* Reads all of the basic + ACL file attributes. Access is not checked here.
* @return
* @throws IOException
*/
protected CloudAclFileAttributes readInternalAclFileAttributes() throws IOException {
// Check for a container
if (path.getPathName() == null) {
if (isContainer()) {
return new CloudAclFileAttributes();
}
throw new FileNotFoundException("Unable to locate the file '" + path.getContainerName() + "|" + path.getPathName() + "'");
}
if (isDirectory()) {
return new CloudAclFileAttributes();
}
try {
BlobMetadata blobMetadata = context.getBlobStore().blobMetadata(path.getContainerName(), path.getPathName());
BlobAccess blobAccess = context.getBlobStore().getBlobAccess(path.getContainerName(), path.getPathName());
return new CloudAclFileAttributes(blobMetadata, blobAccess);
} catch (KeyNotFoundException k) {
if (context.getBlobStore().directoryExists(path.getContainerName(), path.getPathName())) {
return new CloudAclFileAttributes();
}
throw new FileNotFoundException("Unable to locate the file '" + path.getContainerName() + "|" + path.getPathName() + "'");
}
}
示例3: emulateCopyBlob
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
private String emulateCopyBlob(BlobStore blobStore, Response resp, BlobMetadata meta,
String destContainer, String destObject, CopyOptions options) {
Response.StatusType statusInfo = resp.getStatusInfo();
if (statusInfo.equals(Response.Status.OK)) {
ContentMetadata contentMetadata = meta.getContentMetadata();
Map<String, String> newMetadata = new HashMap<>();
newMetadata.putAll(meta.getUserMetadata());
newMetadata.putAll(options.userMetadata());
RESERVED_METADATA.forEach(s -> newMetadata.remove(s));
Blob blob = blobStore.blobBuilder(destObject)
.userMetadata(newMetadata)
.payload(new InputStreamPayload((InputStream) resp.getEntity()))
.contentLength(resp.getLength())
.contentDisposition(contentMetadata.getContentDisposition())
.contentEncoding(contentMetadata.getContentEncoding())
.contentType(contentMetadata.getContentType())
.contentLanguage(contentMetadata.getContentLanguage())
.build();
return blobStore.putBlob(destContainer, blob);
} else {
throw new ClientErrorException(statusInfo.getReasonPhrase(), statusInfo.getStatusCode());
}
}
示例4: takeOver
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Override
public void takeOver(String containerName) {
takeOverInProcess = true;
ForkJoinPool fjp = new ForkJoinPool(100);
takeOverFuture = fjp.submit(() -> {
StreamSupport.stream(Utils.crawlBlobStore(getDestination(), containerName).spliterator(), true)
.filter(sm -> !getSource().blobExists(containerName, sm.getName()))
.forEach(sm -> {
logger.debug("taking over blob {}", sm.getName());
BlobMetadata metadata = getDestination().blobMetadata(containerName,
sm.getName());
BounceLink link = new BounceLink(Optional.of(metadata));
getSource().putBlob(containerName, link.toBlob(getSource()));
});
getSource().removeBlob(containerName, TAKEOVER_MARKER);
takeOverInProcess = false;
});
fjp.shutdown();
}
示例5: maybeMoveObject
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
protected final BounceResult maybeMoveObject(String container, BounceStorageMetadata sourceObject,
StorageMetadata destinationObject) throws IOException {
if (sourceObject.getRegions().equals(BounceStorageMetadata.FAR_ONLY)) {
return BounceResult.NO_OP;
}
if (sourceObject.getRegions().containsAll(BounceStorageMetadata.EVERYWHERE)) {
BlobMetadata sourceMetadata = getSource().blobMetadata(container, sourceObject.getName());
BlobMetadata destinationMetadata = getDestination().blobMetadata(container, destinationObject.getName());
if (sourceMetadata != null && destinationMetadata != null) {
Utils.createBounceLink(getSource(), sourceMetadata);
removeMarkerBlob(container, sourceObject.getName());
return BounceResult.LINK;
}
}
logger.debug("moving {}", sourceObject.getName());
Utils.copyBlobAndCreateBounceLink(getSource(), getDestination(), container,
sourceObject.getName());
removeMarkerBlob(container, sourceObject.getName());
return BounceResult.MOVE;
}
示例6: initiateMultipartUpload
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Override
public MultipartUpload initiateMultipartUpload(String s, BlobMetadata blobMetadata) {
return new MultipartUpload() {
@Override
public String containerName() {
return null;
}
@Override
public String blobName() {
return null;
}
@Override
public String id() {
return null;
}
@Override
public BlobMetadata blobMetadata() {
return null;
}
};
}
示例7: testMoveObject
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Test
public void testMoveObject() throws Exception {
String blobName = UtilsTest.createRandomBlobName();
Blob blob = UtilsTest.makeBlob(policy, blobName);
policy.putBlob(containerName, blob);
assertThat(policy.getDestination().blobExists(containerName, blobName)).isFalse();
assertThat(policy.getSource().blobExists(containerName, blobName)).isTrue();
UtilsTest.advanceServiceClock(app, duration.plusHours(1));
BounceService.BounceTaskStatus status = bounceService.bounce(containerName);
status.future().get();
if (policy.getDestination() instanceof BouncePolicy) {
assertStatus(status, status::getMovedObjectCount).isEqualTo(2);
} else {
assertStatus(status, status::getMovedObjectCount).isEqualTo(1);
}
assertThat(policy.getDestination().blobExists(containerName, blobName)).isTrue();
assertThat(policy.getSource().blobExists(containerName, blobName)).isTrue();
BlobMetadata source = policy.getSource().blobMetadata(containerName, blobName);
assertThat(BounceLink.isLink(source)).isTrue();
Blob linkedBlob = policy.getBlob(containerName, blobName);
UtilsTest.assertEqualBlobs(linkedBlob, blob);
}
示例8: testCopiedBlobChangedToLink
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Test
public void testCopiedBlobChangedToLink() throws Exception {
// Check that after a blob is copied, WriteBack policy will create a link
String blobName = UtilsTest.createRandomBlobName();
Blob blob = UtilsTest.makeBlob(policy, blobName);
policy.putBlob(containerName, blob);
// Copy the blob over
BounceService.BounceTaskStatus status = runBounce(bounceService, containerName);
Blob farBlob = policy.getDestination().getBlob(containerName, blobName);
Blob nearBlob = policy.getSource().getBlob(containerName, blobName);
UtilsTest.assertEqualBlobs(nearBlob, farBlob);
// Evict the blob and ensure that a link is created
UtilsTest.advanceServiceClock(app, duration.plusHours(1));
status = runBounce(bounceService, containerName);
BlobMetadata source = policy.getSource().blobMetadata(containerName, blobName);
assertThat(BounceLink.isLink(source)).isTrue();
assertStatus(status, status::getLinkedObjectCount).isEqualTo(1);
Blob linkedBlob = policy.getBlob(containerName, blobName);
UtilsTest.assertEqualBlobs(linkedBlob, blob);
}
示例9: testCopyAndThenBounce
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Test
public void testCopyAndThenBounce() throws Exception {
String fromBlobName = UtilsTest.createRandomBlobName();
String toBlobName = UtilsTest.createRandomBlobName();
Blob blob = UtilsTest.makeBlob(policy, fromBlobName, ByteSource.wrap("foo".getBytes()));
policy.putBlob(containerName, blob);
policy.copyBlob(containerName, fromBlobName, containerName, toBlobName, CopyOptions.NONE);
runBounce(bounceService, containerName);
BlobMetadata meta = policy.getDestination().blobMetadata(containerName, fromBlobName);
assertThat(BounceLink.isLink(meta)).isFalse();
meta = policy.getDestination().blobMetadata(containerName, toBlobName);
assertThat(BounceLink.isLink(meta)).isFalse();
meta = policy.getSource().blobMetadata(containerName, fromBlobName);
assertThat(BounceLink.isLink(meta)).isFalse();
meta = policy.getSource().blobMetadata(containerName, toBlobName);
assertThat(BounceLink.isLink(meta)).isFalse();
}
示例10: testMoveObject
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Test
public void testMoveObject() throws Exception {
String expiringBlob = "expired";
String content = StringUtils.repeat("foo", 3500);
Blob blob = UtilsTest.makeBlob(policy, expiringBlob, ByteSource.wrap(content.getBytes()));
policy.putBlob(containerName, blob);
BounceService.BounceTaskStatus status = bounceService.bounce(containerName);
status.future().get();
assertStatus(status, status::getErrorObjectCount).isEqualTo(0);
assertStatus(status, status::getMovedObjectCount).isEqualTo(1);
String farContainer = ((BlobStoreTarget) policy.getDestination()).mapContainer(null);
Blob farBlob = policy.getDestination().getBlob(farContainer, expiringBlob);
assertThat(farBlob.getMetadata().getContentMetadata().getContentLength()).isEqualTo(content.length());
BlobMetadata link = policy.getSource().blobMetadata(containerName, expiringBlob);
assertThat(BounceLink.isLink(link)).isTrue();
}
示例11: testMoveObjectLRU
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Test
public void testMoveObjectLRU() throws Exception {
String expiringBlob = "expired";
String recentBlob = "recent";
String content = StringUtils.repeat("foo", 3000);
Blob blob = UtilsTest.makeBlob(policy, expiringBlob, ByteSource.wrap(content.getBytes()));
policy.putBlob(containerName, blob);
blob = UtilsTest.makeBlob(policy, recentBlob, ByteSource.wrap(content.getBytes()));
policy.putBlob(containerName, blob);
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
policy.getBlob(containerName, recentBlob);
BounceService.BounceTaskStatus status = bounceService.bounce(containerName);
status.future().get();
assertStatus(status, status::getMovedObjectCount).isEqualTo(1);
BlobMetadata link = policy.getSource().blobMetadata(containerName, expiringBlob);
assertThat(BounceLink.isLink(link)).isTrue();
link = policy.getSource().blobMetadata(containerName, recentBlob);
assertThat(BounceLink.isLink(link)).isFalse();
}
示例12: testMoveAfterCopy
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Test
public void testMoveAfterCopy() throws Exception {
toggleMoveEverything();
Blob blob = UtilsTest.makeBlob(policy, UtilsTest.createRandomBlobName());
policy.getSource().putBlob(containerName, blob);
Utils.copyBlob(policy.getSource(), policy.getDestination(), containerName, containerName,
blob.getMetadata().getName());
BounceTaskStatus status = bounceService.bounce(containerName);
status.future().get();
assertStatus(status, status::getMovedObjectCount).isEqualTo(0);
assertStatus(status, status::getTotalObjectCount).isEqualTo(1);
assertStatus(status, status::getLinkedObjectCount).isEqualTo(1);
BlobMetadata nearBlob = policy.getSource().blobMetadata(containerName, blob.getMetadata().getName());
assertThat(BounceLink.isLink(nearBlob)).isTrue();
}
示例13: testBounceBlob
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Test
public void testBounceBlob() throws Exception {
String blobName = "blob";
ByteSource byteSource = ByteSource.wrap(new byte[1]);
Blob blob = UtilsTest.makeBlob(policy, blobName, byteSource);
ContentMetadata metadata = blob.getMetadata().getContentMetadata();
policy.getSource().putBlob(containerName, blob);
BlobMetadata meta1 = policy.blobMetadata(containerName, blobName);
Utils.copyBlobAndCreateBounceLink(nearBlobStore, farBlobStore,
containerName, blobName);
BlobMetadata meta2 = policy.blobMetadata(containerName, blobName);
assertThat((Object) meta2).isEqualToComparingFieldByField(meta1);
Blob blob2 = policy.getBlob(containerName, blobName);
UtilsTest.assertEqualBlobs(blob2, blob);
}
示例14: contains
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
@Override
public boolean contains(Object key) {
String objectName = encodeKey(key);
Blob blob = blobStore.getBlob(containerName, objectName);
if (blob == null) {
return false;
}
BlobMetadata blobMetadata = blob.getMetadata();
if(isExpired(blobMetadata)) {
blobStore.removeBlob(containerName, objectName);
return false;
} else {
return true;
}
}
示例15: isExpired
import org.jclouds.blobstore.domain.BlobMetadata; //导入依赖的package包/类
protected boolean isExpired(BlobMetadata blobMetadata) {
long now = initializationContext.getTimeService().wallClockTime();
Map<String, String> ispnMetadata = blobMetadata.getUserMetadata();
long et = -1;
if (ispnMetadata != null && ispnMetadata.containsKey(EXPIRE_TIME)) {
try {
et = ispnMetadata.containsKey(EXPIRE_TIME) ? Long.parseLong(ispnMetadata.get(EXPIRE_TIME)) : -1;
} catch(NumberFormatException e) {
// fall back to blob store expires time
if (blobMetadata.getContentMetadata().getExpires() != null)
et = blobMetadata.getContentMetadata().getExpires().getTime();
}
} else {
if (blobMetadata.getContentMetadata().getExpires() != null)
et = blobMetadata.getContentMetadata().getExpires().getTime();
}
return (et > -1 && et < now);
}