本文整理汇总了Java中org.javaswift.joss.model.Container.exists方法的典型用法代码示例。如果您正苦于以下问题:Java Container.exists方法的具体用法?Java Container.exists怎么用?Java Container.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javaswift.joss.model.Container
的用法示例。
在下文中一共展示了Container.exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flush
import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
@Override
public void flush(Map<TopicPartition, OffsetAndMetadata> currentOffsets) {
try {
Iterator<BulkedData> items = bulker.convert();
while (items.hasNext()) {
final BulkedData item = items.next();
final Container container = this.account.getContainer(item.getContainer());
if (!container.exists()) {
container.create();
}
final StoredObject object = container.getObject(item.getObject());
object.uploadObject(item.getStream());
}
} catch (Exception exception) {
log.error("Failed to add record", exception);
throw new ConnectException("Failed to flush", exception);
}
}
示例2: getActualSegmentSize
import org.javaswift.joss.model.Container; //导入方法依赖的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() ;
}
示例3: createContainer
import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
/**
* {@inheritDoc}.
*/
@Override
public synchronized void createContainer(ContainerSpecification spec, SwiftCallback callback) {
CheckAccount () ;
if (spec != null) {
if (spec.getName().endsWith(SwiftUtils.segmentsContainerPostfix))
throw new AssertionError ("A container name cannot end with \"" + SwiftUtils.segmentsContainerPostfix + "\"") ;
Container c = account.getContainer(spec.getName());
if (!c.exists()) {
c.create();
if (spec.isPrivateContainer()) {
c.makePrivate();
} else {
c.makePublic();
}
}
callback.onUpdateContainers(eagerFetchContainers(account));
callback.onNumberOfCalls(account.getNumberOfCalls());
}
}
示例4: CreateObject
import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
public static void CreateObject(String username,String passwod,String dataNode, String container, String key, InputStream content)throws Exception
{
try{
Account client = ViPRSwiftClient(username, passwod, dataNode);
Container myContainer = client.getContainer(container);
if (!myContainer.exists()) {
myContainer.create();
myContainer.makePublic();
}
StoredObject object = myContainer.getObject(key);
object.uploadObject(content);
}
catch(Exception e)
{
System.out.println("error during creating "+key);
e.printStackTrace();
}
}
示例5: getSegmentsList
import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
private List<StoredObject> getSegmentsList (StoredObject obj, long offset, long nobj)
{
List<StoredObject> ret = new ArrayList<StoredObject> () ;
Container segCont = getSegmentsContainer (obj, false) ;
if (segCont == null || !segCont.exists())
return ret ;
// First, we try to get the segments from the manifest
ret.addAll(getSegmentsListFromManifest (segCont, obj, offset, nobj)) ;
if (!ret.isEmpty())
return ret ;
// If no segments were found using the manifest (typically, because the object does not exist,
// e.g., if only some segments were uploaded)
long segCount = 1 ;
StoredObject segObj = getObjectSegment ((AbstractContainer)segCont, (AbstractStoredObject)obj, Long.valueOf(segCount)) ;
while (segObj != null && segObj.exists())
{
if (segCount >= (offset + 1))
ret.add (segObj) ;
if (nobj > 0 && ret.size() >= nobj)
return ret ;
++segCount ;
segObj = getObjectSegment ((AbstractContainer)segCont, (AbstractStoredObject)obj, Long.valueOf(segCount)) ;
}
return ret ;
}
示例6: getSegmentsContainer
import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
private Container getSegmentsContainer (StoredObject obj, boolean createIfNeeded)
{
String containerName = null ;
if (obj.exists())
{
String manifest = obj.getManifest() ;
if (manifest != null && !manifest.isEmpty())
{
// http://docs.openstack.org/api/openstack-object-storage/1.0/content/large-object-creation.html
// {container}/{prefix}
int index = manifest.indexOf(SwiftUtils.separator) ;
if (index > 0) {
containerName = manifest.substring(0, index) ;
}
}
}
if (containerName == null)
{
StringBuilder segmentsContainerName = new StringBuilder () ;
segmentsContainerName.append(((AbstractStoredObject)obj).getContainer().getName()) ;
segmentsContainerName.append(SwiftUtils.segmentsContainerPostfix) ;
containerName = segmentsContainerName.toString() ;
}
else
logger.info("Segment objects container obtained from the manifest: " + containerName) ;
Container segmentsContainer = account.getContainer(containerName) ;
if (createIfNeeded && !segmentsContainer.exists())
{
segmentsContainer.create() ;
segmentsContainer.makePrivate();
}
return segmentsContainer ;
}