本文整理汇总了Java中org.jets3t.service.StorageObjectsChunk类的典型用法代码示例。如果您正苦于以下问题:Java StorageObjectsChunk类的具体用法?Java StorageObjectsChunk怎么用?Java StorageObjectsChunk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StorageObjectsChunk类属于org.jets3t.service包,在下文中一共展示了StorageObjectsChunk类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: list
import org.jets3t.service.StorageObjectsChunk; //导入依赖的package包/类
/**
* list objects
* @param prefix prefix
* @param delimiter delimiter
* @param maxListingLength max no. of entries
* @param priorLastKey last key in any previous search
* @return a list of matches
* @throws IOException on any reported failure
*/
private PartialListing list(String prefix, String delimiter,
int maxListingLength, String priorLastKey) throws IOException {
try {
if (!prefix.isEmpty() && !prefix.endsWith(PATH_DELIMITER)) {
prefix += PATH_DELIMITER;
}
StorageObjectsChunk chunk = s3Service.listObjectsChunked(bucket.getName(),
prefix, delimiter, maxListingLength, priorLastKey);
FileMetadata[] fileMetadata =
new FileMetadata[chunk.getObjects().length];
for (int i = 0; i < fileMetadata.length; i++) {
StorageObject object = chunk.getObjects()[i];
fileMetadata[i] = new FileMetadata(object.getKey(),
object.getContentLength(), object.getLastModifiedDate().getTime());
}
return new PartialListing(chunk.getPriorLastKey(), fileMetadata,
chunk.getCommonPrefixes());
} catch (ServiceException e) {
handleException(e, prefix);
return null; // never returned - keep compiler happy
}
}
示例2: run
import org.jets3t.service.StorageObjectsChunk; //导入依赖的package包/类
public void run() {
try {
List allObjects = new ArrayList();
List allCommonPrefixes = new ArrayList();
do {
StorageObjectsChunk chunk = storageService.listObjectsChunked(
bucketName, prefix, delimiter, maxListingLength, priorLastKey);
priorLastKey = chunk.getPriorLastKey();
allObjects.addAll(Arrays.asList(chunk.getObjects()));
allCommonPrefixes.addAll(Arrays.asList(chunk.getCommonPrefixes()));
} while (!halted && priorLastKey != null);
result = new StorageObjectsChunk(
prefix, delimiter,
(StorageObject[]) allObjects.toArray(new StorageObject[allObjects.size()]),
(String[]) allCommonPrefixes.toArray(new String[allCommonPrefixes.size()]),
null);
} catch (ServiceException e) {
result = e;
}
}
示例3: listAll
import org.jets3t.service.StorageObjectsChunk; //导入依赖的package包/类
public List<ListItem> listAll(String path) {
m_logger.debug("Start list all: " + path);
try {
List<ListItem> result = new ArrayList<>();
String priorLastKey = null;
while(true) {
StorageObjectsChunk chunk = m_s3service.listObjectsChunked(BUCKET, path, "/", CHUNK_SIZE, priorLastKey);
m_logger.trace("ListObjects: {}", path);
inc();
StorageObject[] objects = chunk.getObjects();
for(int i = 0; i < objects.length; i++) {
String key = objects[i].getKey();
if(key.endsWith("/")) key = key.substring(0, key.length() - 1);
key = key.substring(path.length(), key.length());
ListItem item = new ListItem(key, objects[i].getContentLength() != 0);
result.add(item);
}
if(chunk.isListingComplete()) break;
priorLastKey = chunk.getPriorLastKey();
}
return result;
} catch (ServiceException e) {
throw new RuntimeException(e);
}
}
示例4: deleteAll
import org.jets3t.service.StorageObjectsChunk; //导入依赖的package包/类
public void deleteAll(String path) {
try {
String priorLastKey = null;
while(true) {
StorageObjectsChunk chunk = m_s3service.listObjectsChunked(BUCKET, path, "?", CHUNK_SIZE, priorLastKey);
m_logger.trace("ListObjects to delete: {}", path);
inc();
StorageObject[] objects = chunk.getObjects();
if(objects.length == 0) break;
String[] names = new String[objects.length];
for(int i = 0; i < objects.length; i++) {
names[i] = objects[i].getKey();
}
m_s3service.deleteMultipleObjects(BUCKET, names);
m_logger.trace("DeleteObjects: {}", objects.length);
// do not inc() because delete requests are not counted
if(chunk.isListingComplete()) break;
priorLastKey = chunk.getPriorLastKey();
}
} catch (ServiceException e) {
throw new RuntimeException(e);
}
}
示例5: listObjectsChunkedImpl
import org.jets3t.service.StorageObjectsChunk; //导入依赖的package包/类
@Override
protected StorageObjectsChunk listObjectsChunkedImpl(String bucketName, String prefix, String delimiter,
long maxListingLength, String priorLastKey, boolean completeListing) throws ServiceException
{
return listObjectsInternal(bucketName, prefix, delimiter,
maxListingLength, completeListing, priorLastKey, null);
}
示例6: newInProgressEvent
import org.jets3t.service.StorageObjectsChunk; //导入依赖的package包/类
public static ListObjectsEvent newInProgressEvent(ThreadWatcher threadWatcher,
List<StorageObjectsChunk> chunkList, Object uniqueOperationId)
{
ListObjectsEvent event = new ListObjectsEvent(EVENT_IN_PROGRESS, uniqueOperationId);
event.setThreadWatcher(threadWatcher);
event.setChunkList(chunkList);
return event;
}
示例7: buildObjectMapPartial
import org.jets3t.service.StorageObjectsChunk; //导入依赖的package包/类
/**
* Builds a service Object Map containing a partial set of objects within the given target path,
* where the map's key for each object is the relative path to the object.
* <p>
* If the method is asked to perform a complete listing, it will use the
* {@link #listObjectsThreaded(StorageService, String, String)} method to list the objects
* in the bucket, potentially taking advantage of any bucket name partitioning
* settings you have applied.
* <p>
* If the method is asked to perform only a partial listing, no bucket name
* partitioning will be applied.
*
* @see #lookupObjectMetadataForPotentialClashes(StorageService, String, String, StorageObject[], Map, boolean, boolean, BytesProgressWatcher, StorageServiceEventListener)
*
* @param service
* @param bucketName
* @param targetPath
* @param priorLastKey
* the prior last key value returned by a prior invocation of this method, if any.
* @param objectKeyToFilepathMap
* map of '/'-delimited object key names to local file absolute paths
* @param forceMetadataDownload
* if true, metadata is always downloaded for objects in the storage service. If false,
* metadata is only downloaded if deemed necessary. This flag should be set to true when
* data for any objects in the storage service has been transformed, such as by
* encryption or compression during upload.
* @param isForceUpload
* set to true if the calling tool will upload files regardless of the comparison, so this
* method will avoid any unnecessary and potentially expensive data/date comparison checks.
* @param completeListing
* if true, this method will perform a complete listing of a service target.
* If false, the method will list a partial set of objects commencing from the
* given prior last key.
* @param progressWatcher
* watcher to monitor bytes read during comparison operations, may be null.
* @param eventListener
*
* @return
* an object containing a mapping of key names to StorageObjects, and the prior last
* key (if any) that should be used to perform follow-up method calls.
* @throws ServiceException
*/
public PartialObjectListing buildObjectMapPartial(StorageService service,
String bucketName, String targetPath, String priorLastKey,
Map<String, String> objectKeyToFilepathMap, boolean completeListing,
boolean forceMetadataDownload, boolean isForceUpload,
BytesProgressWatcher progressWatcher, StorageServiceEventListener eventListener)
throws ServiceException
{
String prefix = (targetPath.length() > 0 ? targetPath : null);
StorageObject[] objects = null;
String resultPriorLastKey = null;
if (completeListing) {
objects = listObjectsThreaded(service, bucketName, prefix);
} else {
StorageObjectsChunk chunk = service.listObjectsChunked(
bucketName, prefix, null, Constants.DEFAULT_OBJECT_LIST_CHUNK_SIZE,
priorLastKey, completeListing);
objects = chunk.getObjects();
resultPriorLastKey = chunk.getPriorLastKey();
}
Map<String, StorageObject> objectsMap = lookupObjectMetadataForPotentialClashes(
service, bucketName, targetPath, objects, objectKeyToFilepathMap,
forceMetadataDownload, isForceUpload, progressWatcher, eventListener);
return new PartialObjectListing(objectsMap, resultPriorLastKey);
}
示例8: setChunkList
import org.jets3t.service.StorageObjectsChunk; //导入依赖的package包/类
private void setChunkList(List<StorageObjectsChunk> chunkList) {
this.chunkList = chunkList;
}
示例9: getChunkList
import org.jets3t.service.StorageObjectsChunk; //导入依赖的package包/类
/**
* @return
* a list of the {@link StorageObjectsChunk}s that have been generated since the
* last progress event was fired.
* @throws IllegalStateException
* listed objects are only available from EVENT_IN_PROGRESS events.
*/
public List<StorageObjectsChunk> getChunkList() throws IllegalStateException {
if (getEventCode() != EVENT_IN_PROGRESS) {
throw new IllegalStateException("Chunk list is only available from EVENT_IN_PROGRESS events");
}
return this.chunkList;
}