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


Java Blob.getPayload方法代码示例

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


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

示例1: get

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
@Override
public Reader get( EntityReference entityReference )
    throws EntityStoreException
{
    Blob blob = storeContext.getBlobStore().getBlob( container, entityReference.identity().toString() );
    if( blob == null )
    {
        throw new EntityNotFoundException( entityReference );
    }
    Payload payload = blob.getPayload();
    if( payload == null )
    {
        throw new EntityNotFoundException( entityReference );
    }
    try( InputStream input = payload.openStream() )
    {
        String state = new Scanner( input, StandardCharsets.UTF_8.name() ).useDelimiter( "\\Z" ).next();
        return new StringReader( state );
    }
    catch( IOException ex )
    {
        throw new EntityStoreException( "Unable to read entity state for: " + entityReference, ex );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:25,代码来源:JCloudsEntityStoreMixin.java

示例2: readAfterCreate

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
public int readAfterCreate() throws IOException {
    int count = 0;
    for (int i = 0; i < iterations; ++i) {
        String blobName = makeBlobName();
        blobStore.putBlob(containerName, makeBlob(blobName, payload1));
        Blob getBlob = blobStoreRead.getBlob(containerName, blobName);
        if (getBlob == null) {
            ++count;
        } else {
            try (Payload payload = getBlob.getPayload();
                 InputStream is = payload.openStream()) {
                ByteStreams.copy(is, ByteStreams.nullOutputStream());
            }
        }
        blobStore.removeBlob(containerName, blobName);
    }
    return count;
}
 
开发者ID:gaul,项目名称:are-we-consistent-yet,代码行数:19,代码来源:AreWeConsistentYet.java

示例3: readAfterDelete

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
public int readAfterDelete() throws IOException {
    int count = 0;
    for (int i = 0; i < iterations; ++i) {
        String blobName = makeBlobName();
        blobStoreRead.putBlob(containerName, makeBlob(blobName, payload1));
        blobStore.removeBlob(containerName, blobName);
        Blob getBlob = blobStoreRead.getBlob(containerName, blobName);
        if (getBlob != null) {
            ++count;
            try (Payload payload = getBlob.getPayload();
                 InputStream is = payload.openStream()) {
                ByteStreams.copy(is, ByteStreams.nullOutputStream());
            }
        }
    }
    return count;
}
 
开发者ID:gaul,项目名称:are-we-consistent-yet,代码行数:18,代码来源:AreWeConsistentYet.java

示例4: readAfterOverwrite

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
public int readAfterOverwrite() throws IOException {
    int count = 0;
    for (int i = 0; i < iterations; ++i) {
        String blobName = makeBlobName();
        blobStore.putBlob(containerName, makeBlob(blobName, payload1));
        blobStore.putBlob(containerName, makeBlob(blobName, payload2));
        Blob getBlob = blobStoreRead.getBlob(containerName, blobName);
        if (getBlob == null) {
            ++count;
            continue;
        }
        try (Payload payload = getBlob.getPayload();
             InputStream is = payload.openStream()) {
            if (Arrays.equals(payload1.read(), ByteStreams.toByteArray(
                    is))) {
                ++count;
            }
        }
        blobStore.removeBlob(containerName, blobName);
    }
    return count;
}
 
开发者ID:gaul,项目名称:are-we-consistent-yet,代码行数:23,代码来源:AreWeConsistentYet.java

示例5: readBlob

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
/**
 * Reads from a {@link BlobStore}. It returns an Object.
 */
public static InputStream readBlob(BlobStore blobStore, String container, String blobName) throws IOException {
    InputStream is = null;
    if (!Strings.isNullOrEmpty(blobName)) {
        Blob blob = blobStore.getBlob(container, blobName);
        if (blob != null && blob.getPayload() != null) {
            is = blobStore.getBlob(container, blobName).getPayload().openStream();
        }
    }
    return is;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:JcloudsBlobStoreHelper.java

示例6: readBlockFromBackend

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
/**
 * Reads the data from the actual cloud service.
 */
@Override
protected byte[] readBlockFromBackend(BlockId blockId) throws Exception {
    Preconditions.checkNotNull(context);

    String id = StringUtils.convertBytesToHex(blockId.getDigest());
    byte[] data = cache.get(id);
    if (data == null) {
        Blob cloudBlob = context.getBlobStore().getBlob(cloudContainer, id);
        if (cloudBlob == null) {
            String message = "Did not find block " + id;
            LOG.error(message);
            throw new IOException(message);
        }

        Payload payload = cloudBlob.getPayload();
        try {
            data = ByteStreams.toByteArray(payload.getInput());
            cache.put(id, data);        
        } finally {
            payload.close();
        }
    }
    if (blockId.getPos() == 0) {
        return data;
    }
    int len = (int) (data.length - blockId.getPos());
    if (len < 0) {
        return new byte[0];
    }
    byte[] d2 = new byte[len];
    System.arraycopy(data, (int) blockId.getPos(), d2, 0, len);
    return d2;
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:37,代码来源:CloudBlobStore.java

示例7: pipeBlobAndReturn

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
private Blob pipeBlobAndReturn(String container, Blob blob) throws IOException {
    String name = blob.getMetadata().getName();
    logger.debug("piping {} from {} to {}", name, getDestStoreName(), getSourceStoreName());

    PipedInputStream pipeIn = new PipedInputStream();
    PipedOutputStream pipeOut = new PipedOutputStream(pipeIn);

    Payload blobPayload = blob.getPayload();
    MutableContentMetadata contentMetadata = blob.getMetadata().getContentMetadata();
    Blob retBlob = new BlobImpl(replaceSystemMetadata(blob.getMetadata()));
    retBlob.setPayload(pipeIn);
    retBlob.setAllHeaders(blob.getAllHeaders());
    TeeInputStream tee = new TeeInputStream(blobPayload.openStream(), pipeOut, true);
    retBlob.getMetadata().setContentMetadata(contentMetadata);

    app.executeBackgroundTask(() -> {
        try {
            logger.debug("copying {} to tee stream", name);
            return Utils.copyBlob(getDestination(), getSource(), container, blob, tee);
        } catch (RuntimeException e) {
            logger.error("copying " + name + " to tee stream failed", e);
            throw e;
        } finally {
            tee.close();
        }
    });
    return retBlob;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:29,代码来源:WriteBackPolicy.java

示例8: BlobStoreByteSource

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的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


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