Package arvados :: Module arvfile :: Class _BufferBlock
[hide private]
[frames] | no frames]

Class _BufferBlock

source code

builtins.object --+
                  |
                 _BufferBlock

A stand-in for a Keep block that is in the process of being written.

Writers can append to it, get the size, and compute the Keep locator.
There are three valid states:

WRITABLE
  Can append to block.

PENDING
  Block is in the process of being uploaded to Keep, append is an error.

COMMITTED
  The block has been written to Keep, its internal buffer has been
  released, fetching the block will fetch it via keep client (since we
  discarded the internal copy), and identifiers referring to the BufferBlock
  can be replaced with the block locator.

Instance Methods [hide private]
 
__init__(self, blockid, starting_capacity, owner)
:blockid: the identifier for this block
source code
 
append(self, data)
Append some data to the buffer.
source code
 
set_state(self, nextstate, val=None) source code
 
state(self) source code
 
size(self)
The amount of data written to the buffer.
source code
 
locator(self)
The Keep locator for this buffer's contents.
source code
 
clone(self, new_blockid, owner) source code
 
clear(self) source code
 
repack_writes(self)
Optimize buffer block by repacking segments in file sequence.
source code
 
__repr__(self) source code
Class Variables [hide private]
  WRITABLE = 0
  PENDING = 1
  COMMITTED = 2
  ERROR = 3
  DELETED = 4
  STATE_TRANSITIONS = frozenset([(WRITABLE, PENDING), (PENDING, ...
Method Details [hide private]

__init__(self, blockid, starting_capacity, owner)
(Constructor)

source code 

:blockid:
  the identifier for this block

:starting_capacity:
  the initial buffer capacity

:owner:
  ArvadosFile that owns this block

append(self, data)

source code 

Append some data to the buffer.

Only valid if the block is in WRITABLE state. Implements an expanding buffer, doubling capacity as needed to accomdate all the data.

Decorators:
  • @synchronized

set_state(self, nextstate, val=None)

source code 
Decorators:
  • @synchronized

state(self)

source code 
Decorators:
  • @synchronized

locator(self)

source code 

The Keep locator for this buffer's contents.

Decorators:
  • @synchronized

clone(self, new_blockid, owner)

source code 
Decorators:
  • @synchronized

clear(self)

source code 
Decorators:
  • @synchronized

repack_writes(self)

source code 

Optimize buffer block by repacking segments in file sequence.

When the client makes random writes, they appear in the buffer block in the sequence they were written rather than the sequence they appear in the file. This makes for inefficient, fragmented manifests. Attempt to optimize by repacking writes in file sequence.

Decorators:
  • @synchronized

Class Variable Details [hide private]

STATE_TRANSITIONS

Value:
frozenset([(WRITABLE, PENDING), (PENDING, COMMITTED), (PENDING, ERROR)\
, (ERROR, PENDING)])