Skip to content

Commit

Permalink
feat(backup): 2. update and refactor meta backup engine class (#1102)
Browse files Browse the repository at this point in the history
  • Loading branch information
hycdong authored Aug 11, 2022
1 parent 4a3a173 commit abd52ae
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 159 deletions.
14 changes: 14 additions & 0 deletions src/rdsn/include/dsn/cpp/json_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ ENUM_TYPE_SERIALIZATION(dsn::replication::partition_status::type,
ENUM_TYPE_SERIALIZATION(dsn::app_status::type, dsn::app_status::AS_INVALID)
ENUM_TYPE_SERIALIZATION(dsn::replication::bulk_load_status::type,
dsn::replication::bulk_load_status::BLS_INVALID)
ENUM_TYPE_SERIALIZATION(dsn::replication::backup_status::type,
dsn::replication::backup_status::UNINITIALIZED)

// json serialization for gpid, we treat it as string: "app_id.partition_id"
inline void json_encode(JsonWriter &out, const dsn::gpid &pid)
Expand Down Expand Up @@ -386,6 +388,8 @@ inline void json_encode(JsonWriter &out, const dsn::replication::file_meta &f_me
inline bool json_decode(const JsonObject &in, dsn::replication::file_meta &f_meta);
inline void json_encode(JsonWriter &out, const dsn::replication::bulk_load_metadata &metadata);
inline bool json_decode(const JsonObject &in, dsn::replication::bulk_load_metadata &metadata);
inline void json_encode(JsonWriter &out, const dsn::replication::backup_item &backup_item);
inline bool json_decode(const JsonObject &in, dsn::replication::backup_item &backup_item);

template <typename T>
inline void json_encode_iterable(JsonWriter &out, const T &t)
Expand Down Expand Up @@ -655,5 +659,15 @@ NON_MEMBER_JSON_SERIALIZATION(dsn::app_info,
NON_MEMBER_JSON_SERIALIZATION(dsn::replication::file_meta, name, size, md5)

NON_MEMBER_JSON_SERIALIZATION(dsn::replication::bulk_load_metadata, files, file_total_size)

NON_MEMBER_JSON_SERIALIZATION(dsn::replication::backup_item,
backup_id,
app_id,
app_name,
backup_provider_type,
backup_path,
start_time_ms,
end_time_ms,
status)
} // namespace json
} // namespace dsn
12 changes: 12 additions & 0 deletions src/rdsn/include/dsn/dist/replication/replication_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,16 @@ ENUM_REG(replication::manual_compaction_status::QUEUING)
ENUM_REG(replication::manual_compaction_status::RUNNING)
ENUM_REG(replication::manual_compaction_status::FINISHED)
ENUM_END2(replication::manual_compaction_status::type, manual_compaction_status)

ENUM_BEGIN2(replication::backup_status::type,
backup_status,
replication::backup_status::UNINITIALIZED)
ENUM_REG(replication::backup_status::UNINITIALIZED)
ENUM_REG(replication::backup_status::CHECKPOINTING)
ENUM_REG(replication::backup_status::CHECKPOINTED)
ENUM_REG(replication::backup_status::UPLOADING)
ENUM_REG(replication::backup_status::SUCCEED)
ENUM_REG(replication::backup_status::FAILED)
ENUM_REG(replication::backup_status::CANCELED)
ENUM_END2(replication::backup_status::type, backup_status)
} // namespace dsn
36 changes: 24 additions & 12 deletions src/rdsn/src/common/backup.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ include "../../../../idl/dsn.layer2.thrift"

namespace cpp dsn.replication

enum backup_status
{
UNINITIALIZED,
CHECKPOINTING,
CHECKPOINTED,
UPLOADING,
SUCCEED,
FAILED,
CANCELED
}

struct backup_item
{
1:i64 backup_id;
2:i32 app_id;
3:string app_name;
4:string backup_provider_type;
// user specified backup_path.
5:string backup_path;
6:i64 start_time_ms;
7:i64 end_time_ms;
8:backup_status status;
}

struct policy_info
{
1:string policy_name;
Expand Down Expand Up @@ -177,18 +201,6 @@ struct start_backup_app_response
3:optional i64 backup_id;
}

struct backup_item
{
1:i64 backup_id;
2:string app_name;
3:string backup_provider_type;
// user specified backup_path.
4:string backup_path;
5:i64 start_time_ms;
6:i64 end_time_ms;
7:bool is_backup_failed;
}

struct query_backup_status_request
{
1:i32 app_id;
Expand Down
Loading

0 comments on commit abd52ae

Please sign in to comment.