本文整理汇总了Java中org.jclouds.blobstore.domain.internal.StorageMetadataImpl类的典型用法代码示例。如果您正苦于以下问题:Java StorageMetadataImpl类的具体用法?Java StorageMetadataImpl怎么用?Java StorageMetadataImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StorageMetadataImpl类属于org.jclouds.blobstore.domain.internal包,在下文中一共展示了StorageMetadataImpl类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: list
import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; //导入依赖的package包/类
@Override
public PageSet<? extends StorageMetadata> list() {
OSS oss = api.getOSSClient(OSSApi.DEFAULT_REGION);
PageSetImpl<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(
transform(oss.listBuckets(), new Function<Bucket, StorageMetadata>() {
@Override
public StorageMetadata apply(Bucket input) {
String bucketLocation = input.getLocation();
Location location = new LocationBuilder()
.id(bucketLocation)
.scope(LocationScope.REGION)
.description(bucketLocation)
.build();
StorageMetadata storageMetadata = new StorageMetadataImpl(
StorageType.CONTAINER,
input.getName(),
input.getName(),
location,
null,
null,
input.getCreationDate(),
input.getCreationDate(),
ImmutableMap.<String, String>builder().build(),
0L);
return storageMetadata;
}
}), null);
return pageSet;
}
示例2: testMoveSomeObjects
import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; //导入依赖的package包/类
@Test
public void testMoveSomeObjects() throws Exception {
String expiredBlob = "blob";
Date expiredTime = Date.from(Instant.now());
long expiredSize = 8000L;
String remainingBlob = "staying";
Date remainingTime = Date.from(Instant.now().plus(1, ChronoUnit.DAYS));
long remainingSize = 4000L;
BounceStorageMetadata expiredBlobMetadata = new BounceStorageMetadata(
new StorageMetadataImpl(StorageType.BLOB, null, expiredBlob, null, null, null, expiredTime,
expiredTime, ImmutableMap.of(), expiredSize),
BounceStorageMetadata.NEAR_ONLY);
BounceStorageMetadata remainingBlobMetadata = new BounceStorageMetadata(
new StorageMetadataImpl(StorageType.BLOB, null, remainingBlob, null, null, null, remainingTime,
remainingTime, ImmutableMap.of(), remainingSize),
BounceStorageMetadata.NEAR_ONLY
);
ImmutableSet<StorageMetadata> listResults = ImmutableSet.of(expiredBlobMetadata, remainingBlobMetadata);
StoragePolicy mock = Mockito.spy(policy);
BlobStore mockSource = Mockito.mock(BlobStore.class);
Mockito.doReturn(policy.getSource().getContext()).when(mock).getContext();
Mockito.doReturn(mockSource).when(mock).getSource();
Mockito.doReturn(new PageSetImpl<>(listResults, null)).when(mockSource).list(Mockito.anyString(),
Mockito.any(ListContainerOptions.class));
mock.prepareBounce(containerName);
try {
BouncePolicy.BounceResult result = mock.reconcileObject(containerName,
new BounceStorageMetadata(expiredBlobMetadata, BounceStorageMetadata.NEAR_ONLY), null);
assertThat(result).isEqualTo(BouncePolicy.BounceResult.MOVE);
result = mock.reconcileObject(containerName,
new BounceStorageMetadata(remainingBlobMetadata, BounceStorageMetadata.NEAR_ONLY), null);
assertThat(result).isEqualTo(BouncePolicy.BounceResult.NO_OP);
} catch (MockitoException e) {
e.setStackTrace(e.getUnfilteredStackTrace());
throw e;
}
}
示例3: list
import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; //导入依赖的package包/类
@Override
public PageSet<? extends StorageMetadata> list() {
List<StorageMetadata> results = policyMap.keySet().stream()
.map(container -> new StorageMetadataImpl(StorageType.CONTAINER, null, container, null, null,
null, null, null, ImmutableMap.of(), null))
.sorted()
.collect(Collectors.toList());
return new PageSetImpl<>(results, null);
}