Java Code Examples for org.jclouds.blobstore.domain.Blob#getPayload()
The following examples show how to use
org.jclouds.blobstore.domain.Blob#getPayload() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JCloudsEntityStoreMixin.java From attic-polygene-java with Apache License 2.0 | 6 votes |
@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 ); } }
Example 2
Source File: AreWeConsistentYet.java From are-we-consistent-yet with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: AreWeConsistentYet.java From are-we-consistent-yet with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: AreWeConsistentYet.java From are-we-consistent-yet with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: ObjectStoreFileStorage.java From multiapps-controller with Apache License 2.0 | 5 votes |
@Override public <T> T processFileContent(String space, String id, FileContentProcessor<T> fileContentProcessor) throws FileStorageException { FileEntry fileEntry = createFileEntry(space, id); try { Blob blob = getBlobWithRetries(fileEntry, 3); if (blob == null) { throw new FileStorageException(MessageFormat.format(Messages.FILE_WITH_ID_AND_SPACE_DOES_NOT_EXIST, fileEntry.getId(), fileEntry.getSpace())); } Payload payload = blob.getPayload(); return processContent(fileContentProcessor, payload); } catch (Exception e) { throw new FileStorageException(e); } }