protected void setAllocationAllowed ( ) throws ObjectManagerException { final String methodName = "setAllocationAllowed" ; if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . entry ( this , cclass , methodName , new Object [ ] { new Long ( storeFileSizeAllocated ) , new Long ( storeFileSizeUsed ) } ) ; // Users of the store should have reserved space in the store for Objects that are allocated before // they finally add them to the store. We have already reserved enough space for a complete replacement // of the directory which also implies there is already enough space to delete any number of // ManagedObjects in the store. // Calculate how much file space we need to continue storing ManagedObjects. // We make the pessimistic assumption that the entire contents of the log might need to be written // to this ObjectStore. // We have to take into account any pending request to increase the size of the log file, because this // would allow applications to over commit the store if they used the extra log space when it did not // exist in the Object Store. long storeFileSizeRequired = storeFileSizeAllocated ; if ( simulateFullReservedSize > 0 ) { // We are simulating a a full filesystem. allocationAllowed = false ; reservationThreshold = 0 ; } else { // do we have enough space to accomdate the whole log in the store plus reserved space in the store long currentReservedSize = reservedSize . get ( ) ; long pesimisticSpaceRequired = Math . max ( objectManagerState . logOutput . getLogFileSize ( ) , objectManagerState . logOutput . getLogFileSizeRequested ( ) ) + directoryReservedSize + currentReservedSize ; long largestFreeSpace = 0 ; if ( freeSpaceByLength . size ( ) > 0 ) { largestFreeSpace = ( ( FreeSpace ) freeSpaceByLength . last ( ) ) . length ; } if ( pesimisticSpaceRequired <= largestFreeSpace ) { // we can at least fit the whole log plus reserved space in the largest free space entry // so we are ok allocationAllowed = true ; } else { storeFileSizeRequired = storeFileSizeUsed + pesimisticSpaceRequired ; // See if we need to change the size of the store file. if ( storeFileSizeRequired <= storeFileSizeAllocated ) { // we have allocated more than is required, its just not in the free space map yet allocationAllowed = true ; } else if ( storeFileSizeRequired <= maximumStoreFileSize ) { // we need more than we have allocated, and that is less than the maximum allowed, try grow to the required... allocationAllowed = setStoreFileSizeInternal ( storeFileSizeRequired ) ; } else { // We need greater than the maximum allowed, make sure we have all the space we are // allowed to have. if ( storeFileSizeAllocated < maximumStoreFileSize ) setStoreFileSizeInternal ( maximumStoreFileSize ) ; // TODO We could still allow allocation until we really are full when the reservation scheme will catch it! allocationAllowed = false ; // Request a checkpoint, see if we can clear some space. numberOfStoreFullCheckpointsTriggered ++ ; objectManagerState . requestCheckpoint ( persistent ) ; } // if ( storeFileSizeRequired... reservationThreshold = storeFileSizeAllocated - storeFileSizeUsed - directoryReservedSize ; reservationCheckpointThreshold = Math . min ( reservationThreshold , currentReservedSize + reservationCheckpointMaximum ) ; } } // Release at least one blocked reservation request. if ( reservationPacing ) { synchronized ( reservationPacingLock ) { reservationPacing = false ; reservationPacingLock . notify ( ) ; } // synchronized (reservationPacingLock). } if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , methodName , new Object [ ] { new Boolean ( allocationAllowed ) , new Long ( storeFileSizeRequired ) } ) ; }
Tests to see if allocation of new Objects should be allowed or not . Caller must be synchronized on this .