本文整理汇总了Java中org.jclouds.blobstore.domain.StorageMetadata.getName方法的典型用法代码示例。如果您正苦于以下问题:Java StorageMetadata.getName方法的具体用法?Java StorageMetadata.getName怎么用?Java StorageMetadata.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jclouds.blobstore.domain.StorageMetadata
的用法示例。
在下文中一共展示了StorageMetadata.getName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: getBlobsWithinRange
import org.jclouds.blobstore.domain.StorageMetadata; //导入方法依赖的package包/类
private NavigableMap<Long,String> getBlobsWithinRange(PageSet<? extends StorageMetadata> pages) {
// TreeMap used because of sorted property
TreeMap<Long, String> tsToBlobName = new TreeMap<Long, String>();
for (StorageMetadata blobMeta : pages) {
String fileName = blobMeta.getName(); // 20140226_1393442533000.json.gz
String dateAndTs = fileName.split("\\.", 2)[0].trim(); // 20140226_1393442533000
String tsCreated = dateAndTs.split("_")[1].trim(); // 1393442533000
long ts = Long.parseLong(tsCreated);
tsToBlobName.put(ts, fileName);
}
//Gets key within the time range specified
NavigableMap<Long, String> mapWithinRange = tsToBlobName.subMap(START_TIME - 60000*15, true, STOP_TIME + 60000*30, true);
if(mapWithinRange.isEmpty()) {
lastMarker = tsToBlobName.lastEntry().getValue().trim();
synchronized (CloudFilesManager.this) {
// this is where we resume from.
MarkerUtils.writeLastMarker(tsToBlobName.lastEntry().getValue().trim());
}
}
return mapWithinRange;
}
示例4: readNextListing
import org.jclouds.blobstore.domain.StorageMetadata; //导入方法依赖的package包/类
void readNextListing() throws IOException {
BlobStore blobStore = dirPath.getFileSystem().getBlobStoreContext().getBlobStore();
List<CloudPath> paths = new ArrayList<>();
// Set next page marker
if (pageSetMarker != null) {
listContainerOptions.afterMarker(pageSetMarker);
}
// Perform a file listing
PageSet<? extends StorageMetadata> pageSet =
blobStore.list(dirPath.getContainerName(), listContainerOptions);
for (StorageMetadata meta : pageSet) {
String filename = dirPathName == null ? meta.getName() :
StringUtils.substringAfter(meta.getName(), dirPathName);
// The listing returns the directory name as part of the listing, don't return this
if (StringUtils.isNotBlank(filename)) {
CloudBasicFileAttributes cloudFileAttributes = new CloudBasicFileAttributes(meta);
CloudPath path =
new CloudPathWithAttributes(dirPath.getFileSystem(), false, dirPath, filename, cloudFileAttributes);
if (filter == null || filter.accept(path)) {
paths.add(path);
}
}
}
currentPage = paths.iterator();
pageSetMarker = pageSet.getNextMarker();
readNextPage = pageSetMarker != null;
}
示例5: poll
import org.jclouds.blobstore.domain.StorageMetadata; //导入方法依赖的package包/类
@Override
protected int poll() throws Exception {
shutdownRunningTask = null;
pendingExchanges = 0;
Queue<Exchange> queue = new LinkedList<Exchange>();
String directory = endpoint.getDirectory();
ListContainerOptions opt = new ListContainerOptions();
if (!Strings.isNullOrEmpty(directory)) {
opt = opt.inDirectory(directory);
}
for (StorageMetadata md : blobStore.list(container, opt.maxResults(maxMessagesPerPoll).recursive())) {
String blobName = md.getName();
if (md.getType().equals(StorageType.BLOB)) {
if (!Strings.isNullOrEmpty(blobName)) {
InputStream body = JcloudsBlobStoreHelper.readBlob(blobStore, container, blobName);
if (body != null) {
Exchange exchange = endpoint.createExchange();
CachedOutputStream cos = new CachedOutputStream(exchange);
IOHelper.copy(body, cos);
exchange.getIn().setBody(cos.newStreamCache());
exchange.setProperty(JcloudsConstants.BLOB_NAME, blobName);
queue.add(exchange);
}
}
}
}
return queue.isEmpty() ? 0 : processBatch(CastUtils.cast(queue));
}
示例6: moveObject
import org.jclouds.blobstore.domain.StorageMetadata; //导入方法依赖的package包/类
private BounceResult moveObject(String container, StorageMetadata objectMetadata) {
try {
logger.debug("copying blob {}", objectMetadata.getName());
Blob blob = Utils.copyBlob(getSource(), getDestination(), container, container, objectMetadata.getName());
if (blob == null) {
throw new RuntimeException("Failed to move the blob: " + objectMetadata.getName());
}
getSource().removeBlob(container, objectMetadata.getName());
return BounceResult.MOVE;
} catch (IOException e) {
throw propagate(e);
}
}
示例7: reconcileObject
import org.jclouds.blobstore.domain.StorageMetadata; //导入方法依赖的package包/类
@Override
public BounceResult reconcileObject(String container, BounceStorageMetadata sourceObject, StorageMetadata
destinationObject) {
if ((sourceObject == null) && (destinationObject == null)) {
throw new AssertionError("At least one of source or destination objects must be non-null");
}
String blobName = sourceObject == null ? destinationObject.getName() : sourceObject.getName();
logger.debug("reconciling {}", blobName);
if (sourceObject.getRegions().equals(DESTINATION)) {
return BounceResult.NO_OP;
}
try (ReconcileLocker.LockKey ignored = reconcileLocker.lockObject(container, blobName, true)) {
if (sourceObject.getRegions().equals(SOURCE)) {
return moveObject(container, sourceObject);
}
BlobMetadata sourceMeta = getSource().blobMetadata(container, blobName);
BlobMetadata destinationMeta = getDestination().blobMetadata(container, blobName);
if (sourceMeta == null && destinationMeta != null) {
return BounceResult.NO_OP;
} else if (sourceMeta != null && destinationMeta == null) {
return moveObject(container, sourceMeta);
} else {
if (!sourceMeta.getSize().equals(destinationMeta.getSize()) ||
sourceMeta.getLastModified().compareTo(destinationMeta.getLastModified()) > 0) {
logger.warn("Different objects with the same name: {}", sourceMeta.getName());
return BounceResult.NO_OP;
} else {
getSource().removeBlob(container, sourceMeta.getName());
return BounceResult.REMOVE;
}
}
} catch (ServiceUnavailableException e) {
// not able to lock key, another PUT is in operation, so we can just skip
// this. note that we should not delete the object from source store,
// because the PUT may fail
return BounceResult.NO_OP;
}
}
示例8: list
import org.jclouds.blobstore.domain.StorageMetadata; //导入方法依赖的package包/类
@Override
public PageSet<? extends StorageMetadata> list(String containerName, ListContainerOptions listContainerOptions) {
PeekingIterator<StorageMetadata> sourcePage = Iterators.peekingIterator(
Utils.crawlBlobStore(getSource(), containerName, listContainerOptions)
.iterator());
PeekingIterator<StorageMetadata> destinationPage = Iterators.peekingIterator(
Utils.crawlBlobStore(getDestination(), containerName, listContainerOptions)
.iterator());
TreeMap<String, BounceStorageMetadata> contents = new TreeMap<>();
int maxResults = listContainerOptions.getMaxResults() == null ?
1000 : listContainerOptions.getMaxResults();
StorageMetadata sourceMeta = Utils.getNextOrNull(sourcePage);
StorageMetadata destinationMeta = Utils.getNextOrNull(destinationPage);
while (contents.size() < maxResults && (sourceMeta != null || destinationMeta != null)) {
if (sourceMeta != null && destinationMeta != null) {
String sourceName = sourceMeta.getName();
String destinationName = destinationMeta.getName();
int compare = sourceName.compareTo(destinationName);
if (compare < 0) {
contents.put(sourceName, new BounceStorageMetadata(sourceMeta, SOURCE));
sourceMeta = com.bouncestorage.bounce.Utils.getNextOrNull(sourcePage);
} else if (compare == 0) {
contents.put(sourceName, new BounceStorageMetadata(sourceMeta, BounceStorageMetadata.EVERYWHERE));
sourceMeta = Utils.getNextOrNull(sourcePage);
destinationMeta = Utils.getNextOrNull(destinationPage);
} else {
contents.put(destinationName, new BounceStorageMetadata(destinationMeta, DESTINATION));
destinationMeta = Utils.getNextOrNull(destinationPage);
}
} else if (sourceMeta == null) {
contents.put(destinationMeta.getName(), new BounceStorageMetadata(destinationMeta, DESTINATION));
destinationMeta = Utils.getNextOrNull(destinationPage);
} else {
contents.put(sourceMeta.getName(), new BounceStorageMetadata(sourceMeta, SOURCE));
sourceMeta = Utils.getNextOrNull(sourcePage);
}
}
if (sourceMeta != null || destinationMeta != null) {
return new PageSetImpl<>(contents.values(), contents.lastKey());
}
return new PageSetImpl<>(contents.values(), null);
}