CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ObjectPackConsumer Class Reference

#include <pack.h>

Inheritance diagram for ObjectPackConsumer:
Collaboration diagram for ObjectPackConsumer:

Classes

struct  IndexEntry
 

Public Member Functions

 ObjectPackConsumer (const shash::Any &expected_digest, const unsigned expected_header_size)
 
ObjectPackBuild::State ConsumeNext (const unsigned buf_size, const unsigned char *buf)
 
- Public Member Functions inherited from Observable< ObjectPackBuild::Event >
virtual ~Observable ()
 
CallbackPtr RegisterListener (typename BoundClosure< ObjectPackBuild::Event, DelegateT, ClosureDataT >::CallbackMethod method, DelegateT *delegate, ClosureDataT data)
 
CallbackPtr RegisterListener (typename BoundCallback< ObjectPackBuild::Event, DelegateT >::CallbackMethod method, DelegateT *delegate)
 
CallbackPtr RegisterListener (typename Callback< ObjectPackBuild::Event >::CallbackFunction fn)
 
void UnregisterListener (CallbackPtr callback_object)
 
void UnregisterListeners ()
 

Private Member Functions

bool ParseHeader ()
 
bool ParseItem (const std::string &line, IndexEntry *entry, uint64_t *sum_size)
 
ObjectPackBuild::State ConsumePayload (const unsigned buf_size, const unsigned char *buf)
 

Private Attributes

shash::Any expected_digest_
 
unsigned expected_header_size_
 
uint64_t pos_
 
unsigned idx_
 
unsigned pos_in_object_
 
unsigned char accumulator_ [kAccuSize]
 
unsigned pos_in_accu_
 
ObjectPackBuild::State state_
 
std::string raw_header_
 
uint64_t size_
 
std::vector< IndexEntryindex_
 

Static Private Attributes

static const unsigned kAccuSize = 128 * 1024
 

Additional Inherited Members

- Public Types inherited from Observable< ObjectPackBuild::Event >
typedef Callbackable
< ObjectPackBuild::Event >
::CallbackTN
CallbackPtr
 
- Public Types inherited from Callbackable< ObjectPackBuild::Event >
typedef CallbackBase
< ObjectPackBuild::Event
CallbackTN
 
- Static Public Member Functions inherited from Callbackable< ObjectPackBuild::Event >
static CallbackTNMakeClosure (typename BoundClosure< ObjectPackBuild::Event, DelegateT, ClosureDataT >::CallbackMethod method, DelegateT *delegate, const ClosureDataT &closure_data)
 
static CallbackTNMakeCallback (typename BoundCallback< ObjectPackBuild::Event, DelegateT >::CallbackMethod method, DelegateT *delegate)
 
static CallbackTNMakeCallback (typename Callback< ObjectPackBuild::Event >::CallbackFunction function)
 
- Protected Types inherited from Observable< ObjectPackBuild::Event >
typedef std::set< CallbackPtrCallbacks
 
- Protected Member Functions inherited from Observable< ObjectPackBuild::Event >
void RegisterListener (CallbackPtr callback_object)
 
 Observable ()
 
void NotifyListeners (const ObjectPackBuild::Event &parameter)
 

Detailed Description

Deserializes an ObjectPack created by ObjectPackProducer. For every object it calls all listeners with a Event parameter at least once for every object. For large objects, it calls the listeners multiple times. It won't verify the incoming data, this is up to the listeners handling the data. The ObjectPackConsumer will verify the header digest, however.

Definition at line 230 of file pack.h.

Constructor & Destructor Documentation

ObjectPackConsumer::ObjectPackConsumer ( const shash::Any expected_digest,
const unsigned  expected_header_size 
)
explicit

Definition at line 258 of file pack.cc.

Member Function Documentation

ObjectPackBuild::State ObjectPackConsumer::ConsumeNext ( const unsigned  buf_size,
const unsigned char *  buf 
)

At the end of the function, pos_ will have progressed by buf_size (unless the buffer contains trailing garbage bytes.

Definition at line 281 of file pack.cc.

Referenced by receiver::PayloadProcessor::Process().

Here is the call graph for this function:

Here is the caller graph for this function:

ObjectPackBuild::State ObjectPackConsumer::ConsumePayload ( const unsigned  buf_size,
const unsigned char *  buf 
)
private

Informs listeners for small complete objects. For large objects, buffers the input into reasonably sized chunks. buf can contain both a chunk of data that needs to be added to the consumer's accumulator and a bunch of complete small objects. We use the accumulator only if necessary to avoid unnecessary memory copies.

Definition at line 338 of file pack.cc.

Referenced by ConsumeNext().

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectPackConsumer::ParseHeader ( )
private

Definition at line 388 of file pack.cc.

Referenced by ConsumeNext().

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectPackConsumer::ParseItem ( const std::string &  line,
ObjectPackConsumer::IndexEntry entry,
uint64_t *  sum_size 
)
private

Definition at line 425 of file pack.cc.

Referenced by ParseHeader().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

unsigned char ObjectPackConsumer::accumulator_[kAccuSize]
private

Collects data for large objects so that the number of callbacks to the listeners is reduced.

Definition at line 283 of file pack.h.

Referenced by ConsumePayload().

shash::Any ObjectPackConsumer::expected_digest_
private

Definition at line 261 of file pack.h.

Referenced by ConsumeNext().

unsigned ObjectPackConsumer::expected_header_size_
private

Definition at line 262 of file pack.h.

Referenced by ConsumeNext().

unsigned ObjectPackConsumer::idx_
private

Keeps track of the current index in the array of objects (index_)

Definition at line 272 of file pack.h.

Referenced by ConsumePayload().

std::vector<IndexEntry> ObjectPackConsumer::index_
private

Hash id and size of the individual objects in order.

Definition at line 310 of file pack.h.

Referenced by ConsumeNext(), ConsumePayload(), and ParseHeader().

const unsigned ObjectPackConsumer::kAccuSize = 128 * 1024
staticprivate

For large objects, notify listeners in chunks of 128kB.

Definition at line 241 of file pack.h.

Referenced by ConsumePayload().

uint64_t ObjectPackConsumer::pos_
private

Keeps track of how many bytes have been consumed from the payload.

Definition at line 267 of file pack.h.

Referenced by ConsumeNext(), and ConsumePayload().

unsigned ObjectPackConsumer::pos_in_accu_
private

Keeps track of how many live bytes are stored in the accumulator_.

Definition at line 288 of file pack.h.

Referenced by ConsumePayload().

unsigned ObjectPackConsumer::pos_in_object_
private

Keeps track of how many bytes have been processed from the current object.

Definition at line 277 of file pack.h.

Referenced by ConsumePayload().

std::string ObjectPackConsumer::raw_header_
private

Temporary store for the incomplete header. Once completely consumed, the header is interpreted into global_header_ and object_index_.

Definition at line 300 of file pack.h.

Referenced by ConsumeNext(), ObjectPackConsumer(), and ParseHeader().

uint64_t ObjectPackConsumer::size_
private

Total size of all the objects in the pack (header not included).

Definition at line 305 of file pack.h.

Referenced by ParseHeader().

ObjectPackBuild::State ObjectPackConsumer::state_
private

The state starts in kStateContinue and makes exactly one transition into one of the other states as more bytes are consumed.

Definition at line 294 of file pack.h.

Referenced by ConsumeNext(), ConsumePayload(), and ObjectPackConsumer().


The documentation for this class was generated from the following files: