You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-15 12:09:09 +03:00
Added a basic config file, config class, and some stubs
for object storage functionality.
This commit is contained in:
@@ -1,15 +1,6 @@
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(storagemanager)
|
||||
|
||||
option(ENABLE_UNITY_BUILD "" ON)
|
||||
option(BUILD_SHARED_LIBS "" OFF)
|
||||
option(ENABLE_TESTING "" OFF)
|
||||
set(CMAKE_INSTALL_PREFIX_ORIG ${CMAKE_INSTALL_PREFIX})
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/aws-sdk-deps)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/aws-sdk-cpp)
|
||||
add_subdirectory(aws-sdk-cpp)
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX_ORIG})
|
||||
|
||||
include_directories(include)
|
||||
|
||||
set(storagemanager_SRCS
|
||||
@@ -29,6 +20,9 @@ set(storagemanager_SRCS
|
||||
src/CopyTask.cpp
|
||||
src/IOCoordinator.cpp
|
||||
src/SessionManager.cpp
|
||||
src/Config.cpp
|
||||
src/CloudStorage.cpp
|
||||
src/S3Storage.cpp
|
||||
)
|
||||
|
||||
option(TRACE "Enable some tracing output" OFF)
|
||||
@@ -42,6 +36,16 @@ target_link_libraries(StorageManager boost_system boost_thread boost_filesystem
|
||||
add_executable(unit_tests src/unit_tests.cpp ${storagemanager_SRCS})
|
||||
target_link_libraries(unit_tests boost_system boost_thread boost_filesystem)
|
||||
|
||||
# config & import the AWS SDK
|
||||
option(ENABLE_UNITY_BUILD "" ON)
|
||||
option(BUILD_SHARED_LIBS "" OFF)
|
||||
option(ENABLE_TESTING "" OFF)
|
||||
set(CMAKE_INSTALL_PREFIX_ORIG ${CMAKE_INSTALL_PREFIX})
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/aws-sdk-deps)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/aws-sdk-cpp)
|
||||
add_subdirectory(aws-sdk-cpp)
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX_ORIG})
|
||||
|
||||
#install(TARGETS StorageManager DESTINATION ${ENGINE_BINDIR} COMPONENT platform)
|
||||
|
||||
|
||||
|
||||
39
src/CloudStorage.cpp
Normal file
39
src/CloudStorage.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
#include "CloudStorage.h"
|
||||
#include "Config.h"
|
||||
#include "S3Storage.h"
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <syslog.h>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
boost::mutex m;
|
||||
storagemanager::CloudStorage *inst;
|
||||
}
|
||||
|
||||
namespace storagemanager
|
||||
{
|
||||
CloudStorage * CloudStorage::get()
|
||||
{
|
||||
if (inst)
|
||||
return inst;
|
||||
|
||||
Config *conf = Config::get();
|
||||
string type = conf->getValue("ObjectStorage", "service");
|
||||
boost::mutex::scoped_lock s(m);
|
||||
if (inst)
|
||||
return inst;
|
||||
if (type == "s3" || type == "S3")
|
||||
inst = new S3Storage();
|
||||
else {
|
||||
syslog(LOG_CRIT, "CloudStorage: got unknown service provider: %s", type.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
}
|
||||
24
src/CloudStorage.h
Normal file
24
src/CloudStorage.h
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef CLOUDSTORAGE_H_
|
||||
#define CLOUDSTORAGE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace storagemanager
|
||||
{
|
||||
|
||||
class CloudStorage
|
||||
{
|
||||
public:
|
||||
virtual int getObject(const std::string &sourceKey, const std::string &destFile) = 0;
|
||||
virtual int putObject(const std::string &sourceFile, const std::string &destKey) = 0;
|
||||
virtual void deleteObject(const std::string &key) = 0;
|
||||
|
||||
// this will return a CloudStorage instance of the type specified in StorageManager.cnf
|
||||
static CloudStorage *get();
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
70
src/Config.cpp
Normal file
70
src/Config.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
#include "Config.h"
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
boost::mutex m;
|
||||
storagemanager::Config *inst = NULL;
|
||||
}
|
||||
|
||||
namespace storagemanager
|
||||
{
|
||||
|
||||
Config * Config::get()
|
||||
{
|
||||
if (inst)
|
||||
return inst;
|
||||
boost::mutex::scoped_lock s(m);
|
||||
if (inst)
|
||||
return inst;
|
||||
inst = new Config();
|
||||
return inst;
|
||||
}
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
/* This will search the current directory,
|
||||
then the $COLUMNSTORE_INSTALL_DIR/etc,
|
||||
then /etc
|
||||
looking for storagemanager.cnf
|
||||
|
||||
We can change this however we need later.
|
||||
*/
|
||||
char *cs_install_dir = getenv("COLUMNSTORE_INSTALL_DIR");
|
||||
|
||||
vector<string> paths;
|
||||
|
||||
// the paths to search in order
|
||||
paths.push_back("./");
|
||||
if (cs_install_dir)
|
||||
paths.push_back(cs_install_dir);
|
||||
paths.push_back("/etc");
|
||||
|
||||
for (int i = 0; i < paths.size(); i++)
|
||||
{
|
||||
if (boost::filesystem::exists(paths[i] + "/storagemanager.cnf"))
|
||||
{
|
||||
filename = paths[i] + "/storagemanager.cnf";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (filename.empty())
|
||||
throw runtime_error("Config: Could not find the config file for StorageManager");
|
||||
|
||||
boost::property_tree::ini_parser::read_ini(filename, contents);
|
||||
}
|
||||
|
||||
string Config::getValue(const string §ion, const string &key) const
|
||||
{
|
||||
return contents.get<string>(section + "." + key);
|
||||
}
|
||||
|
||||
}
|
||||
27
src/Config.h
Normal file
27
src/Config.h
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
#ifndef CONFIG_H_
|
||||
#define CONFIG_H_
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace storagemanager
|
||||
{
|
||||
class Config : public boost::noncopyable
|
||||
{
|
||||
public:
|
||||
static Config *get();
|
||||
|
||||
std::string getValue(const std::string §ion, const std::string &key) const;
|
||||
|
||||
private:
|
||||
Config();
|
||||
|
||||
std::string filename;
|
||||
boost::property_tree::ptree contents;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
31
src/S3Storage.cpp
Normal file
31
src/S3Storage.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#include "S3Storage.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace storagemanager
|
||||
{
|
||||
|
||||
S3Storage::S3Storage()
|
||||
{
|
||||
}
|
||||
|
||||
S3Storage::~S3Storage()
|
||||
{
|
||||
}
|
||||
|
||||
int S3Storage::getObject(const string &courceKey, const string &destFile)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int S3Storage::putObject(const string &sourceFile, const string &destKey)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void S3Storage::deleteObject(const string &key)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
30
src/S3Storage.h
Normal file
30
src/S3Storage.h
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
#ifndef S3STORAGE_H_
|
||||
#define S3STORAGE_H_
|
||||
|
||||
#include <string>
|
||||
#include "CloudStorage.h"
|
||||
|
||||
namespace storagemanager
|
||||
{
|
||||
|
||||
class S3Storage : public CloudStorage
|
||||
{
|
||||
public:
|
||||
S3Storage();
|
||||
virtual ~S3Storage();
|
||||
|
||||
int getObject(const std::string &sourceKey, const std::string &destFile);
|
||||
int putObject(const std::string &sourceFile, const std::string &destKey);
|
||||
void deleteObject(const std::string &key);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
10
storagemanager.cnf
Normal file
10
storagemanager.cnf
Normal file
@@ -0,0 +1,10 @@
|
||||
[ObjectStorage]
|
||||
service=S3
|
||||
|
||||
[S3]
|
||||
region = us-west-1
|
||||
|
||||
# S3 credentials will come through standard AWS methods
|
||||
# ex, by setting AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY envvars.
|
||||
# see https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
|
||||
|
||||
Reference in New Issue
Block a user