18#define TIMEOUT_INTERVAL 30000
72 return "HeartBigDataAPI";
75void QH::BigDataParser::insertNewBigData(
const QSharedPointer<PKG::BigDataHeader> &header) {
76 if (!_pool.contains(header->packageId())) {
77 QVector<QSharedPointer<PKG::BigDataPart>> _array;
78 _array.resize(header->getPackagesCount());
79 _pool[header->packageId()] = {header, _array,
static_cast<int>(time(0))};
82 checkOutDatedPacakges(header->packageId());
89 if (!header->isValid())
92 insertNewBigData(header);
96 request.setPackageId(header->packageId());
98 qDebug() <<
"Receive BigData Header:" << header->toString();
107 if (!_pool.contains(
part->packageId())) {
111 checkOutDatedPacakges(
part->packageId());
115 qDebug () <<
"Process Part of" <<
part->packageId() <<
": part" <<
part->getPakckageNumber() <<
"/" <<
localPool.chaindata.size() - 1;
128 if (
part->getPakckageNumber() + 1 <
localPool.chaindata.size()) {
134 auto package = node()->genPackage(localPool.header->getCommand(),
154 _pool.remove(
part->packageId());
164 unsigned int id =
request->packageId();
166 if (!_pool.contains(
id)) {
167 qDebug() <<
"requested data is missing!";
171 checkOutDatedPacakges(
id);
205 auto hdr = QSharedPointer<PKG::BigDataHeader>::create();
206 hdr->setPackagesCount(std::ceil(
rawData.size() /
static_cast<double>(
sizeLimit)));
207 hdr->setPackageId(
rand());
208 hdr->setCommand(data->
cmd());
210 insertNewBigData(hdr);
212 for (
int i = 0;
i < hdr->getPackagesCount(); ++
i) {
213 auto part = QSharedPointer<PKG::BigDataPart>::create();
214 part->setPackageId(hdr->packageId());
215 part->setPakckageNumber(
i);
218 _pool[hdr->packageId()].chaindata[
i] =
part;
236 for (
auto key = _pool.keyBegin();
key != _pool.keyEnd(); ++
key) {
The AbstractNodeInfo class contains information about client or server connection and tcp socket of n...
The AbstractNode class - Abstract implementation of node. this implementation have a methods for send...
virtual unsigned int sendData(const PKG::AbstractData *resp, const HostAddress &address, const Header *req=nullptr)
sendData This method send data object another to node
QString parserId() const override
parserId This is id of the parsers. All parser will be synced betwin nodes by ids.
ParserResult parsePackage(const QSharedPointer< PKG::AbstractData > &pkg, const Header &pkgHeader, AbstractNodeInfo *sender) override
parsePackage This is main method of all childs classes of an AbstractNode class. This method work on ...
bool processBigDataWraper(const QSharedPointer< PKG::BigDataWraper > &request, AbstractNodeInfo *sender, const Header &pkgHeader)
sendBigDataPackage This method separate big pacakge and sent only heder ot serve.
bool processPart(const QSharedPointer< PKG::BigDataPart > &part, AbstractNodeInfo *sender, const QH::Header &pkgHeader)
processPart This method process part of package
bool processRequest(const QSharedPointer< PKG::BigDataRequest > &request, QH::AbstractNodeInfo *sender, const QH::Header &pkgHeader)
finishPart This metho process last package of big data transaction.
BigDataParser(AbstractNode *parentNode)
int version() const override
version This method return version of parser object
bool newPackage(const QSharedPointer< PKG::BigDataHeader > &header, AbstractNodeInfo *sender, const Header &pkgHeader)
newPackage This method process first header packge of the big data.
The AbstractData class is provide base functions for transport data by network For create you own pac...
virtual unsigned short cmd() const =0
cmd - This is command of this object, (for generate cmd use macross QH_PACKAGE)
The BigDataPart class This data class used for transporting big data files greater than 64kb.
The BigDataRequest class contains missing package parts for redownload. If missing parts count is 0 t...
void setCurrentPart(int newCurrentPart)
setCurrentPart This method sets current new value of current page
static unsigned int maximumSize()
maximumSize This method return maximu size of pacakge. If pacakge large the maximum size then package...
QByteArray toBytes() const
toBytes This method convert a current object to bytes array.
The iParser class This class provide functions for parsing income packages. For yousing just override...
virtual unsigned int sendData(const PKG::AbstractData *resp, const HostAddress &address, const Header *req=nullptr) const
sendData This method send data object another to node
void registerPackageType()
registerPackageType This method register package type T. This is need to prepare pacakge for parsing ...
virtual ParserResult parsePackage(const QSharedPointer< PKG::AbstractData > &pkg, const Header &pkgHeader, AbstractNodeInfo *sender)=0
parsePackage This is main method of all childs classes of an AbstractNode class. This method work on ...
AbstractNode * node() const
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
ParserResult
The ParserResult enum. Error - parser detect a errorob package. NotProcessed - the parser does not kn...
@ NotProcessed
the parser does not know what to do with the package or has not finished processing it.
@ Error
parser detect a errorob package.