Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

ADPPRG-126821: Reduce contention in access to pdx registry #6

Open
wants to merge 6 commits into
base: release-nordix/1.15.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions cppcache/include/geode/Region.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* @throws RegionDestroyedException if the method is called on a destroyed
*region
**/
virtual std::shared_ptr<Cacheable> get(
virtual std::shared_ptr<Serializable> get(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline std::shared_ptr<Cacheable> get(
inline std::shared_ptr<Serializable> get(
const KEYTYPE& key,
const std::shared_ptr<Serializable>& callbackArg = nullptr) {
return get(CacheableKey::create(key), callbackArg);
Expand Down Expand Up @@ -373,7 +373,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual void put(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -385,7 +385,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {

/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline void put(const KEYTYPE& key, const std::shared_ptr<Cacheable>& value,
inline void put(const KEYTYPE& key, const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
put(CacheableKey::create(key), value, arg);
}
Expand All @@ -398,6 +398,11 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
put(key, Serializable::create(value), arg);
}

virtual std::shared_ptr<Serializable> putIfAbsent(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/**
* Places a set of new values in this region with the specified keys
* given as a map of key/value pairs.
Expand Down Expand Up @@ -447,7 +452,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual void localPut(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -460,7 +465,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline void localPut(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
localPut(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -521,7 +526,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual void create(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -534,7 +539,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline void create(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
create(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -574,7 +579,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual void localCreate(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -587,7 +592,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline void localCreate(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
localCreate(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -804,7 +809,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual bool remove(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -817,7 +822,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline bool remove(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
return remove(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -926,7 +931,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual bool localRemove(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -940,7 +945,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline bool localRemove(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
return localRemove(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -1027,7 +1032,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* Return all values in the local process for this region. No value is
* included for entries that are invalidated.
*/
virtual std::vector<std::shared_ptr<Cacheable>> values() = 0;
virtual std::vector<std::shared_ptr<Serializable>> values() = 0;

virtual std::vector<std::shared_ptr<RegionEntry>> entries(bool recursive) = 0;

Expand Down
1 change: 1 addition & 0 deletions cppcache/integration/framework/Cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Cluster.h"

#include <algorithm>
#include <fstream>
#include <future>
#include <thread>

Expand Down
2 changes: 2 additions & 0 deletions cppcache/integration/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ add_executable(cpp-integration-test
PositionKey.cpp
PositionKey.hpp
RegionGetAllTest.cpp
RegionPutTest.cpp
RegionPutAllTest.cpp
RegionPutGetAllTest.cpp
RegisterKeysTest.cpp
Expand All @@ -71,6 +72,7 @@ add_executable(cpp-integration-test
WanDeserializationTest.cpp
WritablePdxInstanceTest.cpp
)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(cpp-integration-test
PUBLIC
Expand Down
12 changes: 10 additions & 2 deletions cppcache/integration/test/FunctionExecutionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ using apache::geode::client::RegionShortcut;
using apache::geode::client::ResultCollector;
using apache::geode::client::TimeoutException;

using ::testing::Eq;
using ::testing::Le;

const int ON_SERVERS_TEST_REGION_ENTRIES_SIZE = 34;
Expand Down Expand Up @@ -796,7 +797,7 @@ TEST(FunctionExecutionTest,
.withType("PARTITION")
.execute();

auto cache = CacheFactory().set("log-level", "debug").create();
auto cache = CacheFactory().create();
auto poolFactory = cache.getPoolManager().createFactory();

ServerAddress serverAddress = cluster.getServers()[1].getAddress();
Expand All @@ -818,7 +819,14 @@ TEST(FunctionExecutionTest,
auto execute =
functionService.withCollector(std::make_shared<TestResultCollector>());

EXPECT_ANY_THROW(execute.execute("ThrowingISEFunction"));
try {
execute.execute("ThrowingISEFunction");
ASSERT_TRUE(false) << "An exception is expected";
} catch (Exception &e) {
std::string expected =
"org.apache.geode.cache.execute.FunctionException: An error occurred";
ASSERT_THAT(e.getMessage().substr(0, expected.length()), Eq(expected));
}

auto poolSizeAfter = cacheImpl->getPoolSize("pool");
ASSERT_THAT(poolSizeBefore, Le(poolSizeAfter));
Expand Down
Loading