geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bben...@apache.org
Subject [geode-native] branch develop updated: GEODE-5769: remove app domain context (#412)
Date Wed, 05 Dec 2018 22:19:12 GMT
This is an automated email from the ASF dual-hosted git repository.

bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new d258c24  GEODE-5769: remove app domain context (#412)
d258c24 is described below

commit d258c24e5c53ce12108146b57c31966a4245d19f
Author: Matthew Reddington <mreddington@pivotal.io>
AuthorDate: Wed Dec 5 14:19:07 2018 -0800

    GEODE-5769: remove app domain context (#412)
    
    * Remove appDomainContext and add query test
    * Updated the tests to pass consistently.
---
 clicache/integration-test2/CMakeLists.txt |   1 +
 clicache/integration-test2/QueryTest.cs   | 202 ++++++++++++++++++++++++++++++
 cppcache/src/TcrChunkedContext.hpp        |  11 +-
 3 files changed, 204 insertions(+), 10 deletions(-)

diff --git a/clicache/integration-test2/CMakeLists.txt b/clicache/integration-test2/CMakeLists.txt
index f555ef1..e122168 100644
--- a/clicache/integration-test2/CMakeLists.txt
+++ b/clicache/integration-test2/CMakeLists.txt
@@ -38,6 +38,7 @@ add_library( ${PROJECT_NAME} SHARED
     CacheXml.cs
     CacheXmlTests.cs
     CqOperationTest.cs
+    QueryTest.cs
     RegionTest.cs
     RegionSSLTest.cs
     Position.cs
diff --git a/clicache/integration-test2/QueryTest.cs b/clicache/integration-test2/QueryTest.cs
new file mode 100644
index 0000000..17fc292
--- /dev/null
+++ b/clicache/integration-test2/QueryTest.cs
@@ -0,0 +1,202 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.IO;
+using Xunit;
+using System.Diagnostics;
+using System.Threading;
+
+namespace Apache.Geode.Client.IntegrationTests
+{
+  public class QueryOrder : IPdxSerializable
+  {
+    private const string ORDER_ID_KEY_ = "order_id";
+    private const string NAME_KEY_ = "name";
+    private const string QUANTITY_KEY_ = "quantity";
+    public long OrderId { get; set; }
+    public string Name { get; set; }
+    public short Quantity { get; set; }
+    // A default constructor is required for deserialization
+    public QueryOrder() { }
+    public QueryOrder(int orderId, string name, short quantity)
+    {
+      OrderId = orderId;
+      Name = name;
+      Quantity = quantity;
+    }
+    public override string ToString()
+    {
+      return string.Format("Order: [{0}, {1}, {2}]", OrderId, Name, Quantity);
+    }
+    public void ToData(IPdxWriter output)
+    {
+      output.WriteLong(ORDER_ID_KEY_, OrderId);
+      output.MarkIdentityField(ORDER_ID_KEY_);
+      output.WriteString(NAME_KEY_, Name);
+      output.MarkIdentityField(NAME_KEY_);
+      output.WriteInt(QUANTITY_KEY_, Quantity);
+      output.MarkIdentityField(QUANTITY_KEY_);
+    }
+    public void FromData(IPdxReader input)
+    {
+      OrderId = input.ReadLong(ORDER_ID_KEY_);
+      Name = input.ReadString(NAME_KEY_);
+      Quantity = (short)input.ReadInt(QUANTITY_KEY_);
+    }
+    public static IPdxSerializable CreateDeserializable()
+    {
+      return new QueryOrder();
+    }
+  }
+
+
+  [Trait("Category", "Integration")]
+  public class QueryTest : TestBase, IDisposable
+  {
+    private readonly Cache cache_;
+
+    public QueryTest()
+    {
+      var cacheFactory = new CacheFactory()
+          .Set("log-level", "error");
+      cache_ = cacheFactory.Create();
+    }
+
+    public void Dispose()
+    {
+      cache_.Close();
+    }
+
+    [Fact]
+    public void PdxSerializableQueryHaveCorrectValues()
+    {
+      using (var cluster_ = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+      {
+        Assert.Equal(cluster_.Start(), true);
+        Assert.Equal(cluster_.Gfsh.create()
+            .region()
+            .withName("cqTestRegion")
+            .withType("REPLICATE")
+            .execute(), 0);
+        cache_.TypeRegistry.RegisterPdxType(QueryOrder.CreateDeserializable);
+        var poolFactory = cache_.GetPoolFactory()
+            .AddLocator("localhost", cluster_.Gfsh.LocatorPort);
+        var pool = poolFactory
+            .SetSubscriptionEnabled(true)
+            .Create("pool");
+
+        var regionFactory = cache_.CreateRegionFactory(RegionShortcut.PROXY)
+            .SetPoolName("pool");
+
+        var region = regionFactory.Create<string, QueryOrder>("cqTestRegion");
+
+        var queryService = pool.GetQueryService();
+
+        Debug.WriteLine("Putting and changing Position objects in the region");
+        var order1 = new QueryOrder(1, "product x", 23);
+        var order2 = new QueryOrder(2, "product y", 37);
+        var order3 = new QueryOrder(3, "product z", 101);
+
+        region.Put("order1", order1);
+
+        region.Put("order2", order2);
+
+        region.Put("order3", order3);
+
+        order1.Quantity = 20;
+        region.Put("order1", order1);
+
+        order2.Quantity = 45;
+        region.Put("order2", order2);
+
+        order3.Quantity = 11;
+        region.Put("order3", order3);
+
+        var results = region.Query<QueryOrder>("SELECT * FROM /cqTestRegion WHERE quantity
> 30");
+        Assert.Equal(results.Size, 1UL);
+        Assert.Equal(results[0].Name, "product y");
+
+        region.Clear();
+      }
+    }
+
+    [Fact]
+    public void DataSerializableQueryHaveCorrectValues()
+    {
+      using (var cluster_ = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+      {
+        Assert.Equal(cluster_.Start(), true);
+        Assert.Equal(cluster_.Gfsh.deploy()
+            .withJar(Config.JavaobjectJarPath)
+            .execute(), 0);
+        Assert.Equal(cluster_.Gfsh.create()
+            .region()
+            .withName("cqTestRegion")
+            .withType("REPLICATE")
+            .execute(), 0);
+
+        cluster_.Gfsh.executeFunction()
+            .withId("InstantiateDataSerializable")
+            .withMember("DataSerializableQueryHaveCorre_server_0")
+            .execute();
+
+        cache_.TypeRegistry.RegisterType(Position.CreateDeserializable, 22);
+
+        var poolFactory = cache_.GetPoolFactory()
+            .AddLocator("localhost", cluster_.Gfsh.LocatorPort);
+        var pool = poolFactory
+            .SetSubscriptionEnabled(true)
+            .Create("pool");
+
+        var regionFactory = cache_.CreateRegionFactory(RegionShortcut.PROXY)
+            .SetPoolName("pool");
+
+        var region = regionFactory.Create<string, Position>("cqTestRegion");
+
+        Debug.WriteLine("Putting and changing Position objects in the region");
+        var order1 = new Position("GOOG", 23);
+        var order2 = new Position("IBM", 37);
+        var order3 = new Position("PVTL", 101);
+
+        region.Put("order1", order1);
+        var Value = region["order1"];
+
+        region.Put("order2", order2);
+
+        order1.SharesOutstanding = 55;
+        region.Put("order1", order1);
+
+        order2.SharesOutstanding = 77;
+        region.Put("order2", order2);
+
+        order2.SharesOutstanding = 11;
+        region.Put("order2", order2);
+
+        region.Remove("order1");
+
+        region.Put("order3", order3);
+
+        var results = region.Query<Position>("SELECT * FROM /cqTestRegion WHERE sharesOutstanding
> 50");
+        Assert.Equal(results.Size, 1UL);
+        Assert.Equal(results[0].SecId, "PVTL");
+
+        region.Clear();
+      }
+    }
+  }
+}
diff --git a/cppcache/src/TcrChunkedContext.hpp b/cppcache/src/TcrChunkedContext.hpp
index 3e548c2..e5df84c 100644
--- a/cppcache/src/TcrChunkedContext.hpp
+++ b/cppcache/src/TcrChunkedContext.hpp
@@ -41,7 +41,6 @@ class TcrChunkedResult {
   ACE_Semaphore* m_finalizeSema;
   std::shared_ptr<Exception> m_ex;
   bool m_inSameThread;
-  std::unique_ptr<AppDomainContext> appDomainContext;
 
  protected:
   uint16_t m_dsmemId;
@@ -56,7 +55,6 @@ class TcrChunkedResult {
       : m_finalizeSema(nullptr),
         m_ex(nullptr),
         m_inSameThread(false),
-        appDomainContext(createAppDomainContext()),
         m_dsmemId(0) {}
   virtual ~TcrChunkedResult() {}
   void setFinalizeSemaphore(ACE_Semaphore* finalizeSema) {
@@ -73,14 +71,7 @@ class TcrChunkedResult {
   void fireHandleChunk(const uint8_t* bytes, int32_t len,
                        uint8_t isLastChunkWithSecurity,
                        const CacheImpl* cacheImpl) {
-    if (appDomainContext) {
-      appDomainContext->run(
-          [this, bytes, len, isLastChunkWithSecurity, cacheImpl]() {
-            handleChunk(bytes, len, isLastChunkWithSecurity, cacheImpl);
-          });
-    } else {
-      handleChunk(bytes, len, isLastChunkWithSecurity, cacheImpl);
-    }
+    handleChunk(bytes, len, isLastChunkWithSecurity, cacheImpl);
   }
 
   /**


Mime
View raw message