1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

Merge pull request #855 from mariadb-corporation/move-etc

Move config files
This commit is contained in:
benthompson15
2019-09-09 15:54:30 -05:00
committed by GitHub
67 changed files with 535 additions and 5808 deletions

View File

@ -1,108 +0,0 @@
// A good set of defaults for the dev compile
#ifndef CONFIGCPP_CONFIG_H__
#define CONFIGCPP_CONFIG_H__
#ifndef HAVE_CONFIG_H
#ifndef _MSC_VER
#define HAVE_ALARM 1
#define HAVE_ALLOCA 1
#define HAVE_ALLOCA_H 1
#define HAVE_ARPA_INET_H 1
#define HAVE_DECL_STRERROR_R 1
#define HAVE_DLFCN_H 1
#define HAVE_DUP2 1
#define HAVE_FCNTL_H 1
#define HAVE_FLOOR 1
#define HAVE_FORK 1
#define HAVE_FTIME 1
#define HAVE_FTRUNCATE 1
#define HAVE_GETHOSTBYNAME 1
#define HAVE_GETPAGESIZE 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_INET_NTOA 1
#define HAVE_INTTYPES_H 1
#define HAVE_ISASCII 1
#define HAVE_LIMITS_H 1
#define HAVE_LOCALTIME_R 1
#define HAVE_MALLOC 1
#define HAVE_MALLOC_H 1
#define HAVE_MBSTATE_T 1
#define HAVE_MEMCHR 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMORY_H 1
#define HAVE_MEMSET 1
#define HAVE_MKDIR 1
#define HAVE_NETDB_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_POW 1
#define HAVE_PTRDIFF_T 1
#define HAVE_REGCOMP 1
#define HAVE_RMDIR 1
#define HAVE_SELECT 1
#define HAVE_SETENV 1
#define HAVE_SETLOCALE 1
#define HAVE_SOCKET 1
#define HAVE_STDBOOL_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRCASECMP 1
#define HAVE_STRCHR 1
#define HAVE_STRCSPN 1
#define HAVE_STRDUP 1
#define HAVE_STRERROR 1
#define HAVE_STRERROR_R 1
#define HAVE_STRFTIME 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_STRRCHR 1
#define HAVE_STRSPN 1
#define HAVE_STRSTR 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOULL 1
#define HAVE_SYSLOG_H 1
#define HAVE_SYS_FILE_H 1
#define HAVE_SYS_MOUNT_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STATFS_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIMEB_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_UTIME 1
#define HAVE_UTIME_H 1
#define HAVE_VALUES_H 1
#define HAVE_VFORK 1
#define HAVE_WORKING_VFORK 1
#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
//#define PACKAGE "calpont"
//#define PACKAGE_BUGREPORT "support@calpont.com"
//#define PACKAGE_NAME "Calpont"
//#define PACKAGE_STRING "Calpont 1.0.0"
//#define PACKAGE_TARNAME "calpont"
//#define PACKAGE_VERSION "1.0.0"
#define PROTOTYPES 1
#define RETSIGTYPE void
#define SELECT_TYPE_ARG1 int
#define SELECT_TYPE_ARG234 (fd_set *)
#define SELECT_TYPE_ARG5 (struct timeval *)
#define STDC_HEADERS 1
#define STRERROR_R_CHAR_P 1
#define TIME_WITH_SYS_TIME 1
#define VERSION "1.0.0"
#define __PROTOTYPES 1
#define restrict __restrict
#else // _MSC_VER
#endif
#endif //!HAVE_CONFIG_H
#endif //!CONFIGCPP_CONFIG_H__

View File

@ -107,7 +107,7 @@ Config* Config::makeConfig(const char* cf)
if (defaultFilePath.empty())
{
fs::path configFilePath;
configFilePath = fs::path(installDir) / fs::path("etc") / defaultCalpontConfigFile;
configFilePath = fs::path(MCSSYSCONFDIR) / fs::path("columnstore") / defaultCalpontConfigFile;
defaultFilePath = configFilePath.string();
}
@ -383,7 +383,7 @@ void Config::writeConfig(const string& configFile) const
const fs::path saveCalpontConfigFileTemp("Columnstore.xml.columnstoreSave");
const fs::path tmpCalpontConfigFileTemp("Columnstore.xml.temp1");
fs::path etcdir = fs::path(fInstallDir) / fs::path("etc");
fs::path etcdir = fs::path(MCSSYSCONFDIR) / fs::path("columnstore");
fs::path dcf = etcdir / fs::path(defaultCalpontConfigFile);
fs::path dcft = etcdir / fs::path(defaultCalpontConfigFileTemp);

View File

@ -1,232 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
// $Id: writeonce.cpp 3495 2013-01-21 14:09:51Z rdempsey $
#include "writeonce.h"
#include <string>
#include <stdexcept>
#include <sstream>
#include <fstream>
#include <errno.h>
#include <unistd.h>
//#define NDEBUG
#include <cassert>
#include <cstring>
using namespace std;
#include <boost/any.hpp>
using namespace boost;
#include "bytestream.h"
using namespace messageqcpp;
#include "installdir.h"
namespace
{
const string DefaultWriteOnceConfigFilename("woparms.dat");
}
namespace config
{
//If you add parm, you need to update all the methods below until the next comment
void WriteOnceConfig::initializeDefaults()
{
string tmpDir = startup::StartUp::tmpDir();
fLBID_Shift = make_pair("13", false);
fDBRootCount = make_pair("1", false);
fDBRMRoot = make_pair("/mnt/OAM/dbrm/BRM_saves", false);
string file = tmpDir + "/ColumnstoreShm";
fSharedMemoryTmpFile1 = make_pair(file, false);
fTxnIDFile = make_pair("/mnt/OAM/dbrm/SMTxnID", false);
file = tmpDir + "/CalpontSessionMonitorShm";
fSharedMemoryTmpFile2 = make_pair(file, false);
}
void WriteOnceConfig::setup()
{
typedef EntryMap_t::value_type VT;
fEntryMap.insert(VT("PrimitiveServers.LBID_Shift", &fLBID_Shift));
fEntryMap.insert(VT("SystemConfig.DBRootCount", &fDBRootCount));
fEntryMap.insert(VT("SystemConfig.DBRMRoot", &fDBRMRoot));
fEntryMap.insert(VT("SessionManager.SharedMemoryTmpFile", &fSharedMemoryTmpFile1));
fEntryMap.insert(VT("SessionManager.TxnIDFile", &fTxnIDFile));
fEntryMap.insert(VT("SessionMonitor.SharedMemoryTmpFile", &fSharedMemoryTmpFile2));
ByteStream ibs = load();
if (ibs.length() > 0)
unserialize(ibs);
else
initializeDefaults();
}
void WriteOnceConfig::serialize(ByteStream& obs) const
{
obs << WriteOnceConfigVersion;
obs << fLBID_Shift.first;
obs << fDBRootCount.first;
obs << fDBRMRoot.first;
obs << fSharedMemoryTmpFile1.first;
obs << fTxnIDFile.first;
obs << fSharedMemoryTmpFile2.first;
}
void WriteOnceConfig::unserialize(ByteStream& ibs)
{
uint32_t version;
ibs >> version;
if (version < WriteOnceConfigVersion)
{
ostringstream oss;
oss << "Invalid version found in WriteOnceConfig file: " << version;
throw runtime_error(oss.str().c_str());
}
else if (version > WriteOnceConfigVersion)
{
ostringstream oss;
oss << "Invalid version found in WriteOnceConfig file: " << version;
throw runtime_error(oss.str().c_str());
}
ibs >> fLBID_Shift.first;
fLBID_Shift.second = true;
ibs >> fDBRootCount.first;
fDBRootCount.second = true;
ibs >> fDBRMRoot.first;
fDBRMRoot.second = true;
ibs >> fSharedMemoryTmpFile1.first;
fSharedMemoryTmpFile1.second = true;
ibs >> fTxnIDFile.first;
fTxnIDFile.second = true;
ibs >> fSharedMemoryTmpFile2.first;
fSharedMemoryTmpFile2.second = true;
}
//End of methods that need to be changed when adding parms
ByteStream WriteOnceConfig::load()
{
ByteStream bs;
if (access(fConfigFileName.c_str(), F_OK) != 0)
{
initializeDefaults();
return bs;
}
idbassert(access(fConfigFileName.c_str(), F_OK) == 0);
ifstream ifs(fConfigFileName.c_str());
int e = errno;
if (!ifs.good())
{
ostringstream oss;
oss << "Error opening WriteOnceConfig file " << fConfigFileName << ": " << strerror(e);
throw runtime_error(oss.str().c_str());
}
ifs >> bs;
return bs;
}
void WriteOnceConfig::save(ByteStream& ibs) const
{
ofstream ofs(fConfigFileName.c_str());
int e = errno;
if (!ofs.good())
{
ostringstream oss;
oss << "Error opening WriteOnceConfig file " << fConfigFileName << ": " << strerror(e);
throw runtime_error(oss.str().c_str());
}
ofs << ibs;
}
WriteOnceConfig::WriteOnceConfig(const char* cf)
{
string cfs;
if (cf != 0)
cfs = cf;
else
cfs = startup::StartUp::installDir() + "/etc/" + DefaultWriteOnceConfigFilename;
fConfigFileName = cfs;
setup();
}
void WriteOnceConfig::setConfig(const string& section, const string& name, const string& value, bool force)
{
EntryMap_t::iterator iter;
iter = fEntryMap.find(string(section + "." + name));
if (iter == fEntryMap.end())
{
ostringstream oss;
oss << "Invalid request for " << section << '.' << name;
throw runtime_error(oss.str().c_str());
}
if ((*iter->second).second && !force)
{
ostringstream oss;
oss << "Invalid attempt to write read-only " << section << '.' << name;
throw runtime_error(oss.str().c_str());
}
(*iter->second).first = value;
(*iter->second).second = true;
ByteStream obs;
serialize(obs);
save(obs);
}
const string WriteOnceConfig::getConfig(const string& section, const string& name) const
{
string val;
EntryMap_t::const_iterator iter;
iter = fEntryMap.find(string(section + "." + name));
if (iter == fEntryMap.end())
{
ostringstream oss;
oss << "Invalid request for " << section << '.' << name;
throw runtime_error(oss.str().c_str());
}
val = (*iter->second).first;
return val;
}
}