add prototypes of loadStoredObject and

some relevant helpers in replicateddb
This commit is contained in:
Val 2020-04-24 17:12:54 +03:00
parent e0f52965e5
commit c1c132502c
2 changed files with 83 additions and 0 deletions

View File

@ -190,4 +190,26 @@ void DatabaseReplicated::drop(const Context & context)
// zookeeper path. does it work recursively? hope so...
}
void DatabaseOrdinary::loadStoredObjects(
Context & context,
bool has_force_restore_data_flag)
{
syncReplicaState(context);
updateMetadata(context);
DatabaseOrdinary::loadStoredObjects(context, has_force_restore_data_flag);
}
// sync replica's zookeeper metadata
void syncReplicaState(Context & context) {
}
// get the up to date metadata from zookeeper to local metadata dir
// for replicated (only?) tables
void updateMetadata(Context & context) {
}
}

View File

@ -0,0 +1,61 @@
#pragma once
#include <Databases/DatabaseOrdinary.h>
#include <Common/randomSeed.h>
#include <Common/ZooKeeper/ZooKeeper.h>
namespace DB
{
/** Replicated database engine.
* It stores tables list using list of .sql files,
* that contain declaration of table represented by SQL ATTACH TABLE query
* and operation log in zookeeper
*/
class DatabaseReplicated : public DatabaseOrdinary
{
public:
DatabaseReplicated(const String & name_, const String & metadata_path_, const String & zookeeper_path_, const String & replica_name_, const Context & context);
String getEngineName() const override { return "Replicated"; }
void createTable(
const Context & context,
const String & table_name,
const StoragePtr & table,
const ASTPtr & query) override;
void removeTable(
const Context & context,
const String & table_name) override;
void renameTable(
const Context & context,
const String & table_name,
IDatabase & to_database,
const String & to_table_name,
TableStructureWriteLockHolder & lock) override;
void drop(const Context & context) override;
void loadStoredObjects(
Context & context,
bool has_force_restore_data_flag) override;
private:
String zookeeper_path;
String replica_name;
String replica_path;
zkutil::ZooKeeperPtr current_zookeeper; /// Use only the methods below.
mutable std::mutex current_zookeeper_mutex; /// To recreate the session in the background thread.
zkutil::ZooKeeperPtr tryGetZooKeeper() const;
zkutil::ZooKeeperPtr getZooKeeper() const;
void setZooKeeper(zkutil::ZooKeeperPtr zookeeper);
void syncReplicaState(Context & context);
void updateMetadata(Context & context);
};
}