summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ndb/include/mgmapi/mgmapi_config_parameters.h2
-rw-r--r--ndb/src/common/mgmcommon/ConfigInfo.cpp14
-rw-r--r--ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp6
-rw-r--r--ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp2
-rw-r--r--ndb/src/kernel/blocks/ndbfs/Filename.cpp54
-rw-r--r--ndb/src/kernel/blocks/ndbfs/Filename.hpp9
-rw-r--r--ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp4
-rw-r--r--ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp1
-rw-r--r--ndb/src/kernel/vm/Configuration.cpp76
-rw-r--r--ndb/src/kernel/vm/Configuration.hpp8
10 files changed, 109 insertions, 67 deletions
diff --git a/ndb/include/mgmapi/mgmapi_config_parameters.h b/ndb/include/mgmapi/mgmapi_config_parameters.h
index 07d0aa87380..faa1851c09d 100644
--- a/ndb/include/mgmapi/mgmapi_config_parameters.h
+++ b/ndb/include/mgmapi/mgmapi_config_parameters.h
@@ -90,7 +90,7 @@
#define CFG_DB_LONG_SIGNAL_BUFFER 157
-#define CFG_DB_BACKUP_DATA_PATH 158
+#define CFG_DB_BACKUP_DATADIR 158
#define CFG_NODE_ARBIT_RANK 200
#define CFG_NODE_ARBIT_DELAY 201
diff --git a/ndb/src/common/mgmcommon/ConfigInfo.cpp b/ndb/src/common/mgmcommon/ConfigInfo.cpp
index 769fc707c2a..52023fe4619 100644
--- a/ndb/src/common/mgmcommon/ConfigInfo.cpp
+++ b/ndb/src/common/mgmcommon/ConfigInfo.cpp
@@ -89,7 +89,7 @@ static bool fixExtConnection(InitConfigFileParser::Context & ctx, const char * d
static bool fixDepricated(InitConfigFileParser::Context & ctx, const char *);
static bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *);
static bool fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data);
-static bool fixBackupDataPath(InitConfigFileParser::Context & ctx, const char * data);
+static bool fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data);
const ConfigInfo::SectionRule
ConfigInfo::m_SectionRules[] = {
@@ -145,7 +145,7 @@ ConfigInfo::m_SectionRules[] = {
{ "*", applyDefaultValues, "system" },
{ DB_TOKEN, fixFileSystemPath, 0 },
- { DB_TOKEN, fixBackupDataPath, 0 },
+ { DB_TOKEN, fixBackupDataDir, 0 },
{ DB_TOKEN, checkDbConstraints, 0 },
@@ -1101,8 +1101,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"1" },
{
- CFG_DB_BACKUP_DATA_PATH,
- "BackupDataPath",
+ CFG_DB_BACKUP_DATADIR,
+ "BackupDataDir",
DB_TOKEN,
"Path to where to store backups",
ConfigInfo::USED,
@@ -2497,14 +2497,14 @@ fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data){
}
bool
-fixBackupDataPath(InitConfigFileParser::Context & ctx, const char * data){
+fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data){
const char * path;
- if (ctx.m_currentSection->get("BackupDataPath", &path))
+ if (ctx.m_currentSection->get("BackupDataDir", &path))
return true;
if (ctx.m_currentSection->get("FileSystemPath", &path)) {
- require(ctx.m_currentSection->put("BackupDataPath", path));
+ require(ctx.m_currentSection->put("BackupDataDir", path));
return true;
}
diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
index c2b8cc80a44..c61fccad22a 100644
--- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
+++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
@@ -108,8 +108,10 @@ AsyncFile::AsyncFile() :
}
void
-AsyncFile::doStart(Uint32 nodeId, const char * filesystemPath) {
- theFileName.init(nodeId, filesystemPath);
+AsyncFile::doStart(Uint32 nodeId,
+ const char * filesystemPath,
+ const char * backup_path) {
+ theFileName.init(nodeId, filesystemPath, backup_path);
// Stacksize for filesystem threads
// An 8k stack should be enough
diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp
index 9a405bc1580..2176c93c5d5 100644
--- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp
+++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp
@@ -181,7 +181,7 @@ public:
void execute( Request* request );
- void doStart(Uint32 nodeId, const char * fspath);
+ void doStart(Uint32 nodeId, const char * fspath, const char * backup_path);
// its a thread so its always running
void run();
diff --git a/ndb/src/kernel/blocks/ndbfs/Filename.cpp b/ndb/src/kernel/blocks/ndbfs/Filename.cpp
index 660fe6eee94..28aa1d23df4 100644
--- a/ndb/src/kernel/blocks/ndbfs/Filename.cpp
+++ b/ndb/src/kernel/blocks/ndbfs/Filename.cpp
@@ -46,43 +46,31 @@ Filename::Filename() :
}
void
-Filename::init(Uint32 nodeid, const char * pFileSystemPath){
+Filename::init(Uint32 nodeid,
+ const char * pFileSystemPath,
+ const char * pBackupDirPath){
+ DBUG_ENTER("Filename::init");
+
if (pFileSystemPath == NULL) {
ERROR_SET(fatal, AFS_ERROR_NOPATH, ""," Filename::init()");
return;
}
- strncpy(theBaseDirectory, pFileSystemPath, PATH_MAX);
-
- // the environment variable is set,
- // check that it is pointing on a valid directory
- //
- char buf2[PATH_MAX]; memset(buf2, 0,sizeof(buf2));
-#ifdef NDB_WIN32
- char* szFilePart;
- if(!GetFullPathName(theBaseDirectory, sizeof(buf2), buf2, &szFilePart)
- || (::GetFileAttributes(theBaseDirectory)&FILE_ATTRIBUTE_READONLY))
-#else
- if((::realpath(theBaseDirectory, buf2) == NULL)||
- (::access(theBaseDirectory, W_OK) != 0))
-#endif
- {
- ERROR_SET(fatal, AFS_ERROR_INVALIDPATH, pFileSystemPath, " Filename::init()");
- }
- strncpy(theBaseDirectory, buf2, sizeof(theBaseDirectory));
- // path seems ok, add delimiter if missing
- if (strcmp(&theBaseDirectory[strlen(theBaseDirectory) - 1],
- DIR_SEPARATOR) != 0)
- strcat(theBaseDirectory, DIR_SEPARATOR);
-
- snprintf(buf2, sizeof(buf2), "ndb_%u_fs%s", nodeid, DIR_SEPARATOR);
- strcat(theBaseDirectory, buf2);
+ snprintf(theFileSystemDirectory, sizeof(theFileSystemDirectory),
+ "%sndb_%u_fs%s", pFileSystemPath, nodeid, DIR_SEPARATOR);
+ strncpy(theBackupDirectory, pBackupDirPath, sizeof(theBackupDirectory));
+
+ DBUG_PRINT("info", ("theFileSystemDirectory=%s", theFileSystemDirectory));
+ DBUG_PRINT("info", ("theBackupDirectory=%s", theBackupDirectory));
#ifdef NDB_WIN32
- CreateDirectory(theBaseDirectory, 0);
+ CreateDirectory(theFileSystemDirectory, 0);
#else
- mkdir(theBaseDirectory, S_IRUSR | S_IWUSR | S_IXUSR | S_IXGRP | S_IRGRP);
+ mkdir(theFileSystemDirectory, S_IRUSR | S_IWUSR | S_IXUSR | S_IXGRP | S_IRGRP);
#endif
+ theBaseDirectory= 0;
+
+ DBUG_VOID_RETURN;
}
Filename::~Filename(){
@@ -94,10 +82,16 @@ Filename::set(BlockReference blockReference,
{
char buf[PATH_MAX];
theLevelDepth = 0;
- strncpy(theName, theBaseDirectory, PATH_MAX);
-
+
const Uint32 type = FsOpenReq::getSuffix(filenumber);
const Uint32 version = FsOpenReq::getVersion(filenumber);
+
+ if (version == 2)
+ theBaseDirectory= theBackupDirectory;
+ else
+ theBaseDirectory= theFileSystemDirectory;
+ strncpy(theName, theBaseDirectory, PATH_MAX);
+
switch(version){
case 1 :{
const Uint32 diskNo = FsOpenReq::v1_getDisk(filenumber);
diff --git a/ndb/src/kernel/blocks/ndbfs/Filename.hpp b/ndb/src/kernel/blocks/ndbfs/Filename.hpp
index 25c06092436..249c1b1ca10 100644
--- a/ndb/src/kernel/blocks/ndbfs/Filename.hpp
+++ b/ndb/src/kernel/blocks/ndbfs/Filename.hpp
@@ -67,13 +67,16 @@ public:
const char* directory(int level);
int levels() const;
const char* c_str() const;
-
- void init(Uint32 nodeid, const char * fileSystemPath);
+
+ void init(Uint32 nodeid, const char * fileSystemPath,
+ const char * backupDirPath);
private:
int theLevelDepth;
char theName[PATH_MAX];
- char theBaseDirectory[PATH_MAX];
+ char theFileSystemDirectory[PATH_MAX];
+ char theBackupDirectory[PATH_MAX];
+ char *theBaseDirectory;
char theDirectory[PATH_MAX];
};
diff --git a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp
index c7ef1a91099..56e3d3abbed 100644
--- a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp
+++ b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp
@@ -58,6 +58,8 @@ Ndbfs::Ndbfs(const Configuration & conf) :
m_maxOpenedFiles(0)
{
theFileSystemPath = conf.fileSystemPath();
+ theBackupFilePath = conf.backupFilePath();
+
theRequestPool = new Pool<Request>;
const ndb_mgm_configuration_iterator * p = conf.getOwnConfigIterator();
@@ -559,7 +561,7 @@ Ndbfs::createAsyncFile(){
}
AsyncFile* file = new AsyncFile;
- file->doStart(getOwnNodeId(), theFileSystemPath);
+ file->doStart(getOwnNodeId(), theFileSystemPath, theBackupFilePath);
// Put the file in list of all files
theFiles.push_back(file);
diff --git a/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp b/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp
index 080196a9ea5..c5aaa4e5c49 100644
--- a/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp
+++ b/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp
@@ -80,6 +80,7 @@ private:
Vector<AsyncFile*> theIdleFiles; // List of idle AsyncFiles
OpenFiles theOpenFiles; // List of open AsyncFiles
const char * theFileSystemPath;
+ const char * theBackupFilePath;
// Statistics variables
Uint32 m_maxOpenedFiles;
diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp
index 1acc5d59f97..d91d720b18a 100644
--- a/ndb/src/kernel/vm/Configuration.cpp
+++ b/ndb/src/kernel/vm/Configuration.cpp
@@ -144,6 +144,7 @@ Configuration::Configuration()
_programName = 0;
_connectString = 0;
_fsPath = 0;
+ _backupPath = 0;
_initialStart = false;
_daemonMode = false;
m_config_retriever= 0;
@@ -156,6 +157,9 @@ Configuration::~Configuration(){
if(_fsPath != NULL)
free(_fsPath);
+ if(_backupPath != NULL)
+ free(_backupPath);
+
if (m_config_retriever) {
delete m_config_retriever;
}
@@ -237,8 +241,48 @@ Configuration::fetch_configuration(){
}
}
+static char * get_and_validate_path(ndb_mgm_configuration_iterator &iter,
+ Uint32 param, const char *param_string)
+{
+ const char* path = NULL;
+ if(iter.get(param, &path)){
+ ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched missing ",
+ param_string);
+ }
+
+ if(path == 0 || strlen(path) == 0){
+ ERROR_SET(fatal, ERR_INVALID_CONFIG,
+ "Invalid configuration fetched. Configuration does not contain valid ",
+ param_string);
+ }
+
+ // check that it is pointing on a valid directory
+ //
+ char buf2[PATH_MAX];
+ memset(buf2, 0,sizeof(buf2));
+#ifdef NDB_WIN32
+ char* szFilePart;
+ if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart)
+ || (::GetFileAttributes(alloc_path)&FILE_ATTRIBUTE_READONLY))
+#else
+ if((::realpath(path, buf2) == NULL)||
+ (::access(buf2, W_OK) != 0))
+#endif
+ {
+ ERROR_SET(fatal, AFS_ERROR_INVALIDPATH, path, " Filename::init()");
+ }
+
+ if (strcmp(&buf2[strlen(buf2) - 1], DIR_SEPARATOR))
+ strcat(buf2, DIR_SEPARATOR);
+
+ return strdup(buf2);
+}
+
void
Configuration::setupConfiguration(){
+
+ DBUG_ENTER("Configuration::setupConfiguration");
+
ndb_mgm_configuration * p = m_clusterConfig;
/**
@@ -284,29 +328,15 @@ Configuration::setupConfiguration(){
}
/**
- * Get filesystem path
+ * Get paths
*/
- {
- const char* pFileSystemPath = NULL;
- if(iter.get(CFG_DB_FILESYSTEM_PATH, &pFileSystemPath)){
- ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched",
- "FileSystemPath missing");
- }
-
- if(pFileSystemPath == 0 || strlen(pFileSystemPath) == 0){
- ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched",
- "Configuration does not contain valid filesystem path");
- }
-
- if(pFileSystemPath[strlen(pFileSystemPath) - 1] == '/')
- _fsPath = strdup(pFileSystemPath);
- else {
- _fsPath = (char *)NdbMem_Allocate(strlen(pFileSystemPath) + 2);
- strcpy(_fsPath, pFileSystemPath);
- strcat(_fsPath, "/");
- }
- }
-
+ if (_fsPath)
+ free(_fsPath);
+ _fsPath= get_and_validate_path(iter, CFG_DB_FILESYSTEM_PATH, "FileSystemPath");
+ if (_backupPath)
+ free(_backupPath);
+ _backupPath= get_and_validate_path(iter, CFG_DB_BACKUP_DATADIR, "BackupDataDir");
+
if(iter.get(CFG_DB_STOP_ON_ERROR_INSERT, &m_restartOnErrorInsert)){
ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched",
"RestartOnErrorInsert missing");
@@ -327,6 +357,8 @@ Configuration::setupConfiguration(){
(p, CFG_SECTION_NODE);
calcSizeAlt(cf);
+
+ DBUG_VOID_RETURN;
}
bool
diff --git a/ndb/src/kernel/vm/Configuration.hpp b/ndb/src/kernel/vm/Configuration.hpp
index bd91f3fa74b..e84ff8d9193 100644
--- a/ndb/src/kernel/vm/Configuration.hpp
+++ b/ndb/src/kernel/vm/Configuration.hpp
@@ -53,6 +53,7 @@ public:
// Cluster configuration
const char * programName() const;
const char * fileSystemPath() const;
+ const char * backupFilePath() const;
char * getConnectStringCopy() const;
/**
@@ -89,6 +90,7 @@ private:
*/
char * _programName;
char * _fsPath;
+ char * _backupPath;
bool _initialStart;
char * _connectString;
bool _daemonMode;
@@ -109,6 +111,12 @@ Configuration::fileSystemPath() const {
}
inline
+const char *
+Configuration::backupFilePath() const {
+ return _backupPath;
+}
+
+inline
bool
Configuration::getInitialStart() const {
return _initialStart;