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


Java StorageType类代码示例

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


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


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