本文整理汇总了Java中org.javaswift.joss.model.StoredObject.getContentLength方法的典型用法代码示例。如果您正苦于以下问题:Java StoredObject.getContentLength方法的具体用法?Java StoredObject.getContentLength怎么用?Java StoredObject.getContentLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javaswift.joss.model.StoredObject
的用法示例。
在下文中一共展示了StoredObject.getContentLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
/**
* The get function will first search for the object in the cache.
* If not found will issue a HEAD request for the object metadata
* and add the object to the cache.
*
* @param objName object name
* @return cached entry of the object
* @throws IOException if failed to parse time stamp
*/
public SwiftCachedObject get(String objName) throws IOException {
LOG.trace("Get from cache {} ", objName);
SwiftCachedObject res = cache.get(objName);
if (res == null) {
LOG.trace("Cache get: {} is not in the cache. Access Swift to get content length", objName);
StoredObject rawObj = container.getObject(removeTrailingSlash(objName));
if (rawObj != null && rawObj.exists()) {
res = new SwiftCachedObject(rawObj.getContentLength(),
Utils.lastModifiedAsLong(rawObj.getLastModified()));
put(objName, res);
} else {
return null;
}
}
return res;
}
示例2: RemoteItem
import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
public RemoteItem (StoredObject storedObject) throws IOException
{
super () ;
if (storedObject == null)
throw new IllegalArgumentException ("storedObject cannot be null") ;
this.storedObject = storedObject ;
this.exists = storedObject.exists() ;
this.size = (exists) ? (storedObject.getContentLength()) : (-2) ;
if (exists)
{
// For segmented object, the etag may be bounded by "".
String etag = storedObject.getEtag() ;
if (etag.startsWith("\""))
etag = etag.replace("\"", "") ;
this.md5 = etag ;
}
else
this.md5 = "" ;
}
示例3: getActualSegmentSize
import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
@Override
public long getActualSegmentSize (StoredObject obj)
{
final long notFound = -1 ;
Container segCont = getSegmentsContainer (obj, false) ;
if (segCont == null || !segCont.exists())
return notFound ;
StoredObject segObj = getObjectSegment ((AbstractContainer)segCont, (AbstractStoredObject)obj, Long.valueOf(1)) ;
if (segObj == null || !segObj.exists())
{
// the object may have been segmented using another convention,
// we check using the manifest
List<StoredObject> sgl = getSegmentsList(obj, 0, 1) ;
if (!sgl.isEmpty())
segObj = sgl.get(0) ;
}
if (segObj == null || !segObj.exists())
return notFound ;
return segObj.getContentLength() ;
}
示例4: onPreviewStoredObject
import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
protected void onPreviewStoredObject() {
StoredObject obj = single(getSelectedStoredObjects());
if (SwiftUtils.isDirectory(obj))
{
Container container = getSelectedContainer();
if (container == null)
return ;
loadDirectory (container, obj.getName(), callback) ;
}
else
{
if (obj.getContentLength() < 16 * 1024 * 1024) {
previewPanel.preview(obj.getContentType(), obj.downloadObject());
}
}
}
示例5: setCorrectSize
import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
/**
* Swift has a bug where container listing might wrongly report size 0
* for large objects. It's seems to be a well known issue in Swift without
* solution.
* We have to provide work around for this.
* If container listing reports size 0 for some object, we send
* additional HEAD on that object to verify it's size.
*
* @param tmp JOSS StoredObject
* @param cObj JOSS Container object
*/
private void setCorrectSize(StoredObject tmp, Container cObj) {
long objectSize = tmp.getContentLength();
if (objectSize == 0) {
// we may hit a well known Swift bug.
// container listing reports 0 for large objects.
StoredObject soDirect = cObj
.getObject(tmp.getName());
long contentLength = soDirect.getContentLength();
if (contentLength > 0) {
tmp.setContentLength(contentLength);
}
}
}
示例6: createFileStatus
import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
/**
* Maps StoredObject of JOSS into Hadoop FileStatus
*
* @param tmp Stored Object
* @param cObj Container Object
* @param hostName host name
* @param path path to the object
* @return FileStatus representing current object
* @throws IllegalArgumentException if error
* @throws IOException if error
*/
private FileStatus createFileStatus(StoredObject tmp, Container cObj,
String hostName, Path path) throws IllegalArgumentException, IOException {
String newMergedPath = getMergedPath(hostName, path, tmp.getName());
return new FileStatus(tmp.getContentLength(), false, 1, blockSize,
Utils.lastModifiedAsLong(tmp.getLastModified()), 0, null,
null, null, new Path(newMergedPath));
}