Skip to content

Commit

Permalink
[feature](merge-cloud) Add CloudTablet (apache#30045)
Browse files Browse the repository at this point in the history
  • Loading branch information
platoneko authored Jan 18, 2024
1 parent 41672f2 commit 4f4e207
Show file tree
Hide file tree
Showing 17 changed files with 752 additions and 142 deletions.
26 changes: 13 additions & 13 deletions be/src/cloud/cloud_meta_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <type_traits>
#include <vector>

#include "cloud/cloud_tablet.h"
#include "cloud/config.h"
#include "cloud/pb_convert.h"
#include "common/logging.h"
Expand All @@ -38,7 +39,6 @@
#include "gen_cpp/olap_file.pb.h"
#include "olap/olap_common.h"
#include "olap/rowset/rowset_factory.h"
#include "olap/tablet.h"
#include "olap/tablet_meta.h"
#include "runtime/stream_load/stream_load_context.h"
#include "util/network_util.h"
Expand Down Expand Up @@ -270,12 +270,12 @@ Status CloudMetaMgr::get_tablet_meta(int64_t tablet_id, TabletMetaSharedPtr* tab
return Status::OK();
}

Status CloudMetaMgr::sync_tablet_rowsets(Tablet* tablet, bool warmup_delta_data) {
Status CloudMetaMgr::sync_tablet_rowsets(CloudTablet* tablet, bool warmup_delta_data) {
return Status::NotSupported("CloudMetaMgr::sync_tablet_rowsets is not implemented");
}

Status CloudMetaMgr::sync_tablet_delete_bitmap(
Tablet* tablet, int64_t old_max_version,
CloudTablet* tablet, int64_t old_max_version,
const google::protobuf::RepeatedPtrField<RowsetMetaPB>& rs_metas,
const TabletStatsPB& stats, const TabletIndexPB& idx, DeleteBitmap* delete_bitmap) {
return Status::NotSupported("CloudMetaMgr::sync_tablet_delete_bitmap is not implemented");
Expand Down Expand Up @@ -425,15 +425,15 @@ Status CloudMetaMgr::update_tablet_schema(int64_t tablet_id, const TabletSchema&
return Status::OK();
}

Status CloudMetaMgr::update_delete_bitmap(const Tablet* tablet, int64_t lock_id, int64_t initiator,
DeleteBitmap* delete_bitmap) {
VLOG_DEBUG << "update_delete_bitmap , tablet_id: " << tablet->tablet_id();
Status CloudMetaMgr::update_delete_bitmap(const CloudTablet& tablet, int64_t lock_id,
int64_t initiator, DeleteBitmap* delete_bitmap) {
VLOG_DEBUG << "update_delete_bitmap , tablet_id: " << tablet.tablet_id();
UpdateDeleteBitmapRequest req;
UpdateDeleteBitmapResponse res;
req.set_cloud_unique_id(config::cloud_unique_id);
req.set_table_id(tablet->table_id());
req.set_partition_id(tablet->partition_id());
req.set_tablet_id(tablet->tablet_id());
req.set_table_id(tablet.table_id());
req.set_partition_id(tablet.partition_id());
req.set_tablet_id(tablet.tablet_id());
req.set_lock_id(lock_id);
req.set_initiator(initiator);
for (auto iter = delete_bitmap->delete_bitmap.begin();
Expand All @@ -451,18 +451,18 @@ Status CloudMetaMgr::update_delete_bitmap(const Tablet* tablet, int64_t lock_id,
if (res.status().code() == MetaServiceCode::LOCK_EXPIRED) {
return Status::Error<ErrorCode::DELETE_BITMAP_LOCK_ERROR, false>(
"lock expired when update delete bitmap, tablet_id: {}, lock_id: {}",
tablet->tablet_id(), lock_id);
tablet.tablet_id(), lock_id);
}
return st;
}

Status CloudMetaMgr::get_delete_bitmap_update_lock(const Tablet* tablet, int64_t lock_id,
Status CloudMetaMgr::get_delete_bitmap_update_lock(const CloudTablet& tablet, int64_t lock_id,
int64_t initiator) {
VLOG_DEBUG << "get_delete_bitmap_update_lock , tablet_id: " << tablet->tablet_id();
VLOG_DEBUG << "get_delete_bitmap_update_lock , tablet_id: " << tablet.tablet_id();
GetDeleteBitmapUpdateLockRequest req;
GetDeleteBitmapUpdateLockResponse res;
req.set_cloud_unique_id(config::cloud_unique_id);
req.set_table_id(tablet->table_id());
req.set_table_id(tablet.table_id());
req.set_lock_id(lock_id);
req.set_initiator(initiator);
req.set_expiration(10); // 10s expiration time for compaction and schema_change
Expand Down
11 changes: 6 additions & 5 deletions be/src/cloud/cloud_meta_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace doris {

class DeleteBitmap;
class StreamLoadContext;
class Tablet;
class CloudTablet;
class TabletMeta;
class TabletSchema;
class RowsetMeta;
Expand All @@ -51,7 +51,7 @@ class CloudMetaMgr {

Status get_tablet_meta(int64_t tablet_id, std::shared_ptr<TabletMeta>* tablet_meta);

Status sync_tablet_rowsets(Tablet* tablet, bool warmup_delta_data = false);
Status sync_tablet_rowsets(CloudTablet* tablet, bool warmup_delta_data = false);

Status prepare_rowset(const RowsetMeta& rs_meta, bool is_tmp,
std::shared_ptr<RowsetMeta>* existed_rs_meta = nullptr);
Expand Down Expand Up @@ -79,14 +79,15 @@ class CloudMetaMgr {

Status update_tablet_schema(int64_t tablet_id, const TabletSchema& tablet_schema);

Status update_delete_bitmap(const Tablet* tablet, int64_t lock_id, int64_t initiator,
Status update_delete_bitmap(const CloudTablet& tablet, int64_t lock_id, int64_t initiator,
DeleteBitmap* delete_bitmap);

Status get_delete_bitmap_update_lock(const Tablet* tablet, int64_t lock_id, int64_t initiator);
Status get_delete_bitmap_update_lock(const CloudTablet& tablet, int64_t lock_id,
int64_t initiator);

private:
Status sync_tablet_delete_bitmap(
Tablet* tablet, int64_t old_max_version,
CloudTablet* tablet, int64_t old_max_version,
const google::protobuf::RepeatedPtrField<RowsetMetaPB>& rs_metas,
const TabletStatsPB& stas, const TabletIndexPB& idx, DeleteBitmap* delete_bitmap);
};
Expand Down
39 changes: 39 additions & 0 deletions be/src/cloud/cloud_storage_engine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

#pragma once

#include <memory>

namespace doris {
namespace cloud {
class CloudMetaMgr;
}

class CloudStorageEngine {
public:
CloudStorageEngine();

~CloudStorageEngine();

cloud::CloudMetaMgr& meta_mgr() { return *_meta_mgr; }

private:
std::unique_ptr<cloud::CloudMetaMgr> _meta_mgr;
};

} // namespace doris
Loading

0 comments on commit 4f4e207

Please sign in to comment.