2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Made protected member variable private. Added accessor funcs.
	* src/CheckIntegrityCommand.cc
	* src/FileAllocationCommand.cc
	* src/RealtimeCommand.h
pull/1/head
Tatsuhiro Tsujikawa 2010-06-09 14:21:10 +00:00
parent b357fd39fc
commit d4dfb6c4a8
4 changed files with 43 additions and 26 deletions

View File

@ -1,3 +1,10 @@
2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made protected member variable private. Added accessor funcs.
* src/CheckIntegrityCommand.cc
* src/FileAllocationCommand.cc
* src/RealtimeCommand.h
2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> 2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made protected member variable private. Added accessor funcs. Made protected member variable private. Added accessor funcs.

View File

@ -60,59 +60,59 @@ CheckIntegrityCommand::~CheckIntegrityCommand() {}
bool CheckIntegrityCommand::executeInternal() bool CheckIntegrityCommand::executeInternal()
{ {
if(_requestGroup->isHaltRequested()) { if(getRequestGroup()->isHaltRequested()) {
_e->getCheckIntegrityMan()->dropPickedEntry(); getDownloadEngine()->getCheckIntegrityMan()->dropPickedEntry();
return true; return true;
} }
_entry->validateChunk(); _entry->validateChunk();
if(_entry->finished()) { if(_entry->finished()) {
_e->getCheckIntegrityMan()->dropPickedEntry(); getDownloadEngine()->getCheckIntegrityMan()->dropPickedEntry();
// Enable control file saving here. See also // Enable control file saving here. See also
// RequestGroup::processCheckIntegrityEntry() to know why this is // RequestGroup::processCheckIntegrityEntry() to know why this is
// needed. // needed.
_requestGroup->enableSaveControlFile(); getRequestGroup()->enableSaveControlFile();
if(_requestGroup->downloadFinished()) { if(getRequestGroup()->downloadFinished()) {
getLogger()->notice getLogger()->notice
(MSG_VERIFICATION_SUCCESSFUL, (MSG_VERIFICATION_SUCCESSFUL,
_requestGroup->getDownloadContext()->getBasePath().c_str()); getRequestGroup()->getDownloadContext()->getBasePath().c_str());
std::vector<Command*> commands; std::vector<Command*> commands;
try { try {
_entry->onDownloadFinished(commands, _e); _entry->onDownloadFinished(commands, getDownloadEngine());
} catch(RecoverableException& e) { } catch(RecoverableException& e) {
std::for_each(commands.begin(), commands.end(), Deleter()); std::for_each(commands.begin(), commands.end(), Deleter());
throw; throw;
} }
_e->addCommand(commands); getDownloadEngine()->addCommand(commands);
} else { } else {
getLogger()->error getLogger()->error
(MSG_VERIFICATION_FAILED, (MSG_VERIFICATION_FAILED,
_requestGroup->getDownloadContext()->getBasePath().c_str()); getRequestGroup()->getDownloadContext()->getBasePath().c_str());
std::vector<Command*> commands; std::vector<Command*> commands;
try { try {
_entry->onDownloadIncomplete(commands,_e); _entry->onDownloadIncomplete(commands, getDownloadEngine());
} catch(RecoverableException& e) { } catch(RecoverableException& e) {
std::for_each(commands.begin(), commands.end(), Deleter()); std::for_each(commands.begin(), commands.end(), Deleter());
throw; throw;
} }
_e->addCommand(commands); getDownloadEngine()->addCommand(commands);
} }
_e->setNoWait(true); getDownloadEngine()->setNoWait(true);
return true; return true;
} else { } else {
_e->addCommand(this); getDownloadEngine()->addCommand(this);
return false; return false;
} }
} }
bool CheckIntegrityCommand::handleException(Exception& e) bool CheckIntegrityCommand::handleException(Exception& e)
{ {
_e->getCheckIntegrityMan()->dropPickedEntry(); getDownloadEngine()->getCheckIntegrityMan()->dropPickedEntry();
getLogger()->error(MSG_FILE_VALIDATION_FAILURE, e, getLogger()->error(MSG_FILE_VALIDATION_FAILURE, e,
util::itos(getCuid()).c_str()); util::itos(getCuid()).c_str());
getLogger()->error getLogger()->error
(MSG_DOWNLOAD_NOT_COMPLETE, (MSG_DOWNLOAD_NOT_COMPLETE,
util::itos(getCuid()).c_str(), util::itos(getCuid()).c_str(),
_requestGroup->getDownloadContext()->getBasePath().c_str()); getRequestGroup()->getDownloadContext()->getBasePath().c_str());
return true; return true;
} }

View File

@ -62,8 +62,8 @@ FileAllocationCommand::~FileAllocationCommand() {}
bool FileAllocationCommand::executeInternal() bool FileAllocationCommand::executeInternal()
{ {
if(_requestGroup->isHaltRequested()) { if(getRequestGroup()->isHaltRequested()) {
_e->getFileAllocationMan()->dropPickedEntry(); getDownloadEngine()->getFileAllocationMan()->dropPickedEntry();
return true; return true;
} }
_fileAllocationEntry->allocateChunk(); _fileAllocationEntry->allocateChunk();
@ -72,34 +72,34 @@ bool FileAllocationCommand::executeInternal()
getLogger()->debug getLogger()->debug
(MSG_ALLOCATION_COMPLETED, (MSG_ALLOCATION_COMPLETED,
_timer.difference(global::wallclock), _timer.difference(global::wallclock),
util::itos(_requestGroup->getTotalLength(), true).c_str()); util::itos(getRequestGroup()->getTotalLength(), true).c_str());
} }
_e->getFileAllocationMan()->dropPickedEntry(); getDownloadEngine()->getFileAllocationMan()->dropPickedEntry();
std::vector<Command*> commands; std::vector<Command*> commands;
try { try {
_fileAllocationEntry->prepareForNextAction(commands, _e); _fileAllocationEntry->prepareForNextAction(commands, getDownloadEngine());
} catch(RecoverableException& e) { } catch(RecoverableException& e) {
std::for_each(commands.begin(), commands.end(), Deleter()); std::for_each(commands.begin(), commands.end(), Deleter());
throw; throw;
} }
_e->addCommand(commands); getDownloadEngine()->addCommand(commands);
_e->setNoWait(true); getDownloadEngine()->setNoWait(true);
return true; return true;
} else { } else {
_e->addCommand(this); getDownloadEngine()->addCommand(this);
return false; return false;
} }
} }
bool FileAllocationCommand::handleException(Exception& e) bool FileAllocationCommand::handleException(Exception& e)
{ {
_e->getFileAllocationMan()->dropPickedEntry(); getDownloadEngine()->getFileAllocationMan()->dropPickedEntry();
getLogger()->error getLogger()->error
(MSG_FILE_ALLOCATION_FAILURE, e, util::itos(getCuid()).c_str()); (MSG_FILE_ALLOCATION_FAILURE, e, util::itos(getCuid()).c_str());
getLogger()->error getLogger()->error
(MSG_DOWNLOAD_NOT_COMPLETE, util::itos(getCuid()).c_str(), (MSG_DOWNLOAD_NOT_COMPLETE, util::itos(getCuid()).c_str(),
_requestGroup->getDownloadContext()->getBasePath().c_str()); getRequestGroup()->getDownloadContext()->getBasePath().c_str());
return true; return true;
} }

View File

@ -44,9 +44,19 @@ class DownloadEngine;
class Exception; class Exception;
class RealtimeCommand : public Command { class RealtimeCommand : public Command {
protected: private:
RequestGroup* _requestGroup; RequestGroup* _requestGroup;
DownloadEngine* _e; DownloadEngine* _e;
protected:
DownloadEngine* getDownloadEngine() const
{
return _e;
}
RequestGroup* getRequestGroup() const
{
return _requestGroup;
}
public: public:
RealtimeCommand(cuid_t cuid, RequestGroup* requestGroup, DownloadEngine* e); RealtimeCommand(cuid_t cuid, RequestGroup* requestGroup, DownloadEngine* e);