patch 4.0
This commit is contained in:
@ -20,124 +20,81 @@
|
||||
#include "lib/container/ob_iarray.h"
|
||||
#include "share/schema/ob_schema_struct.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
class ObMySQLProxy;
|
||||
class ObISQLClient;
|
||||
class ObAddr;
|
||||
namespace sqlclient {
|
||||
namespace sqlclient
|
||||
{
|
||||
class ObMySQLResult;
|
||||
}
|
||||
} // namespace common
|
||||
namespace share {
|
||||
}
|
||||
namespace share
|
||||
{
|
||||
|
||||
class ObSchemaStatusSnapshotUpdater {
|
||||
class ObSchemaStatusUpdater
|
||||
{
|
||||
public:
|
||||
ObSchemaStatusSnapshotUpdater(int64_t snapshot_timestamp) : snapshot_timestamp_(snapshot_timestamp)
|
||||
{}
|
||||
virtual ~ObSchemaStatusSnapshotUpdater()
|
||||
{}
|
||||
|
||||
int operator()(common::hash::HashMapPair<uint64_t, share::schema::ObRefreshSchemaStatus>& entry);
|
||||
|
||||
private:
|
||||
int64_t snapshot_timestamp_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObSchemaStatusSnapshotUpdater);
|
||||
};
|
||||
|
||||
class ObSchemaStatusVersionUpdater {
|
||||
public:
|
||||
ObSchemaStatusVersionUpdater(int64_t readable_schema_version) : readable_schema_version_(readable_schema_version)
|
||||
{}
|
||||
virtual ~ObSchemaStatusVersionUpdater()
|
||||
{}
|
||||
|
||||
int operator()(common::hash::HashMapPair<uint64_t, share::schema::ObRefreshSchemaStatus>& entry);
|
||||
|
||||
private:
|
||||
int64_t readable_schema_version_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObSchemaStatusVersionUpdater);
|
||||
};
|
||||
|
||||
class ObSchemaStatusCreatedVersionUpdater {
|
||||
public:
|
||||
ObSchemaStatusCreatedVersionUpdater(int64_t created_schema_version) : created_schema_version_(created_schema_version)
|
||||
{}
|
||||
virtual ~ObSchemaStatusCreatedVersionUpdater()
|
||||
{}
|
||||
|
||||
int operator()(common::hash::HashMapPair<uint64_t, share::schema::ObRefreshSchemaStatus>& entry);
|
||||
|
||||
private:
|
||||
int64_t created_schema_version_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObSchemaStatusCreatedVersionUpdater);
|
||||
};
|
||||
|
||||
class ObSchemaStatusUpdater {
|
||||
public:
|
||||
ObSchemaStatusUpdater(share::schema::ObRefreshSchemaStatus schema_status) : schema_status_(schema_status)
|
||||
{}
|
||||
virtual ~ObSchemaStatusUpdater()
|
||||
{}
|
||||
|
||||
int operator()(common::hash::HashMapPair<uint64_t, share::schema::ObRefreshSchemaStatus>& entry);
|
||||
ObSchemaStatusUpdater(share::schema::ObRefreshSchemaStatus schema_status)
|
||||
: schema_status_(schema_status) {}
|
||||
virtual ~ObSchemaStatusUpdater() {}
|
||||
|
||||
int operator() (common::hash::HashMapPair<uint64_t, share::schema::ObRefreshSchemaStatus> &entry);
|
||||
private:
|
||||
share::schema::ObRefreshSchemaStatus schema_status_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObSchemaStatusUpdater);
|
||||
};
|
||||
|
||||
// dodge the bug : https://aone.alibaba-inc.com/issue/17670392
|
||||
// all operation of __all_core_table must be single partition transaction
|
||||
class ObSchemaStatusProxy {
|
||||
class ObSchemaStatusProxy
|
||||
{
|
||||
public:
|
||||
static const char* OB_ALL_SCHEMA_STATUS_TNAME;
|
||||
static const char* TENANT_ID_CNAME;
|
||||
static const char* SNAPSHOT_TIMESTAMP_CNAME;
|
||||
static const char* READABLE_SCHEMA_VERSION_CNAME;
|
||||
static const char* CREATED_SCHEMA_VERSION_CNAME;
|
||||
static const char *OB_ALL_SCHEMA_STATUS_TNAME;
|
||||
static const char *TENANT_ID_CNAME;
|
||||
static const char *SNAPSHOT_TIMESTAMP_CNAME;
|
||||
static const char *READABLE_SCHEMA_VERSION_CNAME;
|
||||
static const char *CREATED_SCHEMA_VERSION_CNAME;
|
||||
static const int64_t TENANT_SCHEMA_STATUS_BUCKET_NUM = 100;
|
||||
|
||||
public:
|
||||
ObSchemaStatusProxy(common::ObISQLClient& sql_proxy)
|
||||
: sql_proxy_(sql_proxy), schema_status_cache_(), is_inited_(false)
|
||||
{}
|
||||
virtual ~ObSchemaStatusProxy()
|
||||
{}
|
||||
ObSchemaStatusProxy(common::ObISQLClient &sql_proxy)
|
||||
: sql_proxy_(sql_proxy),
|
||||
schema_status_cache_(),
|
||||
is_inited_(false) {}
|
||||
virtual ~ObSchemaStatusProxy() {}
|
||||
|
||||
int init();
|
||||
|
||||
int nonblock_get(const uint64_t refresh_tenant_id, share::schema::ObRefreshSchemaStatus& refresh_schema_status);
|
||||
int nonblock_get(const uint64_t refresh_tenant_id,
|
||||
share::schema::ObRefreshSchemaStatus &refresh_schema_status);
|
||||
|
||||
int get_refresh_schema_status(const uint64_t tenant_id, share::schema::ObRefreshSchemaStatus& refresh_schema_status);
|
||||
int get_refresh_schema_status(
|
||||
const uint64_t tenant_id,
|
||||
share::schema::ObRefreshSchemaStatus &refresh_schema_status);
|
||||
|
||||
int get_refresh_schema_status(common::ObIArray<share::schema::ObRefreshSchemaStatus>& refresh_schema_status_array);
|
||||
int get_refresh_schema_status(
|
||||
common::ObIArray<share::schema::ObRefreshSchemaStatus> &refresh_schema_status_array);
|
||||
|
||||
int load_refresh_schema_status();
|
||||
|
||||
int set_refresh_schema_status(const share::schema::ObRefreshSchemaStatus& refresh_schema_status);
|
||||
|
||||
int batch_update_schema_status(const common::ObIArray<share::schema::ObRefreshSchemaStatus>& schema_status);
|
||||
|
||||
int del_tenant_schema_status(const uint64_t tenant_id);
|
||||
|
||||
int update_snapshot_timestamp(const uint64_t tenant_id, int64_t snapshot_timestamp);
|
||||
int set_tenant_schema_status(
|
||||
const share::schema::ObRefreshSchemaStatus &refresh_schema_status);
|
||||
|
||||
int update_readable_schema_version(const uint64_t tenant_id, int64_t readable_schema_version);
|
||||
|
||||
int update_created_schema_version(const uint64_t tenant_id, int64_t created_schema_version);
|
||||
|
||||
int update_schema_status(const share::schema::ObRefreshSchemaStatus& curr_schema_status);
|
||||
int update_schema_status(const share::schema::ObRefreshSchemaStatus &cur_schema_status);
|
||||
|
||||
private:
|
||||
int check_inner_stat();
|
||||
|
||||
private:
|
||||
common::ObISQLClient& sql_proxy_;
|
||||
common::hash::ObHashMap<uint64_t, share::schema::ObRefreshSchemaStatus, common::hash::ReadWriteDefendMode>
|
||||
schema_status_cache_;
|
||||
common::ObISQLClient &sql_proxy_;
|
||||
common::hash::ObHashMap<uint64_t, share::schema::ObRefreshSchemaStatus, common::hash::ReadWriteDefendMode> schema_status_cache_;
|
||||
bool is_inited_;
|
||||
};
|
||||
|
||||
} // end namespace share
|
||||
} // end namespace oceanbase
|
||||
} // end namespace share
|
||||
} // end namespace oceanbase
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user