From 1b20589efebc472c2b2990a823a968ac96c5f962 Mon Sep 17 00:00:00 2001 From: htt1997 Date: Thu, 24 Aug 2023 14:50:41 +0800 Subject: [PATCH] update Signed-off-by: htt1997 --- data_share/CMakeLists.txt | 10 +++++----- .../adapter/CMakeLists.txt | 7 +++++++ .../framework/include/store/auto_cache.h | 2 ++ .../framework/include/store/general_store.h | 2 ++ .../framework/store/auto_cache.cpp | 9 +++++++-- .../service/CMakeLists.txt | 17 ++--------------- .../service/cloud/sync_manager.cpp | 3 +++ .../data_share/gaussdb_rd/CMakeLists.txt | 2 +- .../service/rdb/rdb_general_store.cpp | 7 ++++++- .../service/rdb/rdb_general_store.h | 3 ++- .../service/rdb/rdb_service_impl.cpp | 3 +++ kv_store/frameworks/common/itypes_util.h | 4 ++-- relational_store/CMakeLists.txt | 2 -- .../interfaces/inner_api/rdb/BUILD.gn | 2 +- test/CMakeLists.txt | 1 + 15 files changed, 44 insertions(+), 30 deletions(-) diff --git a/data_share/CMakeLists.txt b/data_share/CMakeLists.txt index 9f7967ce..e39e4c20 100644 --- a/data_share/CMakeLists.txt +++ b/data_share/CMakeLists.txt @@ -31,10 +31,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/native/consumer/contr include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/native/consumer/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/native/provider/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/native/proxy/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/common/include/basic) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/common/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/consumer/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/provider/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../kv_store/frameworks/common) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../datamgr_service/services/distributeddataservice/adapter/include/dfx) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../utils_native/base/include) @@ -43,4 +39,8 @@ include(${MOCK_DIR}/include/CMakeLists.txt OPTIONAL) set(links secure mock relational_store) add_library(data_share SHARED ${data_share_src}) -target_link_libraries(data_share ${links}) \ No newline at end of file +target_link_libraries(data_share ${links}) +target_include_directories(data_share PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/common/include/basic) +target_include_directories(data_share PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/common/include) +target_include_directories(data_share PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/consumer/include) +target_include_directories(data_share PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/provider/include) \ No newline at end of file diff --git a/datamgr_service/services/distributeddataservice/adapter/CMakeLists.txt b/datamgr_service/services/distributeddataservice/adapter/CMakeLists.txt index af998470..cadc2b8d 100644 --- a/datamgr_service/services/distributeddataservice/adapter/CMakeLists.txt +++ b/datamgr_service/services/distributeddataservice/adapter/CMakeLists.txt @@ -44,3 +44,10 @@ set(links secure mock distributeddb crypto) add_library(adapter SHARED ${adapterSrc}) target_link_libraries(adapter ${links}) +target_include_directories(adapter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_include_directories(adapter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/account) +target_include_directories(adapter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/broadcaster) +target_include_directories(adapter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/communicator) +target_include_directories(adapter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/dfx) +target_include_directories(adapter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/permission) +target_include_directories(adapter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/utils) diff --git a/datamgr_service/services/distributeddataservice/framework/include/store/auto_cache.h b/datamgr_service/services/distributeddataservice/framework/include/store/auto_cache.h index e4940b91..947132c5 100644 --- a/datamgr_service/services/distributeddataservice/framework/include/store/auto_cache.h +++ b/datamgr_service/services/distributeddataservice/framework/include/store/auto_cache.h @@ -44,6 +44,8 @@ public: API_EXPORT void Bind(std::shared_ptr executor); + API_EXPORT bool IsBind(); + API_EXPORT Store GetStore(const StoreMetaData &meta, const Watchers &watchers); API_EXPORT void CloseStore(uint32_t tokenId, const std::string &storeId); diff --git a/datamgr_service/services/distributeddataservice/framework/include/store/general_store.h b/datamgr_service/services/distributeddataservice/framework/include/store/general_store.h index c39a328b..51aab6d0 100644 --- a/datamgr_service/services/distributeddataservice/framework/include/store/general_store.h +++ b/datamgr_service/services/distributeddataservice/framework/include/store/general_store.h @@ -61,6 +61,8 @@ public: }; virtual ~GeneralStore() = default; + virtual bool IsValid() = 0; + virtual int32_t Bind(const Database &database, BindInfo bindInfo) = 0; virtual bool IsBound() = 0; diff --git a/datamgr_service/services/distributeddataservice/framework/store/auto_cache.cpp b/datamgr_service/services/distributeddataservice/framework/store/auto_cache.cpp index 53fb2197..69b182d8 100644 --- a/datamgr_service/services/distributeddataservice/framework/store/auto_cache.cpp +++ b/datamgr_service/services/distributeddataservice/framework/store/auto_cache.cpp @@ -71,7 +71,7 @@ AutoCache::Store AutoCache::GetStore(const StoreMetaData &meta, const Watchers & return !stores.empty(); } auto *dbStore = creators_[meta.storeType](meta); - if (dbStore == nullptr) { + if (dbStore == nullptr || !dbStore->IsValid()) { return !stores.empty(); } auto result = stores.emplace(std::piecewise_construct, std::forward_as_tuple(meta.storeId), @@ -136,7 +136,7 @@ void AutoCache::GarbageCollect(bool isForce) auto current = std::chrono::steady_clock::now(); stores_.EraseIf([¤t, isForce](auto &key, std::map &delegates) { for (auto it = delegates.begin(); it != delegates.end();) { - // if the kv store is BUSY we wait more INTERVAL minutes again + // if the store is BUSY we wait more INTERVAL minutes again if ((isForce || it->second < current) && it->second.Close()) { it = delegates.erase(it); } else { @@ -147,6 +147,11 @@ void AutoCache::GarbageCollect(bool isForce) }); } +bool AutoCache::IsBind() +{ + return executor_ != nullptr; +} + AutoCache::Delegate::Delegate(GeneralStore *delegate, const Watchers &watchers, int32_t user) : store_(delegate), watchers_(watchers), user_(user) { diff --git a/datamgr_service/services/distributeddataservice/service/CMakeLists.txt b/datamgr_service/services/distributeddataservice/service/CMakeLists.txt index d9622fd0..fb10301f 100644 --- a/datamgr_service/services/distributeddataservice/service/CMakeLists.txt +++ b/datamgr_service/services/distributeddataservice/service/CMakeLists.txt @@ -60,22 +60,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/udmf/store) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/udmf) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/kvdb) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../framework/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/log) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/account) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/autils) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/broadcaster) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/communicator) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/dfx) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/log) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/permission) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/security) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../adapter/include/utils) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../app/src) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../kv_store/frameworks/common) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../data_share/interfaces/inner_api/common/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../data_share/interfaces/inner_api/provider/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../data_share/interfaces/inner_api/consumer/include) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../relational_store/interfaces/inner_api/rdb/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../data_share/frameworks/native/common/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../data_share/frameworks/native/common/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../data_object/frameworks/innerkitsimpl/include) @@ -85,7 +72,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../utils_native/base/in include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../utils_native/safwk/native/include) include(${MOCK_DIR}/include/CMakeLists.txt OPTIONAL) include(${KV_STORE_DIR}/interfaces/CMakeLists.txt OPTIONAL) -set(links secure mock kvdb svcFwk adapter data_share udmf document_ut cloud_data) +set(links secure mock kvdb svcFwk adapter data_share udmf document_ut cloud_data relational_store) set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/../../../") add_library(service SHARED ${serviceSrc}) target_link_libraries(service ${links}) diff --git a/datamgr_service/services/distributeddataservice/service/cloud/sync_manager.cpp b/datamgr_service/services/distributeddataservice/service/cloud/sync_manager.cpp index e89cef75..0ae20650 100644 --- a/datamgr_service/services/distributeddataservice/service/cloud/sync_manager.cpp +++ b/datamgr_service/services/distributeddataservice/service/cloud/sync_manager.cpp @@ -133,6 +133,9 @@ SyncManager::~SyncManager() int32_t SyncManager::Bind(std::shared_ptr executor) { executor_ = executor; + if (!AutoCache::GetInstance().IsBind()) { + AutoCache::GetInstance().Bind(executor_); + } return E_OK; } diff --git a/datamgr_service/services/distributeddataservice/service/data_share/gaussdb_rd/CMakeLists.txt b/datamgr_service/services/distributeddataservice/service/data_share/gaussdb_rd/CMakeLists.txt index 75734853..dc4311de 100644 --- a/datamgr_service/services/distributeddataservice/service/data_share/gaussdb_rd/CMakeLists.txt +++ b/datamgr_service/services/distributeddataservice/service/data_share/gaussdb_rd/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.11.2) project(document_ut) set(GAUSE_SOURCE_DIR "${PROJECT_SOURCE_DIR}") diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp index ce85ed48..5385952e 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp @@ -143,7 +143,7 @@ int32_t RdbGeneralStore::Close() bindInfo_.db_ = nullptr; rdbCloud_ = nullptr; rdbLoader_ = nullptr; - return 0; + return GeneralError::E_OK; } int32_t RdbGeneralStore::Execute(const std::string &table, const std::string &sql) @@ -404,6 +404,11 @@ RdbGeneralStore::GenErr RdbGeneralStore::ConvertStatus(DistributedDB::DBStatus s return GenErr::E_ERROR; } +bool RdbGeneralStore::IsValid() +{ + return delegate_ != nullptr; +} + void RdbGeneralStore::ObserverProxy::OnChange(const DBChangedIF &data) { if (!HasWatcher()) { diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.h b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.h index 8e1d6b49..8f41c446 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.h +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.h @@ -43,9 +43,11 @@ public: explicit RdbGeneralStore(const StoreMetaData &meta); ~RdbGeneralStore(); + bool IsValid() override; int32_t Bind(const Database &database, BindInfo bindInfo) override; bool IsBound() override; int32_t Execute(const std::string &table, const std::string &sql) override; + int32_t SetDistributedTables(const std::vector &tables, int32_t type) override; int32_t BatchInsert(const std::string &table, VBuckets &&values) override; int32_t BatchUpdate(const std::string &table, const std::string &sql, VBuckets &&values) override; int32_t Delete(const std::string &table, const std::string &sql, Values &&args) override; @@ -58,7 +60,6 @@ public: int32_t Close() override; int32_t AddRef() override; int32_t Release() override; - int32_t SetDistributedTables(const std::vector &tables, int32_t type) override; private: using RdbDelegate = DistributedDB::RelationalStoreDelegate; diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 9a2ec41b..c3707042 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -630,6 +630,9 @@ std::pair RdbServiceImpl::GetInstIndexAndUser(uint32_t tokenId int32_t RdbServiceImpl::OnBind(const BindInfo &bindInfo) { executors_ = bindInfo.executors; + if (!AutoCache::GetInstance().IsBind()) { + AutoCache::GetInstance().Bind(executors_); + } return 0; } diff --git a/kv_store/frameworks/common/itypes_util.h b/kv_store/frameworks/common/itypes_util.h index dafdc8d3..f9c21890 100644 --- a/kv_store/frameworks/common/itypes_util.h +++ b/kv_store/frameworks/common/itypes_util.h @@ -36,8 +36,8 @@ template struct is_container> : std::true_type { }; namespace ITypesUtil { -static constexpr size_t MAX_COUNT = 100000; -static constexpr size_t MAX_SIZE = 1 * 1024 * 1024 * 1024; //1G +inline constexpr size_t MAX_COUNT = 100000; +inline constexpr size_t MAX_SIZE = 1 * 1024 * 1024 * 1024; //1G static inline bool Marshal(MessageParcel &data) { return true; diff --git a/relational_store/CMakeLists.txt b/relational_store/CMakeLists.txt index d903d371..1729baea 100644 --- a/relational_store/CMakeLists.txt +++ b/relational_store/CMakeLists.txt @@ -51,12 +51,10 @@ add_library(relational_store SHARED ${relational_store_src} ${rdb_adapter_src}) target_link_libraries(relational_store ${links}) target_include_directories(relational_store PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/rdb/include) target_include_directories(relational_store PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/appdatafwk/include) -target_include_directories(relational_store PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/appdatafwk/include) target_include_directories(relational_store PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/rdb_bms_adapter/include) target_include_directories(relational_store PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/rdb_data_ability_adapter/include) target_include_directories(relational_store PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/rdb_data_share_adapter/include) target_include_directories(relational_store PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/dataability/include) -target_include_directories(relational_store PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/rdb/include) add_library(js_relational_store SHARED ${js_common_src} ${js_relational_store_src}) diff --git a/relational_store/interfaces/inner_api/rdb/BUILD.gn b/relational_store/interfaces/inner_api/rdb/BUILD.gn index 9dd419b1..a0b22c98 100644 --- a/relational_store/interfaces/inner_api/rdb/BUILD.gn +++ b/relational_store/interfaces/inner_api/rdb/BUILD.gn @@ -70,7 +70,7 @@ if (is_ohos && !build_ohos_sdk) { ] } - config("native_rdb_public_config") { + config(" ") { visibility = [ ":*" ] include_dirs = [ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4d73750a..2958fb95 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,6 +7,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -fPIC -fpic -ffunction-s set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed -ldl") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=0 -fpermissive") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations -Wno-deprecated-declarations") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") include_directories(${CMAKE_SOURCE_DIR}/utils_native/base/include) -- Gitee