diff --git a/data_share/CMakeLists.txt b/data_share/CMakeLists.txt index 9f7967ce4c16b8ab8e068a652c36545a592b14c2..e39e4c20dd1e05a36c9b1040d4273d2b1ee66c15 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 af9984701f0c9b922c267968fa40df3b590303aa..cadc2b8d97d4c32b9acf69c50dc270e2995a0743 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 e4940b91999f5be44fac8027941eb77cde54717f..947132c568287618e8cd2421c7429231520eeb4a 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 c39a328b4fd4f5395d7ace0c98805ee44d87d6c9..51aab6d051cf7e304fcebf10ccae52f9f3be55fa 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 53fb21977264431be304e10af8dab08aeaef09b8..69b182d85bca9f398f15271bac238dbe895bbf27 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 d9622fd0e18672ffc2f78e76977b87efae68941c..fb10301f6cdb0ac8e60a0407782832c182eb16a9 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 e89cef75ef38b4025a3994c4fc49be77c857494c..0ae20650e6a70db09ed6e6ead6020307aa4e0d11 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 75734853acad9c8e7d58b91c7e2c8f4c5771f9bd..dc4311de05e39f3ef76eb9a3319d1bd3bbca8372 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 ce85ed48a2bd1979b7d390bff9f50918be019523..5385952e3b5fa5aaa654f8b5ca520963669586b0 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 8e1d6b4988b1566ffc38ab6106ba5ffe0a5d9336..8f41c4469a277839401ada3d7833e57b98c6b6a2 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 9a2ec41bed1809824682517afdf2ca1a95a80c55..c37070429b2c4da0d309af5432337263f743169e 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 dafdc8d3e18544e0ceeedc1c01ad3740d4697b85..f9c2189016c4e675f4abdc0f04a1296743855f64 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 d903d371eb3076713ed7bd2ed8f1ab9439abd312..1729baea30236c4f48f21e14950c93a43df371e4 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 9dd419b1438c02feeba3eaa871f88a6fd41b2936..a0b22c987d4d3aec227d82e8d69a2806ecc6e966 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 4d73750aa2b96c387237fe16890264905240051f..2958fb950b52ee41a45a47a7cace127d535938c2 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)