Commit e97e08b2 authored by tomas@poseidon.(none)'s avatar tomas@poseidon.(none)

new parameter BackupDataDir

parent 50cee6ab
......@@ -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
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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();
......
......@@ -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(theFileSystemDirectory, sizeof(theFileSystemDirectory),
"%sndb_%u_fs%s", pFileSystemPath, nodeid, DIR_SEPARATOR);
strncpy(theBackupDirectory, pBackupDirPath, sizeof(theBackupDirectory));
snprintf(buf2, sizeof(buf2), "ndb_%u_fs%s", nodeid, DIR_SEPARATOR);
strcat(theBaseDirectory, buf2);
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);
......
......@@ -68,12 +68,15 @@ public:
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];
};
......
......@@ -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);
......
......@@ -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;
......
......@@ -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,28 +328,14 @@ 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",
......@@ -327,6 +357,8 @@ Configuration::setupConfiguration(){
(p, CFG_SECTION_NODE);
calcSizeAlt(cf);
DBUG_VOID_RETURN;
}
bool
......
......@@ -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;
......@@ -108,6 +110,12 @@ Configuration::fileSystemPath() const {
return _fsPath;
}
inline
const char *
Configuration::backupFilePath() const {
return _backupPath;
}
inline
bool
Configuration::getInitialStart() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment