本文整理汇总了Java中org.jclouds.blobstore.domain.StorageMetadata类的典型用法代码示例。如果您正苦于以下问题:Java StorageMetadata类的具体用法?Java StorageMetadata怎么用?Java StorageMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StorageMetadata类属于org.jclouds.blobstore.domain包,在下文中一共展示了StorageMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CloudBasicFileAttributes
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
public CloudBasicFileAttributes(StorageMetadata meta) {
lastModified = meta.getLastModified() == null ? FileTime.from(0L, TimeUnit.MILLISECONDS) :
FileTime.from(meta.getLastModified().getTime(), TimeUnit.MILLISECONDS);
created = meta.getCreationDate() == null ? lastModified : FileTime.from(meta.getCreationDate().getTime(), TimeUnit.MILLISECONDS);
key = meta.getProviderId();
storageType = meta.getType();
physicalLocation = meta.getLocation();
uri = meta.getUri();
size = Optional.ofNullable(meta.getSize()).orElse(Long.valueOf(0));
eTag = meta.getETag();
userMetadata = meta.getUserMetadata();
contentDisposition = null;
contentEncoding = null;
contentLanguage = null;
contentMD5 = null;
contentType = null;
expires = null;
}
示例2: directoryContentsToString
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
public final String directoryContentsToString(String path) {
BlobStore blobStore = blobStoreContext.getBlobStore();
String marker = null;
ListContainerOptions opts = new ListContainerOptions().recursive();
if (StringUtils.isNotBlank(path)) {
opts.inDirectory(path);
}
StringBuilder ret = new StringBuilder((path == null ? "Container '" : "Directory '" + path)).append("' contains: [ ");
do {
if (marker != null) {
opts.afterMarker(marker);
}
PageSet<? extends StorageMetadata> page = blobStore.list(CONTAINER_NAME, opts);
page.forEach(
m -> ret.append('{').append(m.getName()).append(" (")
.append(m.getType() == StorageType.BLOB ? "FILE" : "DIRECTORY").append(")} "));
marker = page.getNextMarker();
} while (marker != null);
return ret.append(']').toString();
}
示例3: deleteApp
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
@Override
public boolean deleteApp( App app )
{
log.info( "Deleting app " + app.getName() );
// Delete all files related to app
for ( StorageMetadata resource : blobStore.list( config.container, inDirectory( app.getFolderName() ) ) )
{
log.info( "Deleting app file: " + resource.getName() );
blobStore.removeBlob( config.container, resource.getName() );
}
log.info( "Deleted app " + app.getName() );
return true;
}
示例4: getDLOSegments
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
private List<ManifestEntry> getDLOSegments(BlobStore blobStore, String container, String objectsPrefix) {
ListContainerOptions listOptions = new ListContainerOptions()
.recursive()
.prefix(objectsPrefix);
logger.debug("dlo prefix: {}", objectsPrefix);
Iterable<StorageMetadata> res = Utils.crawlBlobStore(blobStore, container, listOptions);
List<ManifestEntry> segments = new ArrayList<>();
for (StorageMetadata sm : res) {
if (sm.getName().startsWith(objectsPrefix)) {
ManifestEntry entry = new ManifestEntry();
entry.container = container;
entry.object = sm.getName();
entry.size_bytes = sm.getSize();
entry.etag = sm.getETag();
segments.add(entry);
} else {
throw new IllegalStateException(
String.format("list object %s from prefix %s", sm.getName(), objectsPrefix));
}
}
segments.forEach(e -> logger.debug("sub-object: {}", e));
return segments;
}
示例5: computeNext
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
@Override
protected StorageMetadata computeNext() {
while (true) {
if (!iterator.hasNext()) {
if (marker == null) {
return endOfData();
}
advance();
continue;
}
StorageMetadata metadata = iterator.next();
// filter out folders with atmos and filesystem providers
// accept metadata == null for Google Cloud Storage folders
if (metadata == null || metadata.getType() == StorageType.RELATIVE_PATH) {
continue;
}
return metadata;
}
}
示例6: getInputStream
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public InputStream getInputStream(String id, String root, String filePath) throws IOException {
ContainerAndName can = getContainerAndName(id, root, filePath);
Blob blob = getBlobStore().getBlob(can.container, can.name);
if (blob == null){
throw new IOException("No object found for " + id);
}
StorageMetadata metadata = blob.getMetadata();
Long size = metadata.getSize();
if (size != null && size.longValue() > maxBlobStreamSize) {
return streamFromTempFile(blob, size);
} else {
// SAK-30325: why can't we just send the stream straight back: blob.getPayload().openStream() ?
// Good question, but it doesn't work properly unless the stream is fully copied and re-streamed....
return new ByteArrayInputStream(FileCopyUtils.copyToByteArray(blob.getPayload().openStream()));
}
}
示例7: handleDescribe
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
private void handleDescribe(HttpExchange httpExchange, Map<String, String> parameters) throws IOException {
String vaultName = parameters.get("vault");
if (!proxy.getBlobStore().containerExists(vaultName)) {
logger.debug("Describe vault: vault {} does not exist", vaultName);
Util.sendNotFound("vault", vaultName, httpExchange);
return;
}
logger.debug("Describe vault request for {}", vaultName);
JsonObject vault = new JsonObject();
for (StorageMetadata container : proxy.getBlobStore().list()) {
if (!container.getName().equals(vaultName)) {
continue;
}
vault.addProperty("CreationDate", Util.getTimeStamp(container.getCreationDate()));
vault.addProperty("LastInventoryDate", Util.getTimeStamp(container.getCreationDate()));
}
vault.addProperty("SizeInBytes", -1);
vault.addProperty("VaultARN", Util.getARN(parameters.get("account"), parameters.get("vault")));
vault.addProperty("VaultName", parameters.get("vault"));
Util.sendJSON(httpExchange, Response.Status.OK, vault);
}
示例8: testCreateBlobGetBlob
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
@Test
public void testCreateBlobGetBlob() throws Exception {
String blobName = createRandomBlobName();
Blob blob = makeBlob(nullBlobStore, blobName);
nullBlobStore.putBlob(containerName, blob);
blob = nullBlobStore.getBlob(containerName, blobName);
validateBlobMetadata(blob.getMetadata(), BYTE_SOURCE);
// content differs, only compare length
try (InputStream actual = blob.getPayload().openStream();
InputStream expected = BYTE_SOURCE.openStream()) {
long actualLength = ByteStreams.copy(actual,
ByteStreams.nullOutputStream());
long expectedLength = ByteStreams.copy(expected,
ByteStreams.nullOutputStream());
assertThat(actualLength).isEqualTo(expectedLength);
}
PageSet<? extends StorageMetadata> pageSet = nullBlobStore.list(
containerName);
assertThat(pageSet).hasSize(1);
StorageMetadata sm = pageSet.iterator().next();
assertThat(sm.getName()).isEqualTo(blobName);
assertThat(sm.getSize()).isEqualTo(0);
}
示例9: next
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
@Override
public Pair<BounceStorageMetadata, StorageMetadata> next() {
BounceStorageMetadata src = (BounceStorageMetadata) peekOrNull(srcIter);
StorageMetadata dest = peekOrNull(destIter);
if (dest == null) {
srcIter.next();
} else if (src == null) {
destIter.next();
} else {
int compare = dest.getName().compareTo(src.getName());
if (compare == 0) {
srcIter.next();
destIter.next();
} else if (compare < 0) {
src = null;
destIter.next();
} else {
dest = null;
srcIter.next();
}
}
return Pair.of(src, dest);
}
示例10: processPolicy
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
private void processPolicy(BouncePolicy policy) {
logger.info("processing policy {} {}", policy.getClass(), status.container);
ListContainerOptions options = new ListContainerOptions().recursive();
PeekingIterator<StorageMetadata> destinationIterator = Iterators.peekingIterator(
Utils.crawlBlobStore(policy.getDestination(), container, options).iterator());
PeekingIterator<StorageMetadata> sourceIterator = Iterators.peekingIterator(
Utils.crawlBlobStore(policy, container, options).iterator());
policy.prepareBounce(container);
StreamSupport.stream(Spliterators.spliteratorUnknownSize(
new ReconcileIterator(sourceIterator, destinationIterator), Spliterator.CONCURRENT), true)
.filter(p -> p.getRight() == null || !WriteBackPolicy.isSwiftSegmentBlob(p.getRight().getName()))
.forEach((p) -> {
BounceStorageMetadata sourceObject = p.getLeft();
StorageMetadata destinationObject = p.getRight();
reconcileObject(policy, sourceObject, destinationObject);
});
}
示例11: setEvictionTime
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
@Override
protected void setEvictionTime(String containerName) {
currentSize = 0;
// The MultiSet is limited to int, hence using the Map here
TreeMap<Instant, Long> sizeHistogram = new TreeMap<>();
// Populate the histogram
for (StorageMetadata meta : Utils.crawlBlobStore(getSource(), containerName)) {
String blobName = meta.getName();
if (!lru.containsKey(getLRUKey(containerName, blobName))) {
Instant date = getInstant(meta.getLastModified());
sizeHistogram.put(date, sizeHistogram.getOrDefault(date, 0L) + meta.getSize());
}
currentSize += meta.getSize();
}
evictionTime = getEvictionTime(sizeHistogram);
logger.debug("Set eviction time for " + containerName + ": " + evictionTime);
}
示例12: maybeMoveObject
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的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;
}
示例13: getContainerList
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
@GET
@Timed
public List<Container> getContainerList(@PathParam("id") int providerId) {
BlobStore blobStore = app.getBlobStore(providerId);
ObjectStore store = getStoreById(providerId, app.getConfiguration());
if (blobStore == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
Map<String, ContainerMapEntry> containerMap = createVirtualContainerMap(providerId);
if (store.getStorageClass() == null) {
PageSet<? extends StorageMetadata> pageSet = blobStore.list();
return pageSet.stream()
.filter(sm -> true)
.map(sm -> createContainerObject(sm.getName(), containerMap))
.collect(Collectors.toList());
}
GoogleCloudStorageApi googleApi = blobStore.getContext().unwrapApi(GoogleCloudStorageApi.class);
ListPage<Bucket> listPage = googleApi.getBucketApi().listBucket(store.translateIdentity());
return listPage.stream()
.filter(bucket -> bucket.storageClass() ==
DomainResourceReferences.StorageClass.valueOf(store.translateStorageClass()))
.filter(bucket -> bucket.location().name().equalsIgnoreCase(store.getRegion()))
.map(bucket -> createContainerObject(bucket.name(), containerMap))
.collect(Collectors.toList());
}
示例14: computeNext
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
@Override
protected StorageMetadata computeNext() {
while (true) {
if (!iterator.hasNext()) {
if (marker == null) {
return endOfData();
}
advance();
continue;
}
StorageMetadata metadata = iterator.next();
// filter out folders with atmos and filesystem providers
if (metadata.getType() == StorageType.RELATIVE_PATH) {
continue;
}
return metadata;
}
}
示例15: equals
import org.jclouds.blobstore.domain.StorageMetadata; //导入依赖的package包/类
/**
* we don't want to use StorageMetadata.equals directly because that compares
* fields like URI and ProviderID which we don't care about.
*/
public static boolean equals(StorageMetadata meta1, StorageMetadata meta2) {
if (meta1 == meta2) {
return true;
}
if (meta1 == null || meta2 == null) {
return false;
}
return Objects.equals(meta1.getCreationDate(), meta2.getCreationDate())
&& eTagsEqual(meta1.getETag(), meta2.getETag())
&& Objects.equals(meta1.getLastModified(), meta2.getLastModified())
&& Objects.equals(meta1.getName(), meta2.getName())
&& Objects.equals(meta1.getSize(), meta2.getSize())
&& Objects.equals(meta1.getType(), meta2.getType())
;
}