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

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

moleske commented on a change in pull request #715:
URL: https://github.com/apache/geode-native/pull/715#discussion_r585762028



##########
File path: cppcache/integration/test/PdxTypeRegistryTest.cpp
##########
@@ -0,0 +1,159 @@
+/* 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 <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/CacheListener.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/QueryService.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+#include "framework/Framework.h"
+#include "framework/Gfsh.h"
+
+namespace {
+
+using apache::geode::client::Cache;
+using apache::geode::client::CacheableInt16;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::CacheListener;
+using apache::geode::client::NotConnectedException;
+using apache::geode::client::PdxInstance;
+using apache::geode::client::Region;
+using apache::geode::client::RegionEvent;
+using apache::geode::client::RegionShortcut;
+using apache::geode::client::SelectResults;
+
+static bool isDisconnected = false;
+
+class RegionListener : public CacheListener {
+ public:
+  void waitConnected() {
+    std::unique_lock<decltype(mutex_)> lock{mutex_};
+    status_cv_.wait(lock, [this] { return status_; });
+  }
+
+  void waitDisconnected() {
+    std::unique_lock<decltype(mutex_)> lock{mutex_};
+    status_cv_.wait(lock, [this] { return !status_; });
+  }
+
+ protected:
+  void afterRegionDisconnected(Region&) override {
+    std::unique_lock<decltype(mutex_)> lock{mutex_};
+
+    status_ = false;
+    status_cv_.notify_all();
+  }
+
+  void afterRegionLive(const RegionEvent&) override {
+    std::unique_lock<decltype(mutex_)> lock{mutex_};
+
+    status_ = true;
+    status_cv_.notify_all();
+  }
+
+ protected:
+  bool status_;
+  std::mutex mutex_;
+  std::condition_variable status_cv_;
+};
+
+Cache createTestCache() {
+  CacheFactory cacheFactory;
+  return cacheFactory.set("log-level", "none")
+      .set("connect-timeout", "2s")
+      .set("statistic-sampling-enabled", "false")
+      .set("on-client-disconnect-clear-pdxType-Ids", "true")
+      .setPdxReadSerialized(true)
+      .create();
+}
+
+void createTestPool(Cluster& cluster, Cache& cache) {
+  auto poolFactory = cache.getPoolManager()
+                         .createFactory()
+                         .setReadTimeout(std::chrono::seconds{1})
+                         .setPingInterval(std::chrono::seconds{5})
+                         .setSubscriptionEnabled(true);
+
+  cluster.applyLocators(poolFactory);
+  poolFactory.create("pool");
+}
+
+std::shared_ptr<Region> createTestRegion(
+    Cache& cache, std::shared_ptr<RegionListener> listener) {
+  auto regionFactory = cache.createRegionFactory(RegionShortcut::PROXY);
+  return regionFactory.setPoolName("pool").setCacheListener(listener).create(
+      "region");
+}
+
+std::shared_ptr<PdxInstance> createTestPdxInstance(Cache& cache,
+                                                   const std::string& entry) {
+  auto factory = cache.createPdxInstanceFactory("__GEMFIRE_JSON", false);
+  return factory.writeString("entryName", entry)
+      .writeInt("int-value", -1)
+      .create();
+}
+
+TEST(PdxTypeRegistryTest, cleanupOnClusterRestart) {
+  Cluster cluster{LocatorCount{1}, ServerCount{2}};
+  cluster.start();
+
+  auto& gfsh = cluster.getGfsh();
+  gfsh.create().region().withName("region").withType("PARTITION").execute();
+
+  bool running = true;

Review comment:
       I believe this is unused




----------------------------------------------------------------
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


> Fix PdxTypeRegistry cleanup upon cluster disconnection
> ------------------------------------------------------
>
>                 Key: GEODE-8793
>                 URL: https://issues.apache.org/jira/browse/GEODE-8793
>             Project: Geode
>          Issue Type: Bug
>          Components: native client
>    Affects Versions: 1.13.0, 1.13.1
>            Reporter: Mario Salazar de Torres
>            Assignee: Mario Salazar de Torres
>            Priority: Major
>              Labels: pull-request-available
>
> *GIVEN* A native client cache with on-client-disconnect-clear-pdxType-Ids is 
> set to "true" (not the best name if you ask me)
> *WHEN* the connection towards the cluster is lost
> *THEN* PdxTypeRegistry should be cleaned up straight away.
> ----
> *Additional information*
> **Instead of being cleaned up straight away, PdxTypeRegistry it's cleaned up 
> every 2 cluster disconnections.
> Probably the issue is that semaphores in place are missused.
> Consider additionally to change the callback name "cliCallback" as it does 
> not represent the actual functionality here.



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

Reply via email to