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

Java StorageType类代码示例

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

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



StorageType类属于org.jclouds.blobstore.domain包,在下文中一共展示了StorageType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: registerAddress

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
private void registerAddress(String cluster, InetSocketAddress address) throws HekateException {
    try (BlobStoreContext ctx = createContext()) {
        BlobStore store = ctx.getBlobStore();

        String file = cluster + '/' + AddressUtils.toFileName(address);

        try {
            if (!store.blobExists(container, file)) {
                Blob blob = store.blobBuilder(file)
                    .type(StorageType.BLOB)
                    .payload(new byte[]{1})
                    .build();

                store.putBlob(container, blob);

                if (log.isInfoEnabled()) {
                    log.info("Registered address to the cloud store [container={}, file={}]", container, file);
                }
            }
        } catch (ResourceNotFoundException | HttpResponseException e) {
            throw new HekateException("Failed to register the seed node address to the cloud store "
                + "[container=" + container + ", file=" + file + ']', e);
        }
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:26,代码来源:CloudStoreSeedNodeProvider.java


示例2: CloudBasicFileAttributes

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
/**
 * Placeholder indicates a directory
 */
public CloudBasicFileAttributes() {
	lastModified = FileTime.from(0L, TimeUnit.MILLISECONDS);
	created = FileTime.from(0L, TimeUnit.MILLISECONDS);
	key = null;
	storageType = StorageType.FOLDER;
	physicalLocation = null;
	uri = null;
	size = null;
	eTag = null;
	userMetadata = null;
	contentDisposition = null;
	contentEncoding = null;
	contentLanguage = null;
	contentMD5 = null;
	contentType = null;
	expires = null;
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:21,代码来源:CloudBasicFileAttributes.java


示例3: directoryContentsToString

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
public final String directoryContentsToString(String path) {
	BlobStore blobStore = blobStoreContext.getBlobStore();
	String marker = null;
	ListContainerOptions opts = new ListContainerOptions().recursive();
	if (StringUtils.isNotBlank(path)) {
		opts.inDirectory(path);
	}

	StringBuilder ret = new StringBuilder((path == null ? "Container '" : "Directory '" + path)).append("' contains: [ ");
	do {
		if (marker != null) {
			opts.afterMarker(marker);
		}

		PageSet<? extends StorageMetadata> page = blobStore.list(CONTAINER_NAME, opts);
		page.forEach(
				m -> ret.append('{').append(m.getName()).append(" (")
						.append(m.getType() == StorageType.BLOB ? "FILE" : "DIRECTORY").append(")} "));
		marker = page.getNextMarker();
	} while (marker != null);
	
	return ret.append(']').toString();
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:24,代码来源:AbstractJCloudsIntegrationTest.java


示例4: mockStorageTypeAttributes

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
protected CloudBasicFileAttributes mockStorageTypeAttributes(CloudFileSystem fs, final StorageType storageType, final Path path) throws IOException {
	final FileSystemProvider provider = context.mock(FileSystemProvider.class);
	final CloudBasicFileAttributes basicAttributes = storageType == null ? null : context.mock(CloudBasicFileAttributes.class);
	
	context.checking(new Expectations() {{
		allowing(fs).provider();
		will(returnValue(provider));

		if (basicAttributes == null) {
			exactly(1).of(provider).readAttributes(path, CloudBasicFileAttributes.class);
			will(throwException(new FileNotFoundException()));
		} else {
			exactly(1).of(provider).readAttributes(path, CloudBasicFileAttributes.class);
			will(returnValue(basicAttributes));

			allowing(basicAttributes).getStorageType();
			will(returnValue(storageType));
		}
	}});

	return basicAttributes;
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:23,代码来源:CloudFileTest.java


示例5: testLastModifiedReturnsAValueForAFile

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Test
public void testLastModifiedReturnsAValueForAFile() throws IOException {
	final String container = "blah";
	final String filePath = "fah/wah/woo/hah/plank.txt";
	long lastModified = 2378222L;
	final CloudFileSystem fs = context.mock(CloudFileSystem.class);
	CloudFile cf = new CloudFile(new CloudPath(fs, true, "/" + container + "/" + filePath));
	CloudBasicFileAttributes attributes = mockStorageTypeAttributes(fs, StorageType.BLOB, cf.toPath());
	final FileTime lastModifiedTime = FileTime.fromMillis(lastModified);

	context.checking(new Expectations() {{
		exactly(1).of(attributes).lastModifiedTime();
		will(returnValue(lastModifiedTime));
	}});

	Assert.assertEquals(lastModified, cf.lastModified());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:18,代码来源:CloudFileTest.java


示例6: testLengthReturnsAValueForAFile

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Test
public void testLengthReturnsAValueForAFile() throws IOException {
	final String container = "blah";
	final String filePath = "fah/wah/woo/hah/plank.txt";
	long length = 2378L;
	final CloudFileSystem fs = context.mock(CloudFileSystem.class);
	CloudFile cf = new CloudFile(new CloudPath(fs, true, "/" + container + "/" + filePath));
	CloudBasicFileAttributes attributes = mockStorageTypeAttributes(fs, StorageType.BLOB, cf.toPath());

	context.checking(new Expectations() {{
		exactly(1).of(attributes).size();
		will(returnValue(length));
	}});

	Assert.assertEquals(length, cf.length());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:17,代码来源:CloudFileTest.java


示例7: computeNext

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Override
protected StorageMetadata computeNext() {
    while (true) {
        if (!iterator.hasNext()) {
            if (marker == null) {
                return endOfData();
            }
            advance();
            continue;
        }

        StorageMetadata metadata = iterator.next();
        // filter out folders with atmos and filesystem providers
        // accept metadata == null for Google Cloud Storage folders
        if (metadata == null || metadata.getType() == StorageType.RELATIVE_PATH) {
            continue;
        }
        return metadata;
    }
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:21,代码来源:Utils.java


示例8: computeNext

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Override
protected StorageMetadata computeNext() {
    while (true) {
        if (!iterator.hasNext()) {
            if (marker == null) {
                return endOfData();
            }
            advance();
            continue;
        }
        StorageMetadata metadata = iterator.next();
        // filter out folders with atmos and filesystem providers
        if (metadata.getType() == StorageType.RELATIVE_PATH) {
            continue;
        }
        return metadata;
    }
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:19,代码来源:Utils.java


示例9: apply

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Override
public OrionStorageMetadata apply(OrionChildMetadata childMetadata) {
	final OrionStorageMetadata storageMetadata = Preconditions.checkNotNull(this.getInjector().getInstance(OrionStorageMetadata.class), "storageMetadata is null");
	storageMetadata.setLocation(this.location);
	storageMetadata.setName(OrionUtils.createOriginalNameFromLocation(getUserWorkspace(), childMetadata.getLocation()));
	if (OrionUtils.isContainerFromPath(childMetadata.getLocation())) {
		storageMetadata.setType(StorageType.CONTAINER);
	} else if (childMetadata.isDirectory()) {
		storageMetadata.setType(StorageType.FOLDER);
	} else if (!childMetadata.isDirectory()) {
		storageMetadata.setType(StorageType.BLOB);
	}
	
	storageMetadata.setLastModified(new Date(childMetadata.getLocalTimeStamp()));
	return storageMetadata;
}
 
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:17,代码来源:ChildMetadataToStorageMetadata.java


示例10: apply

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Override
public MutableBlobMetadata apply(BlobProperties from) {
	if (from == null) {
		return null;
	}
	MutableBlobMetadata to = new MutableBlobMetadataImpl();
	HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata());
	to.setUserMetadata(from.getMetadata());
	to.setETag(from.getETag());
	to.setLastModified(from.getLastModified());
	to.setName(from.getName());
	to.setContainer(from.getContainer());
	to.setUri(from.getUrl());

	if (from.getType() == org.jclouds.orion.domain.BlobType.FOLDER_BLOB) {
		to.setType(StorageType.FOLDER);
	} else if (from.getType() == org.jclouds.orion.domain.BlobType.FILE_BLOB) {
		to.setType(StorageType.BLOB);
	} else if (from.getType() == org.jclouds.orion.domain.BlobType.PROJECT_BLOB) {
		to.setType(StorageType.CONTAINER);
	} else {
		to.setType(null);
	}
	return to;
}
 
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:26,代码来源:BlobPropertiesToBlobMetadata.java


示例11: getBlobMetadata

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Test
protected void getBlobMetadata() throws Exception {
	
	this.blobStore.createContainerInLocation(null, this.container);
	
	Blob blob = this.blobStore.blobBuilder(this.blobName).type(StorageType.FOLDER).build();
	blob.setPayload(this.payload);
	
	this.blobStore.putBlob(this.container, blob);
	blob = this.blobStore.blobBuilder(this.blobName).type(StorageType.FOLDER).build();
	blob.setPayload(this.payload);
	blob.getMetadata().getUserMetadata().put("test", "test");
	this.blobStore.putBlob(this.container, blob);
	
	final BlobMetadata metadata = this.blobStore.blobMetadata(this.container, this.blobName);
	Assert.assertEquals(metadata.getUserMetadata().containsKey("test"), true, "user metadata is not there");
	
}
 
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:19,代码来源:OrionBlobStoreLiveTests.java


示例12: isStorageType

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
boolean isStorageType(CloudBasicFileAttributes readAttributes, EnumSet<StorageType> storageTypes) {
	// This path doesn't exist in the FS
	if (readAttributes == null) {
		return false;
	}

	StorageType storageType = readAttributes.getStorageType();
	return readAttributes == null || storageType == null? false :
		storageTypes.contains(storageType);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:11,代码来源:CloudFile.java


示例13: testIsDirectoryReturnsTrueForAContainer

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Test
public void testIsDirectoryReturnsTrueForAContainer() throws IOException {
	final String container = "blah";
	final CloudFileSystem fs = context.mock(CloudFileSystem.class);
	CloudFile cf = new CloudFile(new CloudPath(fs, true, "/" + container));
	mockStorageTypeAttributes(fs, StorageType.CONTAINER, cf.toPath());
	Assert.assertTrue(cf.isDirectory());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:9,代码来源:CloudFileTest.java


示例14: testIsDirectoryReturnsTrueForADirectoryStorageType

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Test
public void testIsDirectoryReturnsTrueForADirectoryStorageType() throws IOException {
	final String container = "blah";
	final String filePath = "fah/wah/woo/hah";
	final CloudFileSystem fs = context.mock(CloudFileSystem.class);
	final CloudFile cf = new CloudFile(new CloudPath(fs, true, "/" + container + "/" + filePath));
	mockStorageTypeAttributes(fs, StorageType.FOLDER, cf.toPath());
	Assert.assertTrue(cf.isDirectory());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:10,代码来源:CloudFileTest.java


示例15: testIsDirectoryReturnsFalseForAFileStorageType

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Test
public void testIsDirectoryReturnsFalseForAFileStorageType() throws IOException {
	final String container = "blah";
	final String filePath = "fah/wah/woo/hah";
	final CloudFileSystem fs = context.mock(CloudFileSystem.class);
	final CloudFile cf = new CloudFile(new CloudPath(fs, true, "/" + container + "/" + filePath));
	mockStorageTypeAttributes(fs, StorageType.BLOB, cf.toPath());
	Assert.assertFalse(cf.isDirectory());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:10,代码来源:CloudFileTest.java


示例16: testIsFileReturnsFalseForAContainer

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Test
public void testIsFileReturnsFalseForAContainer() throws IOException {
	final String container = "blah";
	final CloudFileSystem fs = context.mock(CloudFileSystem.class);
	CloudFile cf = new CloudFile(new CloudPath(fs, true, "/" + container));
	mockStorageTypeAttributes(fs, StorageType.FOLDER, cf.toPath());
	Assert.assertFalse(cf.isFile());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:9,代码来源:CloudFileTest.java


示例17: testIsFileReturnsFalseForADirectoryStorageType

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Test
public void testIsFileReturnsFalseForADirectoryStorageType() throws IOException {
	final String container = "blah";
	final String filePath = "fah/wah/woo/hah";
	final CloudFileSystem fs = context.mock(CloudFileSystem.class);
	final CloudFile cf = new CloudFile(new CloudPath(fs, true, "/" + container + "/" + filePath));
	mockStorageTypeAttributes(fs, StorageType.FOLDER, cf.toPath());
	Assert.assertFalse(cf.isFile());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:10,代码来源:CloudFileTest.java


示例18: testIsFileReturnsTrueForABlobStorageType

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Test
public void testIsFileReturnsTrueForABlobStorageType() throws IOException {
	final String container = "blah";
	final String filePath = "fah/wah/woo/hah/plank.txt";
	
	final CloudFileSystem fs = context.mock(CloudFileSystem.class);
	final CloudFile cf = new CloudFile(new CloudPath(fs, true, "/" + container + "/" + filePath));
	mockStorageTypeAttributes(fs, StorageType.BLOB, cf.toPath());
	Assert.assertTrue(cf.isFile());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:11,代码来源:CloudFileTest.java


示例19: list

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Override
public PageSet<? extends StorageMetadata> list() {
   OSS oss = api.getOSSClient(OSSApi.DEFAULT_REGION);
   PageSetImpl<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(
         transform(oss.listBuckets(), new Function<Bucket, StorageMetadata>() {
               @Override
               public StorageMetadata apply(Bucket input) {
                  String bucketLocation = input.getLocation();
                  Location location = new LocationBuilder()
                        .id(bucketLocation)
                        .scope(LocationScope.REGION)
                        .description(bucketLocation)
                        .build();
                  StorageMetadata storageMetadata = new StorageMetadataImpl(
                        StorageType.CONTAINER,
                        input.getName(),
                        input.getName(),
                        location,
                        null,
                        null,
                        input.getCreationDate(),
                        input.getCreationDate(),
                        ImmutableMap.<String, String>builder().build(),
                        0L);
                  return storageMetadata;
               }
            }), null);
   return pageSet;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:30,代码来源:OSSBlobStore.java


示例20: poll

import org.jclouds.blobstore.domain.StorageType; //导入依赖的package包/类
@Override
protected int poll() throws Exception {
    shutdownRunningTask = null;
    pendingExchanges = 0;

    Queue<Exchange> queue = new LinkedList<Exchange>();
    String directory = endpoint.getDirectory();

    ListContainerOptions opt = new ListContainerOptions();

    if (!Strings.isNullOrEmpty(directory)) {
        opt = opt.inDirectory(directory);
    }

    for (StorageMetadata md : blobStore.list(container, opt.maxResults(maxMessagesPerPoll).recursive())) {
        String blobName = md.getName();
        if (md.getType().equals(StorageType.BLOB)) {
            if (!Strings.isNullOrEmpty(blobName)) {
                InputStream body = JcloudsBlobStoreHelper.readBlob(blobStore, container, blobName);
                if (body != null) {
                    Exchange exchange = endpoint.createExchange();
                    CachedOutputStream cos = new CachedOutputStream(exchange);
                    IOHelper.copy(body, cos);
                    exchange.getIn().setBody(cos.newStreamCache());
                    exchange.setProperty(JcloudsConstants.BLOB_NAME, blobName);
                    queue.add(exchange);
                }
            }
        }
    }
    return queue.isEmpty() ? 0 : processBatch(CastUtils.cast(queue));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:JcloudsBlobStoreConsumer.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java IndexFileNameFilter类代码示例发布时间:2022-05-22
下一篇:
Java XAssignment类代码示例发布时间: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