• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Container类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.javaswift.joss.model.Container的典型用法代码示例。如果您正苦于以下问题:Java Container类的具体用法?Java Container怎么用?Java Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Container类属于org.javaswift.joss.model包,在下文中一共展示了Container类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: rename

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Override
public boolean rename(String hostName, String srcPath, String dstPath) throws IOException {
  LOG.debug("Rename from {} to {}. hostname is {}", srcPath, dstPath, hostName);
  String objNameSrc = srcPath.toString();
  if (srcPath.toString().startsWith(hostName)) {
    objNameSrc = getObjName(hostName, srcPath);
  }
  String objNameDst = dstPath.toString();
  if (objNameDst.toString().startsWith(hostName)) {
    objNameDst = getObjName(hostName, dstPath);
  }
  if (stocatorPath.isTemporaryPathContain(objNameSrc)) {
    LOG.debug("Rename on the temp object {}. Return true", objNameSrc);
    return true;
  }
  LOG.debug("Rename modified from {} to {}", objNameSrc, objNameDst);
  Container cont = mJossAccount.getAccount().getContainer(container);
  StoredObject so = cont.getObject(objNameSrc);
  StoredObject soDst = cont.getObject(objNameDst);
  so.copyObject(cont, soDst);
  return true;
}
 
开发者ID:SparkTC,项目名称:stocator,代码行数:23,代码来源:SwiftAPIClient.java


示例3: shouldNotDownloadStoredObject

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Test(expected = AssertionError.class)
  public void shouldNotDownloadStoredObject() 
  {
  	final String directoryName = "directory" ;
      Container container = account.getContainer("x").create();  
      
      ops.createDirectory(container, null, directoryName, callback);
      StoredObject objectDir = container.getObject(directoryName);
      assertTrue (objectDir.exists()) ;
      
      try 
      {
	ops.downloadStoredObject(container, objectDir, tmpFolder.newFile(), null, callback);
} 
      catch (IOException e) 
{
      	logger.error ("Error occurred in shouldNotDownloadStoredObject", e) ;
      	assertFalse(true) ;
}
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:21,代码来源:SwiftOperationsTest.java


示例4: shouldGetAllContainedStoredObjectInContainer

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Test
  public void shouldGetAllContainedStoredObjectInContainer () throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException
  {
      Container container = account.getContainer("x").create();
      
      StoredObject object1 = container.getObject("obj1");
      object1.uploadObject(new byte[]{'a', 'b', 'c'});
      
      StoredObject objectDir1 = container.getObject("dir1");
      objectDir1.uploadObject(new UploadInstructions (new byte[] {}).setContentType(SwiftUtils.directoryContentType)) ;
  	
      StoredObject object2 = container.getObject(objectDir1.getName() + SwiftUtils.separator + "obj2");
      object2.uploadObject(new byte[]{'a', 'b', 'c'});
      
      StoredObject objectDir2 = container.getObject(objectDir1.getName() + SwiftUtils.separator + "subDir");
      objectDir2.uploadObject(new UploadInstructions (new byte[] {}).setContentType(SwiftUtils.directoryContentType)) ;
  	
      // call a private method via reflection
      Class<?> c = SwiftOperationsImpl.class;
  	Method method = c.getDeclaredMethod ("getAllContainedStoredObject", Container.class, Directory.class);
  	method.setAccessible(true);
  	@SuppressWarnings("unchecked")
Collection<StoredObject> ret = (Collection<StoredObject>) method.invoke(ops, container, null);
  	
  	assertTrue (ret.size() == 4) ;
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:27,代码来源:SwiftOperationsTest.java


示例5: shouldUploadStoredObject

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Test
public void shouldUploadStoredObject() throws IOException 
{
	Container container = account.getContainer("x").create();
    
	final String dir = "dir" ; 
	final String name = "file.dat" ; 
	
    StoredObject object = container.getObject(dir);
    object.uploadObject(new UploadInstructions (new byte[] {}).setContentType(SwiftUtils.directoryContentType)) ;

    File file = TestUtils.getTestFile(tmpFolder, name, 4096) ; 
    
	ops.uploadFiles(container, object, new File [] {file}, true, stopRequester, callback);
	
    //Mockito.verify(callback, Mockito.atLeastOnce()).onNewStoredObjects();
    Mockito.verify(callback, Mockito.atLeastOnce()).onAppendStoredObjects(Mockito.any(Container.class), Mockito.eq(0),
            Mockito.anyListOf(StoredObject.class));
    
    StoredObject upObj = container.getObject(dir + SwiftUtils.separator + name) ;
    assertTrue (upObj.exists());
    assertTrue (upObj.getEtag().equals(FileUtils.getMD5(file))) ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:24,代码来源:SwiftOperationsTest.java


示例6: uploadObjectAsSegments

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Override
public void uploadObjectAsSegments(StoredObject obj, File file, UploadInstructions uploadInstructions, long size, ProgressInformation progInfo, SwiftCallback callback) 
{    	
	Container segmentsContainer = getSegmentsContainer (obj, true) ;
	
	AbstractContainer abstractContainer = (AbstractContainer)segmentsContainer ;
	uploadSegmentedObjects(abstractContainer, (AbstractStoredObject)obj, file, uploadInstructions, size, progInfo, callback);
	
	StringBuilder sb = new StringBuilder () ;
	sb.append(segmentsContainer.getName()) ;
	sb.append(obj.getPath().replaceFirst(((AbstractStoredObject)obj).getContainer().getPath(), "")) ;
	
    UploadInstructions manifest = new UploadInstructions(new byte[] {})
        .setObjectManifest(new ObjectManifest(sb.toString())) // Manifest does not accept preceding slash
        .setContentType(uploadInstructions.getContentType()
     		);
    obj.uploadObject(manifest);
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:19,代码来源:LargeObjectManagerImpl.java


示例7: shouldReturnObjectFile

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Test
public void shouldReturnObjectFile () throws IOException
{
	Container container = account.getContainer("x").create() ;
	
	final String root = "root" ;
	File rootDirectory = TestUtils.getTestDirectoryWithFiles (tmpFolder, root, "file", 2) ;
	Path file = Paths.get(new File (rootDirectory.getPath() + File.separator + "file_1").getPath()) ;
	assertTrue (Files.exists(file)) ;

	DifferencesFinder.LocalItem li = new DifferencesFinder.LocalItem(file, Paths.get(rootDirectory.getPath()), Long.MAX_VALUE) ;
	
	StoredObject obj = container.getObject(li.getRemoteFullName()) ;
	obj.uploadObject(new byte[]{'a', 'b', 'c'}) ;
	assertTrue (obj.exists()) ;

	DifferencesFinder.RemoteItem ri = new DifferencesFinder.RemoteItem(obj) ;

	assertTrue (Paths.get(DifferencesFinder.getFile(ri, rootDirectory).getPath()).equals(file)) ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:21,代码来源:DifferencesFinderTest.java


示例8: 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


示例9: shouldStopUploadingDirectory

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Test
  public void shouldStopUploadingDirectory ()
  {
  	final String directoryName = "directory" ;
      Container container = account.getContainer("x").create();
      try 
      {
      	SwiftOperationStopRequesterImpl stopReq = new SwiftOperationStopRequesterImpl () ;
      	stopReq.stop();
      	
       File folder = TestUtils.getTestDirectoryWithFiles (tmpFolder, directoryName, "file", 10) ;
       ops.uploadDirectory(container, null, folder, true, stopReq, callback);     
     		Mockito.verify(callback, Mockito.times(1)).onStopped();
} 
      catch (IOException e) 
{
      	logger.error ("Error occurred in shouldStopUploadingDirectory", e) ;
      	assertFalse(true) ;
}  
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:21,代码来源:SwiftOperationsTest.java


示例10: 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


示例11: uploadAndOverwrite

import org.javaswift.joss.model.Container; //导入依赖的package包/类
private void uploadAndOverwrite (boolean overwrite) throws IOException
{
	final String objName = "testObject.dat" ;
	
    Container container = account.getContainer("x").create();
    StoredObject object = container.getObject(objName);
    object.uploadObject(TestUtils.getTestFile(tmpFolder, objName, 4096));

    assertTrue (object.exists()) ;
    String md5 = object.getEtag() ;
    
    // upload a new file with the same name, the overwrite flag is set to overwrite
    ops.uploadFiles(container, null, new File [] {TestUtils.getTestFile(tmpFolder, objName, 4096)}, overwrite, stopRequester, callback);
    
    StoredObject newObject = container.getObject(objName);
    assertTrue (newObject.exists()) ;
    
    // we assume no collision ;-)
    assertTrue (md5.equals(newObject.getEtag()) == !overwrite) ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:21,代码来源:SwiftOperationsTest.java


示例12: addedObjectToContainer

import org.javaswift.joss.model.Container; //导入依赖的package包/类
private void addedObjectToContainer(Container container, List<StoredObject> newObjects, SwiftCallback callback) {
  	
  	if (container == null)
  		throw new AssertionError ("container cannot be null") ;
  	
  	container.reload();

  	if (newObjects == null || newObjects.isEmpty())
  		return ;
  	
int page = 0;
while (page * MAX_PAGE_SIZE < newObjects.size())
{
	callback.onAppendStoredObjects(container, page, newObjects.subList(page * MAX_PAGE_SIZE, Math.min(newObjects.size(), (page + 1) * MAX_PAGE_SIZE))) ;
	++page ;
}
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:18,代码来源:SwiftOperationsImpl.java


示例13: getAllContainedStoredObject

import org.javaswift.joss.model.Container; //导入依赖的package包/类
private Collection<StoredObject> getAllContainedStoredObject (Container container, Directory parent)
{
	Set<StoredObject> results = new TreeSet<StoredObject>();
	Queue<DirectoryOrObject> queue = new ArrayDeque<DirectoryOrObject> () ;
	queue.addAll((parent == null) ? (container.listDirectory()) : (container.listDirectory(parent))) ;
	while (!queue.isEmpty())
	{
		DirectoryOrObject currDirOrObj = queue.poll() ;    		
		if (currDirOrObj != null)
		{
if (currDirOrObj.isObject())
	results.add(currDirOrObj.getAsObject()) ;
			if (currDirOrObj.isDirectory())
				queue.addAll(container.listDirectory(currDirOrObj.getAsDirectory())) ;
		}
	}
	return results ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:19,代码来源:SwiftOperationsImpl.java


示例14: findDifferences

import org.javaswift.joss.model.Container; //导入依赖的package包/类
/**
    * {@inheritDoc}.
    * @throws IOException 
    */
@Override
public synchronized void findDifferences (Container container, StoredObject remote, File local, ResultCallback<Collection<Pair<? extends ComparisonItem, ? extends ComparisonItem> > > resultCallback, StopRequester stopRequester, SwiftCallback callback) throws IOException
{
	CheckAccount () ;
	
	if (!remote.getBareName().equals(local.getName()))
		throw new IllegalArgumentException ("The local and the remote items must have the same name") ; 
	
   	if (SwiftUtils.isDirectory(remote) && Files.isDirectory(Paths.get(local.getPath()))) {
   		// here we compare two folders
   		findDirectoriesDifferences (container, remote, local, resultCallback, stopRequester, callback) ;
   	}
   	else if (SwiftUtils.isDirectory(remote)) {
   		throw new AssertionError ("A remote directory can only be compared with a local directory") ;
   	}
   	else{
   		// here we only compare two "files"
   		findFilesDifferences (container, remote, local, resultCallback, stopRequester, callback) ;
   	}
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:25,代码来源:SwiftOperationsImpl.java


示例15: getObjectRelativelyInDirectory

import org.javaswift.joss.model.Container; //导入依赖的package包/类
private StoredObject getObjectRelativelyInDirectory (Container container, String parentDir, Path source, Path path)
{
	final String separator = SwiftUtils.separator ;
	
	StringBuilder objectPathBuilder = new StringBuilder () ;
	if (parentDir != null)
		objectPathBuilder.append (parentDir) ;
	objectPathBuilder.append (source.getFileName().toString()) ;
	objectPathBuilder.append(separator) ;
	objectPathBuilder.append(source.relativize(path).toString()) ;

	String objectPath = objectPathBuilder.toString() ;
	if (!separator.equals(File.separator))
		objectPath = objectPath.replace(File.separator, separator) ;

	// relevant when creating folder
	if (objectPath.length() > 1 && objectPath.endsWith(separator))
		objectPath = objectPath.substring(0, objectPath.length() - 1) ;
	
	return container.getObject(objectPath.toString());
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:22,代码来源:SwiftOperationsImpl.java


示例16: shouldReturnObjectParentObject

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Test
public void shouldReturnObjectParentObject () throws IOException
{
	Container container = account.getContainer("x").create() ;
	
	StoredObject parentObject = container.getObject("parent") ;
	parentObject.uploadObject(new UploadInstructions (new byte[] {}).setContentType(SwiftUtils.directoryContentType)) ;
	
	StoredObject childObject = container.getObject("parent" + SwiftUtils.separator + "object") ;
	childObject.uploadObject(new byte[] {'a', 'b', 'c'}) ;

	DifferencesFinder.RemoteItem ri = new DifferencesFinder.RemoteItem (childObject) ;
	StoredObject parent = DifferencesFinder.getParentObject(container, ri) ;
	
	assertTrue (parent.exists()) ;
	assertTrue (parent.getName().equals(parentObject.getName())) ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:18,代码来源:DifferencesFinderTest.java


示例17: shouldDownloadStoredObject

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Test
  public void shouldDownloadStoredObject() {
      Container create = account.getContainer("x").create();
      StoredObject object = create.getObject("y");
      object.uploadObject(new byte[8192]);
      File target = new File("./target/downloadTest.dat");
      boolean exceptionThrown = false ;
      try
      {
      	ops.downloadStoredObject(create, object, target, stopRequester, callback);
      }
      catch (IOException e) 
      {
      	exceptionThrown = true ;
}
      finally
      {
       assertTrue(target.exists());
       target.delete();
       assertFalse(exceptionThrown);
      }
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:23,代码来源:SwiftOperationsTest.java


示例18: 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


示例19: shouldStopUploadingFiles

import org.javaswift.joss.model.Container; //导入依赖的package包/类
@Test
  public void shouldStopUploadingFiles ()
  {
  	final String objName = "testObject.dat" ;
      Container container = account.getContainer("x").create();
      try 
      {
      	SwiftOperationStopRequesterImpl stopReq = new SwiftOperationStopRequesterImpl () ;
      	stopReq.stop();
	ops.uploadFiles(container, null, new File [] {TestUtils.getTestFile(tmpFolder, objName, 4096)}, false, stopReq, callback);
	Mockito.verify(callback, Mockito.times(1)).onStopped();
} 
      catch (IOException e) 
{
      	logger.error ("Error occurred in shouldStopUploadingFiles", e) ;
      	assertFalse(true) ;
}  
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:19,代码来源:SwiftOperationsTest.java


示例20: onOpenInBrowserStoredObject

import org.javaswift.joss.model.Container; //导入依赖的package包/类
protected void onOpenInBrowserStoredObject() {
    Container container = getSelectedContainer();
    List<StoredObject> objects = getSelectedStoredObjects();
    if (container.isPublic()) 
    {
        for (StoredObject obj : objects) 
        {
            String publicURL = obj.getPublicURL();
            if (Desktop.isDesktopSupported()) {
                try 
                {
                    Desktop.getDesktop().browse(new URI(publicURL));
                } 
                catch (Exception e) 
                {
                	logger.error("Error occurred while opening the browser.", e);
                }
            }
        }
    }
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:22,代码来源:MainPanel.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FinalizeCommandProto类代码示例发布时间:2022-05-22
下一篇:
Java EditorHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap