public BlobBlock(String blockId, BlockSearchMode searchMode, InputStream blockStream) { this(new BlockEntry(blockId, searchMode), blockStream); }
UploadBlockCommand(String blockId, ByteBuffer payload) { super(blobLength); BlockEntry blockEntry = new BlockEntry(blockId); blockEntry.setSize(payload.position()); blockEntry.setSearchMode(BlockSearchMode.LATEST); this.payload = payload; this.entry = blockEntry; uncommittedBlockEntries.add(blockEntry); }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { String currentNode = this.elementStack.pop(); // if the node popped from the stack and the localName don't match, the xml document is improperly formatted if (!localName.equals(currentNode)) { throw new SAXException(SR.INVALID_RESPONSE_RECEIVED); } String value = this.bld.toString(); if (value.isEmpty()) { value = null; } if (BlobConstants.BLOCK_ELEMENT.equals(currentNode)) { final BlockEntry newBlock = new BlockEntry(this.blockName, this.searchMode); newBlock.setSize(this.blockSize); this.blocks.add(newBlock); } else if (Constants.NAME_ELEMENT.equals(currentNode)) { this.blockName = value; } else if (BlobConstants.SIZE_ELEMENT.equals(currentNode)) { this.blockSize = Long.parseLong(value); } this.bld = new StringBuilder(); }
BlockEntry entry = new BlockEntry(blockId, BlockSearchMode.UNCOMMITTED); entry.setSize(blockSize); blob.uploadBlock(entry.getId(), content, blockSize); uploadedBytes += blockSize;
if (block.getSearchMode() == BlockSearchMode.COMMITTED) { xmlw.writeStartElement(BlobConstants.COMMITTED_ELEMENT); else if (block.getSearchMode() == BlockSearchMode.UNCOMMITTED) { xmlw.writeStartElement(BlobConstants.UNCOMMITTED_ELEMENT); else if (block.getSearchMode() == BlockSearchMode.LATEST) { xmlw.writeStartElement(BlobConstants.LATEST_ELEMENT); xmlw.writeCharacters(block.getId()); xmlw.writeEndElement();
blob.uploadBlock(block.getId(), new ByteArrayInputStream(buffer), length); blob.uploadBlock(block.getId(), new ByteArrayInputStream(buffer), length); assertEquals(3, blockList.size()); for (BlockEntry blockItem : blockList) { assertEquals(BlockSearchMode.COMMITTED, blockItem.getSearchMode()); assertEquals(length, blockItem.getSize()); assertFalse(blocks.remove(blockItem.getId()) == null); assertEquals(2, blockList.size()); for (BlockEntry blockItem : blockList) { assertEquals(BlockSearchMode.UNCOMMITTED, blockItem.getSearchMode()); assertEquals(length, blockItem.getSize()); assertFalse(extraBlocks.remove(blockItem.getId()) == null);
segmentOffsetEnd += block.getSize(); if (segmentOffsetEnd - segmentOffsetBegin > maxBlockSize.get()) { if (segmentEnd - segmentBegin > 2) { maxSegmentEnd = segmentEnd; maxSegmentOffsetBegin = segmentOffsetBegin; maxSegmentOffsetEnd = segmentOffsetEnd - block.getSize(); segmentOffsetBegin = segmentOffsetEnd - block.getSize(); newBlock.setId(blockId); newBlock.setSearchMode(BlockSearchMode.LATEST); newBlock.setSize(maxSegmentOffsetEnd - maxSegmentOffsetBegin);
/** * Execute command. */ void execute() throws InterruptedException { uploadingSemaphore.acquire(1); writeBlockRequestInternal(entry.getId(), payload, true); uploadingSemaphore.release(1); }
/** * Creates an instance of the <code>BlockEntry</code> class with the specified id and default search mode * {@link BlockSearchMode#LATEST}. * * @param id * A <code>String</code> which represents the ID of the block. */ public BlockEntry(final String id) { this.setId(id); this.searchMode = BlockSearchMode.LATEST; }
private void verifyBlockList(BlockBlobAppendStream blockBlobStream, int[] testData) throws Throwable { List<BlockEntry> blockList = blockBlobStream.getBlockList(); Assert.assertEquals("Block list length", testData.length, blockList.size()); int i = 0; for (BlockEntry block: blockList) { Assert.assertTrue(block.getSize() == testData[i++]); } }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { String currentNode = this.elementStack.pop(); // if the node popped from the stack and the localName don't match, the xml document is improperly formatted if (!localName.equals(currentNode)) { throw new SAXException(SR.INVALID_RESPONSE_RECEIVED); } String value = this.bld.toString(); if (value.isEmpty()) { value = null; } if (BlobConstants.BLOCK_ELEMENT.equals(currentNode)) { final BlockEntry newBlock = new BlockEntry(this.blockName, this.searchMode); newBlock.setSize(this.blockSize); this.blocks.add(newBlock); } else if (Constants.NAME_ELEMENT.equals(currentNode)) { this.blockName = value; } else if (BlobConstants.SIZE_ELEMENT.equals(currentNode)) { this.blockSize = Long.parseLong(value); } this.bld = new StringBuilder(); }
if (block.getSearchMode() == BlockSearchMode.COMMITTED) { Utility.serializeElement(xmlw, BlobConstants.COMMITTED_ELEMENT, block.getId()); else if (block.getSearchMode() == BlockSearchMode.UNCOMMITTED) { Utility.serializeElement(xmlw, BlobConstants.UNCOMMITTED_ELEMENT, block.getId()); else if (block.getSearchMode() == BlockSearchMode.LATEST) { Utility.serializeElement(xmlw, BlobConstants.LATEST_ELEMENT, block.getId());
? blockEntries.get(0).getId() : ""; String prefix = UUID.randomUUID().toString() + "-";
/** * Creates an instance of the <code>BlockEntry</code> class with the specified id and search mode. * * @param id * A <code>String</code> which represents the ID of the block. * @param searchMode * A {@link BlockSearchMode} value which represents the block search mode. */ public BlockEntry(final String id, final BlockSearchMode searchMode) { this.setId(id); this.searchMode = searchMode; }
public static Map<String, BlockEntry> getBlockEntryList(int count) { Map<String, BlockEntry> blocks = new HashMap<String, BlockEntry>(); for (int i = 0; i < count; i++) { final String name = generateRandomBlobNameWithPrefix(null); blocks.put(name, new BlockEntry(name, BlockSearchMode.LATEST)); } return blocks; }
for (BlobBlock blobBlock : blobBlocks) { blockEntries.add(blobBlock.getBlockEntry()); client.uploadBlock(blobBlock.getBlockEntry().getId(), blobBlock.getBlockStream(), -1, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
/** * Creates an instance of the <code>BlockEntry</code> class with the specified id and default search mode * {@link BlockSearchMode#LATEST}. * * @param id * A <code>String</code> which represents the ID of the block. */ public BlockEntry(final String id) { this.setId(id); this.searchMode = BlockSearchMode.LATEST; }
); BlockEntry blockEntry = new BlockEntry(blockId); blockList.add(blockEntry); final InputStream sourceStream = block;