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


Java Container.getObject方法代码示例

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


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

示例4: shouldStopDeletingDirectory

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
@Test
  public void shouldStopDeletingDirectory ()
  {
  	final String dirName = "dir" ;
      Container container = account.getContainer("x").create();
      
  	ops.createDirectory(container, null, dirName, callback);
  	
  	StoredObject obj = container.getObject(dirName) ;
  	assertTrue (obj.exists()) ;
  	
  	SwiftOperationStopRequesterImpl stopReq = new SwiftOperationStopRequesterImpl () ;
  	stopReq.stop();
ops.deleteDirectory(container, obj, stopReq, callback);
Mockito.verify(callback, Mockito.times(1)).onStopped();
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:17,代码来源:SwiftOperationsTest.java

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

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

示例7: setCorrectSize

import org.javaswift.joss.model.Container; //导入方法依赖的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);
    }
  }
}
 
开发者ID:SparkTC,项目名称:stocator,代码行数:25,代码来源:SwiftAPIClient.java

示例8: getParentObject

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
public static StoredObject getParentObject (Container container, ComparisonItem item)
{
	if (container == null || item == null)
		throw new IllegalArgumentException () ;
	String name = item.getRemoteFullName() ;
	int index = name.lastIndexOf(SwiftUtils.separator) ;
	if (index < 0)
		return null ;
	return container.getObject(name.substring(0, index)) ;		
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:11,代码来源:DifferencesFinder.java

示例9: shouldStopFindingDifferences

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
@Test
  public void shouldStopFindingDifferences ()
  {
      Container container = account.getContainer("x").create() ;
      final String directoryName = "directory" ;
try 
{
       File folder = TestUtils.getTestDirectoryWithFiles (tmpFolder, directoryName, "file", 10) ;
       ops.uploadDirectory(container, null, folder, true, stopRequester, callback);
   	
       StoredObject remote = container.getObject(directoryName) ;
       assertTrue (remote.exists ()) ;
       
   	SwiftOperationStopRequesterImpl stopReq = new SwiftOperationStopRequesterImpl () ;
   	stopReq.stop();
   	
   	@SuppressWarnings("unchecked")
   	ResultCallback<Collection<Pair<? extends ComparisonItem, ? extends ComparisonItem> > > resultCallback 
   	 	= (ResultCallback<Collection<Pair<? extends ComparisonItem, ? extends ComparisonItem> > >)Mockito.mock(ResultCallback.class) ;
   	
	ops.findDifferences(container, remote, folder, resultCallback, stopReq, callback);
	
	Mockito.verify(callback, Mockito.times(1)).onStopped();
} 
catch (IOException e) {
      	logger.error ("Error occurred in shouldStopFindingDifferences", e) ;
      	assertFalse(true) ;
}
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:30,代码来源:SwiftOperationsTest.java

示例10: DeleteObject

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
public static void DeleteObject(String username,String passwod,String dataNode, String container, String key)throws Exception
{
	
	Account client= ViPRSwiftClient(username, passwod, dataNode);
	Container myContainer=client.getContainer(container);
	StoredObject object = myContainer.getObject(key);
    object.delete();
}
 
开发者ID:thecodeteam,项目名称:VStriker,代码行数:9,代码来源:swiftapi.java

示例11: createStoredObjects

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
/**
   * {@inheritDoc}.
   * @throws IOException 
   */
  @Override
  public synchronized void createStoredObjects(Container container, File[] selectedFiles, StopRequester stopRequester, SwiftCallback callback) throws IOException {
  	
  	CheckAccount () ;
  	
int totalFiles = selectedFiles.length ;
int currentUplodedFilesCount = 0 ;
ProgressInformation progInfo = new ProgressInformation (callback, false) ;

List<StoredObject> newObjects = new ArrayList<> () ;

      for (File selected : selectedFiles) {
      	
      	if (!keepGoing (stopRequester, callback))
      		break ;
      	
      	++currentUplodedFilesCount ;
      	
          if (selected.isFile() && selected.exists()) {
          	                
		totalProgress (currentUplodedFilesCount, totalFiles, Paths.get(selected.getPath()), progInfo, true) ;

              StoredObject obj = container.getObject(selected.getName());
              uploadObject(obj, selected, progInfo, callback) ;
              
              newObjects.add(obj) ;
          }
      }
  	//reloadContainer(container, callback);
  	addedObjectToContainer(container, newObjects, callback);
      callback.onNumberOfCalls(account.getNumberOfCalls());
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:37,代码来源:SwiftOperationsImpl.java

示例12: ReadObject

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
public static InputStream ReadObject(String username,String passwod,String dataNode, String container, String key)throws Exception
{
	
	Account client= ViPRSwiftClient(username, passwod, dataNode);
	Container myContainer=client.getContainer(container);
	StoredObject object = myContainer.getObject(key);
    return object.downloadObjectAsInputStream();

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

示例13: shouldPurgeContainer

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
@Test
public void shouldPurgeContainer() {
    Container create = account.getContainer("x").create();
    StoredObject object = create.getObject("y");
    object.uploadObject(new byte[8192]);
    //
    ops.purgeContainer(create, stopRequester, callback);
    Mockito.verify(callback, Mockito.atLeastOnce()).onUpdateContainers(Mockito.anyListOf(Container.class));
    assertFalse(create.exists());
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:11,代码来源:SwiftOperationsTest.java

示例14: shouldStopDownloadingDirectory

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
@Test
  public void shouldStopDownloadingDirectory ()
  {
  	final String directoryName = "directory" ;
  	
      Container container = account.getContainer("x").create();       
      
      ops.createDirectory(container, null, directoryName, callback);
      StoredObject objectDir = container.getObject(directoryName);
      assertTrue (objectDir.exists()) ;
      
      StoredObject object = container.getObject(directoryName + SwiftUtils.separator + "y");
      object.uploadObject(new byte[100]);
      assertTrue (object.exists()) ;
      
  	SwiftOperationStopRequesterImpl stopReq = new SwiftOperationStopRequesterImpl () ;
  	stopReq.stop();
  	
  	try 
  	{	
	ops.downloadStoredObject(container, objectDir, tmpFolder.newFolder(), stopReq, callback);
	Mockito.verify(callback, Mockito.times(1)).onStopped();
} 
  	catch (IOException e) 
  	{
      	logger.error ("Error occurred in shouldStopDownloadingDirectory", e) ;
      	assertFalse(true) ;
}	
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:30,代码来源:SwiftOperationsTest.java

示例15: shouldFailToCompareFiles

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test(expected = IllegalArgumentException.class)
   public void shouldFailToCompareFiles() throws IOException 
   {
       Container container = account.getContainer("x").create();  
       StoredObject remote = container.getObject("remote");
       
       ops.findDifferences(container, remote, tmpFolder.newFile("locale"), Mockito.mock(ResultCallback.class) , stopRequester, callback) ;
   }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:10,代码来源:SwiftOperationsTest.java


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