Changeset 2226
- Timestamp:
- 07/08/2008 17:35:09 (4 months ago)
- Files:
-
- box/trunk/bin/bbstored/BackupCommands.cpp (modified) (26 diffs)
- box/trunk/bin/bbstored/BackupStoreContext.cpp (moved) (moved from box/trunk/bin/bbstored/BackupContext.cpp) (32 diffs)
- box/trunk/bin/bbstored/BackupStoreContext.h (moved) (moved from box/trunk/bin/bbstored/BackupContext.h) (6 diffs)
- box/trunk/bin/bbstored/BackupStoreDaemon.cpp (modified) (3 diffs)
- box/trunk/bin/bbstored/BackupStoreDaemon.h (modified) (3 diffs)
- box/trunk/bin/bbstored/backupprotocol.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
box/trunk/bin/bbstored/BackupCommands.cpp
r2179 r2226 16 16 #include "autogen_RaidFileException.h" 17 17 #include "BackupConstants.h" 18 #include "Backup Context.h"18 #include "BackupStoreContext.h" 19 19 #include "BackupStoreConstants.h" 20 20 #include "BackupStoreDirectory.h" … … 32 32 33 33 #define CHECK_PHASE(phase) \ 34 if(rContext.GetPhase() != Backup Context::phase) \34 if(rContext.GetPhase() != BackupStoreContext::phase) \ 35 35 { \ 36 36 return std::auto_ptr<ProtocolObject>(new BackupProtocolServerError( \ … … 48 48 // 49 49 // Function 50 // Name: BackupProtocolServerVersion::DoCommand(Protocol &, Backup Context &)50 // Name: BackupProtocolServerVersion::DoCommand(Protocol &, BackupStoreContext &) 51 51 // Purpose: Return the current version, or an error if the requested version isn't allowed 52 52 // Created: 2003/08/20 53 53 // 54 54 // -------------------------------------------------------------------------- 55 std::auto_ptr<ProtocolObject> BackupProtocolServerVersion::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)55 std::auto_ptr<ProtocolObject> BackupProtocolServerVersion::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 56 56 { 57 57 CHECK_PHASE(Phase_Version) … … 65 65 66 66 // Mark the next phase 67 rContext.SetPhase(Backup Context::Phase_Login);67 rContext.SetPhase(BackupStoreContext::Phase_Login); 68 68 69 69 // Return our version … … 74 74 // 75 75 // Function 76 // Name: BackupProtocolServerLogin::DoCommand(Protocol &, Backup Context &)76 // Name: BackupProtocolServerLogin::DoCommand(Protocol &, BackupStoreContext &) 77 77 // Purpose: Return the current version, or an error if the requested version isn't allowed 78 78 // Created: 2003/08/20 79 79 // 80 80 // -------------------------------------------------------------------------- 81 std::auto_ptr<ProtocolObject> BackupProtocolServerLogin::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)81 std::auto_ptr<ProtocolObject> BackupProtocolServerLogin::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 82 82 { 83 83 CHECK_PHASE(Phase_Login) … … 132 132 133 133 // Mark the next phase 134 rContext.SetPhase(Backup Context::Phase_Commands);134 rContext.SetPhase(BackupStoreContext::Phase_Commands); 135 135 136 136 // Log login … … 152 152 // 153 153 // Function 154 // Name: BackupProtocolServerFinished::DoCommand(Protocol &, Backup Context &)154 // Name: BackupProtocolServerFinished::DoCommand(Protocol &, BackupStoreContext &) 155 155 // Purpose: Marks end of conversation (Protocol framework handles this) 156 156 // Created: 2003/08/20 157 157 // 158 158 // -------------------------------------------------------------------------- 159 std::auto_ptr<ProtocolObject> BackupProtocolServerFinished::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)159 std::auto_ptr<ProtocolObject> BackupProtocolServerFinished::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 160 160 { 161 161 BOX_NOTICE("Session finished for Client ID " << … … 173 173 // 174 174 // Function 175 // Name: BackupProtocolServerListDirectory::DoCommand(Protocol &, Backup Context &)175 // Name: BackupProtocolServerListDirectory::DoCommand(Protocol &, BackupStoreContext &) 176 176 // Purpose: Command to list a directory 177 177 // Created: 2003/09/02 178 178 // 179 179 // -------------------------------------------------------------------------- 180 std::auto_ptr<ProtocolObject> BackupProtocolServerListDirectory::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)180 std::auto_ptr<ProtocolObject> BackupProtocolServerListDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 181 181 { 182 182 CHECK_PHASE(Phase_Commands) … … 218 218 // 219 219 // Function 220 // Name: BackupProtocolServerStoreFile::DoCommand(Protocol &, Backup Context &)220 // Name: BackupProtocolServerStoreFile::DoCommand(Protocol &, BackupStoreContext &) 221 221 // Purpose: Command to store a file on the server 222 222 // Created: 2003/09/02 223 223 // 224 224 // -------------------------------------------------------------------------- 225 std::auto_ptr<ProtocolObject> BackupProtocolServerStoreFile::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)225 std::auto_ptr<ProtocolObject> BackupProtocolServerStoreFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 226 226 { 227 227 CHECK_PHASE(Phase_Commands) 228 228 CHECK_WRITEABLE_SESSION 229 230 std::auto_ptr<ProtocolObject> hookResult = 231 rContext.StartCommandHook(*this); 232 if(hookResult.get()) 233 { 234 return hookResult; 235 } 229 236 230 237 // Check that the diff from file actually exists, if it's specified 231 238 if(mDiffFromFileID != 0) 232 239 { 233 if(!rContext.ObjectExists(mDiffFromFileID, Backup Context::ObjectExists_File))240 if(!rContext.ObjectExists(mDiffFromFileID, BackupStoreContext::ObjectExists_File)) 234 241 { 235 242 return std::auto_ptr<ProtocolObject>(new BackupProtocolServerError( … … 276 283 // 277 284 // Function 278 // Name: BackupProtocolServerGetObject::DoCommand(Protocol &, Backup Context &)285 // Name: BackupProtocolServerGetObject::DoCommand(Protocol &, BackupStoreContext &) 279 286 // Purpose: Command to get an arbitary object from the server 280 287 // Created: 2003/09/03 281 288 // 282 289 // -------------------------------------------------------------------------- 283 std::auto_ptr<ProtocolObject> BackupProtocolServerGetObject::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)290 std::auto_ptr<ProtocolObject> BackupProtocolServerGetObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 284 291 { 285 292 CHECK_PHASE(Phase_Commands) … … 304 311 // 305 312 // Function 306 // Name: BackupProtocolServerGetFile::DoCommand(Protocol &, Backup Context &)313 // Name: BackupProtocolServerGetFile::DoCommand(Protocol &, BackupStoreContext &) 307 314 // Purpose: Command to get an file object from the server -- may have to do a bit of 308 315 // work to get the object. … … 310 317 // 311 318 // -------------------------------------------------------------------------- 312 std::auto_ptr<ProtocolObject> BackupProtocolServerGetFile::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)319 std::auto_ptr<ProtocolObject> BackupProtocolServerGetFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 313 320 { 314 321 CHECK_PHASE(Phase_Commands) … … 476 483 // 477 484 // Function 478 // Name: BackupProtocolServerCreateDirectory::DoCommand(Protocol &, Backup Context &)485 // Name: BackupProtocolServerCreateDirectory::DoCommand(Protocol &, BackupStoreContext &) 479 486 // Purpose: Create directory command 480 487 // Created: 2003/09/04 481 488 // 482 489 // -------------------------------------------------------------------------- 483 std::auto_ptr<ProtocolObject> BackupProtocolServerCreateDirectory::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)490 std::auto_ptr<ProtocolObject> BackupProtocolServerCreateDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 484 491 { 485 492 CHECK_PHASE(Phase_Commands) … … 519 526 // 520 527 // Function 521 // Name: BackupProtocolServerChangeDirAttributes::DoCommand(Protocol &, Backup Context &)528 // Name: BackupProtocolServerChangeDirAttributes::DoCommand(Protocol &, BackupStoreContext &) 522 529 // Purpose: Change attributes on directory 523 530 // Created: 2003/09/06 524 531 // 525 532 // -------------------------------------------------------------------------- 526 std::auto_ptr<ProtocolObject> BackupProtocolServerChangeDirAttributes::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)533 std::auto_ptr<ProtocolObject> BackupProtocolServerChangeDirAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 527 534 { 528 535 CHECK_PHASE(Phase_Commands) … … 547 554 // 548 555 // Function 549 // Name: BackupProtocolServerSetReplacementFileAttributes::DoCommand(Protocol &, Backup Context &)556 // Name: BackupProtocolServerSetReplacementFileAttributes::DoCommand(Protocol &, BackupStoreContext &) 550 557 // Purpose: Change attributes on directory 551 558 // Created: 2003/09/06 552 559 // 553 560 // -------------------------------------------------------------------------- 554 std::auto_ptr<ProtocolObject> BackupProtocolServerSetReplacementFileAttributes::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)561 std::auto_ptr<ProtocolObject> BackupProtocolServerSetReplacementFileAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 555 562 { 556 563 CHECK_PHASE(Phase_Commands) … … 582 589 // 583 590 // Function 584 // Name: BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &, Backup Context &)591 // Name: BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &, BackupStoreContext &) 585 592 // Purpose: Delete a file 586 593 // Created: 2003/10/21 587 594 // 588 595 // -------------------------------------------------------------------------- 589 std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)596 std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 590 597 { 591 598 CHECK_PHASE(Phase_Commands) … … 604 611 // 605 612 // Function 606 // Name: BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &, Backup Context &)613 // Name: BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &, BackupStoreContext &) 607 614 // Purpose: Delete a directory 608 615 // Created: 2003/10/21 609 616 // 610 617 // -------------------------------------------------------------------------- 611 std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)618 std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 612 619 { 613 620 CHECK_PHASE(Phase_Commands) … … 632 639 // 633 640 // Function 634 // Name: BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &, Backup Context &)641 // Name: BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &, BackupStoreContext &) 635 642 // Purpose: Undelete a directory 636 643 // Created: 23/11/03 637 644 // 638 645 // -------------------------------------------------------------------------- 639 std::auto_ptr<ProtocolObject> BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)646 std::auto_ptr<ProtocolObject> BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 640 647 { 641 648 CHECK_PHASE(Phase_Commands) … … 659 666 // 660 667 // Function 661 // Name: BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &, Backup Context &)668 // Name: BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &, BackupStoreContext &) 662 669 // Purpose: Command to set the client's store marker 663 670 // Created: 2003/10/29 664 671 // 665 672 // -------------------------------------------------------------------------- 666 std::auto_ptr<ProtocolObject> BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)673 std::auto_ptr<ProtocolObject> BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 667 674 { 668 675 CHECK_PHASE(Phase_Commands) … … 680 687 // 681 688 // Function 682 // Name: BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &, Backup Context &)689 // Name: BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &, BackupStoreContext &) 683 690 // Purpose: Command to move an object from one directory to another 684 691 // Created: 2003/11/12 685 692 // 686 693 // -------------------------------------------------------------------------- 687 std::auto_ptr<ProtocolObject> BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)694 std::auto_ptr<ProtocolObject> BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 688 695 { 689 696 CHECK_PHASE(Phase_Commands) … … 723 730 // 724 731 // Function 725 // Name: BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &, Backup Context &)732 // Name: BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &, BackupStoreContext &) 726 733 // Purpose: Command to find the name of an object 727 734 // Created: 12/11/03 728 735 // 729 736 // -------------------------------------------------------------------------- 730 std::auto_ptr<ProtocolObject> BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)737 std::auto_ptr<ProtocolObject> BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 731 738 { 732 739 CHECK_PHASE(Phase_Commands) … … 749 756 { 750 757 // Check the directory really exists 751 if(!rContext.ObjectExists(dirID, Backup Context::ObjectExists_Directory))758 if(!rContext.ObjectExists(dirID, BackupStoreContext::ObjectExists_Directory)) 752 759 { 753 760 return std::auto_ptr<ProtocolObject>(new BackupProtocolServerObjectName(BackupProtocolServerObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0)); … … 814 821 // 815 822 // Function 816 // Name: BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &, Backup Context &)823 // Name: BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &, BackupStoreContext &) 817 824 // Purpose: Get the block index from a file, by ID 818 825 // Created: 19/1/04 819 826 // 820 827 // -------------------------------------------------------------------------- 821 std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)828 std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 822 829 { 823 830 CHECK_PHASE(Phase_Commands) … … 840 847 // 841 848 // Function 842 // Name: BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &, Backup Context &)849 // Name: BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &, BackupStoreContext &) 843 850 // Purpose: Get the block index from a file, by name within a directory 844 851 // Created: 19/1/04 845 852 // 846 853 // -------------------------------------------------------------------------- 847 std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)854 std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 848 855 { 849 856 CHECK_PHASE(Phase_Commands) … … 892 899 // 893 900 // Function 894 // Name: BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &, Backup Context &)901 // Name: BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &, BackupStoreContext &) 895 902 // Purpose: Return the amount of disc space used 896 903 // Created: 19/4/04 897 904 // 898 905 // -------------------------------------------------------------------------- 899 std::auto_ptr<ProtocolObject> BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)906 std::auto_ptr<ProtocolObject> BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 900 907 { 901 908 CHECK_PHASE(Phase_Commands) … … 923 930 // 924 931 // Function 925 // Name: BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &, Backup Context &)932 // Name: BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &, BackupStoreContext &) 926 933 // Purpose: Return the amount of disc space used 927 934 // Created: 19/4/04 928 935 // 929 936 // -------------------------------------------------------------------------- 930 std::auto_ptr<ProtocolObject> BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &rProtocol, Backup Context &rContext)937 std::auto_ptr<ProtocolObject> BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 931 938 { 932 939 CHECK_PHASE(Phase_Commands) box/trunk/bin/bbstored/BackupStoreContext.cpp
r2127 r2226 2 2 // 3 3 // File 4 // Name: Backup Context.cpp4 // Name: BackupStoreContext.cpp 5 5 // Purpose: Context for backup store server 6 6 // Created: 2003/08/20 … … 12 12 #include <stdio.h> 13 13 14 #include "Backup Context.h"14 #include "BackupStoreContext.h" 15 15 #include "RaidFileWrite.h" 16 16 #include "RaidFileRead.h" … … 49 49 // 50 50 // Function 51 // Name: Backup Context::BackupContext()51 // Name: BackupStoreContext::BackupStoreContext() 52 52 // Purpose: Constructor 53 53 // Created: 2003/08/20 54 54 // 55 55 // -------------------------------------------------------------------------- 56 Backup Context::BackupContext(int32_t ClientID, BackupStoreDaemon &rDaemon)56 BackupStoreContext::BackupStoreContext(int32_t ClientID, BackupStoreDaemon &rDaemon) 57 57 : mClientID(ClientID), 58 58 mrDaemon(rDaemon), … … 61 61 mStoreDiscSet(-1), 62 62 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() 71 72 // Purpose: Destructor 72 73 // Created: 2003/08/20 73 74 // 74 75 // -------------------------------------------------------------------------- 75 Backup Context::~BackupContext()76 BackupStoreContext::~BackupStoreContext() 76 77 { 77 78 // Delete the objects in the cache … … 86 87 // 87 88 // Function 88 // Name: Backup Context::CleanUp()89 // Name: BackupStoreContext::CleanUp() 89 90 // Purpose: Clean up after a connection 90 91 // Created: 16/12/03 91 92 // 92 93 // -------------------------------------------------------------------------- 93 void Backup Context::CleanUp()94 void BackupStoreContext::CleanUp() 94 95 { 95 96 // Make sure the store info is saved, if it has been loaded, isn't read only and has been modified … … 103 104 // 104 105 // Function 105 // Name: Backup Context::ReceivedFinishCommand()106 // Name: BackupStoreContext::ReceivedFinishCommand() 106 107 // Purpose: Called when the finish command is received by the protocol 107 108 // Created: 16/12/03 108 109 // 109 110 // -------------------------------------------------------------------------- 110 void Backup Context::ReceivedFinishCommand()111 void BackupStoreContext::ReceivedFinishCommand() 111 112 { 112 113 if(!mReadOnly && mpStoreInfo.get()) … … 121 122 // 122 123 // Function 123 // Name: Backup Context::AttemptToGetWriteLock()124 // Name: BackupStoreContext::AttemptToGetWriteLock() 124 125 // Purpose: Attempt to get a write lock for the store, and if so, unset the read only flags 125 126 // Created: 2003/09/02 126 127 // 127 128 // -------------------------------------------------------------------------- 128 bool Backup Context::AttemptToGetWriteLock()129 bool BackupStoreContext::AttemptToGetWriteLock() 129 130 { 130 131 // Make the filename of the write lock file … … 167 168 // 168 169 // Function 169 // Name: Backup Context::LoadStoreInfo()170 // Name: BackupStoreContext::LoadStoreInfo() 170 171 // Purpose: Load the store info from disc 171 172 // Created: 2003/09/03 172 173 // 173 174 // -------------------------------------------------------------------------- 174 void Backup Context::LoadStoreInfo()175 void BackupStoreContext::LoadStoreInfo() 175 176 { 176 177 if(mpStoreInfo.get() != 0) … … 196 197 // 197 198 // Function 198 // Name: Backup Context::SaveStoreInfo(bool)199 // Name: BackupStoreContext::SaveStoreInfo(bool) 199 200 // Purpose: Potentially delayed saving of the store info 200 201 // Created: 16/12/03 201 202 // 202 203 // -------------------------------------------------------------------------- 203 void Backup Context::SaveStoreInfo(bool AllowDelay)204 void BackupStoreContext::SaveStoreInfo(bool AllowDelay) 204 205 { 205 206 if(mpStoreInfo.get() == 0) … … 234 235 // 235 236 // Function 236 // Name: Backup Context::MakeObjectFilename(int64_t, std::string &, bool)237 // Name: BackupStoreContext::MakeObjectFilename(int64_t, std::string &, bool) 237 238 // Purpose: Create the filename of an object in the store, optionally creating the 238 239 // containing directory if it doesn't already exist. … … 240 241 // 241 242 // -------------------------------------------------------------------------- 242 void Backup Context::MakeObjectFilename(int64_t ObjectID, std::string &rOutput, bool EnsureDirectoryExists)243 void BackupStoreContext::MakeObjectFilename(int64_t ObjectID, std::string &rOutput, bool EnsureDirectoryExists) 243 244 { 244 245 // Delegate to utility function … … 250 251 // 251 252 // Function 252 // Name: Backup Context::GetDirectoryInternal(int64_t)253 // Name: BackupStoreContext::GetDirectoryInternal(int64_t) 253 254 // Purpose: Return a reference to a directory. Valid only until the 254 255 // next time a function which affects directories is called. … … 258 259 // 259 260 // -------------------------------------------------------------------------- 260 BackupStoreDirectory &Backup Context::GetDirectoryInternal(int64_t ObjectID)261 BackupStoreDirectory &BackupStoreContext::GetDirectoryInternal(int64_t ObjectID) 261 262 { 262 263 // Get the filename … … 344 345 // 345 346 // Function 346 // Name: Backup Context::AllocateObjectID()347 // Name: BackupStoreContext::AllocateObjectID() 347 348 // Purpose: Allocate a new object ID, tolerant of failures to save store info 348 349 // Created: 16/12/03 349 350 // 350 351 // -------------------------------------------------------------------------- 351 int64_t Backup Context::AllocateObjectID()352 int64_t BackupStoreContext::AllocateObjectID() 352 353 { 353 354 if(mpStoreInfo.get() == 0) … … 394 395 // 395 396 // Function 396 // Name: Backup Context::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) 397 398 // Purpose: Add a file to the store, from a given stream, into a specified directory. 398 399 // Returns object ID of the new file. … … 400 401 // 401 402 // -------------------------------------------------------------------------- 402 int64_t Backup Context::AddFile(IOStream &rFile, int64_t InDirectory, int64_t ModificationTime,403 int64_t BackupStoreContext::AddFile(IOStream &rFile, int64_t InDirectory, int64_t ModificationTime, 403 404 int64_t AttributesHash, int64_t DiffFromFileID, const BackupStoreFilename &rFilename, 404 405 bool MarkFileWithSameNameAsOldVersions) … … 682 683 // 683 684 // Function 684 // Name: Backup Context::DeleteFile(const BackupStoreFilename &, int64_t, int64_t &)685 // Name: BackupStoreContext::DeleteFile(const BackupStoreFilename &, int64_t, int64_t &) 685 686 // Purpose: Deletes a file, returning true if the file existed. Object ID returned too, set to zero if not found. 686 687 // Created: 2003/10/21 687 688 // 688 689 // -------------------------------------------------------------------------- 689 bool Backup Context::DeleteFile(const BackupStoreFilename &rFilename, int64_t InDirectory, int64_t &rObjectIDOut)690 bool BackupStoreContext::DeleteFile(const BackupStoreFilename &rFilename, int64_t InDirectory, int64_t &rObjectIDOut) 690 691 { 691 692 // Essential checks! … … 769 770 // 770 771 // Function 771 // Name: Backup Context::RemoveDirectoryFromCache(int64_t)772 // Name: BackupStoreContext::RemoveDirectoryFromCache(int64_t) 772 773 // Purpose: Remove directory from cache 773 774 // Created: 2003/09/04 774 775 // 775 776 // -------------------------------------------------------------------------- 776 void Backup Context::RemoveDirectoryFromCache(int64_t ObjectID)777 void BackupStoreContext::RemoveDirectoryFromCache(int64_t ObjectID) 777 778 { 778 779 std::map<int64_t, BackupStoreDirectory*>::iterator item(mDirectoryCache.find(ObjectID)); … … 790 791 // 791 792 // Function 792 // Name: Backup Context::SaveDirectory(BackupStoreDirectory &, int64_t)793 // Name: BackupStoreContext::SaveDirectory(BackupStoreDirectory &, int64_t) 793 794 // Purpose: Save directory back to disc, update time in cache 794 795 // Created: 2003/09/04 795 796 // 796 797 // -------------------------------------------------------------------------- 797 void Backup Context::SaveDirectory(BackupStoreDirectory &rDir, int64_t ObjectID)798 void BackupStoreContext::SaveDirectory(BackupStoreDirectory &rDir, int64_t ObjectID) 798 799 { 799 800 if(mpStoreInfo.get() == 0) … … 852 853 // 853 854 // Function 854 // Name: Backup Context::AddDirectory(int64_t, const BackupStoreFilename &, bool &)855 // Name: BackupStoreContext::AddDirectory(int64_t, const BackupStoreFilename &, bool &) 855 856 // Purpose: Creates a directory (or just returns the ID of an existing one). rAlreadyExists set appropraitely. 856 857 // Created: 2003/09/04 857 858 // 858 859 // -------------------------------------------------------------------------- 859 int64_t Backup Context::AddDirectory(int64_t InDirectory, const BackupStoreFilename &rFilename, const StreamableMemBlock &Attributes, int64_t AttributesModTime, bool &rAlreadyExists)860 int64_t BackupStoreContext::AddDirectory(int64_t InDirectory, const BackupStoreFilename &rFilename, const StreamableMemBlock &Attributes, int64_t AttributesModTime, bool &rAlreadyExists) 860 861 { 861 862 if(mpStoreInfo.get() == 0) … … 946 947 // 947 948 // Function 948 // Name: Backup Context::DeleteFile(const BackupStoreFilename &, int64_t, int64_t &, bool)949 // Name: BackupStoreContext::DeleteFile(const BackupStoreFilename &, int64_t, int64_t &, bool) 949 950 // Purpose: Recusively deletes a directory (or undeletes if Undelete = true) 950 951 // Created: 2003/10/21 951 952 // 952 953 // -------------------------------------------------------------------------- 953 void Backup Context::DeleteDirectory(int64_t ObjectID, bool Undelete)954 void BackupStoreContext::DeleteDirectory(int64_t ObjectID, bool Undelete) 954 955 { 955 956 // Essential checks! … … 1028 1029 // 1029 1030 // Function 1030 // Name: Backup Context::DeleteDirectoryRecurse(BackupStoreDirectory &, int64_t)1031 // Name: BackupStoreContext::DeleteDirectoryRecurse(BackupStoreDirectory &, int64_t) 1031 1032 // Purpose: Private. Deletes a directory depth-first recusively. 1032 1033 // Created: 2003/10/21 1033 1034 // 1034 1035 // -------------------------------------------------------------------------- 1035 void Backup Context::DeleteDirectoryRecurse(int64_t ObjectID, int64_t &rBlocksDeletedOut, bool Undelete)1036 void BackupStoreContext::DeleteDirectoryRecurse(int64_t ObjectID, int64_t &rBlocksDeletedOut, bool Undelete) 1036 1037 { 1037 1038 try … … 1130 1131 // 1131 1132 // Function 1132 // Name: Backup Context::ChangeDirAttributes(int64_t, const StreamableMemBlock &, int64_t)1133 // Name: BackupStoreContext::ChangeDirAttributes(int64_t, const StreamableMemBlock &, int64_t) 1133 1134 // Purpose: Change the attributes of a directory 1134 1135 // Created: 2003/09/06 1135 1136 // 1136 1137 // -------------------------------------------------------------------------- 1137 void Backup Context::ChangeDirAttributes(int64_t Directory, const StreamableMemBlock &Attributes, int64_t AttributesModTime)1138 void BackupStoreContext::ChangeDirAttributes(int64_t Directory, const StreamableMemBlock &Attributes, int64_t AttributesModTime) 1138 1139 { 1139 1140 if(mpStoreInfo.get() == 0) … … 1167 1168 // 1168 1169 // Function 1169 // Name: Backup Context::ChangeFileAttributes(int64_t, int64_t, const StreamableMemBlock &, int64_t)1170 // Name: BackupStoreContext::ChangeFileAttributes(int64_t, int64_t, const StreamableMemBlock &, int64_t) 1170 1171 // Purpose: Sets the attributes on a directory entry. Returns true if the object existed, false if it didn't. 1171 1172 // Created: 2003/09/06 1172 1173 // 1173 1174 // -------------------------------------------------------------------------- 1174 bool Backup Context::ChangeFileAttributes(const BackupStoreFilename &rFilename, int64_t InDirectory, const StreamableMemBlock &Attributes, int64_t AttributesHash, int64_t &rObjectIDOut)1175 bool BackupStoreContext::ChangeFileAttributes(const BackupStoreFilename &rFilename, int64_t InDirectory, const StreamableMemBlock &Attributes, int64_t AttributesHash, int64_t &rObjectIDOut) 1175 1176 { 1176 1177 if(mpStoreInfo.get() == 0) … … 1232 1233 // 1233 1234 // Function 1234 // Name: Backup Context::ObjectExists(int64_t)1235 // Name: BackupStoreContext::ObjectExists(int64_t) 1235 1236 // Purpose: Test to see if an object of this ID exists in the store 1236 1237 // Created: 2003/09/03 1237 1238 // 1238 1239 // -------------------------------------------------------------------------- 1239 bool Backup Context::ObjectExists(int64_t ObjectID, int MustBe)1240 bool BackupStoreContext::ObjectExists(int64_t ObjectID, int MustBe) 1240 1241 { 1241 1242 if(mpStoreInfo.get() == 0) … … 1303 1304 // 1304 1305 // Function 1305 // Name: Backup Context::OpenObject(int64_t)1306 // Name: BackupStoreContext::OpenObject(int64_t) 1306 1307 // Purpose: Opens an object 1307 1308 // Created: 2003/09/03 1308 1309 // 1309 1310 // -------------------------------------------------------------------------- 1310 std::auto_ptr<IOStream> Backup Context::OpenObject(int64_t ObjectID)1311 std::auto_ptr<IOStream> BackupStoreContext::OpenObject(int64_t ObjectID) 1311 1312 { 1312 1313 if(mpStoreInfo.get() == 0) … … 1325 1326 // 1326 1327 // Function 1327 // Name: Backup Context::GetClientStoreMarker()1328 // Name: BackupStoreContext::GetClientStoreMarker() 1328 1329 // Purpose: Retrieve the client store marker 1329 1330 // Created: 2003/10/29 1330 1331 // 1331 1332 // -------------------------------------------------------------------------- 1332 int64_t Backup Context::GetClientStoreMarker()1333 int64_t BackupStoreContext::GetClientStoreMarker() 1333 1334 { 1334 1335 if(mpStoreInfo.get() == 0) … … 1344 1345 // 1345 1346 // Function 1346 // Name: Backup Context::GetStoreDiscUsageInfo(int64_t &, int64_t &, int64_t &)1347 // Name: BackupStoreContext::GetStoreDiscUsageInfo(int64_t &, int64_t &, int64_t &) 1347 1348 // Purpose: Get disc usage info from store info 1348 1349 // Created: 1/1/04 1349 1350 // 1350 1351 // -------------------------------------------------------------------------- 1351 void Backup Context::GetStoreDiscUsageInfo(int64_t &rBlocksUsed, int64_t &rBlocksSoftLimit, int64_t &rBlocksHardLimit)1352 void BackupStoreContext::GetStoreDiscUsageInfo(int64_t &rBlocksUsed, int64_t &rBlocksSoftLimit, int64_t &rBlocksHardLimit) 1352 1353 { 1353 1354 if(mpStoreInfo.get() == 0) … … 1365 1366 // 1366 1367 // Function 1367 // Name: Backup Context::HardLimitExceeded()1368 // Name: BackupStoreContext::HardLimitExceeded() 1368 1369 // Purpose: Returns true if the hard limit has been exceeded 1369 1370 // Created: 1/1/04 1370 1371 // 1371 1372 // -------------------------------------------------------------------------- 1372 bool Backup Context::HardLimitExceeded()1373 bool BackupStoreContext::HardLimitExceeded() 1373 1374 { 1374 1375 if(mpStoreInfo.get() == 0) … … 1384 1385 // 1385 1386 // Function 1386 // Name: Backup Context::SetClientStoreMarker(int64_t)1387 // Name: BackupStoreContext::SetClientStoreMarker(int64_t) 1387 1388 // Purpose: Sets the client store marker, and commits it to disc 1388 1389 // Created: 2003/10/29 1389 1390 // 1390 1391 // -------------------------------------------------------------------------- 1391 void Backup Context::SetClientStoreMarker(int64_t ClientStoreMarker)1392 void BackupStoreContext::SetClientStoreMarker(int64_t ClientStoreMarker) 1392 1393 { 1393 1394 if(mpStoreInfo.get() == 0) … … 1408 1409 // 1409 1410 // Function 1410 // Name: Backup Context::MoveObject(int64_t, int64_t, int64_t, const BackupStoreFilename &, bool)1411 // Name: BackupStoreContext::MoveObject(int64_t, int64_t, int64_t, const BackupStoreFilename &, bool) 1411 1412 // Purpose: Move an object (and all objects with the same name) from one directory to another 1412 1413 // Created: 12/11/03 1413 1414 // 1414 1415 // -------------------------------------------------------------------------- 1415 void Backup Context::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, int64_t MoveToDirectory, const BackupStoreFilename &rNewFilename, bool MoveAllWithSameName, bool AllowMoveOverDeletedObject)1416 void BackupStoreContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, int64_t MoveToDirectory, const BackupStoreFilename &rNewFilename, bool MoveAllWithSameName, bool AllowMoveOverDeletedObject) 1416 1417 { 1417 1418 if(mReadOnly) … … 1653 1654 // 1654 1655 // Function 1655 // Name: Backup Context::GetBackupStoreInfo()1656 // Name: BackupStoreContext::GetBackupStoreInfo() 1656 1657 // Purpose: Return the backup store info object, exception if it isn't loaded 1657 1658 // Created: 19/4/04 1658 1659 // 1659 1660 // -------------------------------------------------------------------------- 1660 const BackupStoreInfo &Backup Context::GetBackupStoreInfo() const1661 const BackupStoreInfo &BackupStoreContext::GetBackupStoreInfo() const 1661 1662 { 1662 1663 if(mpStoreInfo.get() == 0) box/trunk/bin/bbstored/BackupStoreContext.h
r217 r2226 2 2 // 3 3 // File 4 // Name: Backup Context.h4 // Name: BackupStoreContext.h 5 5 // Purpose: Context for backup store server 6 6 // Created: 2003/08/20 … … 16 16 17 17 #include "NamedLock.h" 18 #include "ProtocolObject.h" 18 19 #include "Utils.h" 19 20 … … 23 24 class BackupStoreInfo; 24 25 class IOStream; 26 class BackupProtocolObject; 25 27 class StreamableMemBlock; 26 28 … … 28 30 // 29 31 // Class 30 // Name: Backup Context32 // Name: BackupStoreContext 31 33 // Purpose: Context for backup store server 32 34 // Created: 2003/08/20 33 35 // 34 36 // -------------------------------------------------------------------------- 35 class Backup Context37 class BackupStoreContext 36 38 { 37 39 public: 38 Backup Context(int32_t ClientID, BackupStoreDaemon &rDaemon);39 ~Backup Context();40 BackupStoreContext(int32_t ClientID, BackupStoreDaemon &rDaemon); 41 ~BackupStoreContext(); 40 42 private: 41 Backup Context(const BackupContext &rToCopy);43 BackupStoreContext(const BackupStoreContext &rToCopy); 42 44 public: 43 45 … … 84 86 // 85 87 // Function 86 // Name: Backup Context::GetDirectory(int64_t)88 // Name: BackupStoreContext::GetDirectory(int64_t) 87 89 // Purpose: Return a reference to a directory. Valid only until the 88 90 // next time a function which affects directories is called. … … 144 146 // Directory cache 145 147 std::map<int64_t, BackupStoreDirectory*> mDirectoryCache; 148 149 public: 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 170 private: 171 TestHook* mpTestHook; 146 172 }; 147 173 box/trunk/bin/bbstored/BackupStoreDaemon.cpp
r1891 r2226 18 18 #endif 19 19 20 #include "Backup Context.h"20 #include "BackupStoreContext.h" 21 21 #include "BackupStoreDaemon.h" 22 22 #include "BackupStoreConfigVerify.h" … … 44 44 mIsHousekeepingProcess(false), 45 45 mHousekeepingInited(false), 46 mInterProcessComms(mInterProcessCommsSocket) 46 mInterProcessComms(mInterProcessCommsSocket), 47 mpTestHook(NULL) 47 48 { 48 49 } … … 321 322 322 323 // 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 } 324 330 325 331 // See if the client has an account? box/trunk/bin/bbstored/BackupStoreDaemon.h
r1891 r2226 14 14 #include "BoxPortsAndFiles.h" 15 15 #include "BackupConstants.h" 16 #include "BackupStoreContext.h" 16 17 #include "IOStreamGetLine.h" 17 18
