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


Java Container.create方法代码示例

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


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

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

示例4: createSomeObjects

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
protected static void createSomeObjects(Account account) {
  Container container =
      account.getContainer("container-" + UUID.randomUUID().toString().toLowerCase());
  container.create();
  for (int i = 0; i < 3; i++) {
    container
        .getObject("OBJECT-" + UUID.randomUUID())
        .uploadObject(createString(4096).getBytes());
  }
}
 
开发者ID:twonote,项目名称:radosgw-admin4j,代码行数:11,代码来源:BaseTest.java

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

示例6: testOpenstackList

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
/**
 * Test openstack list.
 */
@Test
public void testOpenstackList() {

	// if no tenant name are provided joss will try to auto discover
	RunAboveConfig config = new RunAboveConfig().setErrorHandlder(new LoggerErrorHandler()).setLogin(login).setPassword(password).setMocked(true);

	Account runAboveSwift = new RunAboveBuilder(config).createSwiftManager();
	assertNotNull(runAboveSwift);

	// ensure there is at least one container
	Container container = runAboveSwift.getContainer("town1");
	container.create();
	assertTrue(container.exists());

	// now let's play into these containers and insert one obejct
	StoredObjectMock object = new StoredObjectMock(container, "someObject");
	byte[] bytes = new byte[] { 0x01, 0x02, 0x03 };
	object.uploadObject(bytes);

	// and list...
	Collection<Container> containers = runAboveSwift.list();
	for (Container currentContainer : containers) {
		LOG.info(currentContainer.getName());
		ArrayList<StoredObject> so = (ArrayList<StoredObject>) currentContainer.list();
		for (StoredObject storedObject : so) {
			LOG.info("so name ------------- ");
			LOG.info("so name getBareName " + storedObject.getBareName());
			LOG.info("so name getContentLength " + storedObject.getContentLength());
			LOG.info("so name getContentLength " + storedObject.getContentLength());
			LOG.info("so name getContentType " + storedObject.getContentType());
			LOG.info("so name getEtag " + storedObject.getEtag());
			LOG.info("so name getLastModified " + storedObject.getLastModified());
			LOG.info("so name getName " + storedObject.getName());
			LOG.info("so name getPath " + storedObject.getPath());
			LOG.info("so name getURL " + storedObject.getURL());

		}
	}
}
 
开发者ID:ovhlabs,项目名称:java-runabove,代码行数:43,代码来源:SwiftTest.java

示例7: testOpenStackWrite

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
/**
 * Test open stack write.
 */
@Test
public void testOpenStackWrite() {
	RunAboveConfig config = new RunAboveConfig().setErrorHandlder(new LoggerErrorHandler()).setLogin(login).setPassword(password).setMocked(true);

	Account runAboveSwift = new RunAboveBuilder(config).createSwiftManager();
	assertNotNull(runAboveSwift);

	// ensure there is at least one container
	Container container = runAboveSwift.getContainer("town1");
	container.create();
	assertTrue(container.exists());

	Collection<Container> containers = runAboveSwift.list();
	assertNotNull(containers);

	// lets play with the first container
	Container currentContainer = containers.iterator().next();
	assertNotNull(currentContainer);
	
	LOG.info(currentContainer.getName());
	// now let's play into these containers and insert objects and downloads and compare
	StoredObjectMock object = new StoredObjectMock(currentContainer, "someObject");
	byte[] bytes = new byte[] { 0x01, 0x02, 0x03 };
	object.uploadObject(bytes);

	object.uploadObject(uploadBytes);
	object.downloadObject(downloadedFile);
	object.delete();
	object.uploadObject(downloadedFile);
	assertTrue(Arrays.equals(uploadBytes, object.downloadObject()));

	LOG.info("Public URL: " + object.getPublicURL());

}
 
开发者ID:ovhlabs,项目名称:java-runabove,代码行数:38,代码来源:SwiftTest.java

示例8: example

import org.javaswift.joss.model.Container; //导入方法依赖的package包/类
private static void example() {
  // Create a Connection
  AccountConfig config = new AccountConfig();
  config.setUsername(username);
  config.setPassword(password);
  config.setAuthUrl(authUrl);
  config.setAuthenticationMethod(AuthenticationMethod.BASIC);
  Account account = new AccountFactory(config).createAccount();

  // Create a Container
  Container container = account.getContainer("my-new-container");
  container.create();

  // Create an Object
  StoredObject object = container.getObject("foo.txt");
  object.uploadObject(new File("src/test/resources/foo.txt"));

  // Add/Update Object Metadata
  Map<String, Object> metadata = new TreeMap<String, Object>();
  metadata.put("key", "value");
  object.setMetadata(metadata);

  // List Owned Containers
  Collection<Container> containers = account.list();
  for (Container currentContainer : containers) {
    System.out.println(currentContainer.getName());
  }

  // List a Container's Content
  Collection<StoredObject> objects = container.list();
  for (StoredObject currentObject : objects) {
    System.out.println(currentObject.getName());
  }

  // Retrieve an Object's Metadata
  Map<String, Object> returnedMetadata = object.getMetadata();
  for (String name : returnedMetadata.keySet()) {
    System.out.println("META / " + name + ": " + returnedMetadata.get(name));
  }

  // Retrieve an Object
  object.downloadObject(new File("/tmp/outfile.txt"));

  // Delete an Object
  object.delete();

  // Delete a Container
  container.delete();
}
 
开发者ID:twonote,项目名称:radosgw-admin4j,代码行数:50,代码来源:SwiftExample.java


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