Changeset 2226

Show
Ignore:
Timestamp:
07/08/2008 17:35:09 (4 months ago)
Author:
chris
Message:

Rename BackupContext? to BackupStoreContext?.

Add a TestHook? to help test weird server behaviour such as crashes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • box/trunk/bin/bbstored/BackupCommands.cpp

    r2179 r2226  
    1616#include "autogen_RaidFileException.h" 
    1717#include "BackupConstants.h" 
    18 #include "BackupContext.h" 
     18#include "BackupStoreContext.h" 
    1919#include "BackupStoreConstants.h" 
    2020#include "BackupStoreDirectory.h" 
     
    3232 
    3333#define CHECK_PHASE(phase)                                                                                                                                                                              \ 
    34         if(rContext.GetPhase() != BackupContext::phase)                                                                                                                               \ 
     34        if(rContext.GetPhase() != BackupStoreContext::phase)                                                                                                                          \ 
    3535        {                                                                                                                                                                                                                       \ 
    3636                return std::auto_ptr<ProtocolObject>(new BackupProtocolServerError(                                                                             \ 
     
    4848// 
    4949// Function 
    50 //              Name:    BackupProtocolServerVersion::DoCommand(Protocol &, BackupContext &) 
     50//              Name:    BackupProtocolServerVersion::DoCommand(Protocol &, BackupStoreContext &) 
    5151//              Purpose: Return the current version, or an error if the requested version isn't allowed 
    5252//              Created: 2003/08/20 
    5353// 
    5454// -------------------------------------------------------------------------- 
    55 std::auto_ptr<ProtocolObject> BackupProtocolServerVersion::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     55std::auto_ptr<ProtocolObject> BackupProtocolServerVersion::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    5656{ 
    5757        CHECK_PHASE(Phase_Version) 
     
    6565 
    6666        // Mark the next phase 
    67         rContext.SetPhase(BackupContext::Phase_Login); 
     67        rContext.SetPhase(BackupStoreContext::Phase_Login); 
    6868 
    6969        // Return our version 
     
    7474// 
    7575// Function 
    76 //              Name:    BackupProtocolServerLogin::DoCommand(Protocol &, BackupContext &) 
     76//              Name:    BackupProtocolServerLogin::DoCommand(Protocol &, BackupStoreContext &) 
    7777//              Purpose: Return the current version, or an error if the requested version isn't allowed 
    7878//              Created: 2003/08/20 
    7979// 
    8080// -------------------------------------------------------------------------- 
    81 std::auto_ptr<ProtocolObject> BackupProtocolServerLogin::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     81std::auto_ptr<ProtocolObject> BackupProtocolServerLogin::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    8282{ 
    8383        CHECK_PHASE(Phase_Login) 
     
    132132 
    133133        // Mark the next phase 
    134         rContext.SetPhase(BackupContext::Phase_Commands); 
     134        rContext.SetPhase(BackupStoreContext::Phase_Commands); 
    135135         
    136136        // Log login 
     
    152152// 
    153153// Function 
    154 //              Name:    BackupProtocolServerFinished::DoCommand(Protocol &, BackupContext &) 
     154//              Name:    BackupProtocolServerFinished::DoCommand(Protocol &, BackupStoreContext &) 
    155155//              Purpose: Marks end of conversation (Protocol framework handles this) 
    156156//              Created: 2003/08/20 
    157157// 
    158158// -------------------------------------------------------------------------- 
    159 std::auto_ptr<ProtocolObject> BackupProtocolServerFinished::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     159std::auto_ptr<ProtocolObject> BackupProtocolServerFinished::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    160160{ 
    161161        BOX_NOTICE("Session finished for Client ID " <<  
     
    173173// 
    174174// Function 
    175 //              Name:    BackupProtocolServerListDirectory::DoCommand(Protocol &, BackupContext &) 
     175//              Name:    BackupProtocolServerListDirectory::DoCommand(Protocol &, BackupStoreContext &) 
    176176//              Purpose: Command to list a directory 
    177177//              Created: 2003/09/02 
    178178// 
    179179// -------------------------------------------------------------------------- 
    180 std::auto_ptr<ProtocolObject> BackupProtocolServerListDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     180std::auto_ptr<ProtocolObject> BackupProtocolServerListDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    181181{ 
    182182        CHECK_PHASE(Phase_Commands) 
     
    218218// 
    219219// Function 
    220 //              Name:    BackupProtocolServerStoreFile::DoCommand(Protocol &, BackupContext &) 
     220//              Name:    BackupProtocolServerStoreFile::DoCommand(Protocol &, BackupStoreContext &) 
    221221//              Purpose: Command to store a file on the server 
    222222//              Created: 2003/09/02 
    223223// 
    224224// -------------------------------------------------------------------------- 
    225 std::auto_ptr<ProtocolObject> BackupProtocolServerStoreFile::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     225std::auto_ptr<ProtocolObject> BackupProtocolServerStoreFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    226226{ 
    227227        CHECK_PHASE(Phase_Commands) 
    228228        CHECK_WRITEABLE_SESSION 
     229 
     230        std::auto_ptr<ProtocolObject> hookResult = 
     231                rContext.StartCommandHook(*this); 
     232        if(hookResult.get()) 
     233        { 
     234                return hookResult; 
     235        } 
    229236         
    230237        // Check that the diff from file actually exists, if it's specified 
    231238        if(mDiffFromFileID != 0) 
    232239        { 
    233                 if(!rContext.ObjectExists(mDiffFromFileID, BackupContext::ObjectExists_File)) 
     240                if(!rContext.ObjectExists(mDiffFromFileID, BackupStoreContext::ObjectExists_File)) 
    234241                { 
    235242                        return std::auto_ptr<ProtocolObject>(new BackupProtocolServerError( 
     
    276283// 
    277284// Function 
    278 //              Name:    BackupProtocolServerGetObject::DoCommand(Protocol &, BackupContext &) 
     285//              Name:    BackupProtocolServerGetObject::DoCommand(Protocol &, BackupStoreContext &) 
    279286//              Purpose: Command to get an arbitary object from the server 
    280287//              Created: 2003/09/03 
    281288// 
    282289// -------------------------------------------------------------------------- 
    283 std::auto_ptr<ProtocolObject> BackupProtocolServerGetObject::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     290std::auto_ptr<ProtocolObject> BackupProtocolServerGetObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    284291{ 
    285292        CHECK_PHASE(Phase_Commands) 
     
    304311// 
    305312// Function 
    306 //              Name:    BackupProtocolServerGetFile::DoCommand(Protocol &, BackupContext &) 
     313//              Name:    BackupProtocolServerGetFile::DoCommand(Protocol &, BackupStoreContext &) 
    307314//              Purpose: Command to get an file object from the server -- may have to do a bit of  
    308315//                               work to get the object. 
     
    310317// 
    311318// -------------------------------------------------------------------------- 
    312 std::auto_ptr<ProtocolObject> BackupProtocolServerGetFile::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     319std::auto_ptr<ProtocolObject> BackupProtocolServerGetFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    313320{ 
    314321        CHECK_PHASE(Phase_Commands) 
     
    476483// 
    477484// Function 
    478 //              Name:    BackupProtocolServerCreateDirectory::DoCommand(Protocol &, BackupContext &) 
     485//              Name:    BackupProtocolServerCreateDirectory::DoCommand(Protocol &, BackupStoreContext &) 
    479486//              Purpose: Create directory command 
    480487//              Created: 2003/09/04 
    481488// 
    482489// -------------------------------------------------------------------------- 
    483 std::auto_ptr<ProtocolObject> BackupProtocolServerCreateDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     490std::auto_ptr<ProtocolObject> BackupProtocolServerCreateDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    484491{ 
    485492        CHECK_PHASE(Phase_Commands) 
     
    519526// 
    520527// Function 
    521 //              Name:    BackupProtocolServerChangeDirAttributes::DoCommand(Protocol &, BackupContext &) 
     528//              Name:    BackupProtocolServerChangeDirAttributes::DoCommand(Protocol &, BackupStoreContext &) 
    522529//              Purpose: Change attributes on directory 
    523530//              Created: 2003/09/06 
    524531// 
    525532// -------------------------------------------------------------------------- 
    526 std::auto_ptr<ProtocolObject> BackupProtocolServerChangeDirAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     533std::auto_ptr<ProtocolObject> BackupProtocolServerChangeDirAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    527534{ 
    528535        CHECK_PHASE(Phase_Commands) 
     
    547554// 
    548555// Function 
    549 //              Name:    BackupProtocolServerSetReplacementFileAttributes::DoCommand(Protocol &, BackupContext &) 
     556//              Name:    BackupProtocolServerSetReplacementFileAttributes::DoCommand(Protocol &, BackupStoreContext &) 
    550557//              Purpose: Change attributes on directory 
    551558//              Created: 2003/09/06 
    552559// 
    553560// -------------------------------------------------------------------------- 
    554 std::auto_ptr<ProtocolObject> BackupProtocolServerSetReplacementFileAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     561std::auto_ptr<ProtocolObject> BackupProtocolServerSetReplacementFileAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    555562{ 
    556563        CHECK_PHASE(Phase_Commands) 
     
    582589// 
    583590// Function 
    584 //              Name:    BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &, BackupContext &) 
     591//              Name:    BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    585592//              Purpose: Delete a file 
    586593//              Created: 2003/10/21 
    587594// 
    588595// -------------------------------------------------------------------------- 
    589 std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     596std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    590597{ 
    591598        CHECK_PHASE(Phase_Commands) 
     
    604611// 
    605612// Function 
    606 //              Name:    BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &, BackupContext &) 
     613//              Name:    BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    607614//              Purpose: Delete a directory 
    608615//              Created: 2003/10/21 
    609616// 
    610617// -------------------------------------------------------------------------- 
    611 std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     618std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    612619{ 
    613620        CHECK_PHASE(Phase_Commands) 
     
    632639// 
    633640// Function 
    634 //              Name:    BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &, BackupContext &) 
     641//              Name:    BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    635642//              Purpose: Undelete a directory 
    636643//              Created: 23/11/03 
    637644// 
    638645// -------------------------------------------------------------------------- 
    639 std::auto_ptr<ProtocolObject> BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     646std::auto_ptr<ProtocolObject> BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    640647{ 
    641648        CHECK_PHASE(Phase_Commands) 
     
    659666// 
    660667// Function 
    661 //              Name:    BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &, BackupContext &) 
     668//              Name:    BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    662669//              Purpose: Command to set the client's store marker 
    663670//              Created: 2003/10/29 
    664671// 
    665672// -------------------------------------------------------------------------- 
    666 std::auto_ptr<ProtocolObject> BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     673std::auto_ptr<ProtocolObject> BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    667674{ 
    668675        CHECK_PHASE(Phase_Commands) 
     
    680687// 
    681688// Function 
    682 //              Name:    BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &, BackupContext &) 
     689//              Name:    BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    683690//              Purpose: Command to move an object from one directory to another 
    684691//              Created: 2003/11/12 
    685692// 
    686693// -------------------------------------------------------------------------- 
    687 std::auto_ptr<ProtocolObject> BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     694std::auto_ptr<ProtocolObject> BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    688695{ 
    689696        CHECK_PHASE(Phase_Commands) 
     
    723730// 
    724731// Function 
    725 //              Name:    BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &, BackupContext &) 
     732//              Name:    BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    726733//              Purpose: Command to find the name of an object 
    727734//              Created: 12/11/03 
    728735// 
    729736// -------------------------------------------------------------------------- 
    730 std::auto_ptr<ProtocolObject> BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     737std::auto_ptr<ProtocolObject> BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    731738{ 
    732739        CHECK_PHASE(Phase_Commands) 
     
    749756        { 
    750757                // Check the directory really exists 
    751                 if(!rContext.ObjectExists(dirID, BackupContext::ObjectExists_Directory)) 
     758                if(!rContext.ObjectExists(dirID, BackupStoreContext::ObjectExists_Directory)) 
    752759                { 
    753760                        return std::auto_ptr<ProtocolObject>(new BackupProtocolServerObjectName(BackupProtocolServerObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0)); 
     
    814821// 
    815822// Function 
    816 //              Name:    BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &, BackupContext &) 
     823//              Name:    BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    817824//              Purpose: Get the block index from a file, by ID 
    818825//              Created: 19/1/04 
    819826// 
    820827// -------------------------------------------------------------------------- 
    821 std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     828std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    822829{ 
    823830        CHECK_PHASE(Phase_Commands) 
     
    840847// 
    841848// Function 
    842 //              Name:    BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &, BackupContext &) 
     849//              Name:    BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    843850//              Purpose: Get the block index from a file, by name within a directory 
    844851//              Created: 19/1/04 
    845852// 
    846853// -------------------------------------------------------------------------- 
    847 std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     854std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    848855{ 
    849856        CHECK_PHASE(Phase_Commands) 
     
    892899// 
    893900// Function 
    894 //              Name:    BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &, BackupContext &) 
     901//              Name:    BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    895902//              Purpose: Return the amount of disc space used 
    896903//              Created: 19/4/04 
    897904// 
    898905// -------------------------------------------------------------------------- 
    899 std::auto_ptr<ProtocolObject> BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     906std::auto_ptr<ProtocolObject> BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    900907{ 
    901908        CHECK_PHASE(Phase_Commands) 
     
    923930// 
    924931// Function 
    925 //              Name:    BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &, BackupContext &) 
     932//              Name:    BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
    926933//              Purpose: Return the amount of disc space used 
    927934//              Created: 19/4/04 
    928935// 
    929936// -------------------------------------------------------------------------- 
    930 std::auto_ptr<ProtocolObject> BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
     937std::auto_ptr<ProtocolObject> BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
    931938{ 
    932939        CHECK_PHASE(Phase_Commands) 
  • box/trunk/bin/bbstored/BackupStoreContext.cpp

    r2127 r2226  
    22// 
    33// File 
    4 //              Name:    BackupContext.cpp 
     4//              Name:    BackupStoreContext.cpp 
    55//              Purpose: Context for backup store server 
    66//              Created: 2003/08/20 
     
    1212#include <stdio.h> 
    1313 
    14 #include "BackupContext.h" 
     14#include "BackupStoreContext.h" 
    1515#include "RaidFileWrite.h" 
    1616#include "RaidFileRead.h" 
     
    4949// 
    5050// Function 
    51 //              Name:    BackupContext::BackupContext() 
     51//              Name:    BackupStoreContext::BackupStoreContext() 
    5252//              Purpose: Constructor 
    5353//              Created: 2003/08/20 
    5454// 
    5555// -------------------------------------------------------------------------- 
    56 BackupContext::BackupContext(int32_t ClientID, BackupStoreDaemon &rDaemon) 
     56BackupStoreContext::BackupStoreContext(int32_t ClientID, BackupStoreDaemon &rDaemon) 
    5757        : mClientID(ClientID), 
    5858          mrDaemon(rDaemon), 
     
    6161          mStoreDiscSet(-1), 
    6262          mReadOnly(true), 
    63           mSaveStoreInfoDelay(STORE_INFO_SAVE_DELAY) 
    64 
    65 
    66  
    67 // -------------------------------------------------------------------------- 
    68 // 
    69 // Function 
    70 //              Name:    BackupContext::~BackupContext() 
     63          mSaveStoreInfoDelay(STORE_INFO_SAVE_DELAY), 
     64          mpTestHook(NULL) 
     65
     66
     67 
     68// -------------------------------------------------------------------------- 
     69// 
     70// Function 
     71//              Name:    BackupStoreContext::~BackupStoreContext() 
    7172//              Purpose: Destructor 
    7273//              Created: 2003/08/20 
    7374// 
    7475// -------------------------------------------------------------------------- 
    75 BackupContext::~BackupContext() 
     76BackupStoreContext::~BackupStoreContext() 
    7677{ 
    7778        // Delete the objects in the cache 
     
    8687// 
    8788// Function 
    88 //              Name:    BackupContext::CleanUp() 
     89//              Name:    BackupStoreContext::CleanUp() 
    8990//              Purpose: Clean up after a connection 
    9091//              Created: 16/12/03 
    9192// 
    9293// -------------------------------------------------------------------------- 
    93 void BackupContext::CleanUp() 
     94void BackupStoreContext::CleanUp() 
    9495{ 
    9596        // Make sure the store info is saved, if it has been loaded, isn't read only and has been modified 
     
    103104// 
    104105// Function 
    105 //              Name:    BackupContext::ReceivedFinishCommand() 
     106//              Name:    BackupStoreContext::ReceivedFinishCommand() 
    106107//              Purpose: Called when the finish command is received by the protocol 
    107108//              Created: 16/12/03 
    108109// 
    109110// -------------------------------------------------------------------------- 
    110 void BackupContext::ReceivedFinishCommand() 
     111void BackupStoreContext::ReceivedFinishCommand() 
    111112{ 
    112113        if(!mReadOnly && mpStoreInfo.get()) 
     
    121122// 
    122123// Function 
    123 //              Name:    BackupContext::AttemptToGetWriteLock() 
     124//              Name:    BackupStoreContext::AttemptToGetWriteLock() 
    124125//              Purpose: Attempt to get a write lock for the store, and if so, unset the read only flags 
    125126//              Created: 2003/09/02 
    126127// 
    127128// -------------------------------------------------------------------------- 
    128 bool BackupContext::AttemptToGetWriteLock() 
     129bool BackupStoreContext::AttemptToGetWriteLock() 
    129130{ 
    130131        // Make the filename of the write lock file 
     
    167168// 
    168169// Function 
    169 //              Name:    BackupContext::LoadStoreInfo() 
     170//              Name:    BackupStoreContext::LoadStoreInfo() 
    170171//              Purpose: Load the store info from disc 
    171172//              Created: 2003/09/03 
    172173// 
    173174// -------------------------------------------------------------------------- 
    174 void BackupContext::LoadStoreInfo() 
     175void BackupStoreContext::LoadStoreInfo() 
    175176{ 
    176177        if(mpStoreInfo.get() != 0) 
     
    196197// 
    197198// Function 
    198 //              Name:    BackupContext::SaveStoreInfo(bool) 
     199//              Name:    BackupStoreContext::SaveStoreInfo(bool) 
    199200//              Purpose: Potentially delayed saving of the store info 
    200201//              Created: 16/12/03 
    201202// 
    202203// -------------------------------------------------------------------------- 
    203 void BackupContext::SaveStoreInfo(bool AllowDelay) 
     204void BackupStoreContext::SaveStoreInfo(bool AllowDelay) 
    204205{ 
    205206        if(mpStoreInfo.get() == 0) 
     
    234235// 
    235236// Function 
    236 //              Name:    BackupContext::MakeObjectFilename(int64_t, std::string &, bool) 
     237//              Name:    BackupStoreContext::MakeObjectFilename(int64_t, std::string &, bool) 
    237238//              Purpose: Create the filename of an object in the store, optionally creating the  
    238239//                               containing directory if it doesn't already exist. 
     
    240241// 
    241242// -------------------------------------------------------------------------- 
    242 void BackupContext::MakeObjectFilename(int64_t ObjectID, std::string &rOutput, bool EnsureDirectoryExists) 
     243void BackupStoreContext::MakeObjectFilename(int64_t ObjectID, std::string &rOutput, bool EnsureDirectoryExists) 
    243244{ 
    244245        // Delegate to utility function 
     
    250251// 
    251252// Function 
    252 //              Name:    BackupContext::GetDirectoryInternal(int64_t) 
     253//              Name:    BackupStoreContext::GetDirectoryInternal(int64_t) 
    253254//              Purpose: Return a reference to a directory. Valid only until the  
    254255//                               next time a function which affects directories is called. 
     
    258259// 
    259260// -------------------------------------------------------------------------- 
    260 BackupStoreDirectory &BackupContext::GetDirectoryInternal(int64_t ObjectID) 
     261BackupStoreDirectory &BackupStoreContext::GetDirectoryInternal(int64_t ObjectID) 
    261262{ 
    262263        // Get the filename 
     
    344345// 
    345346// Function 
    346 //              Name:    BackupContext::AllocateObjectID() 
     347//              Name:    BackupStoreContext::AllocateObjectID() 
    347348//              Purpose: Allocate a new object ID, tolerant of failures to save store info 
    348349//              Created: 16/12/03 
    349350// 
    350351// -------------------------------------------------------------------------- 
    351 int64_t BackupContext::AllocateObjectID() 
     352int64_t BackupStoreContext::AllocateObjectID() 
    352353{ 
    353354        if(mpStoreInfo.get() == 0) 
     
    394395// 
    395396// Function 
    396 //              Name:    BackupContext::AddFile(IOStream &, int64_t, int64_t, int64_t, const BackupStoreFilename &, bool) 
     397//              Name:    BackupStoreContext::AddFile(IOStream &, int64_t, int64_t, int64_t, const BackupStoreFilename &, bool) 
    397398//              Purpose: Add a file to the store, from a given stream, into a specified directory. 
    398399//                               Returns object ID of the new file. 
     
    400401// 
    401402// -------------------------------------------------------------------------- 
    402 int64_t BackupContext::AddFile(IOStream &rFile, int64_t InDirectory, int64_t ModificationTime, 
     403int64_t BackupStoreContext::AddFile(IOStream &rFile, int64_t InDirectory, int64_t ModificationTime, 
    403404                int64_t AttributesHash, int64_t DiffFromFileID, const BackupStoreFilename &rFilename, 
    404405                bool MarkFileWithSameNameAsOldVersions) 
     
    682683// 
    683684// Function 
    684 //              Name:    BackupContext::DeleteFile(const BackupStoreFilename &, int64_t, int64_t &) 
     685//              Name:    BackupStoreContext::DeleteFile(const BackupStoreFilename &, int64_t, int64_t &) 
    685686//              Purpose: Deletes a file, returning true if the file existed. Object ID returned too, set to zero if not found. 
    686687//              Created: 2003/10/21 
    687688// 
    688689// -------------------------------------------------------------------------- 
    689 bool BackupContext::DeleteFile(const BackupStoreFilename &rFilename, int64_t InDirectory, int64_t &rObjectIDOut) 
     690bool BackupStoreContext::DeleteFile(const BackupStoreFilename &rFilename, int64_t InDirectory, int64_t &rObjectIDOut) 
    690691{ 
    691692        // Essential checks! 
     
    769770// 
    770771// Function 
    771 //              Name:    BackupContext::RemoveDirectoryFromCache(int64_t) 
     772//              Name:    BackupStoreContext::RemoveDirectoryFromCache(int64_t) 
    772773//              Purpose: Remove directory from cache 
    773774//              Created: 2003/09/04 
    774775// 
    775776// -------------------------------------------------------------------------- 
    776 void BackupContext::RemoveDirectoryFromCache(int64_t ObjectID) 
     777void BackupStoreContext::RemoveDirectoryFromCache(int64_t ObjectID) 
    777778{ 
    778779        std::map<int64_t, BackupStoreDirectory*>::iterator item(mDirectoryCache.find(ObjectID)); 
     
    790791// 
    791792// Function 
    792 //              Name:    BackupContext::SaveDirectory(BackupStoreDirectory &, int64_t) 
     793//              Name:    BackupStoreContext::SaveDirectory(BackupStoreDirectory &, int64_t) 
    793794//              Purpose: Save directory back to disc, update time in cache 
    794795//              Created: 2003/09/04 
    795796// 
    796797// -------------------------------------------------------------------------- 
    797 void BackupContext::SaveDirectory(BackupStoreDirectory &rDir, int64_t ObjectID) 
     798void BackupStoreContext::SaveDirectory(BackupStoreDirectory &rDir, int64_t ObjectID) 
    798799{ 
    799800        if(mpStoreInfo.get() == 0) 
     
    852853// 
    853854// Function 
    854 //              Name:    BackupContext::AddDirectory(int64_t, const BackupStoreFilename &, bool &) 
     855//              Name:    BackupStoreContext::AddDirectory(int64_t, const BackupStoreFilename &, bool &) 
    855856//              Purpose: Creates a directory (or just returns the ID of an existing one). rAlreadyExists set appropraitely. 
    856857//              Created: 2003/09/04 
    857858// 
    858859// -------------------------------------------------------------------------- 
    859 int64_t BackupContext::AddDirectory(int64_t InDirectory, const BackupStoreFilename &rFilename, const StreamableMemBlock &Attributes, int64_t AttributesModTime, bool &rAlreadyExists) 
     860int64_t BackupStoreContext::AddDirectory(int64_t InDirectory, const BackupStoreFilename &rFilename, const StreamableMemBlock &Attributes, int64_t AttributesModTime, bool &rAlreadyExists) 
    860861{ 
    861862        if(mpStoreInfo.get() == 0) 
     
    946947// 
    947948// Function 
    948 //              Name:    BackupContext::DeleteFile(const BackupStoreFilename &, int64_t, int64_t &, bool) 
     949//              Name:    BackupStoreContext::DeleteFile(const BackupStoreFilename &, int64_t, int64_t &, bool) 
    949950//              Purpose: Recusively deletes a directory (or undeletes if Undelete = true) 
    950951//              Created: 2003/10/21 
    951952// 
    952953// -------------------------------------------------------------------------- 
    953 void BackupContext::DeleteDirectory(int64_t ObjectID, bool Undelete) 
     954void BackupStoreContext::DeleteDirectory(int64_t ObjectID, bool Undelete) 
    954955{ 
    955956        // Essential checks! 
     
    10281029// 
    10291030// Function 
    1030 //              Name:    BackupContext::DeleteDirectoryRecurse(BackupStoreDirectory &, int64_t) 
     1031//              Name:    BackupStoreContext::DeleteDirectoryRecurse(BackupStoreDirectory &, int64_t) 
    10311032//              Purpose: Private. Deletes a directory depth-first recusively. 
    10321033//              Created: 2003/10/21 
    10331034// 
    10341035// -------------------------------------------------------------------------- 
    1035 void BackupContext::DeleteDirectoryRecurse(int64_t ObjectID, int64_t &rBlocksDeletedOut, bool Undelete) 
     1036void BackupStoreContext::DeleteDirectoryRecurse(int64_t ObjectID, int64_t &rBlocksDeletedOut, bool Undelete) 
    10361037{ 
    10371038        try 
     
    11301131// 
    11311132// Function 
    1132 //              Name:    BackupContext::ChangeDirAttributes(int64_t, const StreamableMemBlock &, int64_t) 
     1133//              Name:    BackupStoreContext::ChangeDirAttributes(int64_t, const StreamableMemBlock &, int64_t) 
    11331134//              Purpose: Change the attributes of a directory 
    11341135//              Created: 2003/09/06 
    11351136// 
    11361137// -------------------------------------------------------------------------- 
    1137 void BackupContext::ChangeDirAttributes(int64_t Directory, const StreamableMemBlock &Attributes, int64_t AttributesModTime) 
     1138void BackupStoreContext::ChangeDirAttributes(int64_t Directory, const StreamableMemBlock &Attributes, int64_t AttributesModTime) 
    11381139{ 
    11391140        if(mpStoreInfo.get() == 0) 
     
    11671168// 
    11681169// Function 
    1169 //              Name:    BackupContext::ChangeFileAttributes(int64_t, int64_t, const StreamableMemBlock &, int64_t) 
     1170//              Name:    BackupStoreContext::ChangeFileAttributes(int64_t, int64_t, const StreamableMemBlock &, int64_t) 
    11701171//              Purpose: Sets the attributes on a directory entry. Returns true if the object existed, false if it didn't. 
    11711172//              Created: 2003/09/06 
    11721173// 
    11731174// -------------------------------------------------------------------------- 
    1174 bool BackupContext::ChangeFileAttributes(const BackupStoreFilename &rFilename, int64_t InDirectory, const StreamableMemBlock &Attributes, int64_t AttributesHash, int64_t &rObjectIDOut) 
     1175bool BackupStoreContext::ChangeFileAttributes(const BackupStoreFilename &rFilename, int64_t InDirectory, const StreamableMemBlock &Attributes, int64_t AttributesHash, int64_t &rObjectIDOut) 
    11751176{ 
    11761177        if(mpStoreInfo.get() == 0) 
     
    12321233// 
    12331234// Function 
    1234 //              Name:    BackupContext::ObjectExists(int64_t) 
     1235//              Name:    BackupStoreContext::ObjectExists(int64_t) 
    12351236//              Purpose: Test to see if an object of this ID exists in the store 
    12361237//              Created: 2003/09/03 
    12371238// 
    12381239// -------------------------------------------------------------------------- 
    1239 bool BackupContext::ObjectExists(int64_t ObjectID, int MustBe) 
     1240bool BackupStoreContext::ObjectExists(int64_t ObjectID, int MustBe) 
    12401241{ 
    12411242        if(mpStoreInfo.get() == 0) 
     
    13031304// 
    13041305// Function 
    1305 //              Name:    BackupContext::OpenObject(int64_t) 
     1306//              Name:    BackupStoreContext::OpenObject(int64_t) 
    13061307//              Purpose: Opens an object 
    13071308//              Created: 2003/09/03 
    13081309// 
    13091310// -------------------------------------------------------------------------- 
    1310 std::auto_ptr<IOStream> BackupContext::OpenObject(int64_t ObjectID) 
     1311std::auto_ptr<IOStream> BackupStoreContext::OpenObject(int64_t ObjectID) 
    13111312{ 
    13121313        if(mpStoreInfo.get() == 0) 
     
    13251326// 
    13261327// Function 
    1327 //              Name:    BackupContext::GetClientStoreMarker() 
     1328//              Name:    BackupStoreContext::GetClientStoreMarker() 
    13281329//              Purpose: Retrieve the client store marker 
    13291330//              Created: 2003/10/29 
    13301331// 
    13311332// -------------------------------------------------------------------------- 
    1332 int64_t BackupContext::GetClientStoreMarker() 
     1333int64_t BackupStoreContext::GetClientStoreMarker() 
    13331334{ 
    13341335        if(mpStoreInfo.get() == 0) 
     
    13441345// 
    13451346// Function 
    1346 //              Name:    BackupContext::GetStoreDiscUsageInfo(int64_t &, int64_t &, int64_t &) 
     1347//              Name:    BackupStoreContext::GetStoreDiscUsageInfo(int64_t &, int64_t &, int64_t &) 
    13471348//              Purpose: Get disc usage info from store info 
    13481349//              Created: 1/1/04 
    13491350// 
    13501351// -------------------------------------------------------------------------- 
    1351 void BackupContext::GetStoreDiscUsageInfo(int64_t &rBlocksUsed, int64_t &rBlocksSoftLimit, int64_t &rBlocksHardLimit) 
     1352void BackupStoreContext::GetStoreDiscUsageInfo(int64_t &rBlocksUsed, int64_t &rBlocksSoftLimit, int64_t &rBlocksHardLimit) 
    13521353{ 
    13531354        if(mpStoreInfo.get() == 0) 
     
    13651366// 
    13661367// Function 
    1367 //              Name:    BackupContext::HardLimitExceeded() 
     1368//              Name:    BackupStoreContext::HardLimitExceeded() 
    13681369//              Purpose: Returns true if the hard limit has been exceeded 
    13691370//              Created: 1/1/04 
    13701371// 
    13711372// -------------------------------------------------------------------------- 
    1372 bool BackupContext::HardLimitExceeded() 
     1373bool BackupStoreContext::HardLimitExceeded() 
    13731374{ 
    13741375        if(mpStoreInfo.get() == 0) 
     
    13841385// 
    13851386// Function 
    1386 //              Name:    BackupContext::SetClientStoreMarker(int64_t) 
     1387//              Name:    BackupStoreContext::SetClientStoreMarker(int64_t) 
    13871388//              Purpose: Sets the client store marker, and commits it to disc 
    13881389//              Created: 2003/10/29 
    13891390// 
    13901391// -------------------------------------------------------------------------- 
    1391 void BackupContext::SetClientStoreMarker(int64_t ClientStoreMarker) 
     1392void BackupStoreContext::SetClientStoreMarker(int64_t ClientStoreMarker) 
    13921393{ 
    13931394        if(mpStoreInfo.get() == 0) 
     
    14081409// 
    14091410// Function 
    1410 //              Name:    BackupContext::MoveObject(int64_t, int64_t, int64_t, const BackupStoreFilename &, bool) 
     1411//              Name:    BackupStoreContext::MoveObject(int64_t, int64_t, int64_t, const BackupStoreFilename &, bool) 
    14111412//              Purpose: Move an object (and all objects with the same name) from one directory to another 
    14121413//              Created: 12/11/03 
    14131414// 
    14141415// -------------------------------------------------------------------------- 
    1415 void BackupContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, int64_t MoveToDirectory, const BackupStoreFilename &rNewFilename, bool MoveAllWithSameName, bool AllowMoveOverDeletedObject) 
     1416void BackupStoreContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, int64_t MoveToDirectory, const BackupStoreFilename &rNewFilename, bool MoveAllWithSameName, bool AllowMoveOverDeletedObject) 
    14161417{ 
    14171418        if(mReadOnly) 
     
    16531654// 
    16541655// Function 
    1655 //              Name:    BackupContext::GetBackupStoreInfo() 
     1656//              Name:    BackupStoreContext::GetBackupStoreInfo() 
    16561657//              Purpose: Return the backup store info object, exception if it isn't loaded 
    16571658//              Created: 19/4/04 
    16581659// 
    16591660// -------------------------------------------------------------------------- 
    1660 const BackupStoreInfo &BackupContext::GetBackupStoreInfo() const 
     1661const BackupStoreInfo &BackupStoreContext::GetBackupStoreInfo() const 
    16611662{ 
    16621663        if(mpStoreInfo.get() == 0) 
  • box/trunk/bin/bbstored/BackupStoreContext.h

    r217 r2226  
    22// 
    33// File 
    4 //              Name:    BackupContext.h 
     4//              Name:    BackupStoreContext.h 
    55//              Purpose: Context for backup store server 
    66//              Created: 2003/08/20 
     
    1616 
    1717#include "NamedLock.h" 
     18#include "ProtocolObject.h" 
    1819#include "Utils.h" 
    1920 
     
    2324class BackupStoreInfo; 
    2425class IOStream; 
     26class BackupProtocolObject; 
    2527class StreamableMemBlock; 
    2628 
     
    2830// 
    2931// Class 
    30 //              Name:    BackupContext 
     32//              Name:    BackupStoreContext 
    3133//              Purpose: Context for backup store server 
    3234//              Created: 2003/08/20 
    3335// 
    3436// -------------------------------------------------------------------------- 
    35 class BackupContext 
     37class BackupStoreContext 
    3638{ 
    3739public: 
    38         BackupContext(int32_t ClientID, BackupStoreDaemon &rDaemon); 
    39         ~BackupContext(); 
     40        BackupStoreContext(int32_t ClientID, BackupStoreDaemon &rDaemon); 
     41        ~BackupStoreContext(); 
    4042private: 
    41         BackupContext(const BackupContext &rToCopy); 
     43        BackupStoreContext(const BackupStoreContext &rToCopy); 
    4244public: 
    4345 
     
    8486        // 
    8587        // Function 
    86         //              Name:    BackupContext::GetDirectory(int64_t) 
     88        //              Name:    BackupStoreContext::GetDirectory(int64_t) 
    8789        //              Purpose: Return a reference to a directory. Valid only until the  
    8890        //                               next time a function which affects directories is called. 
     
    144146        // Directory cache 
    145147        std::map<int64_t, BackupStoreDirectory*> mDirectoryCache; 
     148 
     149public: 
     150        class TestHook 
     151        { 
     152                public: 
     153                virtual std::auto_ptr<ProtocolObject> StartCommand(BackupProtocolObject& 
     154                        rCommand) = 0; 
     155                virtual ~TestHook() { } 
     156        }; 
     157        void SetTestHook(TestHook& rTestHook) 
     158        { 
     159                mpTestHook = &rTestHook; 
     160        } 
     161        std::auto_ptr<ProtocolObject> StartCommandHook(BackupProtocolObject& rCommand) 
     162        { 
     163                if(mpTestHook) 
     164                { 
     165                        return mpTestHook->StartCommand(rCommand); 
     166                } 
     167                return std::auto_ptr<ProtocolObject>(); 
     168        } 
     169 
     170private: 
     171        TestHook* mpTestHook; 
    146172}; 
    147173 
  • box/trunk/bin/bbstored/BackupStoreDaemon.cpp

    r1891 r2226  
    1818#endif 
    1919 
    20 #include "BackupContext.h" 
     20#include "BackupStoreContext.h" 
    2121#include "BackupStoreDaemon.h" 
    2222#include "BackupStoreConfigVerify.h" 
     
    4444          mIsHousekeepingProcess(false), 
    4545          mHousekeepingInited(false), 
    46           mInterProcessComms(mInterProcessCommsSocket) 
     46          mInterProcessComms(mInterProcessCommsSocket), 
     47          mpTestHook(NULL) 
    4748{ 
    4849} 
     
    321322 
    322323        // Create a context, using this ID 
    323         BackupContext context(id, *this); 
     324        BackupStoreContext context(id, *this); 
     325 
     326        if (mpTestHook) 
     327        { 
     328                context.SetTestHook(*mpTestHook); 
     329        } 
    324330         
    325331        // See if the client has an account? 
  • box/trunk/bin/bbstored/BackupStoreDaemon.h

    r1891 r2226  
    1414#include "BoxPortsAndFiles.h" 
    1515#include "BackupConstants.h" 
     16#include "BackupStoreContext.h" 
    1617#include "IOStreamGetLine.h" 
    1718