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

Java GetOptions类代码示例

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

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



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

示例1: conditionalGetSatisified

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
private Response conditionalGetSatisified(GetOptions options, String etag, Date mtime) {
    if (options.getIfMatch() != null && !eTagsEqual(etag, options.getIfMatch())) {
        return Response.status(Response.Status.PRECONDITION_FAILED).build();
    }

    if (options.getIfNoneMatch() != null && eTagsEqual(etag, options.getIfNoneMatch())) {
        return Response.notModified().build();
    }

    if (options.getIfModifiedSince() != null && mtime.compareTo(options.getIfModifiedSince()) <= 0) {
        return Response.notModified().build();
    }

    if (options.getIfUnmodifiedSince() != null && mtime.compareTo(options.getIfUnmodifiedSince()) > 0) {
        return Response.status(Response.Status.PRECONDITION_FAILED).build();
    }

    return null;
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:20,代码来源:ObjectResource.java


示例2: getBlob

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Override
@Nullable
public Blob getBlob(String container, String name, GetOptions options) {
    Blob blob = super.getBlob(container, name, options);
    if (blob == null) {
        return null;
    }

    byte[] array;
    try (InputStream is = blob.getPayload().openStream()) {
        array = ByteStreams.toByteArray(is);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    long length = Longs.fromByteArray(array);
    ByteSourcePayload payload = new ByteSourcePayload(
            new NullByteSource().slice(0, length));
    payload.setContentMetadata(blob.getPayload().getContentMetadata());
    payload.getContentMetadata().setContentLength(length);
    payload.getContentMetadata().setContentMD5((HashCode) null);
    blob.setPayload(payload);
    return blob;
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:25,代码来源:NullBlobStore.java


示例3: testUnbounce

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Test
public void testUnbounce() throws Exception {
    String blobName = "blob";
    Blob blob = UtilsTest.makeBlob(farBlobStore, blobName);
    nearBlobStore.putBlob(containerName, blob);
    Utils.copyBlobAndCreateBounceLink(nearBlobStore, farBlobStore,
            containerName, blobName);

    assertThat(nearBlobStore.blobExists(containerName, blobName)).isTrue();
    assertThat(farBlobStore.blobExists(containerName, blobName)).isTrue();
    Blob nearBlob = nearBlobStore.getBlob(containerName, blobName);
    assertThat(BounceLink.isLink(nearBlob.getMetadata())).isTrue();

    policy.getBlob(containerName, blobName, GetOptions.NONE);
    assertThat(nearBlobStore.blobExists(containerName, blobName)).isTrue();
    assertThat(farBlobStore.blobExists(containerName, blobName)).isTrue();
    nearBlob = nearBlobStore.getBlob(containerName, blobName);
    assertThat(BounceLink.isLink(nearBlob.getMetadata())).isFalse();
    Blob farBlob = farBlobStore.getBlob(containerName, blobName);
    UtilsTest.assertEqualBlobs(nearBlob, blob);
    UtilsTest.assertEqualBlobs(farBlob, blob);
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:23,代码来源:BounceTest.java


示例4: getBlob

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Override
public Blob getBlob(String container, String name, GetOptions options) {
    GridFSIdentifier identifier = parseGridFSIdentifier(container);
    if (!identifier.storeExists(mongo)) {
        throw new ContainerNotFoundException(container, "could not find expected collections in database");
    }
    // TODO: support get options
    if (options != null && (
            options.getIfMatch() != null || options.getIfNoneMatch() != null ||
                    options.getIfModifiedSince() != null || options.getIfUnmodifiedSince() != null ||
                    !options.getRanges().isEmpty()
    )) {
        throw new IllegalArgumentException("Get options are not currently supported by this provider");
    }
    GridFS gridFS = identifier.connect(mongo); // TODO: cache
    GridFSDBFile dbFile = gridFS.findOne(name);
    if (dbFile == null) {
        return null;
    }
    Blob blob = dbFileToBlob.apply(dbFile);
    blob.getMetadata().setContainer(container);
    return blob;
}
 
开发者ID:mhurne,项目名称:jclouds-gridfs-blobstore,代码行数:24,代码来源:GridFSBlobStore.java


示例5: testClassKeyBuilderCreatesAKeyWithShiftedIntegerHashCodesIntoASingleLong

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Test
public void testClassKeyBuilderCreatesAKeyWithShiftedIntegerHashCodesIntoASingleLong() {
	String fileAttributeValue = Long.toBinaryString(GetOptionFileAttribute.class.hashCode());
	String getOptionsValue = Long.toBinaryString(GetOptions.class.hashCode());
	String result = Long.toBinaryString(FileAttributeLookupMap.classKeyBuilder(GetOptionFileAttribute.class, GetOptions.class));
	Assert.assertTrue(result.startsWith(fileAttributeValue));
	Assert.assertTrue(result.endsWith(getOptionsValue));
	//System.out.println(result);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:10,代码来源:FileAttributeLookupMapTest.java


示例6: getBlob

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Override
public Blob getBlob(String container, String name, GetOptions options) {
   OSS oss = api.getOSSClient(OSSApi.DEFAULT_REGION);
   String region = oss.getBucketLocation(container);
   oss = api.getOSSClient(region);
   GetObjectRequest req = new GetObjectRequest(container, name);
   OSSObject object = oss.getObject(req);
   String filename = object.getKey();
   return blobBuilder(container)
         .name(filename)
         .payload(object.getObjectContent())
         .build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:14,代码来源:OSSBlobStore.java


示例7: addRanges

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
private static GetOptions addRanges(GetOptions options, List<Pair<Long, Long>> ranges) {
    ranges.forEach(rangeSpec -> {
        if (rangeSpec.getFirst() == null) {
            if (rangeSpec.getSecond() == 0) {
                throw new ClientErrorException(Response.Status.REQUESTED_RANGE_NOT_SATISFIABLE);
            }
            options.tail(rangeSpec.getSecond());
        } else if (rangeSpec.getSecond() == null) {
            options.startAt(rangeSpec.getFirst());
        } else {
            options.range(rangeSpec.getFirst(), rangeSpec.getSecond());
        }
    });
    return options;
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:16,代码来源:ObjectResource.java


示例8: getDloObject

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
private Response getDloObject(BlobStore blobStore, BlobMetadata meta, GetOptions options, List<Pair<Long, Long>> ranges) {
    String manifest = meta.getUserMetadata().get(DYNAMIC_OBJECT_MANIFEST);
    Pair<String, String> param = validateCopyParam(manifest);
    String dloContainer = param.getFirst();
    String objectsPrefix = param.getSecond();
    List<ManifestEntry> segments = getDLOSegments(blobStore, dloContainer, objectsPrefix);
    Pair<Long, String> sizeAndEtag = getManifestTotalSizeAndETag(segments);

    Response cond = conditionalGetSatisified(options,
            sizeAndEtag.getSecond(), meta.getLastModified());
    if (cond != null) {
        return cond;
    }

    logger.debug("getting DLO object: {}", sizeAndEtag);

    InputStream combined = new ManifestObjectInputStream(blobStore, segments);
    long size = sizeAndEtag.getFirst();
    if (ranges != null) {
        combined = new HttpRangeInputStream(combined, sizeAndEtag.getFirst(), ranges);
        size = getTotalRangesLength(ranges, size);
        logger.debug("range request for {} bytes", size);
    }
    return addObjectHeaders(Response.ok(combined), meta,
            Optional.of(overwriteSizeAndETag(size, sizeAndEtag.getSecond())))
            .build();
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:28,代码来源:ObjectResource.java


示例9: openNextStream

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
void openNextStream() throws IOException {
    if (currentStream != null) {
        currentResp.close();
        currentResp = null;
        currentStream = null;
        availableBytes = 0;
    }
    if (!entries.hasNext()) {
        return;
    }

    ManifestEntry entry = entries.next();
    logger.info("opening {}/{}", entry.container, entry.object);
    Response resp = getObject(blobStore, entry.container, entry.object, GetOptions.NONE, null, false);
    if (!resp.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) {
        resp.close();
        throw new ClientErrorException(Response.Status.CONFLICT);
    }
    availableBytes = Long.parseLong(resp.getHeaderString(HttpHeaders.CONTENT_LENGTH));
    currentStream = (InputStream) resp.getEntity();
    currentResp = resp;
    String etag = resp.getHeaderString(HttpHeaders.ETAG);

    if (entry.size_bytes != availableBytes || !eTagsEqual(entry.etag, etag)) {
        logger.error("409 conflict: {}/{} {} {} != {} {}",
                entry.container, entry.object, entry.etag, entry.size_bytes,
                etag, availableBytes);
        throw new ClientErrorException(Response.Status.CONFLICT);
    }
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:31,代码来源:ObjectResource.java


示例10: getBlob

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Override
public Blob getBlob(String containerName, String blobName, GetOptions options) {
    Date startTime = new Date();
    Blob blob = delegate().getBlob(containerName, blobName, options);

    if (blob != null) {
        app.getBounceStats().logOperation(HttpMethod.GET, getProviderId(), containerName, blobName,
                blob.getMetadata().getSize(), startTime.getTime());
    }
    return blob;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:12,代码来源:LoggingBlobStore.java


示例11: getBlob

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Override
public Blob getBlob(String container, String blobName, GetOptions options) {
    Blob blob = super.getBlob(container, blobName, options);
    if (blob != null) {
        updateLRU(container, blobName, blob.getMetadata().getSize());
    }
    return blob;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:9,代码来源:LRUStoragePolicy.java


示例12: maybeConditionalGet

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
private GetOptions maybeConditionalGet(String container, String blobName, GetOptions options) {
    if (options.getIfMatch() != null || options.getIfNoneMatch() != null ||
            options.getIfModifiedSince() != null || options.getIfUnmodifiedSince() != null) {

        BlobMetadata meta = blobMetadata(container, blobName);
        HttpResponseException ex = null;

        if (options.getIfMatch() != null && !eTagsEqual(options.getIfMatch(), meta.getETag())) {
            throw new ClientErrorException(Response.Status.PRECONDITION_FAILED);
        }

        if (options.getIfNoneMatch() != null && eTagsEqual(options.getIfNoneMatch(), meta.getETag())) {
            throw new WebApplicationException(Response.Status.NOT_MODIFIED);
        }

        if (options.getIfModifiedSince() != null &&
                meta.getLastModified().compareTo(options.getIfModifiedSince()) <= 0) {
            throw new WebApplicationException(Response.Status.NOT_MODIFIED);
        }

        if (options.getIfUnmodifiedSince() != null &&
                meta.getLastModified().compareTo(options.getIfUnmodifiedSince()) > 0) {
            throw new ClientErrorException(Response.Status.PRECONDITION_FAILED);
        }

        return new GetOptions() {
            @Override
            public List<String> getRanges() {
                return options.getRanges();
            }
        };
    }

    return options;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:36,代码来源:WriteBackPolicy.java


示例13: getBlob

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Override
public Blob getBlob(String container, String blobName, GetOptions options) {
    for (BlobStore blobStore : getCheckedStores()) {
        Blob blob = blobStore.getBlob(container, blobName, options);
        if (blob != null) {
            return blob;
        }
    }
    return null;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:11,代码来源:MigrationPolicy.java


示例14: BlobStoreByteSource

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
public BlobStoreByteSource(BlobStore blobStore, Blob blob, GetOptions options, long size) throws IOException {
    requireNonNull(blob);
    this.blobStore = requireNonNull(blobStore);
    this.container = blob.getMetadata().getContainer();
    this.blobName = blob.getMetadata().getName();
    this.size = size;
    this.options = requireNonNull(options);
    this.payload = blob.getPayload();
    this.isStreamRepeatable = blob.getPayload().isRepeatable();
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:11,代码来源:BlobStoreByteSource.java


示例15: slice

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Override
public ByteSource slice(long offset, long length) {
    long remaining = Math.min(size - offset, length);
    GetOptions getOptions = new GetOptions().range(offset, offset + remaining - 1);

    try {
        return new BlobStoreByteSource(blobStore,
                blobStore.getBlob(container, blobName, getOptions), getOptions, remaining);
    } catch (IOException e) {
        throw propagate(e);
    }
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:13,代码来源:BlobStoreByteSource.java


示例16: GetOptionFileAttribute

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
public GetOptionFileAttribute(GetOptions getOptions) {
	this.getOptions = getOptions;
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:4,代码来源:GetOptionFileAttribute.java


示例17: value

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Override
public GetOptions value() {
	return getOptions;
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:5,代码来源:GetOptionFileAttribute.java


示例18: getBlob

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
/**
 * Applies the {@link GetOptionFileAttribute} if they exist to the {@link BlobStore#getBlob(String, String, GetOptions)} method.
 */
@Override
public Blob getBlob(BlobStoreContext blobStoreContext, CloudPath path, GetOptionFileAttribute getOption) {
	GetOptions getOptions = getOption == null ? GetOptions.NONE : getOption.value();
	return blobStoreContext.getBlobStore().getBlob(path.getContainerName(), path.getPathName(), getOptions);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:9,代码来源:DefaultCloudFileChannelTransport.java


示例19: testGetFileAttributeOfType

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Test
public void testGetFileAttributeOfType() {
	CloudPermissionFileAttribute<AccessControlList> permAcl =
			new CloudPermissionFileAttribute<AccessControlList>(new AccessControlList());
	CloudPermissionFileAttribute<PosixFilePermission> permPosix =
			new CloudPermissionFileAttribute<PosixFilePermission>(PosixFilePermission.GROUP_WRITE);
	ContentTypeFileAttribute contentTypeGif = new ContentTypeFileAttribute(MediaType.GIF);
	GetOptionFileAttribute getOption = new GetOptionFileAttribute(GetOptions.NONE);
	PutOptionFileAttribute putOption = new PutOptionFileAttribute(PutOptions.NONE);
	FileAttributeLookupMap lookupMap = new FileAttributeLookupMap(
			permAcl,
			permPosix,
			contentTypeGif,
			getOption,
			putOption);

	// Test getting them explicitly by type
	Assert.assertEquals(lookupMap.toString(),
			permAcl, lookupMap.getFileAttributeOfType(CloudPermissionFileAttribute.class, AccessControlList.class));
	Assert.assertEquals(lookupMap.toString(),
			permPosix, lookupMap.getFileAttributeOfType(CloudPermissionFileAttribute.class, PosixFilePermission.class));
	Assert.assertEquals(lookupMap.toString(),
			contentTypeGif, lookupMap.getFileAttributeOfType(ContentTypeFileAttribute.class, MediaType.class));
	Assert.assertEquals(lookupMap.toString(),
			getOption, lookupMap.getFileAttributeOfType(GetOptionFileAttribute.class, GetOptions.class));
	Assert.assertEquals(lookupMap.toString(),
			putOption, lookupMap.getFileAttributeOfType(PutOptionFileAttribute.class, ImmutablePutOptions.class));
	
	// Test getting all of the attributes of a type
	Collection<CloudPermissionFileAttribute> permAttributes =
			lookupMap.getFileAttributesOfType(CloudPermissionFileAttribute.class);
	Assert.assertEquals(2, permAttributes.size());
	Assert.assertTrue(permAttributes.contains(permAcl));
	Assert.assertTrue(permAttributes.contains(permPosix));
	
	Collection<ContentTypeFileAttribute> contentTypeAttributes =
			lookupMap.getFileAttributesOfType(ContentTypeFileAttribute.class);
	Assert.assertEquals(1, contentTypeAttributes.size());
	Assert.assertEquals(contentTypeGif, contentTypeAttributes.iterator().next());

	Collection<GetOptionFileAttribute> getOptionAttributes =
			lookupMap.getFileAttributesOfType(GetOptionFileAttribute.class);
	Assert.assertEquals(1, getOptionAttributes.size());
	Assert.assertEquals(getOption, getOptionAttributes.iterator().next());

	Collection<PutOptionFileAttribute> putOptionAttributes =
			lookupMap.getFileAttributesOfType(PutOptionFileAttribute.class);
	Assert.assertEquals(1, putOptionAttributes.size());
	Assert.assertEquals(putOption, putOptionAttributes.iterator().next());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:51,代码来源:FileAttributeLookupMapTest.java


示例20: testNewByteChannelCanOpenAFileForReadingIfTheUserHasAccessRights

import org.jclouds.blobstore.options.GetOptions; //导入依赖的package包/类
@Test
public void testNewByteChannelCanOpenAFileForReadingIfTheUserHasAccessRights() throws IOException {
	CloudPath path = context.mock(CloudPath.class, "path");
	BlobStoreContext blobStoreContext = context.mock(BlobStoreContext.class);
	BlobStore blobStore = context.mock(BlobStore.class);
	CloudHostSecurityManager securityManager = context.mock(CloudHostSecurityManager.class);
	UserGroupLookupService<?> lookupService = context.mock(UserGroupLookupService.class);
	UserPrincipal currentUser = context.mock(UserPrincipal.class);
	EnumSet<AclEntryPermission> pathPerms = EnumSet.of(AclEntryPermission.READ_DATA);
	CloudAclFileAttributes aclFileAttributes = context.mock(CloudAclFileAttributes.class, "aclFileAttributes");
	CloudAclEntrySet aclEntrySet = createAclEntrySetMock("aclEntrySet");

	context.checking(new Expectations() {{
		allowing(provider).readAttributes(path, CloudAclFileAttributes.class, new LinkOption[0]);
		will(returnValue(aclFileAttributes));
		
		allowing(aclFileAttributes).getAclSet();
		will(returnValue(aclEntrySet));
		
		allowing(path).getFileSystem();
		will(returnValue(fs));
		
		allowing(fs).getCloudHostConfiguration();
		will(returnValue(config));

		allowing(config).getUserGroupLookupService();
		will(returnValue(lookupService));
		
		allowing(lookupService).getCurrentUser();
		will(returnValue(currentUser));

		allowing(config).getCloudHostSecurityManager();
		will(returnValue(securityManager));

		allowing(path).getContainerName();
		will(returnValue(TEST_CONTAINER));

		allowing(path).getPathName();
		will(returnValue(TEST_PATH));

		allowing(blobStoreContext).getBlobStore();
		will(returnValue(blobStore));
		
		allowing(blobStore).directoryExists(TEST_CONTAINER, TEST_PATH);
		will(returnValue(true));
		
		allowing(path).exists();
		will(returnValue(true));

		// Path access check
		exactly(1).of(securityManager).checkAccessAllowed(aclEntrySet, currentUser, pathPerms);
		will(returnValue(true));
		
		// From within CloudFileChannel init this is invoked, this is how we can tell when the method has succeeded
		exactly(1).of(blobStore).getBlob(with(equal(TEST_CONTAINER)), with(equal(TEST_PATH)), with(any(GetOptions.class)));
		will(throwException(new NotImplementedException("It's OK to fail here")));
	}});

	try {
		impl.newByteChannel(blobStoreContext, path, Sets.newHashSet(StandardOpenOption.READ));
		Assert.fail("Did not expect success");
	} catch (NotImplementedException e) {
		// OK
	}
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:66,代码来源:DefaultCloudFileSystemImplementationTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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