From 079d2844ecde061d45c6884aa0ffee7fdc05de63 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 20 May 2007 13:57:56 +0000 Subject: New files --- src/FileAllocationCommand.cc | 73 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/FileAllocationCommand.cc (limited to 'src/FileAllocationCommand.cc') diff --git a/src/FileAllocationCommand.cc b/src/FileAllocationCommand.cc new file mode 100644 index 00000000..92f26b6f --- /dev/null +++ b/src/FileAllocationCommand.cc @@ -0,0 +1,73 @@ +/* */ +#include "FileAllocationCommand.h" +#include "InitiateConnectionCommandFactory.h" +#include "message.h" + +bool FileAllocationCommand::execute() +{ + setStatusRealtime(); + _e->noWait = true; + try { + _fileAllocationEntry->allocateChunk(); + + if(_fileAllocationEntry->allocationFinished()) { + int64_t totalLength = _requestGroup->getSegmentMan()->totalSize; + logger->debug("%d seconds to allocate %lld byte(s)", + _timer.difference(), totalLength); + + _e->_fileAllocationMan->markCurrentFileAllocationEntryDone(); + + int32_t numCommandsToGenerate = 15; + Commands commands = _requestGroup->getNextCommand(_e, numCommandsToGenerate); + + Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(cuid, _req, _requestGroup, _e); + + commands.push_front(command); + + _e->addCommand(commands); + return true; + } else { + _e->commands.push_back(this); + return false; + } + } catch(Exception* e) { + _requestGroup->getSegmentMan()->errors++; + logger->error("CUID#%d - Exception caught while allocating file space.", e, cuid); + delete e; + logger->notice(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getFilePath().c_str()); + return true; + } +} -- cgit