summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2013-11-26 08:13:30 +0000
committerKim van der Riet <kpvdr@apache.org>2013-11-26 08:13:30 +0000
commitbdbd978b38cec8f5d336d24d6370bec40704d53f (patch)
tree92b99c7346b7074a38689a6fd31fb413e2e8b1ee /cpp
parent7e01aebde53c3bdb29492e6eb056d7249aa8c611 (diff)
downloadqpid-python-bdbd978b38cec8f5d336d24d6370bec40704d53f.tar.gz
QPID-5357 "Linearstore: Empty file recycling not functional": Fix which implements the empty file check for trailing empty files.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1545563 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/linearstore.cmake4
-rw-r--r--cpp/src/qpid/linearstore/journal/LinearFileController.cpp13
-rw-r--r--cpp/src/qpid/linearstore/journal/LinearFileController.h1
3 files changed, 14 insertions, 4 deletions
diff --git a/cpp/src/linearstore.cmake b/cpp/src/linearstore.cmake
index 2930ef9531..8568cdbb77 100644
--- a/cpp/src/linearstore.cmake
+++ b/cpp/src/linearstore.cmake
@@ -147,10 +147,10 @@ if (BUILD_LINEARSTORE)
)
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/db-inc.h)
- message(STATUS "Including BDB from ${DB_INCLUDE_DIR}/db_cxx.h")
+ message(STATUS "Including BDB from ${DB_CXX_INCLUDE_DIR}/db_cxx.h")
file(WRITE
${CMAKE_CURRENT_BINARY_DIR}/db-inc.h
- "#include <${DB_INCLUDE_DIR}/db_cxx.h>\n")
+ "#include <${DB_CXX_INCLUDE_DIR}/db_cxx.h>\n")
endif()
add_library (linearstoreutils SHARED
diff --git a/cpp/src/qpid/linearstore/journal/LinearFileController.cpp b/cpp/src/qpid/linearstore/journal/LinearFileController.cpp
index 99b7f0f381..aa0f6da0de 100644
--- a/cpp/src/qpid/linearstore/journal/LinearFileController.cpp
+++ b/cpp/src/qpid/linearstore/journal/LinearFileController.cpp
@@ -36,7 +36,8 @@ LinearFileController::LinearFileController(jcntl& jcntlRef) :
emptyFilePoolPtr_(0),
currentJournalFilePtr_(0),
fileSeqCounter_("LinearFileController::fileSeqCounter", 0),
- recordIdCounter_("LinearFileController::recordIdCounter", 0)
+ recordIdCounter_("LinearFileController::recordIdCounter", 0),
+ decrCounter_("LinearFileController::decrCounter", 0)
{}
LinearFileController::~LinearFileController() {}
@@ -106,7 +107,15 @@ uint32_t LinearFileController::incrEnqueuedRecordCount(const efpFileCount_t file
uint32_t LinearFileController::decrEnqueuedRecordCount(const efpFileCount_t fileSeqNumber) {
slock l(journalFileListMutex_);
uint32_t r = find(fileSeqNumber)->decrEnqueuedRecordCount();
-// purgeEmptyFilesToEfpNoLock();
+
+ // TODO: Re-evaluate after testing and profiling
+ // This is the first go at implementing auto-purge, which checks for all trailing empty files and recycles
+ // them back to the EFP. This version checks every 100 decrements using decrCounter_ (an action which releases
+ // records). We need to check this rather simple scheme works for outlying scenarios (large and tiny data
+ // records) without impacting performance or performing badly (leaving excessive empty files in the journals).
+ if (decrCounter_.increment() % 100ULL == 0ULL) {
+ purgeEmptyFilesToEfpNoLock();
+ }
return r;
}
diff --git a/cpp/src/qpid/linearstore/journal/LinearFileController.h b/cpp/src/qpid/linearstore/journal/LinearFileController.h
index 61226d3015..fa8327007a 100644
--- a/cpp/src/qpid/linearstore/journal/LinearFileController.h
+++ b/cpp/src/qpid/linearstore/journal/LinearFileController.h
@@ -47,6 +47,7 @@ protected:
JournalFile* currentJournalFilePtr_;
AtomicCounter<uint64_t> fileSeqCounter_;
AtomicCounter<uint64_t> recordIdCounter_;
+ AtomicCounter<uint64_t> decrCounter_;
JournalFileList_t journalFileList_;
smutex journalFileListMutex_;