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

ASF GitHub Bot commented on GEODE-9249:
---------------------------------------

pivotal-jbarrett commented on a change in pull request #804:
URL: https://github.com/apache/geode-native/pull/804#discussion_r631212126



##########
File path: cppcache/integration/test/CachingProxyTest.cpp
##########
@@ -0,0 +1,162 @@
+/*
+ * 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 <list>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+#include <geode/Serializable.hpp>
+
+#include "framework/Cluster.h"
+
+using apache::geode::client::Cacheable;
+using apache::geode::client::CacheableString;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::RegionShortcut;
+using apache::geode::client::Serializable;
+
+namespace CachingProxy {
+
+class CachingProxyTest : public ::testing::Test {
+ protected:
+  CachingProxyTest() {
+    cluster.start();
+
+    cluster.getGfsh()
+        .create()
+        .region()
+        .withName("region")
+        .withType("PARTITION")
+        .execute();
+  }
+
+  ~CachingProxyTest() override = default;
+
+  void SetUp() override {}
+
+  void TearDown() override {}
+
+  Cluster cluster = Cluster{LocatorCount{1}, ServerCount{1}};
+  std::string key = std::string("scharles");
+  std::string value = std::string("Sylvia Charles");
+};
+
+TEST_F(CachingProxyTest, LocalRemoveAfterLocalInvalidate) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  auto user = region->get(key);
+
+  region->localInvalidate(key);
+
+  bool resultLocalRemove = region->localRemove(key, value);
+  ASSERT_FALSE(resultLocalRemove);
+
+  resultLocalRemove = region->localRemove(
+      key, static_cast<std::shared_ptr<Cacheable>>(nullptr));
+  ASSERT_TRUE(resultLocalRemove);
+  cache.close();
+}
+
+TEST_F(CachingProxyTest, RemoveAfterInvalidate) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  region->invalidate(key);
+
+  bool resultRemove = region->remove(key, value);
+  ASSERT_FALSE(resultRemove);
+
+  resultRemove =
+      region->remove(key, static_cast<std::shared_ptr<Cacheable>>(nullptr));
+  ASSERT_TRUE(resultRemove);
+
+  cache.close();
+}
+
+TEST_F(CachingProxyTest, RemoveAfterLocalInvalidate) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  region->localInvalidate(key);
+
+  bool resultRemove =

Review comment:
       `auto`?

##########
File path: cppcache/integration/test/CachingProxyTest.cpp
##########
@@ -0,0 +1,162 @@
+/*
+ * 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 <list>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+#include <geode/Serializable.hpp>
+
+#include "framework/Cluster.h"
+
+using apache::geode::client::Cacheable;
+using apache::geode::client::CacheableString;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::RegionShortcut;
+using apache::geode::client::Serializable;
+
+namespace CachingProxy {
+
+class CachingProxyTest : public ::testing::Test {
+ protected:
+  CachingProxyTest() {
+    cluster.start();
+
+    cluster.getGfsh()
+        .create()
+        .region()
+        .withName("region")
+        .withType("PARTITION")
+        .execute();
+  }
+
+  ~CachingProxyTest() override = default;
+
+  void SetUp() override {}
+
+  void TearDown() override {}
+
+  Cluster cluster = Cluster{LocatorCount{1}, ServerCount{1}};
+  std::string key = std::string("scharles");
+  std::string value = std::string("Sylvia Charles");
+};
+
+TEST_F(CachingProxyTest, LocalRemoveAfterLocalInvalidate) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  auto user = region->get(key);
+
+  region->localInvalidate(key);
+
+  bool resultLocalRemove = region->localRemove(key, value);
+  ASSERT_FALSE(resultLocalRemove);
+
+  resultLocalRemove = region->localRemove(
+      key, static_cast<std::shared_ptr<Cacheable>>(nullptr));
+  ASSERT_TRUE(resultLocalRemove);
+  cache.close();
+}
+
+TEST_F(CachingProxyTest, RemoveAfterInvalidate) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  region->invalidate(key);
+
+  bool resultRemove = region->remove(key, value);
+  ASSERT_FALSE(resultRemove);
+
+  resultRemove =
+      region->remove(key, static_cast<std::shared_ptr<Cacheable>>(nullptr));
+  ASSERT_TRUE(resultRemove);
+
+  cache.close();
+}
+
+TEST_F(CachingProxyTest, RemoveAfterLocalInvalidate) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  region->localInvalidate(key);
+
+  bool resultRemove =
+      region->remove(key, static_cast<std::shared_ptr<Cacheable>>(nullptr));
+  ASSERT_FALSE(resultRemove);
+
+  auto user = region->get(key);
+  ASSERT_EQ(std::dynamic_pointer_cast<CacheableString>(user)->value(), value);
+
+  cache.close();
+}
+
+TEST_F(CachingProxyTest, Remove) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  bool resultRemove = region->remove(key);

Review comment:
       `auto`?

##########
File path: cppcache/src/ThinClientRegion.cpp
##########
@@ -1066,8 +1066,8 @@ GfErrType ThinClientRegion::removeNoThrow_remote(
 
   // do TCR remove
   TcrMessageDestroy request(new DataOutput(m_cacheImpl->createDataOutput()),
-                            this, keyPtr, cvalue, aCallbackArgument,
-                            m_tcrdm.get());
+                            this, keyPtr, cvalue, cvalue == nullptr,

Review comment:
       Is it necessary to put this parameter here since we are sending the 
value as the parameter just before it? Internally we can check for `nullptr` 
rather than putting it on the caller.

##########
File path: cppcache/integration/test/CachingProxyTest.cpp
##########
@@ -0,0 +1,162 @@
+/*
+ * 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 <list>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+#include <geode/Serializable.hpp>
+
+#include "framework/Cluster.h"
+
+using apache::geode::client::Cacheable;
+using apache::geode::client::CacheableString;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::RegionShortcut;
+using apache::geode::client::Serializable;
+
+namespace CachingProxy {
+
+class CachingProxyTest : public ::testing::Test {
+ protected:
+  CachingProxyTest() {
+    cluster.start();
+
+    cluster.getGfsh()
+        .create()
+        .region()
+        .withName("region")
+        .withType("PARTITION")
+        .execute();
+  }
+
+  ~CachingProxyTest() override = default;
+
+  void SetUp() override {}
+
+  void TearDown() override {}
+
+  Cluster cluster = Cluster{LocatorCount{1}, ServerCount{1}};
+  std::string key = std::string("scharles");
+  std::string value = std::string("Sylvia Charles");
+};
+
+TEST_F(CachingProxyTest, LocalRemoveAfterLocalInvalidate) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  auto user = region->get(key);
+
+  region->localInvalidate(key);
+
+  bool resultLocalRemove = region->localRemove(key, value);
+  ASSERT_FALSE(resultLocalRemove);
+
+  resultLocalRemove = region->localRemove(
+      key, static_cast<std::shared_ptr<Cacheable>>(nullptr));
+  ASSERT_TRUE(resultLocalRemove);
+  cache.close();
+}
+
+TEST_F(CachingProxyTest, RemoveAfterInvalidate) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  region->invalidate(key);
+
+  bool resultRemove = region->remove(key, value);
+  ASSERT_FALSE(resultRemove);
+
+  resultRemove =
+      region->remove(key, static_cast<std::shared_ptr<Cacheable>>(nullptr));
+  ASSERT_TRUE(resultRemove);
+
+  cache.close();
+}
+
+TEST_F(CachingProxyTest, RemoveAfterLocalInvalidate) {
+  auto cache = CacheFactory().create();
+
+  cache.getPoolManager()
+      .createFactory()
+      .addLocator("localhost", cluster.getLocatorPort())
+      .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+                    .setPoolName("pool")
+                    .create("region");
+
+  region->put(key, value);
+
+  region->localInvalidate(key);
+
+  bool resultRemove =
+      region->remove(key, static_cast<std::shared_ptr<Cacheable>>(nullptr));

Review comment:
       We don't have a specialization for `nullptr`? We should probably add 
that.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Remove(key, nullptr) Not Working Properly
> -----------------------------------------
>
>                 Key: GEODE-9249
>                 URL: https://issues.apache.org/jira/browse/GEODE-9249
>             Project: Geode
>          Issue Type: Bug
>          Components: native client
>            Reporter: Michael Martell
>            Priority: Major
>
> The Region API supports both local and remote operations. Local operations 
> apply to CACHING_PROXY regions and are supposed to affect only the local 
> cache. However, localInvalidate(key, value) invalidates both local and remote 
> entry.
>  
> This is actually a but in remove(key, nullptr), not localInvalidate.
>  
> Note: Invalidate operations sets the value for the given key to null.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to