当前位置: 首页>>代码示例>>Java>>正文


Java Container.exists方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:yuuzi41,项目名称:kafka-connect-swift,代码行数:23,代码来源:SwiftSinkTask.java

示例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() ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:21,代码来源:LargeObjectManagerImpl.java

示例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());
    }
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:27,代码来源:SwiftOperationsImpl.java

示例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();
	}

}
 
开发者ID:thecodeteam,项目名称:VStriker,代码行数:21,代码来源:swiftapi.java

示例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 ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:30,代码来源:LargeObjectManagerImpl.java

示例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 ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:36,代码来源:LargeObjectManagerImpl.java


注:本文中的org.javaswift.joss.model.Container.exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。