[jira] [Updated] (GEODE-10423) Document the system property “ON_DISCONNECT_CLEAR_PDXTYPEIDS“

2022-09-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/GEODE-10423?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated GEODE-10423:
---
Labels: pull-request-available  (was: )

> Document the system property “ON_DISCONNECT_CLEAR_PDXTYPEIDS“
> -
>
> Key: GEODE-10423
> URL: https://issues.apache.org/jira/browse/GEODE-10423
> Project: Geode
>  Issue Type: Improvement
>  Components: docs
>Reporter: Tim Zhang
>Priority: Major
>  Labels: pull-request-available
>
> Document the java system property “ON_DISCONNECT_CLEAR_PDXTYPEIDS“, this 
> property is used by Java client. add instructions for using this property.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (GEODE-10414) Add putIfAbsent method to region interfaces

2022-09-19 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GEODE-10414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17606478#comment-17606478
 ] 

ASF GitHub Bot commented on GEODE-10414:


albertogpz commented on code in PR #984:
URL: https://github.com/apache/geode-native/pull/984#discussion_r973963090


##
cppcache/integration/test/RegionPutTest.cpp:
##
@@ -0,0 +1,294 @@
+/*
+ * 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.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "CacheRegionHelper.hpp"
+#include "framework/Cluster.h"
+#include "framework/Framework.h"
+#include "framework/Gfsh.h"
+
+namespace {
+
+using apache::geode::client::Cache;
+using apache::geode::client::Cacheable;
+using apache::geode::client::CacheableKey;
+using apache::geode::client::CacheableString;
+using apache::geode::client::CommitConflictException;
+using apache::geode::client::Pool;
+using apache::geode::client::Region;
+using apache::geode::client::RegionShortcut;
+
+using std::chrono::minutes;
+
+using ::testing::Eq;
+using ::testing::IsNull;
+using ::testing::NotNull;
+
+Cache createCache() {
+  using apache::geode::client::CacheFactory;
+
+  auto cache = CacheFactory()
+   .set("log-level", "debug")
+   .set("statistic-sampling-enabled", "false")
+   .create();
+
+  return cache;
+}
+
+std::shared_ptr createPool(Cluster& cluster, Cache& cache) {
+  auto poolFactory = cache.getPoolManager().createFactory();
+  cluster.applyLocators(poolFactory);
+  return poolFactory.create("default");
+}
+
+std::shared_ptr setupRegion(Cache& cache,
+const std::shared_ptr& pool) {
+  auto region = cache.createRegionFactory(RegionShortcut::PROXY)
+.setPoolName(pool->getName())
+.create("region");
+
+  return region;
+}
+
+std::shared_ptr setupCachingRegion(Cache& cache,
+   const std::shared_ptr& pool) {
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+.setPoolName(pool->getName())
+.create("region");
+
+  return region;
+}
+
+TEST(RegionPutTest, testPutIfAbsentNotExistingEntry) {
+  Cluster cluster{LocatorCount{1}, ServerCount{1}};
+
+  cluster.start();
+
+  cluster.getGfsh()
+  .create()
+  .region()
+  .withName("region")
+  .withType("REPLICATE")
+  .execute();
+
+  auto cache = createCache();
+  auto pool = createPool(cluster, cache);
+  auto region = setupRegion(cache, pool);
+  auto key = CacheableKey::create("key-1");
+  auto value = CacheableString::create("value");
+
+  EXPECT_THAT(region->putIfAbsent(key, value), IsNull());
+
+  auto retrieved = region->get(key);
+  EXPECT_THAT(retrieved, NotNull());
+
+  auto converted = std::dynamic_pointer_cast(retrieved);
+  EXPECT_THAT(converted, NotNull());
+  EXPECT_THAT(converted->toString(), Eq(value->toString()));
+}
+
+TEST(RegionPutTest, testPutIfAbsentNotExistingEntryWithCaching) {
+  Cluster cluster{LocatorCount{1}, ServerCount{1}};
+
+  cluster.start();
+
+  cluster.getGfsh()
+  .create()
+  .region()
+  .withName("region")
+  .withType("REPLICATE")
+  .execute();
+
+  auto cache = createCache();
+  auto pool = createPool(cluster, cache);
+  auto region = setupCachingRegion(cache, pool);
+  auto key = CacheableKey::create("key-1");
+  auto value = CacheableString::create("value");
+
+  EXPECT_THAT(region->putIfAbsent(key, value), IsNull());
+
+  auto retrieved = region->get(key);
+  EXPECT_THAT(retrieved, NotNull());
+
+  auto converted = std::dynamic_pointer_cast(retrieved);
+  EXPECT_THAT(converted, NotNull());
+  EXPECT_THAT(converted->toString(), Eq(value->toString()));
+
+  // Verify cached value matches expected
+  auto entry = region->getEntry(key);
+  EXPECT_THAT(entry, NotNull());
+
+  retrieved = entry->getValue();
+  EXPECT_THAT(converted, NotNull());
+
+  converted = std::dynamic_pointer_cast(retrieved);
+  EXPECT_THAT(converted, NotNull());
+  EXPECT_THAT(converted->to