2014-12-09 18:53:11 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_IMPL_DATANODE_H_
|
|
|
|
#define BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_IMPL_DATANODE_H_
|
|
|
|
|
2014-12-10 16:48:00 +01:00
|
|
|
#include "DataNodeView.h"
|
2014-12-09 18:53:11 +01:00
|
|
|
|
2014-12-10 16:48:00 +01:00
|
|
|
#include "blockstore/utils/Data.h"
|
2014-12-09 18:53:11 +01:00
|
|
|
|
|
|
|
namespace blobstore {
|
|
|
|
namespace onblocks {
|
2014-12-13 17:43:02 +01:00
|
|
|
class DataNodeStore;
|
2014-12-09 18:53:11 +01:00
|
|
|
|
|
|
|
class DataNode {
|
|
|
|
public:
|
|
|
|
virtual ~DataNode();
|
|
|
|
|
2014-12-11 00:24:50 +01:00
|
|
|
virtual void read(off_t offset, size_t count, blockstore::Data *result) const = 0;
|
2014-12-10 16:48:00 +01:00
|
|
|
virtual void write(off_t offset, size_t count, const blockstore::Data &data) = 0;
|
2014-12-09 18:53:11 +01:00
|
|
|
|
2014-12-10 23:34:36 +01:00
|
|
|
virtual void resize(uint64_t newsize_bytes) = 0;
|
2014-12-11 00:24:50 +01:00
|
|
|
virtual uint64_t numBytesInThisNode() const = 0;
|
2014-12-09 18:53:11 +01:00
|
|
|
|
2014-12-13 17:43:02 +01:00
|
|
|
const Key &key() const;
|
|
|
|
|
|
|
|
uint8_t depth() const;
|
2014-12-09 18:53:11 +01:00
|
|
|
|
|
|
|
protected:
|
2014-12-13 17:43:02 +01:00
|
|
|
DataNode(DataNodeView block, const Key &key, DataNodeStore *nodestorage);
|
|
|
|
|
|
|
|
DataNodeStore &storage();
|
|
|
|
const DataNodeStore &storage() const;
|
2014-12-09 18:53:11 +01:00
|
|
|
|
2014-12-13 17:43:02 +01:00
|
|
|
DataNodeView &node();
|
|
|
|
const DataNodeView &node() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Key _key; //TODO Remove this and make blockstore::Block store the key
|
2014-12-10 16:48:00 +01:00
|
|
|
DataNodeView _node;
|
2014-12-13 17:43:02 +01:00
|
|
|
DataNodeStore *_nodestorage;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(DataNode);
|
2014-12-09 18:53:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-10 16:48:00 +01:00
|
|
|
|
2014-12-09 18:53:11 +01:00
|
|
|
#endif
|