You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kp...@apache.org on 2014/11/10 22:49:25 UTC
svn commit: r1637985 - in /qpid/trunk/qpid/cpp/src/qpid/linearstore/journal:
EmptyFilePool.cpp EmptyFilePool.h EmptyFilePoolPartition.cpp jerrno.cpp
jerrno.h
Author: kpvdr
Date: Mon Nov 10 21:49:24 2014
New Revision: 1637985
URL: http://svn.apache.org/r1637985
Log:
QPID-5671: [linearstore] Add ability to use disk partitions and select per-queue EFPs. Modified previous code and added new code to allow a seamless updrade of the modified EFP and journal directory structure from the old to the new. The "efp" directory is removed from the directory tree containing the EFPs in a partition and all directories are moved up a level. The journal files are replaced with symlinks as they are used and replaced into the EFP.
Modified:
qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp
qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h
qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp
qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.cpp
qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.h
Modified: qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp?rev=1637985&r1=1637984&r2=1637985&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp Mon Nov 10 21:49:24 2014
@@ -144,7 +144,15 @@ std::string EmptyFilePool::takeEmptyFile
}
void EmptyFilePool::returnEmptyFileSymlink(const std::string& emptyFileSymlink) {
- returnEmptyFile(deleteSymlink(emptyFileSymlink));
+ if (isFile(emptyFileSymlink)) {
+ returnEmptyFile(emptyFileSymlink);
+ } else if(isSymlink(emptyFileSymlink)) {
+ returnEmptyFile(deleteSymlink(emptyFileSymlink));
+ } else {
+ std::ostringstream oss;
+ oss << "File \"" << emptyFileSymlink << "\" is neither a file nor a symlink";
+ throw jexception(jerrno::JERR_EFP_BADFILETYPE, oss.str(), "EmptyFilePool", "returnEmptyFileSymlink");
+ }
}
//static
@@ -422,4 +430,27 @@ std::string EmptyFilePool::deleteSymlink
return std::string(buff, len);
}
+//static
+bool EmptyFilePool::isFile(const std::string& fqName) {
+ struct stat buff;
+ if (::lstat(fqName.c_str(), &buff)) {
+ std::ostringstream oss;
+ oss << "lstat file=\"" << fqName << "\"" << FORMAT_SYSERR(errno);
+ throw jexception(jerrno::JERR_EFP_LSTAT, oss.str(), "EmptyFilePool", "isFile");
+ }
+ return S_ISREG(buff.st_mode);
+}
+
+//static
+bool EmptyFilePool::isSymlink(const std::string& fqName) {
+ struct stat buff;
+ if (::lstat(fqName.c_str(), &buff)) {
+ std::ostringstream oss;
+ oss << "lstat file=\"" << fqName << "\"" << FORMAT_SYSERR(errno);
+ throw jexception(jerrno::JERR_EFP_LSTAT, oss.str(), "EmptyFilePool", "isSymlink");
+ }
+ return S_ISLNK(buff.st_mode);
+
+}
+
}}}
Modified: qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h?rev=1637985&r1=1637984&r2=1637985&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePool.h Mon Nov 10 21:49:24 2014
@@ -102,6 +102,8 @@ protected:
static int createSymLink(const std::string& fqFileName,
const std::string& fqLinkName);
static std::string deleteSymlink(const std::string& fqLinkName);
+ static bool isFile(const std::string& fqName);
+ static bool isSymlink(const std::string& fqName);
};
}}}
Modified: qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp?rev=1637985&r1=1637984&r2=1637985&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp Mon Nov 10 21:49:24 2014
@@ -24,7 +24,9 @@
#include <iomanip>
#include "qpid/linearstore/journal/EmptyFilePool.h"
#include "qpid/linearstore/journal/jdir.h"
+#include "qpid/linearstore/journal/JournalLog.h"
#include "qpid/linearstore/journal/slock.h"
+#include <unistd.h>
namespace qpid {
namespace linearstore {
@@ -54,13 +56,38 @@ EmptyFilePoolPartition::~EmptyFilePoolPa
void
EmptyFilePoolPartition::findEmptyFilePools() {
-//std::cout << "*** Reading " << partitionDir_ << std::endl; // DEBUG
+//std::cout << "*** EmptyFilePoolPartition::findEmptyFilePools(): Reading " << partitionDir_ << std::endl; // DEBUG
std::vector<std::string> dirList;
- jdir::read_dir(partitionDir_, dirList, true, false, false, true);
+ bool upgradeDirStructureFlag = false;
+ std::string oldPartitionDir;
+ jdir::read_dir(partitionDir_, dirList, true, false, false, false);
+//std::cout << "*** dirList.size()=" << dirList.size() << "; dirList.front()=" << dirList.front() << std::endl; // DEBUG
+ if (dirList.size() == 1 && dirList.front().compare("efp") == 0) {
+ upgradeDirStructureFlag = true;
+ oldPartitionDir = partitionDir_ + "/efp";
+//std::cout << "*** oldPartitionDir=" << oldPartitionDir << std::endl; // DEBUG
+ dirList.clear();
+ jdir::read_dir(oldPartitionDir, dirList, true, false, false, false);
+ }
for (std::vector<std::string>::iterator i = dirList.begin(); i != dirList.end(); ++i) {
+ std::string fqFileName(partitionDir_ + "/" + *i);
+ if (upgradeDirStructureFlag) {
+ std::string fqOldFileName(partitionDir_ + "/efp/" + *i);
+ if (::rename(fqOldFileName.c_str(), fqFileName.c_str())) {
+ // File move failed
+ std::ostringstream oss;
+ oss << "File \'" << fqOldFileName << "\' could not be renamed to \'" << fqFileName << "\' (" << FORMAT_SYSERR(errno) << "); file deleted";
+ journalLogRef_.log(JournalLog::LOG_WARN, oss.str());
+ if (::unlink(fqOldFileName.c_str())) {
+ std::ostringstream oss;
+ oss << "File \'" << fqOldFileName << "\' could not be deleted (" << FORMAT_SYSERR(errno) << "\'; file orphaned";
+ journalLogRef_.log(JournalLog::LOG_WARN, oss.str());
+ }
+ }
+ }
EmptyFilePool* efpp = 0;
try {
- efpp = new EmptyFilePool(*i, this, overwriteBeforeReturnFlag_, truncateFlag_, journalLogRef_);
+ efpp = new EmptyFilePool(fqFileName, this, overwriteBeforeReturnFlag_, truncateFlag_, journalLogRef_);
{
slock l(efpMapMutex_);
efpMap_[efpp->dataSize_kib()] = efpp;
@@ -71,12 +98,23 @@ EmptyFilePoolPartition::findEmptyFilePoo
delete efpp;
efpp = 0;
}
- //std::cerr << "WARNING: " << e.what() << std::endl;
+ std::ostringstream oss;
+ oss << "EmptyFilePool create failed: " << e.what();
+ journalLogRef_.log(JournalLog::LOG_WARN, oss.str());
}
if (efpp != 0) {
efpp->initialize();
}
}
+ if (upgradeDirStructureFlag) {
+ std::string oldEfpDir(partitionDir_ + "/efp");
+ if (::rmdir(oldEfpDir.c_str())) {
+ // Unable to delete old "efp" dir
+ std::ostringstream oss;
+ oss << "Unable to delete old EFP directory \'" << oldEfpDir << "\' (" << FORMAT_SYSERR(errno) << "\'; directory orphaned";
+ journalLogRef_.log(JournalLog::LOG_WARN, oss.str());
+ }
+ }
}
EmptyFilePool* EmptyFilePoolPartition::getEmptyFilePool(const efpDataSize_kib_t efpDataSize_kib) {
Modified: qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.cpp?rev=1637985&r1=1637984&r2=1637985&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.cpp Mon Nov 10 21:49:24 2014
@@ -113,6 +113,8 @@ const uint32_t jerrno::JERR_EFP_BADEFPDI
const uint32_t jerrno::JERR_EFP_NOEFP = 0x0d04;
const uint32_t jerrno::JERR_EFP_EMPTY = 0x0d05;
const uint32_t jerrno::JERR_EFP_SYMLINK = 0x0d06;
+const uint32_t jerrno::JERR_EFP_LSTAT = 0x0d07;
+const uint32_t jerrno::JERR_EFP_BADFILETYPE = 0x0d08;
// Negative returns for some functions
const int32_t jerrno::AIO_TIMEOUT = -1;
@@ -208,6 +210,8 @@ jerrno::__init()
_err_map[JERR_EFP_NOEFP] = "JERR_EFP_NOEFP: No Empty File Pool found for given partition and empty file size";
_err_map[JERR_EFP_EMPTY] = "JERR_EFP_EMPTY: Empty File Pool is empty";
_err_map[JERR_EFP_SYMLINK] = "JERR_EFP_SYMLINK: Symbolic link operation failed";
+ _err_map[JERR_EFP_LSTAT] = "JERR_EFP_LSTAT: lstat() operation failed";
+ _err_map[JERR_EFP_BADFILETYPE] = "JERR_EFP_BADFILETYPE: File type incorrect for operation";
//_err_map[] = "";
Modified: qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.h?rev=1637985&r1=1637984&r2=1637985&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/linearstore/journal/jerrno.h Mon Nov 10 21:49:24 2014
@@ -131,6 +131,8 @@ namespace journal {
static const uint32_t JERR_EFP_NOEFP; ///< No EFP found for given partition and file size
static const uint32_t JERR_EFP_EMPTY; ///< EFP empty
static const uint32_t JERR_EFP_SYMLINK; ///< Symbolic Link operation failed
+ static const uint32_t JERR_EFP_LSTAT; ///< lstat operation failed
+ static const uint32_t JERR_EFP_BADFILETYPE; ///< Bad file type
// Negative returns for some functions
static const int32_t AIO_TIMEOUT; ///< Timeout waiting for AIO return
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org