You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2018/03/30 18:29:12 UTC
[geode-native] branch develop updated: GEODE-4790: Fixes back
references to cache (#251)
This is an automated email from the ASF dual-hosted git repository.
jbarrett 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 4e446d1 GEODE-4790: Fixes back references to cache (#251)
4e446d1 is described below
commit 4e446d1b99d0c38a7898bf5b7be94a10ee65875d
Author: M. Oleske <mo...@users.noreply.github.com>
AuthorDate: Fri Mar 30 11:29:09 2018 -0700
GEODE-4790: Fixes back references to cache (#251)
- Region should be referencing CacheImpl, not Cache
- Refactored AuthenticatedView
- Make delta.clone pure virtual
Signed-off-by: Michael Oleske <mo...@pivotal.io>
Signed-off-by: Ryan McMahon <rm...@pivotal.io>
---
.../TestCacheXmlInitializationN.cs | 60 +++++
clicache/integration-test/UnitTests.csproj.in | 1 +
clicache/integration-test/client_pdx.xml | 2 +-
clicache/src/CMakeLists.txt | 4 +-
clicache/src/Cache.cpp | 6 +-
clicache/src/FunctionService.cpp | 10 +-
clicache/src/LocalRegion.cpp | 2 +-
clicache/src/Region.cpp | 2 +-
...uthenticatedCache.cpp => AuthenticatedView.cpp} | 14 +-
...uthenticatedCache.hpp => AuthenticatedView.hpp} | 23 +-
clicache/src/impl/ManagedCacheableDelta.cpp | 3 -
clicache/src/impl/ManagedCacheableDelta.hpp | 237 +++++++++---------
clicache/src/impl/PdxManagedCacheableKey.cpp | 179 ++++++-------
clicache/src/impl/PdxManagedCacheableKey.hpp | 276 ++++++++++----------
.../geode/AuthenticatedView.hpp} | 55 ++--
cppcache/include/geode/Cache.hpp | 13 +-
cppcache/include/geode/Delta.hpp | 12 +-
cppcache/include/geode/FunctionService.hpp | 19 +-
cppcache/include/geode/PdxInstance.hpp | 11 +-
cppcache/include/geode/PdxInstanceFactory.hpp | 7 +-
cppcache/include/geode/Pool.hpp | 4 +-
cppcache/include/geode/Region.hpp | 59 +++--
cppcache/integration-test/DeltaEx.hpp | 10 +-
cppcache/integration-test/ThinClientSecurity.hpp | 15 +-
.../testThinClientSecurityAuthenticationMU.cpp | 97 +++----
.../testThinClientSecurityAuthorizationMU.cpp | 134 +++++-----
.../testThinClientSecurityCQAuthorizationMU.cpp | 235 +++++++++--------
.../testThinClientSecurityDH_MU.cpp | 136 +++++-----
...tThinClientSecurityDurableCQAuthorizationMU.cpp | 278 +++++++++++----------
.../testThinClientSecurityMultiUserTest.cpp | 4 +-
.../testXmlCacheCreationWithPools.cpp | 84 +------
.../testXmlCacheInitialization.cpp | 188 ++++++++++++++
.../src/{ProxyCache.cpp => AuthenticatedView.cpp} | 76 +++---
cppcache/src/Cache.cpp | 22 +-
cppcache/src/CacheImpl.cpp | 2 +-
cppcache/src/CacheImpl.hpp | 2 +-
cppcache/src/CacheRegionHelper.cpp | 10 +-
cppcache/src/CacheRegionHelper.hpp | 4 +-
cppcache/src/CacheTransactionManagerImpl.cpp | 32 ++-
cppcache/src/CacheXmlCreation.cpp | 2 +-
cppcache/src/CqQueryImpl.cpp | 45 ++--
cppcache/src/CqQueryImpl.hpp | 4 +-
cppcache/src/Delta.cpp | 40 ---
cppcache/src/ExecutionImpl.cpp | 23 +-
cppcache/src/ExecutionImpl.hpp | 40 ++-
cppcache/src/FunctionService.cpp | 36 ++-
cppcache/src/FunctionServiceImpl.cpp | 10 +-
cppcache/src/FunctionServiceImpl.hpp | 15 +-
cppcache/src/LocalRegion.cpp | 11 +-
cppcache/src/LocalRegion.hpp | 16 +-
cppcache/src/MapSegment.cpp | 41 ++-
cppcache/src/PdxHelper.cpp | 145 +++++------
cppcache/src/PdxInstanceFactoryImpl.cpp | 21 +-
cppcache/src/PdxInstanceFactoryImpl.hpp | 7 +-
cppcache/src/PdxInstanceImpl.cpp | 37 ++-
cppcache/src/PdxInstanceImpl.hpp | 16 +-
cppcache/src/Pool.cpp | 12 +-
cppcache/src/ProxyRegion.hpp | 66 ++---
cppcache/src/ProxyRemoteQueryService.cpp | 57 +++--
cppcache/src/ProxyRemoteQueryService.hpp | 8 +-
cppcache/src/Region.cpp | 8 +-
cppcache/src/RegionInternal.cpp | 19 +-
cppcache/src/RegionInternal.hpp | 14 +-
cppcache/src/RemoteQuery.cpp | 28 +--
cppcache/src/RemoteQuery.hpp | 7 +-
cppcache/src/RemoteQueryService.cpp | 18 +-
cppcache/src/TXState.cpp | 4 +-
cppcache/src/TXState.hpp | 4 +-
cppcache/src/TcrChunkedContext.hpp | 22 +-
cppcache/src/TcrConnection.cpp | 2 +-
cppcache/src/TcrEndpoint.cpp | 42 ++--
cppcache/src/TcrMessage.cpp | 12 +-
cppcache/src/TcrMessage.hpp | 4 +-
cppcache/src/ThinClientBaseDM.cpp | 34 +--
cppcache/src/ThinClientHARegion.cpp | 7 +-
cppcache/src/ThinClientPoolDM.cpp | 4 +-
cppcache/src/ThinClientPoolDM.hpp | 12 +-
cppcache/src/ThinClientRedundancyManager.cpp | 12 +-
cppcache/src/ThinClientRegion.cpp | 118 ++++-----
cppcache/src/ThinClientRegion.hpp | 37 ++-
cppcache/src/TransactionalOperation.cpp | 47 ++--
cppcache/src/TransactionalOperation.hpp | 29 ++-
cppcache/src/UserAttributes.cpp | 57 ++---
cppcache/src/UserAttributes.hpp | 34 +--
tests/cpp/testobject/DeltaFastAssetAccount.cpp | 2 +-
tests/cpp/testobject/DeltaFastAssetAccount.hpp | 2 +-
tests/cpp/testobject/DeltaPSTObject.cpp | 2 +-
tests/cpp/testobject/DeltaPSTObject.hpp | 9 +-
tests/cpp/testobject/DeltaTestImpl.cpp | 26 +-
tests/cpp/testobject/DeltaTestImpl.hpp | 2 +-
90 files changed, 1875 insertions(+), 1723 deletions(-)
diff --git a/clicache/integration-test/TestCacheXmlInitializationN.cs b/clicache/integration-test/TestCacheXmlInitializationN.cs
new file mode 100644
index 0000000..e98ad1a
--- /dev/null
+++ b/clicache/integration-test/TestCacheXmlInitializationN.cs
@@ -0,0 +1,60 @@
+//=========================================================================
+// Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+// This product is protected by U.S. and international copyright
+// and intellectual property laws. Pivotal products are covered by
+// more patents listed at http://www.pivotal.io/patents.
+//========================================================================
+
+using System;
+
+namespace Apache.Geode.Client.UnitTests
+{
+ using NUnit.Framework;
+ using Apache.Geode.DUnitFramework;
+
+ [TestFixture]
+ [Category("group3")]
+ [Category("unicast_only")]
+ [Category("generics")]
+ public class TestCacheXmlInitialization : ThinClientRegionSteps
+ {
+ protected override ClientBase[] GetClients()
+ {
+ return new ClientBase[] { };
+ }
+
+ [TearDown]
+ public override void EndTest()
+ {
+ Util.Log("EndTest: AppDomain: " + AppDomain.CurrentDomain.Id);
+ try
+ {
+ CacheHelper.ClearEndpoints();
+ CacheHelper.ClearLocators();
+ }
+ finally
+ {
+ CacheHelper.StopJavaServers();
+ CacheHelper.StopJavaLocators();
+ }
+ base.EndTest();
+ }
+
+
+ [Test]
+ public void TestCacheXmlInitialization_GetRegion()
+ {
+ CacheHelper.SetupJavaServers(true, "cacheserver_pdxinstance_hashcode.xml");
+
+ CacheHelper.StartJavaLocator(1, "GFELOC");
+
+ CacheHelper.StartJavaServerWithLocators(1, "GFECS1", 1);
+
+ CacheHelper.InitConfig("client_pdx.xml");
+
+ var region = CacheHelper.GetRegion<object, object>("DistRegionAck");
+
+ Close();
+ }
+ }
+}
diff --git a/clicache/integration-test/UnitTests.csproj.in b/clicache/integration-test/UnitTests.csproj.in
index 9c003ec..460e440 100644
--- a/clicache/integration-test/UnitTests.csproj.in
+++ b/clicache/integration-test/UnitTests.csproj.in
@@ -201,6 +201,7 @@
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\ThinClientRegionQueryTests.cs" />
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\ThinClientAppDomainQueryTests.cs" />
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\ThinClientAppDomainFunctionExecutionTests.cs" />
+ <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\TestCacheXmlInitializationN.cs" />
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\BuiltinCacheableWrappersN.cs" />
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\CacheableWrapperN.cs" />
<Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\DupListenerN.cs" />
diff --git a/clicache/integration-test/client_pdx.xml b/clicache/integration-test/client_pdx.xml
index 39add41..9b2b06a 100644
--- a/clicache/integration-test/client_pdx.xml
+++ b/clicache/integration-test/client_pdx.xml
@@ -24,7 +24,7 @@
xsi:schemaLocation="http://schema.pivotal.io/gemfire/gfcpp-cache
http://schema.pivotal.io/gemfire/gfcpp-cache/gfcpp-cache-9.0.xsd"
version="9.0"
- redundancy-level="1" >
+ >
<pdx read-serialized="true" />
<root-region name='DistRegionAck'>
diff --git a/clicache/src/CMakeLists.txt b/clicache/src/CMakeLists.txt
index 59d6030..250ef87 100644
--- a/clicache/src/CMakeLists.txt
+++ b/clicache/src/CMakeLists.txt
@@ -201,8 +201,8 @@ add_library(${PROJECT_NAME} SHARED
impl/AppDomainContext.cpp
impl/AppDomainContext.hpp
impl/AssemblyInfo.cpp.in
- impl/AuthenticatedCache.cpp
- impl/AuthenticatedCache.hpp
+ impl/AuthenticatedView.cpp
+ impl/AuthenticatedView.hpp
impl/CacheListener.hpp
impl/CacheLoader.hpp
impl/CacheResolver.cpp
diff --git a/clicache/src/Cache.cpp b/clicache/src/Cache.cpp
index fd988bd..06e31d3 100644
--- a/clicache/src/Cache.cpp
+++ b/clicache/src/Cache.cpp
@@ -29,7 +29,7 @@
#include "RegionAttributes.hpp"
#include "QueryService.hpp"
#include "CacheFactory.hpp"
-#include "impl/AuthenticatedCache.hpp"
+#include "impl/AuthenticatedView.hpp"
#include "impl/SafeConvert.hpp"
#include "impl/PdxTypeRegistry.hpp"
#include "impl/PdxInstanceFactoryImpl.hpp"
@@ -242,7 +242,7 @@ namespace Apache
try
{
- return AuthenticatedCache::Create((m_nativeptr->get()->createAuthenticatedView(credentials->GetNative(), "")));
+ return AuthenticatedView::Create((m_nativeptr->get()->createAuthenticatedView(credentials->GetNative(), "")));
}
finally
{
@@ -291,7 +291,7 @@ namespace Apache
try
{
- return AuthenticatedCache::Create( (m_nativeptr->get()->createAuthenticatedView(credentials->GetNative(), marshal_as<std::string>(poolName))));
+ return AuthenticatedView::Create( (m_nativeptr->get()->createAuthenticatedView(credentials->GetNative(), marshal_as<std::string>(poolName))));
}
finally
{
diff --git a/clicache/src/FunctionService.cpp b/clicache/src/FunctionService.cpp
index ddc9302..4540970 100644
--- a/clicache/src/FunctionService.cpp
+++ b/clicache/src/FunctionService.cpp
@@ -25,7 +25,7 @@
#include "Region.hpp"
#include "Execution.hpp"
-#include "impl/AuthenticatedCache.hpp"
+#include "impl/AuthenticatedView.hpp"
using namespace System;
@@ -79,12 +79,12 @@ namespace Apache
if(auto realCache = dynamic_cast<Cache^>(cache))
{
- auto nativeptr = native::FunctionService::onServer(realCache->GetNative());
+ auto nativeptr = native::FunctionService::onServer(*realCache->GetNative());
return Execution<TResult>::Create(std::move(nativeptr), nullptr );
}
else
{
- auto authCache = dynamic_cast<AuthenticatedCache^>(cache);
+ auto authCache = dynamic_cast<AuthenticatedView^>(cache);
auto nativeptr = native::FunctionService::onServer(authCache->GetNative());
return Execution<TResult>::Create(std::move(nativeptr), nullptr );
}
@@ -99,12 +99,12 @@ namespace Apache
if(auto realCache = dynamic_cast<Cache^>(cache))
{
- auto nativeptr = native::FunctionService::onServers(realCache->GetNative());
+ auto nativeptr = native::FunctionService::onServers(*realCache->GetNative());
return Execution<TResult>::Create(std::move(nativeptr), nullptr );
}
else
{
- auto authCache = dynamic_cast<AuthenticatedCache^>(cache);
+ auto authCache = dynamic_cast<AuthenticatedView^>(cache);
auto nativeptr = native::FunctionService::onServers(authCache->GetNative());
return Execution<TResult>::Create(std::move(nativeptr), nullptr );
}
diff --git a/clicache/src/LocalRegion.cpp b/clicache/src/LocalRegion.cpp
index c3957f5..8d0a30d 100644
--- a/clicache/src/LocalRegion.cpp
+++ b/clicache/src/LocalRegion.cpp
@@ -26,7 +26,7 @@
#include "CacheStatistics.hpp"
#include "AttributesMutator.hpp"
#include "RegionEntry.hpp"
-#include "impl/AuthenticatedCache.hpp"
+#include "impl/AuthenticatedView.hpp"
#include "impl/SafeConvert.hpp"
#include "impl/CacheResolver.hpp"
diff --git a/clicache/src/Region.cpp b/clicache/src/Region.cpp
index 589cbe2..05ac785 100644
--- a/clicache/src/Region.cpp
+++ b/clicache/src/Region.cpp
@@ -32,7 +32,7 @@
#include "IGeodeSerializable.hpp"
#include "ResultSet.hpp"
#include "StructSet.hpp"
-#include "impl/AuthenticatedCache.hpp"
+#include "impl/AuthenticatedView.hpp"
#include "impl/SafeConvert.hpp"
#include "LocalRegion.hpp"
#include "Pool.hpp"
diff --git a/clicache/src/impl/AuthenticatedCache.cpp b/clicache/src/impl/AuthenticatedView.cpp
similarity index 88%
rename from clicache/src/impl/AuthenticatedCache.cpp
rename to clicache/src/impl/AuthenticatedView.cpp
index f0603a3..70ccd7b 100644
--- a/clicache/src/impl/AuthenticatedCache.cpp
+++ b/clicache/src/impl/AuthenticatedView.cpp
@@ -29,7 +29,7 @@
#include "../QueryService.hpp"
#include "../FunctionService.hpp"
#include "../Execution.hpp"
-#include "AuthenticatedCache.hpp"
+#include "AuthenticatedView.hpp"
#include "PdxInstanceFactoryImpl.hpp"
using namespace System;
@@ -41,7 +41,7 @@ namespace Apache
namespace Client
{
- bool AuthenticatedCache::IsClosed::get( )
+ bool AuthenticatedView::IsClosed::get( )
{
try
{
@@ -53,7 +53,7 @@ namespace Apache
}
}
- void AuthenticatedCache::Close( )
+ void AuthenticatedView::Close( )
{
_GF_MG_EXCEPTION_TRY2
@@ -71,7 +71,7 @@ namespace Apache
//TODO::split
generic<class TKey, class TValue>
- IRegion<TKey, TValue>^ AuthenticatedCache::GetRegion( String^ path )
+ IRegion<TKey, TValue>^ AuthenticatedView::GetRegion( String^ path )
{
_GF_MG_EXCEPTION_TRY2
@@ -88,7 +88,7 @@ namespace Apache
_GF_MG_EXCEPTION_CATCH_ALL2
}
- Client::QueryService^ AuthenticatedCache::GetQueryService( )
+ Client::QueryService^ AuthenticatedView::GetQueryService( )
{
_GF_MG_EXCEPTION_TRY2
@@ -105,7 +105,7 @@ namespace Apache
}
generic<class TKey, class TValue>
- array<IRegion<TKey, TValue>^>^ AuthenticatedCache::RootRegions( )
+ array<IRegion<TKey, TValue>^>^ AuthenticatedView::RootRegions( )
{
std::vector<std::shared_ptr<apache::geode::client::Region>> vrr;
try
@@ -126,7 +126,7 @@ namespace Apache
return rootRegions;
}
- IPdxInstanceFactory^ AuthenticatedCache::CreatePdxInstanceFactory(String^ className)
+ IPdxInstanceFactory^ AuthenticatedView::CreatePdxInstanceFactory(String^ className)
{
return gcnew Internal::PdxInstanceFactoryImpl(className, nullptr);
}
diff --git a/clicache/src/impl/AuthenticatedCache.hpp b/clicache/src/impl/AuthenticatedView.hpp
similarity index 88%
rename from clicache/src/impl/AuthenticatedCache.hpp
rename to clicache/src/impl/AuthenticatedView.hpp
index 7f543ca..84ffa90 100644
--- a/clicache/src/impl/AuthenticatedCache.hpp
+++ b/clicache/src/impl/AuthenticatedView.hpp
@@ -21,9 +21,10 @@
#include "../geode_defs.hpp"
#include "../begin_native.hpp"
#include <geode/RegionService.hpp>
+#include <geode/AuthenticatedView.hpp>
#include "../end_native.hpp"
-#include "../native_shared_ptr.hpp"
+#include "../native_unique_ptr.hpp"
#include "../RegionShortcut.hpp"
#include "../RegionFactory.hpp"
#include "../IRegionService.hpp"
@@ -56,7 +57,7 @@ namespace Apache
/// A cache can have multiple root regions, each with a different name.
/// </para>
/// </remarks>
- public ref class AuthenticatedCache
+ public ref class AuthenticatedView
: public IRegionService
{
public:
@@ -142,15 +143,14 @@ namespace Apache
/// <returns>
/// The managed wrapper object; null if the native pointer is null.
/// </returns>
- inline static AuthenticatedCache^ Create( std::shared_ptr<native::RegionService> nativeptr )
+ inline static AuthenticatedView^ Create(native::AuthenticatedView&& nativeAuthenticatedView)
{
- return __nullptr == nativeptr ? nullptr :
- gcnew AuthenticatedCache( nativeptr );
+ return gcnew AuthenticatedView(std::move(nativeAuthenticatedView));
}
- std::shared_ptr<native::RegionService> GetNative()
+ native::AuthenticatedView& GetNative()
{
- return m_nativeptr->get_shared_ptr();
+ return *(m_nativeptr->get());
}
private:
@@ -159,11 +159,14 @@ namespace Apache
/// Private constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline AuthenticatedCache( std::shared_ptr<native::RegionService> nativeptr )
+ inline AuthenticatedView(native::AuthenticatedView&& nativeAuthenticatedView)
{
- m_nativeptr = gcnew native_shared_ptr<native::RegionService>(nativeptr);
+ m_nativeptr = gcnew native_unique_ptr<native::AuthenticatedView>(
+ std::unique_ptr<native::AuthenticatedView>(
+ new native::AuthenticatedView(std::move(nativeAuthenticatedView))));
}
- native_shared_ptr<native::RegionService>^ m_nativeptr;
+
+ native_unique_ptr<native::AuthenticatedView>^ m_nativeptr;
};
} // namespace Client
} // namespace Geode
diff --git a/clicache/src/impl/ManagedCacheableDelta.cpp b/clicache/src/impl/ManagedCacheableDelta.cpp
index 5546bb3..8efe7d9 100644
--- a/clicache/src/impl/ManagedCacheableDelta.cpp
+++ b/clicache/src/impl/ManagedCacheableDelta.cpp
@@ -208,9 +208,6 @@ namespace apache
return std::shared_ptr<Delta>(static_cast<ManagedCacheableDeltaGeneric*>(
SafeMSerializableConvertGeneric(Mclone)));
}
- else {
- return Delta::clone();
- }
}
catch (Apache::Geode::Client::GeodeException^ ex) {
ex->ThrowNative();
diff --git a/clicache/src/impl/ManagedCacheableDelta.hpp b/clicache/src/impl/ManagedCacheableDelta.hpp
index 66ad6ac..544e72c 100644
--- a/clicache/src/impl/ManagedCacheableDelta.hpp
+++ b/clicache/src/impl/ManagedCacheableDelta.hpp
@@ -17,19 +17,16 @@
#pragma once
+#include <geode/Delta.hpp>
+#include <vcclr.h>
#include "../geode_defs.hpp"
-#include <vcclr.h>
#include "../begin_native.hpp"
-#include <geode/Delta.hpp>
#include "../end_native.hpp"
-
#include "../IGeodeDelta.hpp"
#include "../IGeodeSerializable.hpp"
-
using namespace System;
-//using namespace apache::geode::client;
namespace Apache
{
@@ -37,7 +34,6 @@ namespace Apache
{
namespace Client
{
-
interface class IGeodeSerializable;
interface class IGeodeDelta;
} // namespace Client
@@ -59,122 +55,119 @@ namespace apache
class ManagedCacheableDeltaGeneric
: public apache::geode::client::CacheableKey, public apache::geode::client::Delta
{
- private:
- int m_hashcode;
- int m_classId;
- size_t m_objectSize;
- public:
-
- /// <summary>
- /// Constructor to initialize with the provided managed object.
- /// </summary>
- /// <param name="managedptr">
- /// The managed object.
- /// </param>
- inline ManagedCacheableDeltaGeneric(
- Apache::Geode::Client::IGeodeDelta^ managedptr)
- : Delta(nullptr), m_managedptr(managedptr)
- {
- m_managedSerializableptr = dynamic_cast <Apache::Geode::Client::IGeodeSerializable^> (managedptr);
- m_classId = m_managedSerializableptr->ClassId;
- m_objectSize = 0;
- }
-
- inline ManagedCacheableDeltaGeneric(
- Apache::Geode::Client::IGeodeDelta^ managedptr, int hashcode, int classId)
- :Delta(nullptr), m_managedptr(managedptr) {
- m_hashcode = hashcode;
- m_classId = classId;
- m_managedSerializableptr = dynamic_cast <Apache::Geode::Client::IGeodeSerializable^> (managedptr);
- m_objectSize = 0;
- }
-
- /// <summary>
- /// serialize this object
- /// </summary>
- virtual void toData(apache::geode::client::DataOutput& output) const override;
-
- /// <summary>
- /// deserialize this object, typical implementation should return
- /// the 'this' pointer.
- /// </summary>
- virtual void fromData(apache::geode::client::DataInput& input) override;
-
- virtual void toDelta(apache::geode::client::DataOutput& output) const override;
-
- virtual void fromDelta(apache::geode::client::DataInput& input) override;
-
- /// <summary>
- /// return the size of this object in bytes
- /// </summary>
- virtual size_t objectSize() const override;
-
- /// <summary>
- /// return the classId of the instance being serialized.
- /// This is used by deserialization to determine what instance
- /// type to create and deserialize into.
- /// </summary>
- virtual System::Int32 classId() const override;
-
- /// <summary>
- /// return the typeId of the instance being serialized.
- /// This is used by deserialization to determine what instance
- /// type to create and deserialize into.
- /// </summary>
- virtual int8_t typeId() const override;
-
- /// <summary>
- /// return the Data Serialization Fixed ID type.
- /// This is used to determine what instance type to create
- /// and deserialize into.
- ///
- /// Note that this should not be overridden by custom implementations
- /// and is reserved only for builtin types.
- /// </summary>
- virtual int8_t DSFID() const override;
-
- virtual bool hasDelta() const override;
-
- virtual std::shared_ptr<apache::geode::client::Delta> clone() const override;
-
- /// <summary>
- /// return the hashcode for this key.
- /// </summary>
- virtual System::Int32 hashcode() const override;
-
- /// <summary>
- /// return true if this key matches other CacheableKey
- /// </summary>
- virtual bool operator == (const CacheableKey& other) const override;
-
- /// <summary>
- /// return true if this key matches other ManagedCacheableDeltaGeneric
- /// </summary>
- virtual bool operator == (const ManagedCacheableDeltaGeneric& other) const;
-
- /// <summary>
- /// Returns the wrapped managed object reference.
- /// </summary>
- inline Apache::Geode::Client::IGeodeDelta^ ptr() const
- {
- return m_managedptr;
- }
-
-
- private:
-
- /// <summary>
- /// Using gcroot to hold the managed delegate pointer (since it cannot be stored directly).
- /// Note: not using auto_gcroot since it will result in 'Dispose' of the IGeodeDelta
- /// to be called which is not what is desired when this object is destroyed. Normally this
- /// managed object may be created by the user and will be handled automatically by the GC.
- /// </summary>
- gcroot<Apache::Geode::Client::IGeodeDelta^> m_managedptr;
- gcroot<Apache::Geode::Client::IGeodeSerializable^> m_managedSerializableptr;
-
- // Disable the copy and assignment constructors
- ManagedCacheableDeltaGeneric(const ManagedCacheableDeltaGeneric&);
- ManagedCacheableDeltaGeneric& operator = (const ManagedCacheableDeltaGeneric&);
+ public:
+ /// <summary>
+ /// Constructor to initialize with the provided managed object.
+ /// </summary>
+ /// <param name="managedptr">
+ /// The managed object.
+ /// </param>
+ inline ManagedCacheableDeltaGeneric(
+ Apache::Geode::Client::IGeodeDelta^ managedptr)
+ : Delta(), m_managedptr(managedptr)
+ {
+ m_managedSerializableptr = dynamic_cast<Apache::Geode::Client::IGeodeSerializable^>(managedptr);
+ m_classId = m_managedSerializableptr->ClassId;
+ m_objectSize = 0;
+ }
+
+ inline ManagedCacheableDeltaGeneric(
+ Apache::Geode::Client::IGeodeDelta^ managedptr, int hashcode, int classId)
+ : Delta(), m_managedptr(managedptr)
+ {
+ m_hashcode = hashcode;
+ m_classId = classId;
+ m_managedSerializableptr = dynamic_cast<Apache::Geode::Client::IGeodeSerializable^> (managedptr);
+ m_objectSize = 0;
+ }
+
+ /// <summary>
+ /// serialize this object
+ /// </summary>
+ virtual void toData(apache::geode::client::DataOutput& output) const override;
+
+ /// <summary>
+ /// deserialize this object, typical implementation should return
+ /// the 'this' pointer.
+ /// </summary>
+ virtual void fromData(apache::geode::client::DataInput& input) override;
+
+ virtual void toDelta(apache::geode::client::DataOutput& output) const override;
+
+ virtual void fromDelta(apache::geode::client::DataInput& input) override;
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual size_t objectSize() const override;
+
+ /// <summary>
+ /// return the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ virtual System::Int32 classId() const override;
+
+ /// <summary>
+ /// return the typeId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ virtual int8_t typeId() const override;
+
+ /// <summary>
+ /// return the Data Serialization Fixed ID type.
+ /// This is used to determine what instance type to create
+ /// and deserialize into.
+ ///
+ /// Note that this should not be overridden by custom implementations
+ /// and is reserved only for builtin types.
+ /// </summary>
+ virtual int8_t DSFID() const override;
+
+ virtual bool hasDelta() const override;
+
+ virtual std::shared_ptr<apache::geode::client::Delta> clone() const override;
+
+ /// <summary>
+ /// return the hashcode for this key.
+ /// </summary>
+ virtual System::Int32 hashcode() const override;
+
+ /// <summary>
+ /// return true if this key matches other CacheableKey
+ /// </summary>
+ virtual bool operator == (const CacheableKey& other) const override;
+
+ /// <summary>
+ /// return true if this key matches other ManagedCacheableDeltaGeneric
+ /// </summary>
+ virtual bool operator == (const ManagedCacheableDeltaGeneric& other) const;
+
+ /// <summary>
+ /// Returns the wrapped managed object reference.
+ /// </summary>
+ inline Apache::Geode::Client::IGeodeDelta^ ptr() const
+ {
+ return m_managedptr;
+ }
+
+ ManagedCacheableDeltaGeneric(const ManagedCacheableDeltaGeneric&) = delete;
+ ManagedCacheableDeltaGeneric& operator = (const ManagedCacheableDeltaGeneric&) = delete;
+
+ private:
+ int m_hashcode;
+ int m_classId;
+ size_t m_objectSize;
+
+ /// <summary>
+ /// Using gcroot to hold the managed delegate pointer (since it cannot be stored directly).
+ /// Note: not using auto_gcroot since it will result in 'Dispose' of the IGeodeDelta
+ /// to be called which is not what is desired when this object is destroyed. Normally this
+ /// managed object may be created by the user and will be handled automatically by the GC.
+ /// </summary>
+ gcroot<Apache::Geode::Client::IGeodeDelta^> m_managedptr;
+ gcroot<Apache::Geode::Client::IGeodeSerializable^> m_managedSerializableptr;
};
} // namespace client
diff --git a/clicache/src/impl/PdxManagedCacheableKey.cpp b/clicache/src/impl/PdxManagedCacheableKey.cpp
index 93b6f7e..161b4da 100644
--- a/clicache/src/impl/PdxManagedCacheableKey.cpp
+++ b/clicache/src/impl/PdxManagedCacheableKey.cpp
@@ -17,17 +17,17 @@
*/
+#include "PdxManagedCacheableKey.hpp"
-#include "../begin_native.hpp"
#include <GeodeTypeIdsImpl.hpp>
-#include "CacheRegionHelper.hpp"
-#include "../end_native.hpp"
-#include "PdxManagedCacheableKey.hpp"
+#include "../begin_native.hpp"
+#include "../end_native.hpp"
#include "../DataInput.hpp"
#include "../DataOutput.hpp"
#include "../CacheableString.hpp"
#include "../ExceptionTypes.hpp"
+#include "CacheRegionHelper.hpp"
#include "PdxHelper.hpp"
#include "SafeConvert.hpp"
#include "CacheResolver.hpp"
@@ -44,32 +44,36 @@ namespace apache
{
void PdxManagedCacheableKey::toData(apache::geode::client::DataOutput& output) const
{
- try {
+ try
+ {
System::UInt32 pos = (int)output.getBufferLength();
auto cache = CacheResolver::Lookup(output.getCache());
Apache::Geode::Client::DataOutput mg_output(&output, true, cache);
Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, m_managedptr);
- //m_managedptr->ToData( %mg_output );
+
//this will move the cursor in c++ layer
mg_output.WriteBytesToUMDataOutput();
- PdxManagedCacheableKey* tmp = const_cast<PdxManagedCacheableKey*>(this);
+ auto tmp = const_cast<PdxManagedCacheableKey*>(this);
tmp->m_objectSize = (int)(output.getBufferLength() - pos);
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
}
void PdxManagedCacheableKey::fromData(apache::geode::client::DataInput& input)
{
- try {
+ try
+ {
auto pos = input.getBytesRead();
auto cache = CacheResolver::Lookup(input.getCache());
Apache::Geode::Client::DataInput mg_input(&input, true, cache);
- //m_managedptr = m_managedptr->FromData( %mg_input );
+
Apache::Geode::Client::IPdxSerializable^ tmp = Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_input, false, CacheRegionHelper::getCacheImpl(input.getCache())->getSerializationRegistry().get());
m_managedptr = tmp;
m_managedDeltaptr = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(tmp);
@@ -77,152 +81,147 @@ namespace apache
//this will move the cursor in c++ layer
input.advanceCursor(mg_input.BytesReadInternally);
m_objectSize = input.getBytesRead() - pos;
- // m_hashcode = m_managedptr->GetHashCode();
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
}
size_t PdxManagedCacheableKey::objectSize() const
{
- try {
+ try
+ {
return m_objectSize;
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
+
return 0;
}
System::Int32 PdxManagedCacheableKey::classId() const
{
- /*System::UInt32 classId;
- try {
- classId = m_managedptr->ClassId;
- }
- catch (Com::Vmware::Cache::GeodeException^ ex) {
- ex->ThrowNative();
- }
- catch (System::Exception^ ex) {
- Apache::Geode::Client::GeodeException::ThrowNative(ex);
- }*/
- //return (m_classId >= 0x80000000 ? 0 : m_classId);
return 0;
}
int8_t PdxManagedCacheableKey::typeId() const
{
- /*if (m_classId >= 0x80000000) {
- return (int8_t)((m_classId - 0x80000000) % 0x20000000);
- }
- else if (m_classId <= 0x7F) {
- return (int8_t)GeodeTypeIdsImpl::CacheableUserData;
- }
- else if (m_classId <= 0x7FFF) {
- return (int8_t)GeodeTypeIdsImpl::CacheableUserData2;
- }
- else {
- return (int8_t)GeodeTypeIdsImpl::CacheableUserData4;
- }*/
return (int8_t)GeodeTypeIdsImpl::PDX;
}
int8_t PdxManagedCacheableKey::DSFID() const
{
- // convention that [0x8000000, 0xa0000000) is for FixedIDDefault,
- // [0xa000000, 0xc0000000) is for FixedIDByte,
- // [0xc0000000, 0xe0000000) is for FixedIDShort
- // and [0xe0000000, 0xffffffff] is for FixedIDInt
- // Note: depends on fact that FixedIDByte is 1, FixedIDShort is 2
- // and FixedIDInt is 3; if this changes then correct this accordingly
- //if (m_classId >= 0x80000000) {
- // return (int8_t)((m_classId - 0x80000000) / 0x20000000);
- //}
return 0;
}
std::string PdxManagedCacheableKey::toString() const
{
- try {
+ try
+ {
return marshal_as<std::string>(m_managedptr->ToString());
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
+
return "";
}
bool PdxManagedCacheableKey::operator ==(const apache::geode::client::CacheableKey& other) const
{
- try {
+ try
+ {
// now checking classId(), typeId(), DSFID() etc. will be much more
// expensive than just a dynamic_cast
- const PdxManagedCacheableKey* p_other =
- dynamic_cast<const PdxManagedCacheableKey*>(&other);
- if (p_other != NULL) {
+ if (const auto p_other = dynamic_cast<const PdxManagedCacheableKey*>(&other))
+ {
return ((Apache::Geode::Client::IPdxSerializable^)m_managedptr)->Equals((p_other->ptr()));
}
+
return false;
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
+
return false;
}
bool PdxManagedCacheableKey::operator ==(const PdxManagedCacheableKey& other) const
{
- try {
+ try
+ {
return ((Apache::Geode::Client::IPdxSerializable^)m_managedptr)->Equals((other.ptr()));
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
+
return false;
}
System::Int32 PdxManagedCacheableKey::hashcode() const
{
if (m_hashcode != 0)
+ {
return m_hashcode;
- try {
- PdxManagedCacheableKey* tmp = const_cast<PdxManagedCacheableKey*>(this);
- tmp->m_hashcode = (
- (Apache::Geode::Client::IPdxSerializable^)tmp->m_managedptr)
+ }
+ try
+ {
+ auto tmp = const_cast<PdxManagedCacheableKey*>(this);
+ tmp->m_hashcode =
+ ((Apache::Geode::Client::IPdxSerializable^)tmp->m_managedptr)
->GetHashCode();
+
return m_hashcode;
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
+
return 0;
}
size_t PdxManagedCacheableKey::logString(char* buffer, size_t maxLength) const
{
- try {
- if (maxLength > 0) {
- String^ logstr = m_managedptr->GetType()->Name + '(' +
+ try
+ {
+ if (maxLength > 0)
+ {
+ auto logstr = m_managedptr->GetType()->Name + '(' +
m_managedptr->ToString() + ')';
+
return snprintf(buffer, maxLength, "%s", marshal_as<std::string>(logstr).c_str());
}
}
@@ -232,6 +231,7 @@ namespace apache
catch (System::Exception^ ex) {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
+
return 0;
}
@@ -241,29 +241,34 @@ namespace apache
{
return m_managedDeltaptr->HasDelta();
}
+
return false;
}
void PdxManagedCacheableKey::toDelta(DataOutput& output) const
{
- try {
+ try
+ {
auto cache = CacheResolver::Lookup(output.getCache());
Apache::Geode::Client::DataOutput mg_output(&output, true, cache);
m_managedDeltaptr->ToDelta(%mg_output);
//this will move the cursor in c++ layer
mg_output.WriteBytesToUMDataOutput();
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
}
void PdxManagedCacheableKey::fromDelta(native::DataInput& input)
{
- try {
+ try
+ {
auto cache = CacheResolver::Lookup(input.getCache());
Apache::Geode::Client::DataInput mg_input(&input, true, cache);
m_managedDeltaptr->FromDelta(%mg_input);
@@ -273,30 +278,36 @@ namespace apache
m_hashcode = m_managedptr->GetHashCode();
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
}
std::shared_ptr<Delta> PdxManagedCacheableKey::clone() const
{
- try {
- if (auto cloneable = dynamic_cast<ICloneable^>((Apache::Geode::Client::IGeodeDelta^) m_managedDeltaptr)) {
- auto Mclone = dynamic_cast<Apache::Geode::Client::IPdxSerializable^>(cloneable->Clone());
- return std::shared_ptr<Delta>(static_cast<PdxManagedCacheableKey*>(SafeGenericM2UMConvert(Mclone)));
- } else {
- return Delta::clone();
+ try
+ {
+ if (auto cloneable = dynamic_cast<ICloneable^>((Apache::Geode::Client::IGeodeDelta^) m_managedDeltaptr))
+ {
+ auto managedclone = dynamic_cast<Apache::Geode::Client::IPdxSerializable^>(cloneable->Clone());
+
+ return std::shared_ptr<Delta>(static_cast<PdxManagedCacheableKey*>(SafeGenericM2UMConvert(managedclone)));
}
}
- catch (Apache::Geode::Client::GeodeException^ ex) {
+ catch (Apache::Geode::Client::GeodeException^ ex)
+ {
ex->ThrowNative();
}
- catch (System::Exception^ ex) {
+ catch (System::Exception^ ex)
+ {
Apache::Geode::Client::GeodeException::ThrowNative(ex);
}
+
return nullptr;
}
} // namespace client
diff --git a/clicache/src/impl/PdxManagedCacheableKey.hpp b/clicache/src/impl/PdxManagedCacheableKey.hpp
index fbed4f3..df9684c 100644
--- a/clicache/src/impl/PdxManagedCacheableKey.hpp
+++ b/clicache/src/impl/PdxManagedCacheableKey.hpp
@@ -17,21 +17,20 @@
#pragma once
-
-#include "../begin_native.hpp"
#include <geode/CacheableKey.hpp>
#include <geode/Delta.hpp>
#include <GeodeTypeIdsImpl.hpp>
-#include "../end_native.hpp"
-
-#include "../geode_defs.hpp"
#include <vcclr.h>
+#include "../begin_native.hpp"
+#include "../end_native.hpp"
+#include "../geode_defs.hpp"
#include "../IPdxSerializable.hpp"
#include "../IGeodeDelta.hpp"
using namespace System;
using namespace apache::geode::client;
+
namespace Apache
{
namespace Geode
@@ -57,142 +56,137 @@ namespace apache
class PdxManagedCacheableKey
: public apache::geode::client::CacheableKey, public apache::geode::client::Delta
{
- private:
- int m_hashcode;
- size_t m_objectSize;
-
- public:
-
- inline PdxManagedCacheableKey()
- : Delta(nullptr), m_managedptr(nullptr), m_hashcode(0), m_objectSize(0), m_managedDeltaptr(nullptr)
- {
-
- }
-
- inline PdxManagedCacheableKey(
- Apache::Geode::Client::IPdxSerializable^ managedptr, int hashcode)
- :Delta(nullptr), m_managedptr(managedptr), m_objectSize(0) {
- m_hashcode = hashcode;
- m_managedDeltaptr = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(managedptr);
- }
- /// <summary>
- /// Constructor to initialize with the provided managed object.
- /// </summary>
- /// <param name="managedptr">
- /// The managed object.
- /// </param>
- inline PdxManagedCacheableKey(
- Apache::Geode::Client::IPdxSerializable^ managedptr)
- : Delta(nullptr), m_managedptr(managedptr), m_objectSize(0) {
- m_hashcode = 0;//it can be zero while initializing the object
- m_managedDeltaptr = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(managedptr);
- }
-
- /// <summary>
- /// serialize this object
- /// </summary>
- virtual void toData(apache::geode::client::DataOutput& output) const override;
-
- /// <summary>
- /// deserialize this object, typical implementation should return
- /// the 'this' pointer.
- /// </summary>
- virtual void fromData(apache::geode::client::DataInput& input) override;
-
- virtual void toDelta(apache::geode::client::DataOutput& output) const override;
-
- virtual void fromDelta(apache::geode::client::DataInput& input) override;
-
- virtual bool hasDelta() const override;
-
- virtual std::shared_ptr<apache::geode::client::Delta> clone() const override;
-
- /// <summary>
- /// return the size of this object in bytes
- /// </summary>
- virtual size_t objectSize() const override;
-
- /// <summary>
- /// return the classId of the instance being serialized.
- /// This is used by deserialization to determine what instance
- /// type to create and deserialize into.
- /// </summary>
- virtual System::Int32 classId() const override;
-
- /// <summary>
- /// return the typeId of the instance being serialized.
- /// This is used by deserialization to determine what instance
- /// type to create and deserialize into.
- /// </summary>
- virtual int8_t typeId() const override;
-
- /// <summary>
- /// return the Data Serialization Fixed ID type.
- /// This is used to determine what instance type to create
- /// and deserialize into.
- ///
- /// Note that this should not be overridden by custom implementations
- /// and is reserved only for builtin types.
- /// </summary>
- virtual int8_t DSFID() const override;
-
- /// <summary>
- /// Display this object as 'string', which depends on the implementation in
- /// the managed class
- /// </summary>
- virtual std::string toString() const override;
-
- /// <summary>
- /// return true if this key matches other CacheableKey
- /// </summary>
- virtual bool operator == (const CacheableKey& other) const;
- /// <summary>
- /// return true if this key matches other ManagedCacheableKey
- /// </summary>
- virtual bool operator == (const PdxManagedCacheableKey& other) const;
-
- /// <summary>
- /// return the hashcode for this key.
- /// </summary>
- virtual System::Int32 hashcode() const;
-
- /// <summary>
- /// Copy the string form of a key into a char* buffer for logging purposes.
- /// implementations should only generate a string as long as maxLength chars,
- /// and return the number of chars written. buffer is expected to be large
- /// enough to hold at least maxLength chars.
- /// The default implementation renders the classname and instance address.
- /// </summary>
- virtual size_t logString(char* buffer, size_t maxLength) const;
-
- /// <summary>
- /// Returns the wrapped managed object reference.
- /// </summary>
- inline Apache::Geode::Client::IPdxSerializable^ ptr() const
- {
- return m_managedptr;
- }
-
-
- static Serializable* CreateDeserializable()
- {
- throw "Not implemented";
- //return new PdxManagedCacheableKey();
- }
- private:
-
- /// <summary>
- /// Using gcroot to hold the managed delegate pointer (since it cannot be stored directly).
- /// Note: not using auto_gcroot since it will result in 'Dispose' of the IGeodeSerializable
- /// to be called which is not what is desired when this object is destroyed. Normally this
- /// managed object may be created by the user and will be handled automatically by the GC.
- /// </summary>
- gcroot<Apache::Geode::Client::IPdxSerializable^> m_managedptr;
- gcroot<Apache::Geode::Client::IGeodeDelta^> m_managedDeltaptr;
-
- // Disable the copy and assignment constructors
- PdxManagedCacheableKey(const PdxManagedCacheableKey&);
- PdxManagedCacheableKey& operator = (const PdxManagedCacheableKey&);
+ public:
+ inline PdxManagedCacheableKey()
+ : Delta(), m_managedptr(nullptr), m_hashcode(0), m_objectSize(0), m_managedDeltaptr(nullptr) {}
+
+ inline PdxManagedCacheableKey(
+ Apache::Geode::Client::IPdxSerializable^ managedptr, int hashcode)
+ :Delta(), m_managedptr(managedptr), m_objectSize(0)
+ {
+ m_hashcode = hashcode;
+ m_managedDeltaptr = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(managedptr);
+ }
+
+ /// <summary>
+ /// Constructor to initialize with the provided managed object.
+ /// </summary>
+ /// <param name="managedptr">
+ /// The managed object.
+ /// </param>
+ inline PdxManagedCacheableKey(
+ Apache::Geode::Client::IPdxSerializable^ managedptr)
+ : Delta(), m_managedptr(managedptr), m_objectSize(0)
+ {
+ m_hashcode = 0; //it can be zero while initializing the object
+ m_managedDeltaptr = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(managedptr);
+ }
+
+ /// <summary>
+ /// serialize this object
+ /// </summary>
+ virtual void toData(apache::geode::client::DataOutput& output) const override;
+
+ /// <summary>
+ /// deserialize this object, typical implementation should return
+ /// the 'this' pointer.
+ /// </summary>
+ virtual void fromData(apache::geode::client::DataInput& input) override;
+
+ virtual void toDelta(apache::geode::client::DataOutput& output) const override;
+
+ virtual void fromDelta(apache::geode::client::DataInput& input) override;
+
+ virtual bool hasDelta() const override;
+
+ virtual std::shared_ptr<apache::geode::client::Delta> clone() const override;
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual size_t objectSize() const override;
+
+ /// <summary>
+ /// return the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ virtual System::Int32 classId() const override;
+
+ /// <summary>
+ /// return the typeId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ virtual int8_t typeId() const override;
+
+ /// <summary>
+ /// return the Data Serialization Fixed ID type.
+ /// This is used to determine what instance type to create
+ /// and deserialize into.
+ ///
+ /// Note that this should not be overridden by custom implementations
+ /// and is reserved only for builtin types.
+ /// </summary>
+ virtual int8_t DSFID() const override;
+
+ /// <summary>
+ /// Display this object as 'string', which depends on the implementation in
+ /// the managed class
+ /// </summary>
+ virtual std::string toString() const override;
+
+ /// <summary>
+ /// return true if this key matches other CacheableKey
+ /// </summary>
+ virtual bool operator == (const CacheableKey& other) const;
+ /// <summary>
+ /// return true if this key matches other ManagedCacheableKey
+ /// </summary>
+ virtual bool operator == (const PdxManagedCacheableKey& other) const;
+
+ /// <summary>
+ /// return the hashcode for this key.
+ /// </summary>
+ virtual System::Int32 hashcode() const;
+
+ /// <summary>
+ /// Copy the string form of a key into a char* buffer for logging purposes.
+ /// implementations should only generate a string as long as maxLength chars,
+ /// and return the number of chars written. buffer is expected to be large
+ /// enough to hold at least maxLength chars.
+ /// The default implementation renders the classname and instance address.
+ /// </summary>
+ virtual size_t logString(char* buffer, size_t maxLength) const;
+
+ /// <summary>
+ /// Returns the wrapped managed object reference.
+ /// </summary>
+ inline Apache::Geode::Client::IPdxSerializable^ ptr() const
+ {
+ return m_managedptr;
+ }
+
+ static Serializable* CreateDeserializable()
+ {
+ throw "Not implemented";
+ }
+
+ PdxManagedCacheableKey(const PdxManagedCacheableKey&) = delete;
+ PdxManagedCacheableKey& operator = (const PdxManagedCacheableKey&) = delete;
+
+ private:
+ int m_hashcode;
+ size_t m_objectSize;
+
+ /// <summary>
+ /// Using gcroot to hold the managed delegate pointer (since it cannot be stored directly).
+ /// Note: not using auto_gcroot since it will result in 'Dispose' of the IGeodeSerializable
+ /// to be called which is not what is desired when this object is destroyed. Normally this
+ /// managed object may be created by the user and will be handled automatically by the GC.
+ /// </summary>
+ gcroot<Apache::Geode::Client::IPdxSerializable^> m_managedptr;
+ gcroot<Apache::Geode::Client::IGeodeDelta^> m_managedDeltaptr;
};
} // namespace client
} // namespace geode
diff --git a/cppcache/src/ProxyCache.hpp b/cppcache/include/geode/AuthenticatedView.hpp
similarity index 78%
rename from cppcache/src/ProxyCache.hpp
rename to cppcache/include/geode/AuthenticatedView.hpp
index 66eb298..91cdd88 100644
--- a/cppcache/src/ProxyCache.hpp
+++ b/cppcache/include/geode/AuthenticatedView.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_PROXYCACHE_H_
-#define GEODE_PROXYCACHE_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,12 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#pragma once
+
+#ifndef GEODE_AUTHENTICATEDVIEW_H_
+#define GEODE_AUTHENTICATEDVIEW_H_
+
#include <geode/internal/geode_globals.hpp>
#include <geode/Region.hpp>
#include <geode/DistributedSystem.hpp>
#include <geode/QueryService.hpp>
#include <geode/PoolFactory.hpp>
-#include "UserAttributes.hpp"
#include <geode/RegionService.hpp>
/**
@@ -35,6 +35,8 @@ namespace apache {
namespace geode {
namespace client {
+class GuardUserAttributes;
+class UserAttributes;
class FunctionServiceImpl;
/**
@@ -51,9 +53,7 @@ class FunctionServiceImpl;
* <p>A cache can have multiple root regions, each with a different name.
*
*/
-class _GEODE_EXPORT ProxyCache
- : public RegionService,
- public std::enable_shared_from_this<ProxyCache> {
+class _GEODE_EXPORT AuthenticatedView : public RegionService {
/**
* @brief public methods
*/
@@ -66,7 +66,7 @@ class _GEODE_EXPORT ProxyCache
*
* @return true, if this cache is closed; false, otherwise
*/
- virtual bool isClosed() const override;
+ bool isClosed() const override;
/**
* Terminates this object cache and releases all the local resources.
@@ -76,13 +76,13 @@ class _GEODE_EXPORT ProxyCache
* @param keepalive whether to keep a durable client's queue alive
* @throws CacheClosedException, if the cache is already closed.
*/
- virtual void close() override;
+ void close() override;
/** Look up a region with the full path from root.
* @param path the region's path, such as <code>RootA/Sub1/Sub1A</code>.
* @returns region, or nullptr if no such region exists.
*/
- virtual std::shared_ptr<Region> getRegion(
+ std::shared_ptr<Region> getRegion(
const std::string& path) const override;
/**
@@ -90,7 +90,7 @@ class _GEODE_EXPORT ProxyCache
*
* @returns A smart pointer to the QueryService.
*/
- virtual std::shared_ptr<QueryService> getQueryService() override;
+ std::shared_ptr<QueryService> getQueryService() override;
/**
* Returns a set of root regions in the cache. This set is a snapshot and
@@ -100,15 +100,20 @@ class _GEODE_EXPORT ProxyCache
* @param regions the returned set of
* regions
*/
- virtual std::vector<std::shared_ptr<Region>> rootRegions() const override;
+ std::vector<std::shared_ptr<Region>> rootRegions() const override;
/**
* @brief destructor
*/
- virtual ~ProxyCache();
+ virtual ~AuthenticatedView();
- ProxyCache(std::shared_ptr<Properties> credentials,
- std::shared_ptr<Pool> pool, CacheImpl* cacheImpl);
+ /**
+ * @brief constructors
+ */
+ AuthenticatedView(std::shared_ptr<Properties> credentials,
+ std::shared_ptr<Pool> pool, CacheImpl* cacheImpl);
+ AuthenticatedView(AuthenticatedView&& other) = default;
+ AuthenticatedView(const AuthenticatedView& other) = delete;
/**
* Returns a factory that can create a {@link PdxInstance}.
@@ -117,18 +122,18 @@ class _GEODE_EXPORT ProxyCache
* when it is fully deserialized.
* @return the factory
*/
- virtual std::shared_ptr<PdxInstanceFactory> createPdxInstanceFactory(
+ std::shared_ptr<PdxInstanceFactory> createPdxInstanceFactory(
std::string className) const override;
- private:
- /**
- * @brief constructors
- */
+ AuthenticatedView& operator=(AuthenticatedView&& other) = default;
+ AuthenticatedView& operator=(const AuthenticatedView& other) = delete;
+ private:
std::shared_ptr<UserAttributes> m_userAttributes;
- bool m_isProxyCacheClosed;
+ bool m_isAuthenticatedViewClosed;
std::shared_ptr<QueryService> m_remoteQueryService;
CacheImpl* m_cacheImpl;
+
friend class Pool;
friend class ProxyRegion;
friend class ProxyRemoteQueryService;
@@ -136,11 +141,11 @@ class _GEODE_EXPORT ProxyCache
friend class ExecutionImpl;
friend class FunctionServiceImpl;
friend class FunctionService;
- friend class GuardUserAttribures;
+ friend class GuardUserAttributes;
friend class CacheRegionHelper;
};
} // namespace client
} // namespace geode
} // namespace apache
-#endif // GEODE_PROXYCACHE_H_
+#endif // GEODE_AUTHENTICATEDVIEW_H_
diff --git a/cppcache/include/geode/Cache.hpp b/cppcache/include/geode/Cache.hpp
index 5e8295a..6c6b21c 100644
--- a/cppcache/include/geode/Cache.hpp
+++ b/cppcache/include/geode/Cache.hpp
@@ -48,6 +48,7 @@ class CacheImpl;
class AuthInitialize;
class CacheTransactionManager;
class RegionFactory;
+class AuthenticatedView;
/**
* @class Cache Cache.hpp
@@ -196,7 +197,7 @@ class _GEODE_EXPORT Cache : public GeodeCache {
* there are more than one Pool in Cache.
*/
- virtual std::shared_ptr<RegionService> createAuthenticatedView(
+ virtual AuthenticatedView createAuthenticatedView(
std::shared_ptr<Properties> userSecurityProperties,
const std::string& poolName);
@@ -238,12 +239,12 @@ class _GEODE_EXPORT Cache : public GeodeCache {
virtual PoolManager& getPoolManager() const;
- /**
- * @brief destructor
- */
+ Cache() = delete;
virtual ~Cache();
-
+ Cache(const Cache& other) = delete;
+ Cache& operator=(const Cache& other) = delete;
Cache(Cache&& other) noexcept;
+ Cache& operator=(Cache&& other) noexcept;
private:
/**
@@ -257,8 +258,6 @@ class _GEODE_EXPORT Cache : public GeodeCache {
std::unique_ptr<TypeRegistry> m_typeRegistry;
protected:
- Cache() = delete;
-
static bool isPoolInMultiuserMode(std::shared_ptr<Region> regionPtr);
friend class CacheFactory;
diff --git a/cppcache/include/geode/Delta.hpp b/cppcache/include/geode/Delta.hpp
index 2ef1127..62cffac 100644
--- a/cppcache/include/geode/Delta.hpp
+++ b/cppcache/include/geode/Delta.hpp
@@ -44,7 +44,6 @@ namespace client {
* of the class.
*/
-class Cache;
class DataInput;
class DataOutput;
@@ -88,18 +87,13 @@ class _GEODE_EXPORT Delta {
* notification.
* The region attribute for cloning must be set to 'true' in order to enable
* cloning.
- * The default implementation of this method creates an object clone by first
- * serializing the object into
- * a buffer, then deserializing from the buffer thus creating a clone of the
- * original.
*/
- virtual std::shared_ptr<Delta> clone() const;
+ virtual std::shared_ptr<Delta> clone() const = 0;
- virtual ~Delta() {}
+ virtual ~Delta() = default;
protected:
- Delta(Cache* cache);
- Cache* m_cache;
+ Delta() = default;
};
} // namespace client
} // namespace geode
diff --git a/cppcache/include/geode/FunctionService.hpp b/cppcache/include/geode/FunctionService.hpp
index 3c4161e..64a9f1a 100644
--- a/cppcache/include/geode/FunctionService.hpp
+++ b/cppcache/include/geode/FunctionService.hpp
@@ -95,8 +95,8 @@ class _GEODE_EXPORT FunctionService {
* @throws UnsupportedOperationException
* if Pool is in multiusersecure Mode
*/
- inline static Execution onServer(const std::shared_ptr<RegionService>& cache) {
- return onServerWithCache(cache);
+ inline static Execution onServer(RegionService& regionService) {
+ return onServerWithCache(regionService);
}
/**
@@ -130,23 +130,20 @@ class _GEODE_EXPORT FunctionService {
* @throws UnsupportedOperationException
* if Pool is in multiusersecure Mode
*/
- inline static Execution onServers(const std::shared_ptr<RegionService>& cache) {
- return onServersWithCache(cache);
+ inline static Execution onServers(RegionService& regionService) {
+ return onServersWithCache(regionService);
}
virtual ~FunctionService() {}
private:
- static Execution onServerWithPool(
- const std::shared_ptr<Pool>& pool);
+ static Execution onServerWithPool(const std::shared_ptr<Pool>& pool);
- static Execution onServerWithCache(
- const std::shared_ptr<RegionService>& cache);
+ static Execution onServerWithCache(RegionService& regionService);
- static Execution onServersWithPool(
- const std::shared_ptr<Pool>& pool);
+ static Execution onServersWithPool(const std::shared_ptr<Pool>& pool);
- static Execution onServersWithCache(const std::shared_ptr<RegionService>& cache);
+ static Execution onServersWithCache(RegionService& regionService);
};
} // namespace client
} // namespace geode
diff --git a/cppcache/include/geode/PdxInstance.hpp b/cppcache/include/geode/PdxInstance.hpp
index 1616f4e..e2c01f9 100644
--- a/cppcache/include/geode/PdxInstance.hpp
+++ b/cppcache/include/geode/PdxInstance.hpp
@@ -509,19 +509,16 @@ class _GEODE_EXPORT PdxInstance : public PdxSerializable {
* @throws IllegalStateException if the PdxInstance typeid is not defined yet,
* to get classname or if PdxType is not defined for PdxInstance.
*/
- virtual PdxFieldTypes getFieldType(
- const std::string& fieldname) const = 0;
+ virtual PdxFieldTypes getFieldType(const std::string& fieldname) const = 0;
+
+ PdxInstance(const PdxInstance& other) = delete;
+ void operator=(const PdxInstance& other) = delete;
protected:
/**
* @brief constructors
*/
PdxInstance() {}
-
- private:
- // never implemented.
- PdxInstance(const PdxInstance& other);
- void operator=(const PdxInstance& other);
};
} // namespace client
diff --git a/cppcache/include/geode/PdxInstanceFactory.hpp b/cppcache/include/geode/PdxInstanceFactory.hpp
index e5ee87a..3db1d64 100644
--- a/cppcache/include/geode/PdxInstanceFactory.hpp
+++ b/cppcache/include/geode/PdxInstanceFactory.hpp
@@ -47,6 +47,8 @@ class _GEODE_EXPORT PdxInstanceFactory {
* @brief destructor
*/
virtual ~PdxInstanceFactory() {}
+ PdxInstanceFactory(const PdxInstanceFactory& other) = delete;
+ void operator=(const PdxInstanceFactory& other) = delete;
protected:
/**
@@ -54,11 +56,6 @@ class _GEODE_EXPORT PdxInstanceFactory {
*/
PdxInstanceFactory() {}
- private:
- // never implemented.
- PdxInstanceFactory(const PdxInstanceFactory& other);
- void operator=(const PdxInstanceFactory& other);
-
public:
/**
* Create a {@link PdxInstance}. The instance
diff --git a/cppcache/include/geode/Pool.hpp b/cppcache/include/geode/Pool.hpp
index 352102c..47d6e98 100644
--- a/cppcache/include/geode/Pool.hpp
+++ b/cppcache/include/geode/Pool.hpp
@@ -39,13 +39,13 @@ namespace apache {
namespace geode {
namespace client {
+class AuthenticatedView;
class Cache;
class CacheFactory;
class PoolAttributes;
class CacheImpl;
class Properties;
class QueryService;
-class RegionService;
/**
* A pool of connections to connect from a client to a set of Geode Cache
@@ -298,7 +298,7 @@ class _GEODE_EXPORT Pool : public std::enable_shared_from_this<Pool> {
* @returns Logical instance of cache to do operations on behalf of one
* particular user.
*/
- virtual std::shared_ptr<RegionService> createSecureUserCache(
+ virtual AuthenticatedView createAuthenticatedView(
std::shared_ptr<Properties> credentials, CacheImpl* cacheImpl);
Pool(const Pool&);
diff --git a/cppcache/include/geode/Region.hpp b/cppcache/include/geode/Region.hpp
index 7aa0120..97158bb 100644
--- a/cppcache/include/geode/Region.hpp
+++ b/cppcache/include/geode/Region.hpp
@@ -143,7 +143,7 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* This operation is not distributed.
*/
virtual void invalidateRegion(
- const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
+ const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
/** Invalidates this region. The invalidation will cascade to
* all the subregions and cached entries. After
@@ -165,7 +165,7 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual void localInvalidateRegion(
- const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
+ const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
/** Destroys the whole region and provides a user-defined parameter
* object to any <code>CacheWriter</code> invoked in the process.
@@ -204,7 +204,7 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* @see invalidateRegion
*/
virtual void destroyRegion(
- const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
+ const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
/**
* Removes all entries from this region and provides a user-defined parameter
* object to any <code>CacheWriter</code> or <code>CacheListener</code>
@@ -212,7 +212,8 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* @see CacheListener#afterRegionClear
* @see CacheWriter#beforeRegionClear
*/
- virtual void clear(const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
+ virtual void clear(
+ const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
/**
* Removes all entries from this region and provides a user-defined parameter
* object to any <code>CacheWriter</code> or <code>CacheListener</code>
@@ -220,7 +221,8 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* @see CacheListener#afterRegionClear
* @see CacheWriter#beforeRegionClear
*/
- virtual void localClear(const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
+ virtual void localClear(
+ const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
/** Destroys the whole region and provides a user-defined parameter
* object to any <code>CacheWriter</code> invoked in the process.
@@ -242,7 +244,7 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* @see localInvalidateRegion
*/
virtual void localDestroyRegion(
- const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
+ const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;
/** Returns the subregion identified by the path, nullptr if no such subregion
*/
@@ -250,8 +252,7 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Creates a subregion with the specified attributes */
virtual std::shared_ptr<Region> createSubregion(
- const std::string& subregionName,
- RegionAttributes aRegionAttributes) = 0;
+ const std::string& subregionName, RegionAttributes aRegionAttributes) = 0;
/** Populates the passed in std::vector<std::shared_ptr<Region>> with
* subregions of the current region
@@ -260,12 +261,14 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* @param[out] sr subregions
* @throws RegionDestroyedException
*/
- virtual std::vector<std::shared_ptr<Region>> subregions(const bool recursive) = 0;
+ virtual std::vector<std::shared_ptr<Region>> subregions(
+ const bool recursive) = 0;
/** Return the meta-object RegionEntry for key.
* @throws IllegalArgumentException, RegionDestroyedException.
*/
- virtual std::shared_ptr<RegionEntry> getEntry(const std::shared_ptr<CacheableKey>& key) = 0;
+ virtual std::shared_ptr<RegionEntry> getEntry(
+ const std::shared_ptr<CacheableKey>& key) = 0;
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
@@ -830,7 +833,9 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
return remove(key, Serializable::create(value), arg);
}
- bool remove(const std::shared_ptr<CacheableKey>& key) { return removeEx(key); }
+ bool remove(const std::shared_ptr<CacheableKey>& key) {
+ return removeEx(key);
+ }
/** Convenience method allowing both key and value to be a const char* */
template <class KEYTYPE>
@@ -1042,7 +1047,8 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* It is not propagated to the Geode cache server
* to which it is connected.
*/
- virtual bool containsValueForKey(const std::shared_ptr<CacheableKey>& keyPtr) const = 0;
+ virtual bool containsValueForKey(
+ const std::shared_ptr<CacheableKey>& keyPtr) const = 0;
/**
* Convenience method allowing key to be a const char*
@@ -1060,28 +1066,32 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* server
* to which it is connected with.
*/
- virtual bool containsKey(const std::shared_ptr<CacheableKey>& keyPtr) const = 0;
+ virtual bool containsKey(
+ const std::shared_ptr<CacheableKey>& keyPtr) const = 0;
/**
* The cache of the server, to which it is connected with, is searched
* for the key to see if the key is present.
* @throws UnsupportedOperationException if the region's scope is
* ScopeType::LOCAL.
*/
- virtual bool containsKeyOnServer(const std::shared_ptr<CacheableKey>& keyPtr) const = 0;
+ virtual bool containsKeyOnServer(
+ const std::shared_ptr<CacheableKey>& keyPtr) const = 0;
/**
* Returns the list of keys on which this client is interested and will be
* notified of changes.
* @throws UnsupportedOperationException if the region's scope is
* ScopeType::LOCAL.
*/
- virtual std::vector<std::shared_ptr<CacheableKey>> getInterestList() const = 0;
+ virtual std::vector<std::shared_ptr<CacheableKey>> getInterestList()
+ const = 0;
/**
* Returns the list of regular expresssions on which this client is
* interested and will be notified of changes.
* @throws UnsupportedOperationException if the region's scope is
* ScopeType::LOCAL.
*/
- virtual std::vector<std::shared_ptr<CacheableString>> getInterestListRegex() const = 0;
+ virtual std::vector<std::shared_ptr<CacheableString>> getInterestListRegex()
+ const = 0;
/**
* Convenience method allowing key to be a const char*
* This operations checks for the key in the local cache .
@@ -1128,10 +1138,10 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* @throws UnknownException For other exceptions.
* @throws TimeoutException if operation timed out
*/
- virtual void registerKeys(const std::vector<std::shared_ptr<CacheableKey>>& keys,
- bool isDurable = false,
- bool getInitialValues = false,
- bool receiveValues = true) = 0;
+ virtual void registerKeys(
+ const std::vector<std::shared_ptr<CacheableKey>>& keys,
+ bool isDurable = false, bool getInitialValues = false,
+ bool receiveValues = true) = 0;
/**
* Unregisters an array of keys to stop getting updates for them.
@@ -1158,7 +1168,8 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* @throws UnknownException For other exceptions.
* @throws TimeoutException if operation timed out
*/
- virtual void unregisterKeys(const std::vector<std::shared_ptr<CacheableKey>>& keys) = 0;
+ virtual void unregisterKeys(
+ const std::vector<std::shared_ptr<CacheableKey>>& keys) = 0;
/**
* Registers to get updates for all keys from the server.
@@ -1461,16 +1472,16 @@ class _GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
virtual const std::shared_ptr<Pool>& getPool() const = 0;
- inline Cache& getCache() { return *m_cache; }
+ Cache& getCache();
Region(const Region&) = delete;
Region& operator=(const Region&) = delete;
protected:
- Region(Cache* cache);
+ Region(CacheImpl* cacheImpl);
virtual ~Region();
- mutable Cache* m_cache;
+ CacheImpl* m_cacheImpl;
_GEODE_FRIEND_STD_SHARED_PTR(Region)
};
diff --git a/cppcache/integration-test/DeltaEx.hpp b/cppcache/integration-test/DeltaEx.hpp
index b884635..42ad983 100644
--- a/cppcache/integration-test/DeltaEx.hpp
+++ b/cppcache/integration-test/DeltaEx.hpp
@@ -41,8 +41,8 @@ class DeltaEx : public Cacheable, public Delta {
static int fromDeltaCount;
static int fromDataCount;
static int cloneCount;
- DeltaEx() : Delta(nullptr), counter(1), isDelta(false) {}
- DeltaEx(int count) : Delta(nullptr), counter(0), isDelta(false) {}
+ DeltaEx() : Delta(), counter(1), isDelta(false) {}
+ DeltaEx(int count) : Delta(), counter(0), isDelta(false) {}
DeltaEx(const DeltaEx& rhs) = default;
virtual bool hasDelta() const override { return isDelta; }
@@ -94,10 +94,10 @@ class PdxDeltaEx : public PdxSerializable, public Delta {
static int m_fromDeltaCount;
static int m_fromDataCount;
static int m_cloneCount;
- PdxDeltaEx() : Delta(nullptr), m_counter(1), m_isDelta(false) {}
- PdxDeltaEx(int count) : Delta(nullptr), m_counter(0), m_isDelta(false) {}
+ PdxDeltaEx() : Delta(), m_counter(1), m_isDelta(false) {}
+ PdxDeltaEx(int count) : Delta(), m_counter(0), m_isDelta(false) {}
PdxDeltaEx(const PdxDeltaEx& rhs)
- : Delta(nullptr), m_counter(rhs.m_counter), m_isDelta(rhs.m_isDelta) {}
+ : Delta(), m_counter(rhs.m_counter), m_isDelta(rhs.m_isDelta) {}
virtual bool hasDelta() const override { return m_isDelta; }
virtual void toDelta(DataOutput& out) const override {
out.writeInt(m_counter);
diff --git a/cppcache/integration-test/ThinClientSecurity.hpp b/cppcache/integration-test/ThinClientSecurity.hpp
index ac93f7c..a0a5316 100644
--- a/cppcache/integration-test/ThinClientSecurity.hpp
+++ b/cppcache/integration-test/ThinClientSecurity.hpp
@@ -26,6 +26,7 @@
* Author: vrao
*/
+#include <geode/AuthenticatedView.hpp>
#include "fw_dunit.hpp"
#include "ThinClientHelper.hpp"
#include "CacheImplHelper.hpp"
@@ -62,19 +63,25 @@ void createRegionForSecurity(
sprintf(buff, "%s_%d", poolName, index++);
poolName = buff;
}
+
printf("createRegionForSecurity poolname = %s \n", poolName);
+
getHelper()->createPoolWithLocators(
poolName, locatorsG, clientNotificationEnabled, subscriptionRedundancy,
std::chrono::milliseconds::zero(), connections, isMultiuserMode);
+
createRegionAndAttachPool(name, ackMode, poolName, caching);
setCacheListener(name, listener);
}
+
std::shared_ptr<Pool> getPool(const char* name) {
return getHelper()->getCache()->getPoolManager().find(name);
}
- std::shared_ptr<RegionService> getVirtualCache(std::shared_ptr<Properties> creds, std::shared_ptr<Pool> pool) {
- auto cachePtr = getHelper()->getCache();
- return cachePtr->createAuthenticatedView(creds, pool->getName());
- }
+
+AuthenticatedView getVirtualCache(std::shared_ptr<Properties> creds,
+ std::shared_ptr<Pool> pool) {
+ auto cachePtr = getHelper()->getCache();
+ return cachePtr->createAuthenticatedView(creds, pool->getName());
+}
#endif // GEODE_INTEGRATION_TEST_THINCLIENTSECURITY_H_
diff --git a/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp b/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp
index 57ac48a..8597b04 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp
@@ -72,11 +72,12 @@ void initCredentialGenerator() {
loopNum++;
if (loopNum > 2) loopNum = 1;
-} std::shared_ptr<Properties> userCreds;
+}
+std::shared_ptr<Properties> userCreds;
void initClientAuth(char credentialsType) {
printf(" in initclientAuth 0 = %c ", credentialsType);
userCreds = Properties::create();
- auto config = Properties::create();
+ auto config = Properties::create();
if (credentialGeneratorHandler == nullptr) {
FAIL("credentialGeneratorHandler is nullptr");
}
@@ -188,13 +189,13 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepOne)
false, -1, true, 0);
LOG(" 5");
// need to insure pool name
- auto pool = getPool(regionNamesAuth[0]);
+ auto pool = getPool(regionNamesAuth[0]);
LOG(" 6");
if (pool != nullptr) {
LOG(" 7");
- auto virtualCache = getVirtualCache(userCreds, pool);
+ auto virtualCache = getVirtualCache(userCreds, pool);
LOG(" 8");
- virtualCache->getRegion(regionNamesAuth[0])->put(keys[0], vals[0]);
+ virtualCache.getRegion(regionNamesAuth[0])->put(keys[0], vals[0]);
LOG("Operation allowed, something is wrong.");
} else {
LOG("Pool is nullptr");
@@ -221,10 +222,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepTwo)
false, -1, true, 0);
char buff[128] = {'\0'};
sprintf(buff, "%s_0", regionNamesAuth[0]);
- auto pool = getPool(regionNamesAuth[0]);
+ auto pool = getPool(regionNamesAuth[0]);
if (pool != nullptr) {
auto virtualCache = getVirtualCache(userCreds, pool);
- auto virtualRegion = virtualCache->getRegion(regionNamesAuth[0]);
+ auto virtualRegion = virtualCache.getRegion(regionNamesAuth[0]);
virtualRegion->create(keys[0], vals[0]);
virtualRegion->put(keys[0], nvals[0]);
virtualRegion->containsKeyOnServer(
@@ -250,10 +251,10 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepThree)
createRegionForSecurity(regionNamesAuth[0], USE_ACK, false, nullptr,
false, -1, true, 0);
// need to insure pool name
- auto pool = getPool(regionNamesAuth[0]);
+ auto pool = getPool(regionNamesAuth[0]);
if (pool != nullptr) {
auto virtualCache = getVirtualCache(userCreds, pool);
- virtualCache->getRegion(regionNamesAuth[0])->put(keys[0], vals[0]);
+ virtualCache.getRegion(regionNamesAuth[0])->put(keys[0], vals[0]);
} else {
LOG("Pool is nullptr");
}
@@ -281,10 +282,10 @@ DUNIT_TASK_DEFINITION(CLIENT3, StepFour)
createRegionForSecurity(regionNamesAuth[0], USE_ACK, false, nullptr,
false, -1, true, 0);
// need to insure pool name
- auto pool = getPool(regionNamesAuth[0]);
+ auto pool = getPool(regionNamesAuth[0]);
if (pool != nullptr) {
auto virtualCache = getVirtualCache(userCreds, pool);
- virtualCache->getRegion(regionNamesAuth[0])->put(keys[0], vals[0]);
+ virtualCache.getRegion(regionNamesAuth[0])->put(keys[0], vals[0]);
} else {
LOG("Pool is nullptr");
}
@@ -313,16 +314,16 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepFive)
createRegionForSecurity(regionNamesAuth[1], USE_ACK, false, nullptr,
false, -1, true, 0);
// need to insure pool name
- auto pool = getPool(regionNamesAuth[1]);
- std::shared_ptr<RegionService> virtualCache;
+ auto pool = getPool(regionNamesAuth[1]);
+
std::shared_ptr<Region> virtualRegion;
if (pool != nullptr) {
- virtualCache = getVirtualCache(userCreds, pool);
- virtualRegion = virtualCache->getRegion(regionNamesAuth[1]);
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ virtualRegion = virtualCache.getRegion(regionNamesAuth[1]);
} else {
LOG("Pool is nullptr");
}
- auto keyPtr = CacheableKey::create(keys[0]);
+ auto keyPtr = CacheableKey::create(keys[0]);
LOG("before get");
auto checkPtr = std::dynamic_pointer_cast<CacheableString>(
virtualRegion->get(keyPtr));
@@ -352,10 +353,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepSix)
false, -1, true, 0);
char buff[128] = {'\0'};
sprintf(buff, "%s_1", regionNamesAuth[0]);
- auto pool = getPool(regionNamesAuth[0]);
+ auto pool = getPool(regionNamesAuth[0]);
if (pool != nullptr) {
auto virtualCache = getVirtualCache(userCreds, pool);
- auto virtualRegion = virtualCache->getRegion(regionNamesAuth[0]);
+ auto virtualRegion = virtualCache.getRegion(regionNamesAuth[0]);
virtualRegion->create(keys[0], vals[0]);
virtualRegion->put(keys[0], nvals[0]);
LOG("Operation allowed, something is wrong.");
@@ -388,10 +389,10 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepSeven)
false, -1, true, 0);
char buff[128] = {'\0'};
sprintf(buff, "%s_0", regionNamesAuth[0]);
- auto pool = getPool(regionNamesAuth[0]);
+ auto pool = getPool(regionNamesAuth[0]);
if (pool != nullptr) {
auto virtualCache = getVirtualCache(userCreds, pool);
- auto virtualRegion = virtualCache->getRegion(regionNamesAuth[0]);
+ auto virtualRegion = virtualCache.getRegion(regionNamesAuth[0]);
virtualRegion->create(keys[0], vals[0]);
virtualRegion->put(keys[0], nvals[0]);
LOG("Operation allowed, something is wrong.");
@@ -419,40 +420,40 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepEight)
createRegionForSecurity(regionNamesAuth[1], USE_ACK, false, nullptr,
false, -1, true, 0);
// need to insure pool name
- auto pool = getPool(regionNamesAuth[1]);
- std::shared_ptr<RegionService> virtualCache;
+ auto pool = getPool(regionNamesAuth[1]);
+
std::shared_ptr<Region> virtualRegion;
if (pool != nullptr) {
- virtualCache = getVirtualCache(userCreds, pool);
- virtualRegion = virtualCache->getRegion(regionNamesAuth[1]);
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ virtualRegion = virtualCache.getRegion(regionNamesAuth[1]);
} else {
LOG("Pool is nullptr");
}
- auto txManager =
- getHelper()->getCache()->getCacheTransactionManager();
- LOG("txManager got");
- txManager->begin();
- LOG("txManager begin done");
- virtualRegion->put("TxKey", "TxValue");
- LOG("createEntryTx done");
- txManager->commit();
- LOG("txManager commit done");
-
- auto checkPtr = std::dynamic_pointer_cast<CacheableString>(
- virtualRegion->get("TxKey"));
- ASSERT(checkPtr != nullptr, "Value not found.");
- LOGINFO("checkPtr->value().c_str() = %s ", checkPtr->value().c_str());
- ASSERT(strcmp("TxValue", checkPtr->value().c_str()) == 0,
- "Value not correct.");
- if (checkPtr != nullptr && !strcmp("TxValue", checkPtr->value().c_str())) {
- LOG("checkPtr is not null");
- char buf[1024];
- sprintf(buf, "In net search, get returned %s for key %s",
- checkPtr->value().c_str(), "TxKey");
- LOG(buf);
- } else {
- LOG("checkPtr is nullptr");
+ auto txManager = getHelper()->getCache()->getCacheTransactionManager();
+ LOG("txManager got");
+ txManager->begin();
+ LOG("txManager begin done");
+ virtualRegion->put("TxKey", "TxValue");
+ LOG("createEntryTx done");
+ txManager->commit();
+ LOG("txManager commit done");
+
+ auto checkPtr = std::dynamic_pointer_cast<CacheableString>(
+ virtualRegion->get("TxKey"));
+ ASSERT(checkPtr != nullptr, "Value not found.");
+ LOGINFO("checkPtr->value().c_str() = %s ", checkPtr->value().c_str());
+ ASSERT(strcmp("TxValue", checkPtr->value().c_str()) == 0,
+ "Value not correct.");
+ if (checkPtr != nullptr &&
+ !strcmp("TxValue", checkPtr->value().c_str())) {
+ LOG("checkPtr is not null");
+ char buf[1024];
+ sprintf(buf, "In net search, get returned %s for key %s",
+ checkPtr->value().c_str(), "TxKey");
+ LOG(buf);
+ } else {
+ LOG("checkPtr is nullptr");
}
txManager->begin();
diff --git a/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
index 379ce06..72e697a 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
@@ -220,20 +220,21 @@ DUNIT_TASK_DEFINITION(ADMIN_CLIENT, StepOne)
-1, true, 0);
LOG("Region created successfully");
LOG("Tying Entry creation");
- std::shared_ptr<RegionService> virtualCache;
- std::shared_ptr<Region> regionPtr;
+
auto pool = getPool(regionNamesAuth[0]);
LOG(" 6");
- if (pool != nullptr) {
- LOG(" 7");
- virtualCache = getVirtualCache(userCreds, pool);
- LOG(" 8");
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
- LOG("Operation allowed, something is wrong.");
- } else {
- LOG("Pool is nullptr");
+
+ if (pool == nullptr) {
+ FAIL("Pool is nullptr");
}
+ LOG(" 7");
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ LOG(" 8");
+ auto regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
+
+ LOG("Operation allowed, something is wrong.");
+
//---------------------for region clear tests-----
regionPtr->put(1, 1);
regionPtr->clear();
@@ -290,7 +291,7 @@ DUNIT_TASK_DEFINITION(ADMIN_CLIENT, StepOne)
FAIL(other.what());
}
- qs = virtualCache->getQueryService();
+ qs = virtualCache.getQueryService();
char queryString[100];
sprintf(queryString, "select * from /%s", regionNamesAuth[0]);
@@ -458,7 +459,7 @@ DUNIT_TASK_DEFINITION(ADMIN_CLIENT, StepOne)
LOG(" 7");
virtualCache = getVirtualCache(userCreds, pool);
LOG(" 8");
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
+ regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
LOG("Operation allowed, something is wrong.");
} else {
LOG("Pool is nullptr");
@@ -467,7 +468,7 @@ DUNIT_TASK_DEFINITION(ADMIN_CLIENT, StepOne)
LOG("Region created successfully");
regionPtr->create(keys[2], vals[2]);
LOG("Entry created successfully");
- virtualCache->close();
+ virtualCache.close();
LOG("Cache close successfully");
}
HANDLE_NO_NOT_AUTHORIZED_EXCEPTION
@@ -491,20 +492,20 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
createRegionForSecurity(regionNamesAuth[0], USE_ACK, true, nullptr, false,
-1, true, 0);
LOG("Region created successfully");
- std::shared_ptr<RegionService> virtualCache;
- std::shared_ptr<Region> regionPtr;
+
auto pool = getPool(regionNamesAuth[0]);
LOG(" 6");
- if (pool != nullptr) {
- LOG(" 7");
- virtualCache = getVirtualCache(userCreds, pool);
- LOG(" 8");
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
- LOG("Operation allowed, something is wrong.");
- } else {
- LOG("Pool is nullptr");
+
+ if (pool == nullptr) {
+ FAIL("Pool is nullptr");
}
+ LOG(" 7");
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ LOG(" 8");
+ auto regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
+ LOG("Operation allowed, something is wrong.");
+
regionPtr->create(keys[0], vals[0]);
LOG("Entry created successfully");
regionPtr->put(keys[0], nvals[0]);
@@ -526,12 +527,11 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
HANDLE_NO_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
std::shared_ptr<Region> regionPtr;
auto pool = getPool(regionNamesAuth[0]);
if (pool != nullptr) {
- virtualCache = getVirtualCache(userCreds, pool);
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
} else {
LOG("Pool is nullptr");
}
@@ -543,19 +543,16 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
HANDLE_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
- std::shared_ptr<Region> regionPtr;
auto pool = getPool(regionNamesAuth[0]);
LOG(" 6");
- if (pool != nullptr) {
- LOG(" 7");
- virtualCache = getVirtualCache(userCreds, pool);
- LOG(" 8");
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
- LOG("Operation allowed, something is wrong.");
- } else {
+ if (pool == nullptr) {
LOG("Pool is nullptr");
}
+ LOG(" 7");
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ LOG(" 8");
+ auto regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
+ LOG("Operation allowed, something is wrong.");
auto keyPtr = CacheableKey::create(keys[2]);
auto checkPtr =
std::dynamic_pointer_cast<CacheableString>(regionPtr->get(keyPtr));
@@ -577,19 +574,16 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
HANDLE_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
- std::shared_ptr<Region> regionPtr;
auto pool = getPool(regionNamesAuth[0]);
LOG(" 6");
- if (pool != nullptr) {
- LOG(" 7");
- virtualCache = getVirtualCache(userCreds, pool);
- LOG(" 8");
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
- LOG("Operation allowed, something is wrong.");
- } else {
+ if (pool == nullptr) {
LOG("Pool is nullptr");
}
+ LOG(" 7");
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ LOG(" 8");
+ auto regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
+ LOG("Operation allowed, something is wrong.");
std::vector<std::shared_ptr<CacheableKey>> entrykeys;
for (int i = 0; i < 5; i++) {
@@ -604,15 +598,14 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
HANDLE_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
std::shared_ptr<Region> regionPtr;
auto pool = getPool(regionNamesAuth[0]);
LOG(" 6");
if (pool != nullptr) {
LOG(" 7");
- virtualCache = getVirtualCache(userCreds, pool);
+ auto virtualCache = getVirtualCache(userCreds, pool);
LOG(" 8");
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
+ regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
LOG("Operation allowed, something is wrong.");
} else {
LOG("Pool is nullptr");
@@ -623,25 +616,23 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
HANDLE_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
auto pool = getPool(regionNamesAuth[0]);
- virtualCache = getVirtualCache(userCreds, pool);
- auto qs = virtualCache->getQueryService();
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ auto queryService = virtualCache.getQueryService();
char queryString[100];
sprintf(queryString, "select * from /%s", regionNamesAuth[0]);
CqAttributesFactory cqFac;
auto cqAttrs = cqFac.create();
- auto qry = qs->newCq("cq_security", queryString, cqAttrs);
- qs->executeCqs();
+ auto qry = queryService->newCq("cq_security", queryString, cqAttrs);
+ queryService->executeCqs();
FAIL("CQ should not have completed successfully");
}
HANDLE_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
auto pool = getPool(regionNamesAuth[0]);
- virtualCache = getVirtualCache(userCreds, pool);
+ auto virtualCache = getVirtualCache(userCreds, pool);
FunctionService::onServer(virtualCache)
.execute("securityTest")
@@ -650,9 +641,8 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
HANDLE_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
auto pool = getPool(regionNamesAuth[0]);
- virtualCache = getVirtualCache(userCreds, pool);
+ auto virtualCache = getVirtualCache(userCreds, pool);
FunctionService::onServers(virtualCache)
.execute("securityTest")
@@ -661,11 +651,10 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
HANDLE_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
auto pool = getPool(regionNamesAuth[0]);
- virtualCache = getVirtualCache(userCreds, pool);
+ auto virtualCache = getVirtualCache(userCreds, pool);
std::shared_ptr<Region> regionPtr;
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
+ regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
//-----------------------Test with
// sendException-------------------------------//
@@ -711,22 +700,20 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
HANDLE_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
auto pool = getPool(regionNamesAuth[0]);
- virtualCache = getVirtualCache(userCreds, pool);
+ auto virtualCache = getVirtualCache(userCreds, pool);
std::shared_ptr<Region> regionPtr;
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
+ regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
FunctionService::onRegion(regionPtr).execute("securityTest")->getResult();
}
HANDLE_NOT_AUTHORIZED_EXCEPTION
try {
- std::shared_ptr<RegionService> virtualCache;
auto pool = getPool(regionNamesAuth[0]);
- virtualCache = getVirtualCache(userCreds, pool);
+ auto virtualCache = getVirtualCache(userCreds, pool);
std::shared_ptr<Region> regionPtr;
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
+ regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
//-----------------------Test with
// sendException-------------------------------//
@@ -769,15 +756,14 @@ DUNIT_TASK_DEFINITION(WRITER_CLIENT, StepTwo)
}
HANDLE_NOT_AUTHORIZED_EXCEPTION
- std::shared_ptr<RegionService> virtualCache;
std::shared_ptr<Region> regionPtr;
auto pool = getPool(regionNamesAuth[0]);
LOG(" 6");
if (pool != nullptr) {
LOG(" 7");
- virtualCache = getVirtualCache(userCreds, pool);
+ auto virtualCache = getVirtualCache(userCreds, pool);
LOG(" 8");
- regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
+ regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
LOG("Operation allowed, something is wrong.");
} else {
LOG("Pool is nullptr");
@@ -799,19 +785,17 @@ DUNIT_TASK_DEFINITION(READER_CLIENT, StepThree)
createRegionForSecurity(regionNamesAuth[0], USE_ACK, false, nullptr, false,
-1, true, 0);
- std::shared_ptr<RegionService> virtualCache;
std::shared_ptr<Region> rptr;
auto pool = getPool(regionNamesAuth[0]);
LOG(" 6");
if (pool != nullptr) {
- LOG(" 7");
- virtualCache = getVirtualCache(userCreds, pool);
- LOG(" 8");
- rptr = virtualCache->getRegion(regionNamesAuth[0]);
- LOG("Operation allowed, something is wrong.");
- } else {
LOG("Pool is nullptr");
}
+ LOG(" 7");
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ LOG(" 8");
+ rptr = virtualCache.getRegion(regionNamesAuth[0]);
+ LOG("Operation allowed, something is wrong.");
sprintf(buf, "%s: %d", rptr->getName().c_str(), i);
auto key = CacheableKey::create(buf);
diff --git a/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
index 357e27b..a0a72bc 100644
--- a/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
@@ -20,6 +20,7 @@
#include <geode/CqListener.hpp>
#include <geode/CqQuery.hpp>
#include <geode/CqServiceStatistics.hpp>
+#include <geode/AuthenticatedView.hpp>
#include <ace/OS.h>
#include <ace/High_Res_Timer.h>
#include <string>
@@ -149,75 +150,75 @@ void initCredentialGenerator() {
FAIL("credentialGeneratorHandler is nullptr");
}
}
- std::shared_ptr<Properties> userCreds;
- void initClientCq(const bool isthinClient) {
- userCreds = Properties::create();
- auto config = Properties::create();
- // credentialGeneratorHandler->getAuthInit(config);
- credentialGeneratorHandler->getValidCredentials(userCreds);
-
- if (cacheHelper == nullptr) {
- cacheHelper = new CacheHelper(isthinClient, config);
- }
- ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
- try {
- auto serializationRegistry =
- CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
- ->getSerializationRegistry();
- serializationRegistry->addType(Position::createDeserializable);
- serializationRegistry->addType(Portfolio::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore exception
- }
- }
-
- DUNIT_TASK_DEFINITION(CLIENT1, CreateServer1)
- {
- initCredentialGenerator();
- std::string cmdServerAuthenticator;
-
- if (isLocalServer) {
- cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
- "authenticator:authorizer:authorizerPP", getXmlPath());
- printf("string %s", cmdServerAuthenticator.c_str());
- CacheHelper::initServer(
- 1, "remotequery.xml", nullptr,
- const_cast<char*>(cmdServerAuthenticator.c_str()));
- LOG("Server1 started");
- }
- }
- END_TASK_DEFINITION
-
- DUNIT_TASK_DEFINITION(CLIENT1, CreateServer2)
- {
- std::string cmdServerAuthenticator;
-
- if (isLocalServer) {
- cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
- "authenticator:authorizer:authorizerPP", getXmlPath());
- printf("string %s", cmdServerAuthenticator.c_str());
- CacheHelper::initServer(
- 2, "remotequery2.xml", nullptr,
- const_cast<char*>(cmdServerAuthenticator.c_str()));
- LOG("Server2 started");
- }
- SLEEP(20000);
- }
- END_TASK_DEFINITION
-
- void stepOne(bool pool = false, bool locator = false) {
- LOG("StepOne1 complete. 1");
- initClientCq(true);
- LOG("StepOne1 complete. 2");
- createRegionForCQMU(regionNamesCq[0], USE_ACK, true, 0, nullptr, false,
- true);
- LOG("StepOne1 complete. 3");
- auto regptr = getHelper()->getRegion(regionNamesCq[0]);
- LOG("StepOne1 complete. 4");
- LOG("StepOne1 complete. 5");
- auto subregPtr = regptr->createSubregion(regionNamesCq[1], regptr->getAttributes());
-
- LOG("StepOne complete.");
+std::shared_ptr<Properties> userCreds;
+void initClientCq(const bool isthinClient) {
+ userCreds = Properties::create();
+ auto config = Properties::create();
+ // credentialGeneratorHandler->getAuthInit(config);
+ credentialGeneratorHandler->getValidCredentials(userCreds);
+
+ if (cacheHelper == nullptr) {
+ cacheHelper = new CacheHelper(isthinClient, config);
+ }
+ ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+ try {
+ auto serializationRegistry =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
+ ->getSerializationRegistry();
+ serializationRegistry->addType(Position::createDeserializable);
+ serializationRegistry->addType(Portfolio::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore exception
+ }
+}
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateServer1)
+ {
+ initCredentialGenerator();
+ std::string cmdServerAuthenticator;
+
+ if (isLocalServer) {
+ cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
+ "authenticator:authorizer:authorizerPP", getXmlPath());
+ printf("string %s", cmdServerAuthenticator.c_str());
+ CacheHelper::initServer(
+ 1, "remotequery.xml", nullptr,
+ const_cast<char*>(cmdServerAuthenticator.c_str()));
+ LOG("Server1 started");
+ }
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateServer2)
+ {
+ std::string cmdServerAuthenticator;
+
+ if (isLocalServer) {
+ cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
+ "authenticator:authorizer:authorizerPP", getXmlPath());
+ printf("string %s", cmdServerAuthenticator.c_str());
+ CacheHelper::initServer(
+ 2, "remotequery2.xml", nullptr,
+ const_cast<char*>(cmdServerAuthenticator.c_str()));
+ LOG("Server2 started");
+ }
+ SLEEP(20000);
+ }
+END_TASK_DEFINITION
+
+void stepOne(bool pool = false, bool locator = false) {
+ LOG("StepOne1 complete. 1");
+ initClientCq(true);
+ LOG("StepOne1 complete. 2");
+ createRegionForCQMU(regionNamesCq[0], USE_ACK, true, 0, nullptr, false, true);
+ LOG("StepOne1 complete. 3");
+ auto regptr = getHelper()->getRegion(regionNamesCq[0]);
+ LOG("StepOne1 complete. 4");
+ LOG("StepOne1 complete. 5");
+ auto subregPtr =
+ regptr->createSubregion(regionNamesCq[1], regptr->getAttributes());
+
+ LOG("StepOne complete.");
}
void stepOne2(bool pool = false, bool locator = false) {
@@ -226,10 +227,11 @@ void stepOne2(bool pool = false, bool locator = false) {
LOG("StepOne2 complete. 2");
createRegionForCQMU(regionNamesCq[0], USE_ACK, true, 0, nullptr, false, true);
LOG("StepOne2 complete. 3");
- auto regptr = getHelper()->getRegion(regionNamesCq[0]);
+ auto regptr = getHelper()->getRegion(regionNamesCq[0]);
LOG("StepOne2 complete. 4");
LOG("StepOne2 complete. 5");
- auto subregPtr = regptr->createSubregion(regionNamesCq[1], regptr->getAttributes());
+ auto subregPtr =
+ regptr->createSubregion(regionNamesCq[1], regptr->getAttributes());
LOG("StepOne2 complete.");
}
@@ -244,31 +246,32 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepOne2_PoolEP)
stepOne2(true, false);
}
END_TASK_DEFINITION
- std::shared_ptr<Pool> getPool(const char* name) {
+std::shared_ptr<Pool> getPool(const char* name) {
return getHelper()->getCache()->getPoolManager().find(name);
- }
- std::shared_ptr<RegionService> getVirtualCache(
- std::shared_ptr<Properties> creds, const char* name) {
- return getHelper()->getCache()->createAuthenticatedView(creds, name);
}
-static std::shared_ptr<RegionService> userCache;
static std::shared_ptr<QueryService> userQueryService;
+AuthenticatedView setUpAuthenticatedView(const int userId) {
+ auto creds = Properties::create();
+ char tmp[25] = {'\0'};
+ sprintf(tmp, "user%d", userId);
+
+ creds->insert("security-username", tmp);
+ creds->insert("security-password", tmp);
+ return getHelper()->getCache()->createAuthenticatedView(creds,
+ regionNamesCq[0]);
+}
+
DUNIT_TASK_DEFINITION(CLIENT1, StepTwo)
{
- auto creds = Properties::create();
- char tmp[25] = {'\0'};
- sprintf(tmp, "user%d", 4);
+ auto authenticatedView = setUpAuthenticatedView(4);
- creds->insert("security-username", tmp);
- creds->insert("security-password", tmp);
+ auto regPtr0 = authenticatedView.getRegion(regionNamesCq[0]);
+ auto subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
- userCache = getVirtualCache(creds, regionNamesCq[0]);
- auto regPtr0 = userCache->getRegion(regionNamesCq[0]);
- auto subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
-
- LOG("StepTwo complete.");
+ authenticatedView.close();
+ LOG("StepTwo complete.");
}
END_TASK_DEFINITION
@@ -277,8 +280,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
uint8_t i = 0;
// QueryHelper * qh = &QueryHelper::getHelper();
// userCache = getVirtualCache(userCreds, regionNamesCq[0]);
-
- userQueryService = userCache->getQueryService();
+ auto authenticatedView = setUpAuthenticatedView(4);
+ userQueryService = authenticatedView.getQueryService();
std::shared_ptr<QueryService> qs;
qs = userQueryService;
@@ -288,10 +291,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
auto cqLstner = std::make_shared<MyCqListener>(i);
CqAttributesFactory cqFac;
cqFac.addCqListener(cqLstner);
- auto cqAttr = cqFac.create();
+ auto cqAttr = cqFac.create();
- auto qry = qs->newCq(cqNames[i], queryStrings[i], cqAttr);
- qry->execute();
+ auto qry = qs->newCq(cqNames[i], queryStrings[i], cqAttr);
+ qry->execute();
}
LOG("EXECUTE 1 START");
@@ -308,45 +311,40 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
LOG(excp.getStackTrace());
}
+ authenticatedView.close();
LOG("StepThree complete.");
}
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, StepTwo2)
{
- auto creds = Properties::create();
- char tmp[25] = {'\0'};
- sprintf(tmp, "user%d", 3);
-
- creds->insert("security-username", tmp);
- creds->insert("security-password", tmp);
-
- userCache = getVirtualCache(creds, regionNamesCq[0]);
- auto regPtr0 = userCache->getRegion(regionNamesCq[0]);
- auto subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
+ auto authenticatedView = setUpAuthenticatedView(3);
+ auto regPtr0 = authenticatedView.getRegion(regionNamesCq[0]);
+ auto subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
- QueryHelper* qh = &QueryHelper::getHelper();
+ QueryHelper* qh = &QueryHelper::getHelper();
- qh->populatePortfolioData(regPtr0, 3, 2, 1);
- qh->populatePositionData(subregPtr0, 3, 2);
- for (int i = 1; i <= 4; i++) {
- auto port = std::make_shared<Portfolio>(i, 2);
+ qh->populatePortfolioData(regPtr0, 3, 2, 1);
+ qh->populatePositionData(subregPtr0, 3, 2);
+ for (int i = 1; i <= 4; i++) {
+ auto port = std::make_shared<Portfolio>(i, 2);
- char tmp[25] = {'\0'};
- sprintf(tmp, "port1-%d", i);
- auto keyport = CacheableKey::create(tmp);
+ char tmp[25] = {'\0'};
+ sprintf(tmp, "port1-%d", i);
+ auto keyport = CacheableKey::create(tmp);
regPtr0->put(keyport, port);
SLEEP(10); // sleep a while to allow server query to complete
- }
+ }
- LOG("StepTwo2 complete. Sleeping .25 min for server query to complete...");
- SLEEP(15000); // sleep .25 min to allow server query to complete
+ LOG("StepTwo2 complete. Sleeping .25 min for server query to complete...");
+ SLEEP(15000); // sleep .25 min to allow server query to complete
+ authenticatedView.close();
}
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
{
- //auto userCache = getVirtualCache(userCreds, regionNamesCq[0]);
+ // auto userCache = getVirtualCache(userCreds, regionNamesCq[0]);
std::shared_ptr<QueryService> qs;
qs = userQueryService;
@@ -369,8 +367,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
for (i = 0; i < MAX_LISTNER; i++) {
sprintf(buf, "get info for cq[%s]:", cqNames[i]);
LOG(buf);
- auto cqy = qs->getCq(cqNames[i]);
- //auto cqStats = cqy->getStatistics();
+ auto cqy = qs->getCq(cqNames[i]);
+ // auto cqStats = cqy->getStatistics();
}
// if key port1-4 then only query 3 and 4 will satisfied
@@ -430,8 +428,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour2)
for (i = 0; i < MAX_LISTNER; i++) {
sprintf(buf, "get info for cq[%s]:", cqNames[i]);
LOG(buf);
- auto cqy = qs->getCq(cqNames[i]);
- //auto cqStats = cqy->getStatistics();
+ auto cqy = qs->getCq(cqNames[i]);
+ // auto cqStats = cqy->getStatistics();
}
// if key port1-4 then only query 3 and 4 will satisfied
@@ -465,7 +463,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour2)
//auto cqStats = cqy->getStatistics();
}*/
- userCache->close();
LOG("StepFour2 complete.");
}
END_TASK_DEFINITION
diff --git a/cppcache/integration-test/testThinClientSecurityDH_MU.cpp b/cppcache/integration-test/testThinClientSecurityDH_MU.cpp
index 81f2bde..26b42d3 100644
--- a/cppcache/integration-test/testThinClientSecurityDH_MU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityDH_MU.cpp
@@ -109,38 +109,38 @@ void initClientAuth(char credentialsType, const char* dhAlgo) {
printf("Initializing Client with %s credential and %s DH Algo\n",
credentialsType == CORRECT_CREDENTIALS ? "Valid" : "Invalid", dhAlgo);
- auto config = Properties::create();
- userCreds = Properties::create();
-
- config->insert("security-client-dhalgo", dhAlgo);
- std::string testsrc = ACE_OS::getenv("TESTSRC");
- testsrc += "/keystore/geode.pem";
- printf("KeyStore Path is: %s", testsrc.c_str());
- config->insert("security-client-kspath", testsrc.c_str());
-
- if (credentialGeneratorHandler == nullptr) {
- FAIL("credentialGeneratorHandler is nullptr");
- }
- bool insertAuthInit = true;
- switch (credentialsType) {
- case CORRECT_CREDENTIALS:
- credentialGeneratorHandler->getValidCredentials(userCreds);
- userCreds->insert("security-password",
- userCreds->find("security-username")->value().c_str());
- printf("Username is %s and Password is %s ",
- userCreds->find("security-username")->value().c_str(),
- userCreds->find("security-password")->value().c_str());
- break;
- case INCORRECT_CREDENTIALS:
- credentialGeneratorHandler->getInvalidCredentials(userCreds);
- userCreds->insert("security-password", "junk");
- printf("Username is %s and Password is %s ",
- userCreds->find("security-username")->value().c_str(),
- userCreds->find("security-password")->value().c_str());
- break;
- default:
- insertAuthInit = false;
- break;
+ auto config = Properties::create();
+ userCreds = Properties::create();
+
+ config->insert("security-client-dhalgo", dhAlgo);
+ std::string testsrc = ACE_OS::getenv("TESTSRC");
+ testsrc += "/keystore/geode.pem";
+ printf("KeyStore Path is: %s", testsrc.c_str());
+ config->insert("security-client-kspath", testsrc.c_str());
+
+ if (credentialGeneratorHandler == nullptr) {
+ FAIL("credentialGeneratorHandler is nullptr");
+ }
+ bool insertAuthInit = true;
+ switch (credentialsType) {
+ case CORRECT_CREDENTIALS:
+ credentialGeneratorHandler->getValidCredentials(userCreds);
+ userCreds->insert("security-password",
+ userCreds->find("security-username")->value().c_str());
+ printf("Username is %s and Password is %s ",
+ userCreds->find("security-username")->value().c_str(),
+ userCreds->find("security-password")->value().c_str());
+ break;
+ case INCORRECT_CREDENTIALS:
+ credentialGeneratorHandler->getInvalidCredentials(userCreds);
+ userCreds->insert("security-password", "junk");
+ printf("Username is %s and Password is %s ",
+ userCreds->find("security-username")->value().c_str(),
+ userCreds->find("security-password")->value().c_str());
+ break;
+ default:
+ insertAuthInit = false;
+ break;
}
if (insertAuthInit) {
// credentialGeneratorHandler->getAuthInit(config);
@@ -164,16 +164,16 @@ void InitIncorrectClients(const char* dhAlgo) {
try {
createRegionForSecurity(regionNamesAuth[0], USE_ACK, false, nullptr, false,
-1, true, 0);
- auto pool = getPool(regionNamesAuth[0]);
- LOG(" 6");
- if (pool != nullptr) {
- LOG(" 7");
- auto virtualCache = getVirtualCache(userCreds, pool);
- LOG(" 8");
- virtualCache->getRegion(regionNamesAuth[0])->put(keys[0], vals[0]);
- LOG("Operation allowed, something is wrong.");
- }
- FAIL("Should have thrown AuthenticationFailedException.");
+ auto pool = getPool(regionNamesAuth[0]);
+ LOG(" 6");
+ if (pool != nullptr) {
+ LOG(" 7");
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ LOG(" 8");
+ virtualCache.getRegion(regionNamesAuth[0])->put(keys[0], vals[0]);
+ LOG("Operation allowed, something is wrong.");
+ }
+ FAIL("Should have thrown AuthenticationFailedException.");
} catch (const apache::geode::client::AuthenticationFailedException& other) {
LOG(other.getStackTrace());
LOG(other.what());
@@ -195,15 +195,15 @@ void InitCorrectClients(const char* dhAlgo) {
try {
createRegionForSecurity(regionNamesAuth[0], USE_ACK, false, nullptr, false,
-1, true, 0);
- auto pool = getPool(regionNamesAuth[0]);
- LOG(" 6");
+ auto pool = getPool(regionNamesAuth[0]);
+ LOG(" 6");
- LOG(" 7");
- auto virtualCache = getVirtualCache(userCreds, pool);
- LOG(" 8");
- auto regionPtr = virtualCache->getRegion(regionNamesAuth[0]);
+ LOG(" 7");
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ LOG(" 8");
+ auto regionPtr = virtualCache.getRegion(regionNamesAuth[0]);
- for (int i = 0; i < 100; i++) regionPtr->put(keys[0], vals[0]);
+ for (int i = 0; i < 100; i++) regionPtr->put(keys[0], vals[0]);
} catch (const apache::geode::client::Exception& other) {
LOG(other.getStackTrace());
FAIL(other.what());
@@ -215,25 +215,25 @@ void DoNetSearch() {
try {
createRegionForSecurity(regionNamesAuth[1], USE_ACK, false, nullptr, false,
-1, true, 0);
- auto pool = getPool(regionNamesAuth[1]);
- LOG(" 6");
-
- LOG(" 7");
- auto virtualCache = getVirtualCache(userCreds, pool);
- LOG(" 8");
- auto regionPtr = virtualCache->getRegion(regionNamesAuth[1]);
-
- auto keyPtr = CacheableKey::create(keys[0]);
- auto checkPtr =
- std::dynamic_pointer_cast<CacheableString>(regionPtr->get(keyPtr));
- if (checkPtr != nullptr && !strcmp(vals[0], checkPtr->value().c_str())) {
- LOG("checkPtr is not null");
- char buf[1024];
- sprintf(buf, "In net search, get returned %s for key %s",
- checkPtr->value().c_str(), keys[0]);
- LOG(buf);
- } else {
- LOG("checkPtr is nullptr");
+ auto pool = getPool(regionNamesAuth[1]);
+ LOG(" 6");
+
+ LOG(" 7");
+ auto virtualCache = getVirtualCache(userCreds, pool);
+ LOG(" 8");
+ auto regionPtr = virtualCache.getRegion(regionNamesAuth[1]);
+
+ auto keyPtr = CacheableKey::create(keys[0]);
+ auto checkPtr =
+ std::dynamic_pointer_cast<CacheableString>(regionPtr->get(keyPtr));
+ if (checkPtr != nullptr && !strcmp(vals[0], checkPtr->value().c_str())) {
+ LOG("checkPtr is not null");
+ char buf[1024];
+ sprintf(buf, "In net search, get returned %s for key %s",
+ checkPtr->value().c_str(), keys[0]);
+ LOG(buf);
+ } else {
+ LOG("checkPtr is nullptr");
}
} catch (const apache::geode::client::Exception& other) {
LOG(other.getStackTrace());
diff --git a/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
index 4689a90..1e6d8fd 100644
--- a/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
@@ -20,6 +20,7 @@
#include <geode/CqListener.hpp>
#include <geode/CqQuery.hpp>
#include <geode/CqServiceStatistics.hpp>
+#include <geode/AuthenticatedView.hpp>
#include <ace/OS.h>
#include <ace/High_Res_Timer.h>
#include <string>
@@ -149,84 +150,84 @@ void initCredentialGenerator() {
FAIL("credentialGeneratorHandler is nullptr");
}
}
- std::shared_ptr<Properties> userCreds;
- const char* durableIds[] = {"DurableId1", "DurableId2"};
- void initClientCq(const bool isthinClient, int clientIdx) {
- userCreds = Properties::create();
- auto config = Properties::create();
- // credentialGeneratorHandler->getAuthInit(config);
- credentialGeneratorHandler->getValidCredentials(userCreds);
-
- config->insert("durable-client-id", durableIds[clientIdx]);
- config->insert("durable-timeout", std::chrono::seconds(60));
- config->insert("notify-ack-interval", std::chrono::seconds(1));
-
- if (cacheHelper == nullptr) {
- cacheHelper = new CacheHelper(isthinClient, config);
- }
- ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
- try {
- CacheImpl* cacheImpl =
- CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get());
- cacheImpl->getSerializationRegistry()->addType(
- Position::createDeserializable);
- cacheImpl->getSerializationRegistry()->addType(
- Portfolio::createDeserializable);
- } catch (const IllegalStateException&) {
- // ignore exception
- }
- }
-
- bool closeLogicalCache = false;
- bool logicalCacheKeepAlive = false;
- bool durableCq = false;
-
- DUNIT_TASK_DEFINITION(CLIENT1, CreateServer1)
- {
- initCredentialGenerator();
- std::string cmdServerAuthenticator;
-
- if (isLocalServer) {
- cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
- "authenticator:authorizerPP", getXmlPath());
- printf("string %s", cmdServerAuthenticator.c_str());
- CacheHelper::initServer(
- 1, "remotequery.xml", nullptr,
- const_cast<char*>(cmdServerAuthenticator.c_str()));
- LOG("Server1 started");
- }
- }
- END_TASK_DEFINITION
-
- DUNIT_TASK_DEFINITION(CLIENT1, CreateServer2)
- {
- std::string cmdServerAuthenticator;
-
- if (isLocalServer) {
- cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
- "authenticator:authorizerPP", getXmlPath());
- printf("string %s", cmdServerAuthenticator.c_str());
- CacheHelper::initServer(
- 2, "remotequery2.xml", nullptr,
- const_cast<char*>(cmdServerAuthenticator.c_str()));
- LOG("Server2 started");
- }
- SLEEP(20000);
- }
- END_TASK_DEFINITION
-
- void stepOne(bool pool = false, bool locator = false) {
- LOG("StepOne1 complete. 1");
- initClientCq(true, 0);
- LOG("StepOne1 complete. 2");
- createRegionForCQMU(regionNamesCq[0], USE_ACK, true, 0, nullptr, false,
- true);
- LOG("StepOne1 complete. 3");
- auto regptr = getHelper()->getRegion(regionNamesCq[0]);
- LOG("StepOne1 complete. 4");
- auto subregPtr = regptr->createSubregion(regionNamesCq[1], regptr->getAttributes());
-
- LOG("StepOne complete.");
+std::shared_ptr<Properties> userCreds;
+const char* durableIds[] = {"DurableId1", "DurableId2"};
+void initClientCq(const bool isthinClient, int clientIdx) {
+ userCreds = Properties::create();
+ auto config = Properties::create();
+ // credentialGeneratorHandler->getAuthInit(config);
+ credentialGeneratorHandler->getValidCredentials(userCreds);
+
+ config->insert("durable-client-id", durableIds[clientIdx]);
+ config->insert("durable-timeout", std::chrono::seconds(60));
+ config->insert("notify-ack-interval", std::chrono::seconds(1));
+
+ if (cacheHelper == nullptr) {
+ cacheHelper = new CacheHelper(isthinClient, config);
+ }
+ ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+ try {
+ CacheImpl* cacheImpl =
+ CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get());
+ cacheImpl->getSerializationRegistry()->addType(
+ Position::createDeserializable);
+ cacheImpl->getSerializationRegistry()->addType(
+ Portfolio::createDeserializable);
+ } catch (const IllegalStateException&) {
+ // ignore exception
+ }
+}
+
+bool closeLogicalCache = false;
+bool logicalCacheKeepAlive = false;
+bool durableCq = false;
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateServer1)
+ {
+ initCredentialGenerator();
+ std::string cmdServerAuthenticator;
+
+ if (isLocalServer) {
+ cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
+ "authenticator:authorizerPP", getXmlPath());
+ printf("string %s", cmdServerAuthenticator.c_str());
+ CacheHelper::initServer(
+ 1, "remotequery.xml", nullptr,
+ const_cast<char*>(cmdServerAuthenticator.c_str()));
+ LOG("Server1 started");
+ }
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateServer2)
+ {
+ std::string cmdServerAuthenticator;
+
+ if (isLocalServer) {
+ cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
+ "authenticator:authorizerPP", getXmlPath());
+ printf("string %s", cmdServerAuthenticator.c_str());
+ CacheHelper::initServer(
+ 2, "remotequery2.xml", nullptr,
+ const_cast<char*>(cmdServerAuthenticator.c_str()));
+ LOG("Server2 started");
+ }
+ SLEEP(20000);
+ }
+END_TASK_DEFINITION
+
+void stepOne(bool pool = false, bool locator = false) {
+ LOG("StepOne1 complete. 1");
+ initClientCq(true, 0);
+ LOG("StepOne1 complete. 2");
+ createRegionForCQMU(regionNamesCq[0], USE_ACK, true, 0, nullptr, false, true);
+ LOG("StepOne1 complete. 3");
+ auto regptr = getHelper()->getRegion(regionNamesCq[0]);
+ LOG("StepOne1 complete. 4");
+ auto subregPtr =
+ regptr->createSubregion(regionNamesCq[1], regptr->getAttributes());
+
+ LOG("StepOne complete.");
}
void readyForEvents() {
@@ -244,9 +245,10 @@ void stepOne2(bool pool = false, bool locator = false) {
LOG("StepOne2 complete. 2");
createRegionForCQMU(regionNamesCq[0], USE_ACK, true, 0, nullptr, false, true);
LOG("StepOne2 complete. 3");
- auto regptr = getHelper()->getRegion(regionNamesCq[0]);
+ auto regptr = getHelper()->getRegion(regionNamesCq[0]);
LOG("StepOne2 complete. 4");
- auto subregPtr = regptr->createSubregion(regionNamesCq[1], regptr->getAttributes());
+ auto subregPtr =
+ regptr->createSubregion(regionNamesCq[1], regptr->getAttributes());
LOG("StepOne2 complete.");
}
@@ -261,36 +263,40 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepOne2_PoolEP)
stepOne2(true, false);
}
END_TASK_DEFINITION
- std::shared_ptr<Pool> getPool(const char* name) {
+
+std::shared_ptr<Pool> getPool(const char* name) {
return getHelper()->getCache()->getPoolManager().find(name);
- }
- std::shared_ptr<RegionService> getVirtualCache(
- std::shared_ptr<Properties> creds, const char* name) {
- return getHelper()->getCache()->createAuthenticatedView(creds, name);
}
-static std::shared_ptr<RegionService> userCache;
+AuthenticatedView setUpAuthenticatedView(const int userId) {
+ auto creds = Properties::create();
+ char tmp[25] = {'\0'};
+ sprintf(tmp, "user%d", userId);
+
+ creds->insert("security-username", tmp);
+ creds->insert("security-password", tmp);
+ return getHelper()->getCache()->createAuthenticatedView(creds,
+ regionNamesCq[0]);
+}
+
static std::shared_ptr<QueryService> userQueryService;
DUNIT_TASK_DEFINITION(CLIENT1, StepTwo)
{
- auto creds = Properties::create();
- char tmp[25] = {'\0'};
- sprintf(tmp, "user%d", 4);
+ auto authenticatedView = setUpAuthenticatedView(4);
+ auto regPtr0 = authenticatedView.getRegion(regionNamesCq[0]);
+ auto subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
- creds->insert("security-username", tmp);
- creds->insert("security-password", tmp);
-
- userCache = getVirtualCache(creds, regionNamesCq[0]);
- auto regPtr0 = userCache->getRegion(regionNamesCq[0]);
- auto subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
+ // QueryHelper * qh = &QueryHelper::getHelper();
- // QueryHelper * qh = &QueryHelper::getHelper();
+ // qh->populatePortfolioData(regPtr0 , 2, 1, 1);
+ // qh->populatePositionData(subregPtr0, 2, 1);
- // qh->populatePortfolioData(regPtr0 , 2, 1, 1);
- // qh->populatePositionData(subregPtr0, 2, 1);
+ if (closeLogicalCache) {
+ authenticatedView.close();
+ }
- LOG("StepTwo complete.");
+ LOG("StepTwo complete.");
}
END_TASK_DEFINITION
@@ -304,7 +310,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
// QueryHelper * qh = &QueryHelper::getHelper();
// userCache = getVirtualCache(userCreds, regionNamesCq[0]);
- userQueryService = userCache->getQueryService();
+ auto authenticatedView = setUpAuthenticatedView(4);
+ userQueryService = authenticatedView.getQueryService();
+
std::shared_ptr<QueryService> qs;
qs = userQueryService;
@@ -314,7 +322,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
auto cqLstner = std::make_shared<MyCqListener>(i);
CqAttributesFactory cqFac;
cqFac.addCqListener(cqLstner);
- auto cqAttr = cqFac.create();
+ auto cqAttr = cqFac.create();
printf("adding new cq = %s , %d", cqNames[i], durableCq);
auto qry = qs->newCq(cqNames[i], queryStrings[i], cqAttr, durableCq);
qry->execute();
@@ -334,6 +342,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
LOG(excp.getStackTrace().c_str());
}
+ if (closeLogicalCache) {
+ authenticatedView.close();
+ }
+
LOG("StepThree complete.");
}
END_TASK_DEFINITION
@@ -348,39 +360,36 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT2, StepTwo2)
{
- auto creds = Properties::create();
- char tmp[25] = {'\0'};
- sprintf(tmp, "user%d", 3);
-
- creds->insert("security-username", tmp);
- creds->insert("security-password", tmp);
-
- userCache = getVirtualCache(creds, regionNamesCq[0]);
- auto regPtr0 = userCache->getRegion(regionNamesCq[0]);
- auto subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
+ auto authenticatedView = setUpAuthenticatedView(3);
+ auto regPtr0 = authenticatedView.getRegion(regionNamesCq[0]);
+ auto subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
- QueryHelper* qh = &QueryHelper::getHelper();
+ QueryHelper* qh = &QueryHelper::getHelper();
- qh->populatePortfolioData(regPtr0, 3, 2, 1);
- qh->populatePositionData(subregPtr0, 3, 2);
- for (int i = 1; i <= 4; i++) {
- auto port = std::make_shared<Portfolio>(i, 2);
+ qh->populatePortfolioData(regPtr0, 3, 2, 1);
+ qh->populatePositionData(subregPtr0, 3, 2);
+ for (int i = 1; i <= 4; i++) {
+ auto port = std::make_shared<Portfolio>(i, 2);
- char tmp[25] = {'\0'};
- sprintf(tmp, "port1-%d", i);
- auto keyport = CacheableKey::create(tmp);
+ char tmp[25] = {'\0'};
+ sprintf(tmp, "port1-%d", i);
+ auto keyport = CacheableKey::create(tmp);
regPtr0->put(keyport, port);
SLEEP(10); // sleep a while to allow server query to complete
- }
+ }
+
+ LOG("StepTwo2 complete. Sleeping .25 min for server query to complete...");
+ SLEEP(15000); // sleep .25 min to allow server query to complete
- LOG("StepTwo2 complete. Sleeping .25 min for server query to complete...");
- SLEEP(15000); // sleep .25 min to allow server query to complete
+ if (closeLogicalCache) {
+ authenticatedView.close();
+ }
}
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
{
- //auto userCache = getVirtualCache(userCreds, regionNamesCq[0]);
+ // auto userCache = getVirtualCache(userCreds, regionNamesCq[0]);
auto qs = userQueryService;
char buf[1024];
@@ -400,8 +409,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
for (i = 0; i < MAX_LISTNER; i++) {
sprintf(buf, "get info for cq[%s]:", cqNames[i]);
LOG(buf);
- auto cqy = qs->getCq(cqNames[i]);
- //auto cqStats = cqy->getStatistics();
+ auto cqy = qs->getCq(cqNames[i]);
+ // auto cqStats = cqy->getStatistics();
}
// if key port1-4 then only query 3 and 4 will satisfied
@@ -425,7 +434,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
ASSERT(cqListener_4->getNumInserts() == 1,
"incorrect number of events got listener 4");
- if (closeLogicalCache) userCache->close();
LOG("StepFour complete.");
}
END_TASK_DEFINITION
@@ -433,8 +441,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepFour2)
{
SLEEP(15000); // sleep .25 min
- //auto userCache = getVirtualCache(userCreds, regionNamesCq[0]);
- userQueryService = userCache->getQueryService();
+ // auto userCache = getVirtualCache(userCreds, regionNamesCq[0]);
+
+ auto authenticatedView = setUpAuthenticatedView(4);
+ userQueryService = authenticatedView.getQueryService();
auto qs = userQueryService;
char buf[1024];
@@ -454,8 +464,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour2)
for (i = 0; i < MAX_LISTNER; i++) {
sprintf(buf, "get info for cq[%s]:", cqNames[i]);
LOG(buf);
- auto cqy = qs->getCq(cqNames[i]);
- //auto cqStats = cqy->getStatistics();
+ auto cqy = qs->getCq(cqNames[i]);
+ // auto cqStats = cqy->getStatistics();
}
if ((durableCq && !logicalCacheKeepAlive && !closeLogicalCache) ||
@@ -516,7 +526,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour2)
//auto cqStats = cqy->getStatistics();
}*/
- userCache->close();
+ if (closeLogicalCache) {
+ authenticatedView.close();
+ }
LOG("StepFour2 complete.");
}
END_TASK_DEFINITION
@@ -596,10 +608,10 @@ void doThinClientCq(bool poolConfig = false, bool poolLocators = false) {
} else if (i == 1) // no durable CQ
{
CALL_TASK(NodurableCQ); // this should not get events
- } else if (i == 2) // ProxyCache.close(true)
+ } else if (i == 2) // AuthenticatedView.close(true)
{
CALL_TASK(LogicalCacheTrueAnddurableCQ); // this should get events
- } else if (i == 3) // ProxyCache.close(false)
+ } else if (i == 3) // AuthenticatedView.close(false)
{
CALL_TASK(LogicalCacheFalseAnddurableCQ); // this should not get events
}
diff --git a/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp b/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
index dd8af43..ffc0a60 100644
--- a/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
+++ b/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
@@ -61,7 +61,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, PerformSecureOperationsWithUserCredentials)
config1->insert("security-password", "root-password");
cache.createAuthenticatedView(config1, "mypool")
- ->getRegion("DistRegionAck")
+ .getRegion("DistRegionAck")
->put("akey", "avalue");
auto config2 = Properties::create();
@@ -70,7 +70,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, PerformSecureOperationsWithUserCredentials)
try {
cache.createAuthenticatedView(config2, "mypool")
- ->getRegion("DistRegionAck")
+ .getRegion("DistRegionAck")
->put("akey", "avalue");
FAIL("Didn't throw expected AuthenticationFailedException.");
} catch (const apache::geode::client::NotAuthorizedException&) {
diff --git a/cppcache/integration-test/testXmlCacheCreationWithPools.cpp b/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
index af8ce4d..8352cbd 100644
--- a/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
+++ b/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
@@ -24,7 +24,6 @@
#include <geode/internal/chrono/duration.hpp>
#define CLIENT1 s1p1
-#define CLIENT2 s1p2
#define SERVER1 s2p1
#define SERVER2 s2p2
@@ -472,75 +471,6 @@ int testXmlCacheCreationWithPools() {
return 0;
}
-int testXmlDeclarativeCacheCreation() {
- char* host_name = (char*)"XML_DECLARATIVE_CACHE_CREATION_TEST";
- auto cacheFactory = CacheFactory();
- std::shared_ptr<Cache> cptr;
-
- std::string directory(ACE_OS::getenv("TESTSRC"));
-
- std::cout << "create DistributedSytem with name=" << host_name << std::endl;
-
- try {
- const auto filePath =
- directory + "/resources/valid_declarative_cache_creation.xml";
- cptr = std::make_shared<Cache>(
- cacheFactory.set("cache-xml-file", filePath).create());
-
- } catch (Exception& ex) {
- std::cout << "Exception: msg = " << ex.what() << std::endl;
- LOG(ex.getStackTrace());
- return -1;
- } catch (...) {
- LOGINFO("unknown exception");
- return -1;
- }
-
- std::cout << "Test if number of root regions are correct" << std::endl;
- auto vrp = cptr->rootRegions();
- std::cout << " vrp.size=" << vrp.size() << std::endl;
-
- if (vrp.size() != 1) {
- std::cout << "Number of root regions does not match" << std::endl;
- return -1;
- }
-
- std::cout << "Root regions in Cache :" << std::endl;
- for (int32_t i = 0; i < vrp.size(); i++) {
- std::cout << "vc[" << i << "].m_reaPtr=" << vrp.at(i).get() << std::endl;
- std::cout << "vc[" << i << "]=" << vrp.at(i)->getName() << std::endl;
- }
- auto regPtr1 = vrp.at(0);
-
- auto regionAttributes = regPtr1->getAttributes();
- std::cout << "Test Attributes of root region Root1 " << std::endl;
- std::cout << "Region name " << regPtr1->getName() << std::endl;
-
- if (regionAttributes.getCacheLoader() == nullptr) {
- std::cout << "Cache Loader not initialized." << std::endl;
- return -1;
- }
-
- if (regionAttributes.getCacheListener() == nullptr) {
- std::cout << "Cache Listener not initialized." << std::endl;
- return -1;
- }
-
- if (regionAttributes.getCacheWriter() == nullptr) {
- std::cout << "Cache Writer not initialized." << std::endl;
- return -1;
- }
-
- std::cout << "Attributes of Root1 are correctly set" << std::endl;
-
- if (!cptr->isClosed()) {
- cptr->close();
- cptr = nullptr;
- }
-
- return 0;
-}
-
DUNIT_TASK_DEFINITION(CLIENT1, ValidXmlTestPools)
{
CacheHelper::initLocator(1);
@@ -562,18 +492,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, ValidXmlTestPools)
}
END_TASK_DEFINITION
-DUNIT_TASK_DEFINITION(CLIENT1, ValidXmlTestDeclarativeCacheCreation)
- {
- int res = testXmlDeclarativeCacheCreation();
- if (res != 0) {
- FAIL("DeclarativeCacheCreation Test Failed.");
- }
- }
-END_TASK_DEFINITION
-
DUNIT_MAIN
- {
- CALL_TASK(ValidXmlTestPools);
- CALL_TASK(ValidXmlTestDeclarativeCacheCreation);
- }
+ { CALL_TASK(ValidXmlTestPools); }
END_MAIN
diff --git a/cppcache/integration-test/testXmlCacheInitialization.cpp b/cppcache/integration-test/testXmlCacheInitialization.cpp
new file mode 100644
index 0000000..5460b34
--- /dev/null
+++ b/cppcache/integration-test/testXmlCacheInitialization.cpp
@@ -0,0 +1,188 @@
+/*
+ * 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 <string>
+#include <iostream>
+#include <vector>
+
+#include "fw_dunit.hpp"
+
+#include <geode/internal/chrono/duration.hpp>
+
+#define CLIENT1 s1p1
+#define SERVER1 s2p1
+#define SERVER2 s2p2
+
+#include "CacheHelper.hpp"
+
+static bool isLocalServer = false;
+static bool isLocator = false;
+static int numberOfLocators = 1;
+const char* endPoints = (const char*)nullptr;
+const char* locatorsG =
+ CacheHelper::getLocatorHostPort(isLocator, isLocalServer, numberOfLocators);
+
+#include "LocatorHelper.hpp"
+
+using namespace apache::geode::client;
+using namespace test;
+using namespace std;
+
+int testXmlDeclarativeCacheCreation() {
+ char* host_name = (char*)"XML_DECLARATIVE_CACHE_CREATION_TEST";
+ auto cacheFactory = CacheFactory();
+ std::shared_ptr<Cache> cptr;
+
+ std::string directory(ACE_OS::getenv("TESTSRC"));
+
+ std::cout << "create DistributedSytem with name=" << host_name << std::endl;
+
+ try {
+ const auto filePath =
+ directory + "/resources/valid_declarative_cache_creation.xml";
+ cptr = std::make_shared<Cache>(
+ cacheFactory.set("cache-xml-file", filePath).create());
+
+ } catch (Exception& ex) {
+ std::cout << "Exception: msg = " << ex.what() << std::endl;
+ LOG(ex.getStackTrace());
+ return -1;
+ } catch (...) {
+ LOGINFO("unknown exception");
+ return -1;
+ }
+
+ std::cout << "Test if number of root regions are correct" << std::endl;
+ auto vrp = cptr->rootRegions();
+ std::cout << " vrp.size=" << vrp.size() << std::endl;
+
+ if (vrp.size() != 1) {
+ std::cout << "Number of root regions does not match" << std::endl;
+ return -1;
+ }
+
+ std::cout << "Root regions in Cache :" << std::endl;
+ for (int32_t i = 0; i < vrp.size(); i++) {
+ std::cout << "vc[" << i << "].m_reaPtr=" << vrp.at(i).get() << std::endl;
+ std::cout << "vc[" << i << "]=" << vrp.at(i)->getName() << std::endl;
+ }
+ auto regPtr1 = vrp.at(0);
+
+ auto regionAttributes = regPtr1->getAttributes();
+ std::cout << "Test Attributes of root region Root1 " << std::endl;
+ std::cout << "Region name " << regPtr1->getName() << std::endl;
+
+ if (regionAttributes.getCacheLoader() == nullptr) {
+ std::cout << "Cache Loader not initialized." << std::endl;
+ return -1;
+ }
+
+ if (regionAttributes.getCacheListener() == nullptr) {
+ std::cout << "Cache Listener not initialized." << std::endl;
+ return -1;
+ }
+
+ if (regionAttributes.getCacheWriter() == nullptr) {
+ std::cout << "Cache Writer not initialized." << std::endl;
+ return -1;
+ }
+
+ std::cout << "Attributes of Root1 are correctly set" << std::endl;
+
+ if (!cptr->isClosed()) {
+ cptr->close();
+ cptr = nullptr;
+ }
+
+ return 0;
+}
+
+int testSetCacheXmlThenGetRegion() {
+ auto cacheFactory = CacheFactory();
+ std::shared_ptr<Cache> cptr;
+
+ std::cout
+ << "Create cache with the configurations provided in valid_cache_pool.xml"
+ << std::endl;
+
+ try {
+ std::string filePath = "valid_cache_pool.xml";
+ std::string duplicateFile;
+ CacheHelper::createDuplicateXMLFile(duplicateFile, filePath);
+
+ cptr = std::make_shared<Cache>(
+ cacheFactory.set("enable-time-statistics", "false")
+ .set("statistic-sampling-enabled", "false")
+ .set("cache-xml-file", duplicateFile)
+ .create());
+
+ } catch (Exception& ex) {
+ std::cout << "Exception: msg = " << ex.what() << std::endl;
+ LOG(ex.getStackTrace());
+ return -1;
+ } catch (...) {
+ LOGINFO("unknown exception");
+ return -1;
+ }
+
+ auto region = cptr->getRegion("Root1");
+
+ if (region == nullptr || region->getName() != "Root1") {
+ return -1;
+ }
+
+ return 0;
+}
+
+DUNIT_TASK_DEFINITION(CLIENT1, ValidXmlTestDeclarativeCacheCreation)
+ {
+ int res = testXmlDeclarativeCacheCreation();
+
+ if (res != 0) {
+ FAIL("DeclarativeCacheCreation Test Failed.");
+ }
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, SetCacheXmlThenGetRegion)
+ {
+ // Reusing server setup from ValidXmlTestPools for simplicity
+ CacheHelper::initLocator(1);
+ char tmp[128];
+ sprintf(tmp, "localhost:%d", CacheHelper::staticLocatorHostPort1);
+ CacheHelper::initServer(1, "cacheserver1_pool.xml", tmp);
+ CacheHelper::initServer(2, "cacheserver2_pool.xml", tmp);
+
+ int res = testSetCacheXmlThenGetRegion();
+
+ CacheHelper::closeServer(1);
+ CacheHelper::closeServer(2);
+
+ CacheHelper::closeLocator(1);
+
+ if (res != 0) {
+ FAIL("SetCacheXmlThenGetRegion Test Failed.");
+ }
+ }
+END_TASK_DEFINITION
+
+DUNIT_MAIN
+ {
+ CALL_TASK(ValidXmlTestDeclarativeCacheCreation);
+ CALL_TASK(SetCacheXmlThenGetRegion);
+ }
+END_MAIN
diff --git a/cppcache/src/ProxyCache.cpp b/cppcache/src/AuthenticatedView.cpp
similarity index 69%
rename from cppcache/src/ProxyCache.cpp
rename to cppcache/src/AuthenticatedView.cpp
index dd6d72a..6acf9cf 100644
--- a/cppcache/src/ProxyCache.cpp
+++ b/cppcache/src/AuthenticatedView.cpp
@@ -28,7 +28,7 @@
#include <geode/FunctionService.hpp>
#include "ProxyRemoteQueryService.hpp"
#include "FunctionServiceImpl.hpp"
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
#include <string>
#include <geode/PoolManager.hpp>
#include "ThinClientPoolDM.hpp"
@@ -44,7 +44,7 @@ using namespace apache::geode::client;
*
* @return true, if this cache is closed; false, otherwise
*/
-bool ProxyCache::isClosed() const { return m_isProxyCacheClosed; }
+bool AuthenticatedView::isClosed() const { return m_isAuthenticatedViewClosed; }
/**
* Terminates this object cache and releases all the local resources.
@@ -54,17 +54,18 @@ bool ProxyCache::isClosed() const { return m_isProxyCacheClosed; }
* @param keepalive whether to keep the durable client's queue
* @throws CacheClosedException, if the cache is already closed.
*/
-void ProxyCache::close() {
- LOGDEBUG("ProxyCache::close: isProxyCacheClosed = %d", m_isProxyCacheClosed);
- if (!m_isProxyCacheClosed) {
+void AuthenticatedView::close() {
+ LOGDEBUG("AuthenticatedView::close: isAuthenticatedViewClosed = %d",
+ m_isAuthenticatedViewClosed);
+ if (!m_isAuthenticatedViewClosed) {
if (m_remoteQueryService != nullptr) {
ProxyRemoteQueryService* prqs =
static_cast<ProxyRemoteQueryService*>(m_remoteQueryService.get());
prqs->closeCqs(false);
}
- GuardUserAttribures gua(this);
- m_isProxyCacheClosed = true;
+ GuardUserAttributes gua(this);
+ m_isAuthenticatedViewClosed = true;
m_userAttributes->unSetCredentials();
// send message to server
auto userAttachedPool = m_userAttributes->getPool();
@@ -80,10 +81,11 @@ void ProxyCache::close() {
}
throw IllegalStateException("User cache has been closed.");
}
-std::shared_ptr<Region> ProxyCache::getRegion(const std::string& path) const {
- LOGDEBUG("ProxyCache::getRegion:");
+std::shared_ptr<Region> AuthenticatedView::getRegion(
+ const std::string& path) const {
+ LOGDEBUG("AuthenticatedView::getRegion:");
- if (!m_isProxyCacheClosed) {
+ if (!m_isAuthenticatedViewClosed) {
std::shared_ptr<Region> result;
if (m_cacheImpl != nullptr && !m_cacheImpl->isClosed()) {
@@ -91,18 +93,18 @@ std::shared_ptr<Region> ProxyCache::getRegion(const std::string& path) const {
}
if (result != nullptr) {
- auto userAttachedPool = m_userAttributes->getPool();
- auto pool = m_cacheImpl->getCache()->getPoolManager().find(
- result->getAttributes().getPoolName());
- if (pool != nullptr && pool.get() == userAttachedPool.get() &&
- !pool->isDestroyed()) {
- return std::make_shared<ProxyRegion>(
- std::const_pointer_cast<ProxyCache>(shared_from_this()),
- std::static_pointer_cast<RegionInternal>(result));
- }
- throw IllegalArgumentException(
- "The Region argument is not attached with the pool, which used to "
- "create this user cache.");
+ auto userAttachedPool = m_userAttributes->getPool();
+ auto pool = m_cacheImpl->getCache()->getPoolManager().find(
+ result->getAttributes().getPoolName());
+ if (pool != nullptr && pool.get() == userAttachedPool.get() &&
+ !pool->isDestroyed()) {
+ return std::make_shared<ProxyRegion>(
+ const_cast<AuthenticatedView&>(*this),
+ std::static_pointer_cast<RegionInternal>(result));
+ }
+ throw IllegalArgumentException(
+ "The Region argument is not attached with the pool, which used to "
+ "create this user cache.");
}
return result;
@@ -118,23 +120,22 @@ std::shared_ptr<Region> ProxyCache::getRegion(const std::string& path) const {
* @param regions the region collection object containing the returned set of
* regions when the function returns
*/
-std::shared_ptr<QueryService> ProxyCache::getQueryService() {
- if (!m_isProxyCacheClosed) {
+std::shared_ptr<QueryService> AuthenticatedView::getQueryService() {
+ if (!m_isAuthenticatedViewClosed) {
if (m_remoteQueryService != nullptr) return m_remoteQueryService;
- auto prqsPtr =
- std::make_shared<ProxyRemoteQueryService>(this->shared_from_this());
+ auto prqsPtr = std::make_shared<ProxyRemoteQueryService>(this);
m_remoteQueryService = prqsPtr;
return prqsPtr;
}
throw IllegalStateException("User cache has been closed.");
}
-std::vector<std::shared_ptr<Region>> ProxyCache::rootRegions() const {
- LOGDEBUG("ProxyCache::rootRegions:");
+std::vector<std::shared_ptr<Region>> AuthenticatedView::rootRegions() const {
+ LOGDEBUG("AuthenticatedView::rootRegions:");
std::vector<std::shared_ptr<Region>> regions;
- if (!m_isProxyCacheClosed && m_cacheImpl && !m_cacheImpl->isClosed()) {
+ if (!m_isAuthenticatedViewClosed && m_cacheImpl && !m_cacheImpl->isClosed()) {
std::vector<std::shared_ptr<Region>> tmp;
// this can cause issue when pool attached with region in multiuserSecure
@@ -146,7 +147,7 @@ std::vector<std::shared_ptr<Region>> ProxyCache::rootRegions() const {
if (m_userAttributes->getPool()->getName() ==
reg->getAttributes().getPoolName()) {
auto pRegion = std::make_shared<ProxyRegion>(
- std::const_pointer_cast<ProxyCache>(shared_from_this()),
+ const_cast<AuthenticatedView&>(*this),
std::static_pointer_cast<RegionInternal>(reg));
regions.push_back(pRegion);
}
@@ -156,21 +157,22 @@ std::vector<std::shared_ptr<Region>> ProxyCache::rootRegions() const {
return regions;
}
-ProxyCache::ProxyCache(std::shared_ptr<Properties> credentials,
- std::shared_ptr<Pool> pool, CacheImpl* cacheImpl)
+AuthenticatedView::AuthenticatedView(std::shared_ptr<Properties> credentials,
+ std::shared_ptr<Pool> pool,
+ CacheImpl* cacheImpl)
: m_remoteQueryService(nullptr),
- m_isProxyCacheClosed(false),
+ m_isAuthenticatedViewClosed(false),
m_userAttributes(
std::make_shared<UserAttributes>(credentials, pool, this)),
m_cacheImpl(cacheImpl) {}
-ProxyCache::~ProxyCache() {}
-std::shared_ptr<PdxInstanceFactory> ProxyCache::createPdxInstanceFactory(
+AuthenticatedView::~AuthenticatedView() {}
+std::shared_ptr<PdxInstanceFactory> AuthenticatedView::createPdxInstanceFactory(
std::string className) const {
return std::make_shared<PdxInstanceFactoryImpl>(
className.c_str(), &(m_cacheImpl->getCachePerfStats()),
- m_cacheImpl->getPdxTypeRegistry(), m_cacheImpl->getCache(),
+ m_cacheImpl->getPdxTypeRegistry(), m_cacheImpl,
m_cacheImpl->getDistributedSystem()
.getSystemProperties()
.getEnableTimeStatistics());
- }
+}
diff --git a/cppcache/src/Cache.cpp b/cppcache/src/Cache.cpp
index 3f2ee57..3315f43 100644
--- a/cppcache/src/Cache.cpp
+++ b/cppcache/src/Cache.cpp
@@ -151,6 +151,15 @@ Cache::Cache(Cache&& other) noexcept
m_cacheImpl->setCache(this);
}
+Cache& Cache::operator=(Cache&& other) noexcept {
+ if (this != &other) {
+ m_cacheImpl = std::move(other.m_cacheImpl);
+ m_typeRegistry = std::move(other.m_typeRegistry);
+ m_cacheImpl->setCache(this);
+ }
+ return *this;
+}
+
Cache::~Cache() = default;
void Cache::initializeDeclarativeCache(const std::string& cacheXml) {
@@ -187,19 +196,19 @@ std::shared_ptr<PdxInstanceFactory> Cache::createPdxInstanceFactory(
std::string className) const {
return std::make_shared<PdxInstanceFactoryImpl>(
className.c_str(), m_cacheImpl->m_cacheStats,
- m_cacheImpl->getPdxTypeRegistry(), this,
+ m_cacheImpl->getPdxTypeRegistry(), m_cacheImpl.get(),
m_cacheImpl->getDistributedSystem()
.getSystemProperties()
.getEnableTimeStatistics());
}
-std::shared_ptr<RegionService> Cache::createAuthenticatedView(
+AuthenticatedView Cache::createAuthenticatedView(
std::shared_ptr<Properties> userSecurityProperties,
const std::string& poolName) {
if (poolName.empty()) {
auto pool = m_cacheImpl->getPoolManager().getDefaultPool();
if (!this->isClosed() && pool != nullptr) {
- return pool->createSecureUserCache(userSecurityProperties,
- m_cacheImpl.get());
+ return pool->createAuthenticatedView(userSecurityProperties,
+ m_cacheImpl.get());
}
throw IllegalStateException(
@@ -210,8 +219,8 @@ std::shared_ptr<RegionService> Cache::createAuthenticatedView(
if (!poolName.empty()) {
auto poolPtr = m_cacheImpl->getPoolManager().find(poolName);
if (poolPtr != nullptr && !poolPtr->isDestroyed()) {
- return poolPtr->createSecureUserCache(userSecurityProperties,
- m_cacheImpl.get());
+ return poolPtr->createAuthenticatedView(userSecurityProperties,
+ m_cacheImpl.get());
}
throw IllegalStateException(
"Either pool not found or it has been destroyed");
@@ -221,7 +230,6 @@ std::shared_ptr<RegionService> Cache::createAuthenticatedView(
throw IllegalStateException("Cache has been closed");
}
- return nullptr;
}
PoolManager& Cache::getPoolManager() const {
diff --git a/cppcache/src/CacheImpl.cpp b/cppcache/src/CacheImpl.cpp
index 38e4718..06852db 100644
--- a/cppcache/src/CacheImpl.cpp
+++ b/cppcache/src/CacheImpl.cpp
@@ -381,7 +381,7 @@ void CacheImpl::createRegion(
auto csptr = std::make_shared<CacheStatistics>();
try {
- rpImpl = createRegion_internal(name.c_str(), nullptr, regionAttributes,
+ rpImpl = createRegion_internal(name, nullptr, regionAttributes,
csptr, false);
} catch (const AuthenticationFailedException&) {
throw;
diff --git a/cppcache/src/CacheImpl.hpp b/cppcache/src/CacheImpl.hpp
index 28c97fa..21bd643 100644
--- a/cppcache/src/CacheImpl.hpp
+++ b/cppcache/src/CacheImpl.hpp
@@ -278,7 +278,7 @@ class _GEODE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
std::shared_ptr<SerializationRegistry> getSerializationRegistry() const;
inline CachePerfStats& getCachePerfStats() { return *m_cacheStats; }
- PoolManager& getPoolManager() { return *m_poolManager; }
+ PoolManager& getPoolManager() const { return *m_poolManager; }
ThreadPool* getThreadPool();
diff --git a/cppcache/src/CacheRegionHelper.cpp b/cppcache/src/CacheRegionHelper.cpp
index a685d11..c4b4823 100644
--- a/cppcache/src/CacheRegionHelper.cpp
+++ b/cppcache/src/CacheRegionHelper.cpp
@@ -17,7 +17,7 @@
#include "CacheRegionHelper.hpp"
#include "CacheImpl.hpp"
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
namespace apache {
namespace geode {
@@ -27,13 +27,13 @@ CacheImpl* CacheRegionHelper::getCacheImpl(const Cache* cache) {
return cache->m_cacheImpl.get();
}
-CacheImpl* CacheRegionHelper::getCacheImpl(const ProxyCache* proxyCache) {
- return proxyCache->m_cacheImpl;
+CacheImpl* CacheRegionHelper::getCacheImpl(const AuthenticatedView* authenticatedView) {
+ return authenticatedView->m_cacheImpl;
}
CacheImpl* CacheRegionHelper::getCacheImpl(const RegionService* regionService) {
- if (const auto proxyCache = dynamic_cast<const ProxyCache*>(regionService)) {
- return getCacheImpl(proxyCache);
+ if (const auto authenticatedView = dynamic_cast<const AuthenticatedView*>(regionService)) {
+ return getCacheImpl(authenticatedView);
}
if (const auto cache = dynamic_cast<const Cache*>(regionService)) {
diff --git a/cppcache/src/CacheRegionHelper.hpp b/cppcache/src/CacheRegionHelper.hpp
index 77cafad..70692f0 100644
--- a/cppcache/src/CacheRegionHelper.hpp
+++ b/cppcache/src/CacheRegionHelper.hpp
@@ -28,7 +28,7 @@ namespace geode {
namespace client {
class CacheImpl;
-class ProxyCache;
+class AuthenticatedView;
class _GEODE_EXPORT CacheRegionHelper {
/**
@@ -37,7 +37,7 @@ class _GEODE_EXPORT CacheRegionHelper {
*/
public:
static CacheImpl* getCacheImpl(const Cache* cache);
- static CacheImpl* getCacheImpl(const ProxyCache* cache);
+ static CacheImpl* getCacheImpl(const AuthenticatedView* authenticatedView);
static CacheImpl* getCacheImpl(const RegionService* cache);
};
} // namespace client
diff --git a/cppcache/src/CacheTransactionManagerImpl.cpp b/cppcache/src/CacheTransactionManagerImpl.cpp
index 537d9bd..8ca2222 100644
--- a/cppcache/src/CacheTransactionManagerImpl.cpp
+++ b/cppcache/src/CacheTransactionManagerImpl.cpp
@@ -44,14 +44,14 @@ void CacheTransactionManagerImpl::begin() {
GfErrTypeThrowException("Transaction already in progress",
GF_CACHE_ILLEGAL_STATE_EXCEPTION);
}
- TXState* txState = new TXState(m_cache->getCache());
+ auto txState = new TXState(m_cache);
TSSTXStateWrapper::s_geodeTSSTXState->setTXState(txState);
addTx(txState->getTransactionId().getId());
}
void CacheTransactionManagerImpl::commit() {
TXCleaner txCleaner(this);
- TXState* txState = txCleaner.getTXState();
+ auto txState = txCleaner.getTXState();
if (txState == nullptr) {
GfErrTypeThrowException(
@@ -59,10 +59,10 @@ void CacheTransactionManagerImpl::commit() {
GF_CACHE_ILLEGAL_STATE_EXCEPTION);
}
- TcrMessageCommit request(m_cache->getCache()->createDataOutput());
+ TcrMessageCommit request(m_cache->createDataOutput());
TcrMessageReply reply(true, nullptr);
- ThinClientPoolDM* tcr_dm = getDM();
+ auto tcr_dm = getDM();
// This is for the case when no cache operation/s is performed between
// tx->begin() and tx->commit()/rollback(),
// simply return without sending COMMIT message to server. tcr_dm is nullptr
@@ -358,9 +358,8 @@ TransactionId& CacheTransactionManagerImpl::suspend() {
.suspendedTxTimeout();
auto handler = new SuspendedTxExpiryHandler(this, txState->getTransactionId(),
suspendedTxTimeout);
- long id = m_cache->getExpiryTaskManager()
- .scheduleExpiryTask(handler, suspendedTxTimeout,
- std::chrono::seconds::zero(), false);
+ long id = m_cache->getExpiryTaskManager().scheduleExpiryTask(
+ handler, suspendedTxTimeout, std::chrono::seconds::zero(), false);
txState->setSuspendedExpiryTaskId(id);
// add the transaction state to the list of suspended transactions
@@ -381,8 +380,8 @@ void CacheTransactionManagerImpl::resume(TransactionId& transactionId) {
}
// get the transaction state of the suspended transaction
- TXState* txState = removeSuspendedTx(
- (static_cast<TXId&>(transactionId)).getId());
+ TXState* txState =
+ removeSuspendedTx((static_cast<TXId&>(transactionId)).getId());
if (txState == nullptr) {
GfErrTypeThrowException(
"Could not get transaction state for the transaction id.",
@@ -393,14 +392,13 @@ void CacheTransactionManagerImpl::resume(TransactionId& transactionId) {
}
bool CacheTransactionManagerImpl::isSuspended(TransactionId& transactionId) {
- return isSuspendedTx(
- (static_cast<TXId&>(transactionId)).getId());
+ return isSuspendedTx((static_cast<TXId&>(transactionId)).getId());
}
bool CacheTransactionManagerImpl::tryResume(TransactionId& transactionId) {
return tryResume(transactionId, true);
}
-bool CacheTransactionManagerImpl::tryResume(
- TransactionId& transactionId, bool cancelExpiryTask) {
+bool CacheTransactionManagerImpl::tryResume(TransactionId& transactionId,
+ bool cancelExpiryTask) {
// get the current state of the thread
if (TSSTXStateWrapper::s_geodeTSSTXState->getTXState() != nullptr) {
LOGFINE("A transaction is already in progress. Cannot resume transaction.");
@@ -408,8 +406,8 @@ bool CacheTransactionManagerImpl::tryResume(
}
// get the transaction state of the suspended transaction
- TXState* txState = removeSuspendedTx(
- (static_cast<TXId&>(transactionId)).getId());
+ TXState* txState =
+ removeSuspendedTx((static_cast<TXId&>(transactionId)).getId());
if (txState == nullptr) return false;
resumeTxUsingTxState(txState, cancelExpiryTask);
@@ -427,8 +425,8 @@ bool CacheTransactionManagerImpl::tryResume(
if (!exists(transactionId)) return false;
// get the transaction state of the suspended transaction
- TXState* txState = removeSuspendedTx(
- (static_cast<TXId&>(transactionId)).getId(), waitTime);
+ TXState* txState =
+ removeSuspendedTx((static_cast<TXId&>(transactionId)).getId(), waitTime);
if (txState == nullptr) return false;
resumeTxUsingTxState(txState);
diff --git a/cppcache/src/CacheXmlCreation.cpp b/cppcache/src/CacheXmlCreation.cpp
index 541bcf8..fe440d5 100644
--- a/cppcache/src/CacheXmlCreation.cpp
+++ b/cppcache/src/CacheXmlCreation.cpp
@@ -57,7 +57,7 @@ void CacheXmlCreation::setPdxReadSerialized(bool val) {
CacheXmlCreation::CacheXmlCreation()
- : m_cache((Cache*)0) {
+ : m_cache(nullptr) {
m_pdxIgnoreUnreadFields = false;
m_readPdxSerialized = false;
}
diff --git a/cppcache/src/CqQueryImpl.cpp b/cppcache/src/CqQueryImpl.cpp
index 74f443b..b2d9634 100644
--- a/cppcache/src/CqQueryImpl.cpp
+++ b/cppcache/src/CqQueryImpl.cpp
@@ -25,6 +25,7 @@
#include "ThinClientRegion.hpp"
#include "ReadWriteLock.hpp"
#include "ThinClientRegion.hpp"
+#include "UserAttributes.hpp"
#include "util/bounds.hpp"
#include "util/Log.hpp"
#include "util/exception.hpp"
@@ -52,9 +53,9 @@ CqQueryImpl::CqQueryImpl(
m_cqAttributesMutator =
std::make_shared<CqAttributesMutatorImpl>(m_cqAttributes);
if (userAttributesPtr != nullptr) {
- m_proxyCache = userAttributesPtr->getProxyCache();
+ m_authenticatedView = userAttributesPtr->getAuthenticatedView();
} else {
- m_proxyCache = nullptr;
+ m_authenticatedView = nullptr;
}
}
@@ -112,9 +113,9 @@ void CqQueryImpl::close(bool sendRequestToServer) {
return;
}
- GuardUserAttribures gua;
- if (m_proxyCache != nullptr) {
- gua.setProxyCache(m_proxyCache);
+ GuardUserAttributes gua;
+ if (m_authenticatedView != nullptr) {
+ gua.setAuthenticatedView(m_authenticatedView);
}
LOGFINE("Started closing CQ CqName : %s", m_cqName.c_str());
@@ -252,9 +253,9 @@ GfErrType CqQueryImpl::execute(TcrEndpoint* endpoint) {
return GF_NOERR;
}
- GuardUserAttribures gua;
- if (m_proxyCache != nullptr) {
- gua.setProxyCache(m_proxyCache);
+ GuardUserAttributes gua;
+ if (m_authenticatedView != nullptr) {
+ gua.setAuthenticatedView(m_authenticatedView);
}
LOGFINE("Executing CQ [%s]", m_cqName.c_str());
@@ -306,9 +307,9 @@ void CqQueryImpl::executeAfterFailover() {
}
void CqQueryImpl::execute() {
- GuardUserAttribures gua;
- if (m_proxyCache != nullptr) {
- gua.setProxyCache(m_proxyCache);
+ GuardUserAttributes gua;
+ if (m_authenticatedView != nullptr) {
+ gua.setAuthenticatedView(m_authenticatedView);
}
ACE_Guard<ACE_Recursive_Thread_Mutex> guardRedundancy(
@@ -323,9 +324,9 @@ void CqQueryImpl::execute() {
// for EXECUTE_REQUEST or REDUNDANT_EXECUTE_REQUEST
bool CqQueryImpl::executeCq(TcrMessage::MsgType requestType) {
- GuardUserAttribures gua;
- if (m_proxyCache != nullptr) {
- gua.setProxyCache(m_proxyCache);
+ GuardUserAttributes gua;
+ if (m_authenticatedView != nullptr) {
+ gua.setAuthenticatedView(m_authenticatedView);
}
LOGDEBUG("CqQueryImpl::executeCq");
@@ -367,9 +368,9 @@ std::shared_ptr<CqResults> CqQueryImpl::executeWithInitialResults(
std::chrono::milliseconds timeout) {
util::PROTOCOL_OPERATION_TIMEOUT_BOUNDS(timeout);
- GuardUserAttribures gua;
- if (m_proxyCache != nullptr) {
- gua.setProxyCache(m_proxyCache);
+ GuardUserAttributes gua;
+ if (m_authenticatedView != nullptr) {
+ gua.setAuthenticatedView(m_authenticatedView);
}
ACE_Guard<ACE_Recursive_Thread_Mutex> guardRedundancy(
@@ -449,9 +450,9 @@ void CqQueryImpl::stop() {
throw CqClosedException(("CQ is closed, CqName : " + m_cqName).c_str());
}
- GuardUserAttribures gua;
- if (m_proxyCache != nullptr) {
- gua.setProxyCache(m_proxyCache);
+ GuardUserAttributes gua;
+ if (m_authenticatedView != nullptr) {
+ gua.setAuthenticatedView(m_authenticatedView);
}
if (!(isRunning())) {
@@ -584,7 +585,7 @@ bool CqQueryImpl::isRunning() const {
bool CqQueryImpl::isStopped() const {
ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
return m_cqState == CqState::STOPPED ||
- (m_proxyCache && m_proxyCache->isClosed());
+ (m_authenticatedView && m_authenticatedView->isClosed());
}
/**
@@ -594,7 +595,7 @@ bool CqQueryImpl::isStopped() const {
bool CqQueryImpl::isClosed() const {
ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
return m_cqState == CqState::CLOSED ||
- (m_proxyCache && m_proxyCache->isClosed());
+ (m_authenticatedView && m_authenticatedView->isClosed());
}
/**
diff --git a/cppcache/src/CqQueryImpl.hpp b/cppcache/src/CqQueryImpl.hpp
index 07c0d35..1ea30e3 100644
--- a/cppcache/src/CqQueryImpl.hpp
+++ b/cppcache/src/CqQueryImpl.hpp
@@ -37,7 +37,7 @@
#include <ace/Time_Value.h>
#include <ace/Guard_T.h>
#include <ace/Recursive_Thread_Mutex.h>
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
/**
* @file
@@ -272,7 +272,7 @@ class CqQueryImpl : public CqQuery,
mutable ACE_Recursive_Thread_Mutex m_mutex;
void sendStopOrClose(TcrMessage::MsgType requestType);
ThinClientBaseDM* m_tccdm;
- ProxyCache* m_proxyCache;
+ AuthenticatedView* m_authenticatedView;
_GEODE_FRIEND_STD_SHARED_PTR(CqQueryImpl)
};
diff --git a/cppcache/src/Delta.cpp b/cppcache/src/Delta.cpp
deleted file mode 100644
index 74a262e..0000000
--- a/cppcache/src/Delta.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 <geode/Delta.hpp>
-#include <geode/Cache.hpp>
-#include <geode/Serializable.hpp>
-
-namespace apache {
-namespace geode {
-namespace client {
-
-Delta::Delta(Cache* cache) : m_cache(cache) {}
-
-std::shared_ptr<Delta> Delta::clone() const {
- auto out = m_cache->createDataOutput();
- auto ptr = dynamic_cast<const Cacheable*>(this);
- out->writeObject(ptr);
- auto in = m_cache->createDataInput(out->getBuffer(), out->getBufferLength());
- std::shared_ptr<Cacheable> theClonePtr;
- in->readObject(theClonePtr);
- return std::dynamic_pointer_cast<Delta>(theClonePtr);
-}
-
-} // namespace client
-} // namespace geode
-} // namespace apache
diff --git a/cppcache/src/ExecutionImpl.cpp b/cppcache/src/ExecutionImpl.cpp
index 12c4956..7742163 100644
--- a/cppcache/src/ExecutionImpl.cpp
+++ b/cppcache/src/ExecutionImpl.cpp
@@ -46,8 +46,9 @@ Execution ExecutionImpl::withFilter(
"first before calling this function");
}
// m_routingObj = routingObj;
- return Execution(std::unique_ptr<ExecutionImpl>(new ExecutionImpl(
- routingObj, m_args, m_rc, m_region, m_allServer, m_pool, m_proxyCache)));
+ return Execution(std::unique_ptr<ExecutionImpl>(
+ new ExecutionImpl(routingObj, m_args, m_rc, m_region, m_allServer, m_pool,
+ m_authenticatedView)));
}
Execution ExecutionImpl::withArgs(std::shared_ptr<Cacheable> args) {
@@ -56,8 +57,9 @@ Execution ExecutionImpl::withArgs(std::shared_ptr<Cacheable> args) {
throw IllegalArgumentException("Execution::withArgs: args is null");
}
// m_args = args;
- return Execution(std::unique_ptr<ExecutionImpl>(new ExecutionImpl(
- m_routingObj, args, m_rc, m_region, m_allServer, m_pool, m_proxyCache)));
+ return Execution(std::unique_ptr<ExecutionImpl>(
+ new ExecutionImpl(m_routingObj, args, m_rc, m_region, m_allServer, m_pool,
+ m_authenticatedView)));
}
Execution ExecutionImpl::withCollector(std::shared_ptr<ResultCollector> rs) {
@@ -67,8 +69,9 @@ Execution ExecutionImpl::withCollector(std::shared_ptr<ResultCollector> rs) {
"Execution::withCollector: collector is null");
}
// m_rc = rs;
- return Execution(std::unique_ptr<ExecutionImpl>(new ExecutionImpl(
- m_routingObj, m_args, rs, m_region, m_allServer, m_pool, m_proxyCache)));
+ return Execution(std::unique_ptr<ExecutionImpl>(
+ new ExecutionImpl(m_routingObj, m_args, rs, m_region, m_allServer, m_pool,
+ m_authenticatedView)));
}
std::vector<int8_t>* ExecutionImpl::getFunctionAttributes(
@@ -94,10 +97,10 @@ std::shared_ptr<ResultCollector> ExecutionImpl::execute(
std::shared_ptr<ResultCollector> ExecutionImpl::execute(
const std::string& func, std::chrono::milliseconds timeout) {
LOGDEBUG("ExecutionImpl::execute: ");
- GuardUserAttribures gua;
- if (m_proxyCache != nullptr) {
- LOGDEBUG("ExecutionImpl::execute function on proxy cache");
- gua.setProxyCache(m_proxyCache.get());
+ GuardUserAttributes gua;
+ if (m_authenticatedView != nullptr) {
+ LOGDEBUG("ExecutionImpl::execute function on authenticated cache");
+ gua.setAuthenticatedView(m_authenticatedView);
}
bool serverHasResult = false;
bool serverIsHA = false;
diff --git a/cppcache/src/ExecutionImpl.hpp b/cppcache/src/ExecutionImpl.hpp
index 0660c57..b0f74b4 100644
--- a/cppcache/src/ExecutionImpl.hpp
+++ b/cppcache/src/ExecutionImpl.hpp
@@ -21,27 +21,26 @@
#define GEODE_EXECUTIONIMPL_H_
#include <map>
-
#include <ace/Condition_Recursive_Thread_Mutex.h>
#include <ace/Guard_T.h>
-
#include <geode/Execution.hpp>
#include <geode/CacheableBuiltins.hpp>
#include <geode/ResultCollector.hpp>
#include <geode/Region.hpp>
-
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
+#include "ErrType.hpp"
namespace apache {
namespace geode {
namespace client {
-typedef std::map<std::string, std::vector<int8_t>*> FunctionToFunctionAttributes;
+typedef std::map<std::string, std::vector<int8_t>*>
+ FunctionToFunctionAttributes;
class ExecutionImpl {
public:
ExecutionImpl(std::shared_ptr<Region> rptr = nullptr,
- std::shared_ptr<ProxyCache> proxyCache = nullptr,
+ AuthenticatedView* authenticatedView = nullptr,
std::shared_ptr<Pool> pp = nullptr)
: m_routingObj(nullptr),
m_args(nullptr),
@@ -49,22 +48,19 @@ class ExecutionImpl {
m_region(rptr),
m_allServer(false),
m_pool(pp),
- m_proxyCache(proxyCache) {}
+ m_authenticatedView(authenticatedView) {}
ExecutionImpl(std::shared_ptr<Pool> pool, bool allServer = false,
- std::shared_ptr<ProxyCache> proxyCache = nullptr)
+ AuthenticatedView* authenticatedView = nullptr)
: m_routingObj(nullptr),
m_args(nullptr),
m_rc(nullptr),
m_region(nullptr),
m_allServer(allServer),
m_pool(pool),
- m_proxyCache(proxyCache) {}
- virtual Execution withFilter(
- std::shared_ptr<CacheableVector> routingObj);
- virtual Execution withArgs(
- std::shared_ptr<Cacheable> args);
- virtual Execution withCollector(
- std::shared_ptr<ResultCollector> rs);
+ m_authenticatedView(authenticatedView) {}
+ virtual Execution withFilter(std::shared_ptr<CacheableVector> routingObj);
+ virtual Execution withArgs(std::shared_ptr<Cacheable> args);
+ virtual Execution withCollector(std::shared_ptr<ResultCollector> rs);
// java function has hasResult property. we put the hasResult argument
// here as a kluge.
virtual std::shared_ptr<ResultCollector> execute(
@@ -74,8 +70,8 @@ class ExecutionImpl {
std::chrono::milliseconds timeout);
virtual std::shared_ptr<ResultCollector> execute(
- const std::string& func, std::chrono::milliseconds timeout =
- DEFAULT_QUERY_RESPONSE_TIMEOUT);
+ const std::string& func,
+ std::chrono::milliseconds timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT);
static void addResults(std::shared_ptr<ResultCollector>& collector,
const std::shared_ptr<CacheableVector>& results);
@@ -88,20 +84,20 @@ class ExecutionImpl {
m_region(rhs.m_region),
m_allServer(rhs.m_allServer),
m_pool(rhs.m_pool),
- m_proxyCache(rhs.m_proxyCache) {}
+ m_authenticatedView(rhs.m_authenticatedView) {}
ExecutionImpl(const std::shared_ptr<CacheableVector>& routingObj,
const std::shared_ptr<Cacheable>& args,
const std::shared_ptr<ResultCollector>& rc,
const std::shared_ptr<Region>& region, const bool allServer,
const std::shared_ptr<Pool>& pool,
- std::shared_ptr<ProxyCache> proxyCache = nullptr)
+ AuthenticatedView* authenticatedView = nullptr)
: m_routingObj(routingObj),
m_args(args),
m_rc(rc),
m_region(region),
m_allServer(allServer),
m_pool(pool),
- m_proxyCache(proxyCache) {}
+ m_authenticatedView(authenticatedView) {}
// ACE_Recursive_Thread_Mutex m_lock;
std::shared_ptr<CacheableVector> m_routingObj;
std::shared_ptr<Cacheable> m_args;
@@ -109,7 +105,7 @@ class ExecutionImpl {
std::shared_ptr<Region> m_region;
bool m_allServer;
std::shared_ptr<Pool> m_pool;
- std::shared_ptr<ProxyCache> m_proxyCache;
+ AuthenticatedView* m_authenticatedView;
static ACE_Recursive_Thread_Mutex m_func_attrs_lock;
static FunctionToFunctionAttributes m_func_attrs;
// std::vector<int8_t> m_attributes;
@@ -125,8 +121,6 @@ class ExecutionImpl {
std::vector<int8_t>* getFunctionAttributes(const std::string& func);
GfErrType getFuncAttributes(const std::string& func,
std::vector<int8_t>** attr);
-
-
};
} // namespace client
} // namespace geode
diff --git a/cppcache/src/FunctionService.cpp b/cppcache/src/FunctionService.cpp
index d61961d..098bc99 100644
--- a/cppcache/src/FunctionService.cpp
+++ b/cppcache/src/FunctionService.cpp
@@ -21,7 +21,7 @@
#include "CacheRegionHelper.hpp"
#include "ProxyRegion.hpp"
#include "UserAttributes.hpp"
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
#include "ExecutionImpl.hpp"
#include "CacheImpl.hpp"
@@ -38,7 +38,7 @@ Execution FunctionService::onRegion(const std::shared_ptr<Region>& region) {
if (pool == nullptr) {
throw IllegalArgumentException("Pool attached with region is closed.");
}
- std::shared_ptr<ProxyCache> proxyCache = nullptr;
+ AuthenticatedView* authenticatedView = nullptr;
if (pool->getMultiuserAuthentication()) {
if (auto pr = std::dynamic_pointer_cast<ProxyRegion>(realRegion)) {
@@ -46,8 +46,8 @@ Execution FunctionService::onRegion(const std::shared_ptr<Region>& region) {
"FunctionService::onRegion(std::shared_ptr<Region> region) proxy "
"cache");
// it is in multiuser mode
- proxyCache = pr->m_proxyCache;
- auto userAttachedPool = proxyCache->m_userAttributes->getPool();
+ authenticatedView = pr->m_authenticatedView;
+ auto userAttachedPool = authenticatedView->m_userAttributes->getPool();
auto pool = realRegion->getCache().getPoolManager().find(
userAttachedPool->getName());
if (!(pool != nullptr && pool.get() == userAttachedPool.get() &&
@@ -73,7 +73,7 @@ Execution FunctionService::onRegion(const std::shared_ptr<Region>& region) {
}
return Execution(std::unique_ptr<ExecutionImpl>(
- new ExecutionImpl(realRegion, proxyCache, pool)));
+ new ExecutionImpl(realRegion, authenticatedView, pool)));
}
Execution FunctionService::onServerWithPool(const std::shared_ptr<Pool>& pool) {
@@ -103,16 +103,13 @@ Execution FunctionService::onServersWithPool(
std::unique_ptr<ExecutionImpl>(new ExecutionImpl(pool, true)));
}
-Execution FunctionService::onServerWithCache(
- const std::shared_ptr<RegionService>& cache) {
- if (cache->isClosed()) {
+Execution FunctionService::onServerWithCache(RegionService& cache) {
+ if (cache.isClosed()) {
throw IllegalStateException("Cache has been closed");
}
- auto pc = std::dynamic_pointer_cast<ProxyCache>(cache);
-
LOGDEBUG("FunctionService::onServer:");
- if (pc != nullptr) {
+ if (auto pc = dynamic_cast<AuthenticatedView*>(&cache)) {
auto userAttachedPool = pc->m_userAttributes->getPool();
auto pool =
pc->m_cacheImpl->getPoolManager().find(userAttachedPool->getName());
@@ -124,22 +121,19 @@ Execution FunctionService::onServerWithCache(
throw IllegalStateException(
"Pool has been close to execute function on server");
} else {
- auto realcache = std::static_pointer_cast<Cache>(cache);
+ auto& realcache = static_cast<Cache&>(cache);
return FunctionService::onServer(
- realcache->m_cacheImpl->getPoolManager().getDefaultPool());
+ realcache.m_cacheImpl->getPoolManager().getDefaultPool());
}
}
-Execution FunctionService::onServersWithCache(
- const std::shared_ptr<RegionService>& cache) {
- if (cache->isClosed()) {
+Execution FunctionService::onServersWithCache(RegionService& cache) {
+ if (cache.isClosed()) {
throw IllegalStateException("Cache has been closed");
}
- auto pc = std::dynamic_pointer_cast<ProxyCache>(cache);
-
LOGDEBUG("FunctionService::onServers:");
- if (pc != nullptr && !cache->isClosed()) {
+ if (auto pc = dynamic_cast<AuthenticatedView*>(&cache)) {
auto userAttachedPool = pc->m_userAttributes->getPool();
auto pool = pc->m_cacheImpl->getCache()->getPoolManager().find(
userAttachedPool->getName());
@@ -151,8 +145,8 @@ Execution FunctionService::onServersWithCache(
throw IllegalStateException(
"Pool has been close to execute function on server");
} else {
- auto realcache = std::static_pointer_cast<Cache>(cache);
+ auto& realcache = static_cast<Cache&>(cache);
return FunctionService::onServers(
- realcache->m_cacheImpl->getPoolManager().getDefaultPool());
+ realcache.m_cacheImpl->getPoolManager().getDefaultPool());
}
}
diff --git a/cppcache/src/FunctionServiceImpl.cpp b/cppcache/src/FunctionServiceImpl.cpp
index 2cb99ab..8f6dd2d 100644
--- a/cppcache/src/FunctionServiceImpl.cpp
+++ b/cppcache/src/FunctionServiceImpl.cpp
@@ -21,11 +21,11 @@
using namespace apache::geode::client;
-FunctionServiceImpl::FunctionServiceImpl(
- std::shared_ptr<ProxyCache> proxyCache) {
- m_proxyCache = proxyCache;
+FunctionServiceImpl::FunctionServiceImpl(AuthenticatedView* authenticatedView) {
+ m_authenticatedView = authenticatedView;
}
+
std::shared_ptr<FunctionService> FunctionServiceImpl::getFunctionService(
- std::shared_ptr<ProxyCache> proxyCache) {
- return std::make_shared<FunctionServiceImpl>(proxyCache);
+ AuthenticatedView* authenticatedView) {
+ return std::make_shared<FunctionServiceImpl>(authenticatedView);
}
diff --git a/cppcache/src/FunctionServiceImpl.hpp b/cppcache/src/FunctionServiceImpl.hpp
index 28983e1..a12ca55 100644
--- a/cppcache/src/FunctionServiceImpl.hpp
+++ b/cppcache/src/FunctionServiceImpl.hpp
@@ -21,7 +21,7 @@
*/
#include <geode/internal/geode_globals.hpp>
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
#include <geode/FunctionService.hpp>
/**
* @file
@@ -51,16 +51,17 @@ class _GEODE_EXPORT FunctionServiceImpl : public FunctionService {
virtual ~FunctionServiceImpl() {}
private:
- FunctionServiceImpl(const FunctionService &);
- FunctionServiceImpl &operator=(const FunctionService &);
+ FunctionServiceImpl(const FunctionService&);
+ FunctionServiceImpl& operator=(const FunctionService&);
- FunctionServiceImpl(std::shared_ptr<ProxyCache> proxyCache);
+ FunctionServiceImpl(AuthenticatedView* authenticatedView);
static std::shared_ptr<FunctionService> getFunctionService(
- std::shared_ptr<ProxyCache> proxyCache);
+ AuthenticatedView* authenticatedView);
- std::shared_ptr<ProxyCache> m_proxyCache;
- friend class ProxyCache;
+ AuthenticatedView* m_authenticatedView;
+
+ friend class AuthenticatedView;
_GEODE_FRIEND_STD_SHARED_PTR(FunctionServiceImpl)
};
diff --git a/cppcache/src/LocalRegion.cpp b/cppcache/src/LocalRegion.cpp
index a5547ae..4747e07 100644
--- a/cppcache/src/LocalRegion.cpp
+++ b/cppcache/src/LocalRegion.cpp
@@ -41,15 +41,14 @@ namespace apache {
namespace geode {
namespace client {
-LocalRegion::LocalRegion(const std::string& name, CacheImpl* cache,
+LocalRegion::LocalRegion(const std::string& name, CacheImpl* cacheImpl,
const std::shared_ptr<RegionInternal>& rPtr,
RegionAttributes attributes,
const std::shared_ptr<CacheStatistics>& stats,
bool shared, bool enableTimeStatistics)
- : RegionInternal(cache->getCache(), attributes),
+ : RegionInternal(cacheImpl, attributes),
m_name(name),
m_parentRegion(rPtr),
- m_cacheImpl(cache),
m_destroyPending(false),
m_listener(nullptr),
m_writer(nullptr),
@@ -89,13 +88,11 @@ LocalRegion::LocalRegion(const std::string& name, CacheImpl* cache,
(m_fullPath = "/") += m_name;
}
- m_regionStats = new RegionStats(cache->getDistributedSystem()
+ m_regionStats = new RegionStats(cacheImpl->getDistributedSystem()
.getStatisticsManager()
->getStatisticsFactory(),
m_fullPath);
- auto p =
- cache->getCache()->getPoolManager().find(getAttributes().getPoolName());
- // m_attachedPool = p;
+ auto p = cacheImpl->getPoolManager().find(getAttributes().getPoolName());
setPool(p);
}
diff --git a/cppcache/src/LocalRegion.hpp b/cppcache/src/LocalRegion.hpp
index e9b96c0..372a10d 100644
--- a/cppcache/src/LocalRegion.hpp
+++ b/cppcache/src/LocalRegion.hpp
@@ -63,12 +63,12 @@ namespace geode {
namespace client {
#ifndef CHECK_DESTROY_PENDING
-#define CHECK_DESTROY_PENDING(lock, function) \
- lock checkGuard(m_rwLock, m_destroyPending); \
- if (m_destroyPending) { \
- std::string err_msg = #function; \
- err_msg += ": region " + m_fullPath + " destroyed"; \
- throw RegionDestroyedException(err_msg.c_str()); \
+#define CHECK_DESTROY_PENDING(lock, function) \
+ lock checkGuard(m_rwLock, m_destroyPending); \
+ if (m_destroyPending) { \
+ std::string err_msg = #function; \
+ err_msg += ": region " + m_fullPath + " destroyed"; \
+ throw RegionDestroyedException(err_msg.c_str()); \
}
#endif
@@ -382,7 +382,8 @@ class _GEODE_EXPORT LocalRegion : public RegionInternal {
virtual bool isDestroyed() const override { return m_destroyPending; }
/* above public methods are inherited from RegionInternal */
- virtual void adjustCacheListener(const std::shared_ptr<CacheListener>& aListener) override;
+ virtual void adjustCacheListener(
+ const std::shared_ptr<CacheListener>& aListener) override;
virtual void adjustCacheListener(const std::string& libpath,
const std::string& factoryFuncName) override;
virtual void adjustCacheLoader(
@@ -506,7 +507,6 @@ class _GEODE_EXPORT LocalRegion : public RegionInternal {
std::shared_ptr<Region> m_parentRegion;
MapOfRegionWithLock m_subRegions;
std::string m_fullPath;
- CacheImpl* m_cacheImpl;
volatile bool m_destroyPending;
std::shared_ptr<CacheListener> m_listener;
std::shared_ptr<CacheWriter> m_writer;
diff --git a/cppcache/src/MapSegment.cpp b/cppcache/src/MapSegment.cpp
index b0801ce..b67eef0 100644
--- a/cppcache/src/MapSegment.cpp
+++ b/cppcache/src/MapSegment.cpp
@@ -88,8 +88,7 @@ GfErrType MapSegment::create(const std::shared_ptr<CacheableKey>& key,
rehash();
}
std::shared_ptr<MapEntry> entry;
- int status;
- if ((status = m_map->find(key, entry)) == -1) {
+ if ((m_map->find(key, entry)) == -1) {
if ((err = putNoEntry(key, newValue, me, updateCount, destroyTracker,
versionTag)) != GF_NOERR) {
return err;
@@ -157,8 +156,7 @@ GfErrType MapSegment::put(const std::shared_ptr<CacheableKey>& key,
rehash();
}
std::shared_ptr<MapEntry> entry;
- int status;
- if ((status = m_map->find(key, entry)) == -1) {
+ if ((m_map->find(key, entry)) == -1) {
if (delta != nullptr) {
return GF_INVALID_DELTA; // You can not apply delta when there is no
}
@@ -215,11 +213,10 @@ GfErrType MapSegment::invalidate(const std::shared_ptr<CacheableKey>& key,
std::shared_ptr<VersionTag> versionTag,
bool& isTokenAdded) {
std::lock_guard<spinlock_mutex> lk(m_spinlock);
- int status;
isTokenAdded = false;
GfErrType err = GF_NOERR;
std::shared_ptr<MapEntry> entry;
- if ((status = m_map->find(key, entry)) != -1) {
+ if ((m_map->find(key, entry)) != -1) {
VersionStamp versionStamp;
if (m_concurrencyChecksEnabled) {
versionStamp = entry->getVersionStamp();
@@ -264,11 +261,10 @@ GfErrType MapSegment::removeWhenConcurrencyEnabled(
bool& isEntryFound, ExpiryTaskManager::id_type expiryTaskID,
TombstoneExpiryHandler* handler, bool& expTaskSet) {
GfErrType err = GF_NOERR;
- int status;
std::shared_ptr<MapEntry> entry;
VersionStamp versionStamp;
// If entry found, else return no entry
- if ((status = m_map->find(key, entry)) != -1) {
+ if ((m_map->find(key, entry)) != -1) {
isEntryFound = true;
// If the version tag is null, use the version tag of
// the existing entry
@@ -332,7 +328,6 @@ GfErrType MapSegment::remove(const std::shared_ptr<CacheableKey>& key,
std::shared_ptr<MapEntryImpl>& me, int updateCount,
std::shared_ptr<VersionTag> versionTag,
bool afterRemote, bool& isEntryFound) {
- int status;
std::shared_ptr<MapEntry> entry;
if (m_concurrencyChecksEnabled) {
TombstoneExpiryHandler* handler;
@@ -355,7 +350,7 @@ GfErrType MapSegment::remove(const std::shared_ptr<CacheableKey>& key,
std::lock_guard<spinlock_mutex> lk(m_spinlock);
std::shared_ptr<Cacheable> value;
- if ((status = m_map->unbind(key, entry)) == -1) {
+ if ((m_map->unbind(key, entry)) == -1) {
// didn't unbind, probably no entry...
oldValue = nullptr;
volatile int destroyTrackers = *m_numDestroyTrackers;
@@ -412,9 +407,8 @@ bool MapSegment::getEntry(const std::shared_ptr<CacheableKey>& key,
std::shared_ptr<MapEntryImpl>& result,
std::shared_ptr<Cacheable>& value) {
std::lock_guard<spinlock_mutex> lk(m_spinlock);
- int status;
std::shared_ptr<MapEntry> entry;
- if ((status = m_map->find(key, entry)) == -1) {
+ if ((m_map->find(key, entry)) == -1) {
result = nullptr;
value = nullptr;
return false;
@@ -438,8 +432,7 @@ bool MapSegment::getEntry(const std::shared_ptr<CacheableKey>& key,
bool MapSegment::containsKey(const std::shared_ptr<CacheableKey>& key) {
std::lock_guard<spinlock_mutex> lk(m_spinlock);
std::shared_ptr<MapEntry> mePtr;
- int status;
- if ((status = m_map->find(key, mePtr)) == -1) {
+ if ((m_map->find(key, mePtr)) == -1) {
return false;
}
// If the value is a tombstone return not found
@@ -577,8 +570,7 @@ void MapSegment::removeTrackerForEntry(
if (m_concurrencyChecksEnabled) return;
std::lock_guard<spinlock_mutex> lk(m_spinlock);
std::shared_ptr<MapEntry> entry;
- int status;
- if ((status = m_map->find(key, entry)) != -1) {
+ if ((m_map->find(key, entry)) != -1) {
auto impl = entry->getImplPtr();
removeTrackerForEntry(key, entry, impl);
}
@@ -622,7 +614,7 @@ void MapSegment::rehash() { // Only called from put, segment must already be
uint32_t newMapSize = TableOfPrimes::getPrime(++m_primeIndex);
LOGFINER("Rehashing MapSegment to size %d.", newMapSize);
- CacheableKeyHashMap* newMap = new CacheableKeyHashMap();
+ auto* newMap = new CacheableKeyHashMap();
newMap->open(newMapSize);
// copy all entries into newMap..
@@ -641,7 +633,7 @@ void MapSegment::rehash() { // Only called from put, segment must already be
std::shared_ptr<Cacheable> MapSegment::getFromDisc(
std::shared_ptr<CacheableKey> key,
std::shared_ptr<MapEntryImpl>& entryImpl) {
- LocalRegion* lregion = static_cast<LocalRegion*>(m_region);
+ auto* lregion = static_cast<LocalRegion*>(m_region);
EntriesMap* em = lregion->getEntryMap();
return em->getFromDisk(key, entryImpl);
}
@@ -654,11 +646,12 @@ GfErrType MapSegment::putForTrackedEntry(
if (updateCount < 0 || m_concurrencyChecksEnabled) {
// for a non-tracked put (e.g. from notification) go ahead with the
// create/update and increment the update counter
- ThinClientRegion* tcRegion = dynamic_cast<ThinClientRegion*>(m_region);
+ auto* thinClientRegion = dynamic_cast<ThinClientRegion*>(m_region);
ThinClientPoolDM* m_poolDM = nullptr;
- if (tcRegion) {
- m_poolDM = dynamic_cast<ThinClientPoolDM*>(tcRegion->getDistMgr());
+ if (thinClientRegion) {
+ m_poolDM = dynamic_cast<ThinClientPoolDM*>(thinClientRegion->getDistMgr());
}
+
if (delta != nullptr) {
std::shared_ptr<Cacheable> oldValue;
entryImpl->getValueI(oldValue);
@@ -675,14 +668,15 @@ GfErrType MapSegment::putForTrackedEntry(
return GF_INVALID_DELTA;
}
}
+
auto valueWithDelta = std::dynamic_pointer_cast<Delta>(oldValue);
- std::shared_ptr<Cacheable>& newValue1 =
- const_cast<std::shared_ptr<Cacheable>&>(newValue);
+ auto& newValue1 = const_cast<std::shared_ptr<Cacheable>&>(newValue);
try {
if (m_region->getAttributes().getCloningEnabled()) {
auto tempVal = valueWithDelta->clone();
ACE_Time_Value currTimeBefore = ACE_OS::gettimeofday();
tempVal->fromDelta(*delta);
+
if (m_poolDM) {
m_poolDM->updateNotificationStats(
true,
@@ -694,6 +688,7 @@ GfErrType MapSegment::putForTrackedEntry(
ACE_Time_Value currTimeBefore = ACE_OS::gettimeofday();
valueWithDelta->fromDelta(*delta);
newValue1 = std::dynamic_pointer_cast<Serializable>(valueWithDelta);
+
if (m_poolDM) {
m_poolDM->updateNotificationStats(
true,
diff --git a/cppcache/src/PdxHelper.cpp b/cppcache/src/PdxHelper.cpp
index e2172a0..c030673 100644
--- a/cppcache/src/PdxHelper.cpp
+++ b/cppcache/src/PdxHelper.cpp
@@ -53,7 +53,6 @@ void PdxHelper::serializePdx(DataOutput& output,
void PdxHelper::serializePdx(
DataOutput& output, const std::shared_ptr<PdxSerializable>& pdxObject) {
-
auto pdxII = std::dynamic_pointer_cast<PdxInstanceImpl>(pdxObject);
auto cacheImpl = CacheRegionHelper::getCacheImpl(output.getCache());
auto pdxTypeRegistry = cacheImpl->getPdxTypeRegistry();
@@ -202,70 +201,70 @@ std::shared_ptr<PdxSerializable> PdxHelper::deserializePdx(
*/
// pdxClassname = pType->getPdxClassName();
pdxObjectptr = serializationRegistry->getPdxType(pType->getPdxClassName());
- auto pdxRealObject = pdxObjectptr;
- if (pdxLocalType == nullptr) // need to know local type
- {
- auto prtc =
- PdxReaderWithTypeCollector(dataInput, pType, length, pdxTypeRegistry);
- pdxObjectptr->fromData(prtc);
-
- // Check for the PdxWrapper
-
- pdxLocalType = prtc.getLocalType();
-
- if (pType->Equals(pdxLocalType)) {
- pdxTypeRegistry->addLocalPdxType(pdxRealObject->getClassName(), pType);
- pdxTypeRegistry->addPdxType(pType->getTypeId(), pType);
- pType->setLocal(true);
- } else {
- // Need to know local type and then merge type
- pdxLocalType->InitializeType();
- pdxLocalType->setTypeId(pdxTypeRegistry->getPDXIdForType(
- pdxObjectptr->getClassName(),
- DataInputInternal::getPoolName(dataInput).c_str(), pdxLocalType,
- true));
- pdxLocalType->setLocal(true);
- pdxTypeRegistry->addLocalPdxType(pdxRealObject->getClassName(),
- pdxLocalType); // added local type
- pdxTypeRegistry->addPdxType(pdxLocalType->getTypeId(), pdxLocalType);
-
- pType->InitializeType();
- pdxTypeRegistry->addPdxType(pType->getTypeId(),
- pType); // adding remote type
-
- // create merge type
- createMergedType(pdxLocalType, pType, dataInput);
-
- auto mergedVersion = pdxTypeRegistry->getMergedType(pType->getTypeId());
-
- if (auto preserveData =
- prtc.getPreservedData(mergedVersion, pdxObjectptr)) {
- pdxTypeRegistry->setPreserveData(pdxObjectptr, preserveData,
- cacheImpl->getExpiryTaskManager());
- }
- }
- prtc.moveStream();
- } else { // remote reader will come here as local type is there
- pType->InitializeType();
- LOGDEBUG("Adding type %d ", pType->getTypeId());
- pdxTypeRegistry->addPdxType(pType->getTypeId(),
- pType); // adding remote type
- auto prr = PdxRemoteReader(dataInput, pType, length, pdxTypeRegistry);
- pdxObjectptr->fromData(prr);
-
- // Check for PdxWrapper to getObject.
-
- createMergedType(pdxLocalType, pType, dataInput);
-
- auto mergedVersion = pdxTypeRegistry->getMergedType(pType->getTypeId());
-
- auto preserveData = prr.getPreservedData(mergedVersion, pdxObjectptr);
- if (preserveData != nullptr) {
- pdxTypeRegistry->setPreserveData(pdxObjectptr, preserveData,
- cacheImpl->getExpiryTaskManager());
- }
- prr.moveStream();
- }
+ auto pdxRealObject = pdxObjectptr;
+ if (pdxLocalType == nullptr) // need to know local type
+ {
+ auto prtc =
+ PdxReaderWithTypeCollector(dataInput, pType, length, pdxTypeRegistry);
+ pdxObjectptr->fromData(prtc);
+
+ // Check for the PdxWrapper
+
+ pdxLocalType = prtc.getLocalType();
+
+ if (pType->Equals(pdxLocalType)) {
+ pdxTypeRegistry->addLocalPdxType(pdxRealObject->getClassName(), pType);
+ pdxTypeRegistry->addPdxType(pType->getTypeId(), pType);
+ pType->setLocal(true);
+ } else {
+ // Need to know local type and then merge type
+ pdxLocalType->InitializeType();
+ pdxLocalType->setTypeId(pdxTypeRegistry->getPDXIdForType(
+ pdxObjectptr->getClassName(),
+ DataInputInternal::getPoolName(dataInput).c_str(), pdxLocalType,
+ true));
+ pdxLocalType->setLocal(true);
+ pdxTypeRegistry->addLocalPdxType(pdxRealObject->getClassName(),
+ pdxLocalType); // added local type
+ pdxTypeRegistry->addPdxType(pdxLocalType->getTypeId(), pdxLocalType);
+
+ pType->InitializeType();
+ pdxTypeRegistry->addPdxType(pType->getTypeId(),
+ pType); // adding remote type
+
+ // create merge type
+ createMergedType(pdxLocalType, pType, dataInput);
+
+ auto mergedVersion = pdxTypeRegistry->getMergedType(pType->getTypeId());
+
+ if (auto preserveData =
+ prtc.getPreservedData(mergedVersion, pdxObjectptr)) {
+ pdxTypeRegistry->setPreserveData(pdxObjectptr, preserveData,
+ cacheImpl->getExpiryTaskManager());
+ }
+ }
+ prtc.moveStream();
+ } else { // remote reader will come here as local type is there
+ pType->InitializeType();
+ LOGDEBUG("Adding type %d ", pType->getTypeId());
+ pdxTypeRegistry->addPdxType(pType->getTypeId(),
+ pType); // adding remote type
+ auto prr = PdxRemoteReader(dataInput, pType, length, pdxTypeRegistry);
+ pdxObjectptr->fromData(prr);
+
+ // Check for PdxWrapper to getObject.
+
+ createMergedType(pdxLocalType, pType, dataInput);
+
+ auto mergedVersion = pdxTypeRegistry->getMergedType(pType->getTypeId());
+
+ auto preserveData = prr.getPreservedData(mergedVersion, pdxObjectptr);
+ if (preserveData != nullptr) {
+ pdxTypeRegistry->setPreserveData(pdxObjectptr, preserveData,
+ cacheImpl->getExpiryTaskManager());
+ }
+ prr.moveStream();
+ }
}
return pdxObjectptr;
}
@@ -310,7 +309,7 @@ std::shared_ptr<PdxSerializable> PdxHelper::deserializePdx(
// TODO::Enable it once the PdxInstanceImple is CheckedIn.
auto pdxObject = std::make_shared<PdxInstanceImpl>(
const_cast<uint8_t*>(dataInput.currentBufferPosition()), len, typeId,
- &cachePerfStats, pdxTypeRegistry, dataInput.getCache(),
+ &cachePerfStats, pdxTypeRegistry, cacheImpl,
cacheImpl->getDistributedSystem()
.getSystemProperties()
.getEnableTimeStatistics());
@@ -321,7 +320,8 @@ std::shared_ptr<PdxSerializable> PdxHelper::deserializePdx(
}
}
-void PdxHelper::createMergedType(std::shared_ptr<PdxType> localType, std::shared_ptr<PdxType> remoteType,
+void PdxHelper::createMergedType(std::shared_ptr<PdxType> localType,
+ std::shared_ptr<PdxType> remoteType,
DataInput& dataInput) {
auto mergedVersion = localType->mergeVersion(remoteType);
auto cacheImpl = CacheRegionHelper::getCacheImpl(dataInput.getCache());
@@ -402,17 +402,18 @@ int32_t PdxHelper::readInt(uint8_t* offsetPosition, int size) {
throw;
}
-int32_t PdxHelper::getEnumValue(const char* enumClassName, const char* enumName,
- int hashcode,
- std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry) {
+int32_t PdxHelper::getEnumValue(
+ const char* enumClassName, const char* enumName, int hashcode,
+ std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry) {
const auto& ei =
std::make_shared<EnumInfo>(enumClassName, enumName, hashcode);
return pdxTypeRegistry->getEnumValue(ei);
}
- std::shared_ptr<EnumInfo> PdxHelper::getEnum(int enumId, std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry) {
+std::shared_ptr<EnumInfo> PdxHelper::getEnum(
+ int enumId, std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry) {
const auto& ei = pdxTypeRegistry->getEnum(enumId);
return ei;
- }
+}
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/PdxInstanceFactoryImpl.cpp b/cppcache/src/PdxInstanceFactoryImpl.cpp
index 95ef881..c80be98 100644
--- a/cppcache/src/PdxInstanceFactoryImpl.cpp
+++ b/cppcache/src/PdxInstanceFactoryImpl.cpp
@@ -28,13 +28,13 @@ PdxInstanceFactoryImpl::~PdxInstanceFactoryImpl() {}
PdxInstanceFactoryImpl::PdxInstanceFactoryImpl(
std::string className, CachePerfStats* cachePerfStats,
- std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry, const Cache* cache,
+ std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry, const CacheImpl* cache,
bool enableTimeStatistics)
: m_pdxType(std::make_shared<PdxType>(pdxTypeRegistry, className, false)),
m_created(false),
m_cachePerfStats(cachePerfStats),
m_pdxTypeRegistry(pdxTypeRegistry),
- m_cache(cache),
+ m_cacheImpl(cache),
m_enableTimeStatistics(enableTimeStatistics) {}
std::unique_ptr<PdxInstance> PdxInstanceFactoryImpl::create() {
@@ -42,9 +42,9 @@ std::unique_ptr<PdxInstance> PdxInstanceFactoryImpl::create() {
throw IllegalStateException(
"The PdxInstanceFactory.Create() method can only be called once.");
}
- auto pi = std::unique_ptr<PdxInstance>(
- new PdxInstanceImpl(m_FieldVsValues, m_pdxType, m_cachePerfStats,
- m_pdxTypeRegistry, m_cache, m_enableTimeStatistics));
+ auto pi = std::unique_ptr<PdxInstance>(new PdxInstanceImpl(
+ m_FieldVsValues, m_pdxType, m_cachePerfStats, m_pdxTypeRegistry,
+ m_cacheImpl, m_enableTimeStatistics));
m_created = true;
return pi;
}
@@ -191,9 +191,8 @@ std::shared_ptr<PdxInstanceFactory> PdxInstanceFactoryImpl::writeByteArray(
isFieldAdded(fieldName);
m_pdxType->addVariableLengthTypeField(fieldName, "byte[]",
PdxFieldTypes::BYTE_ARRAY);
- auto cacheableObject = CacheableArray<int8_t,
- GeodeTypeIds::CacheableBytes>::create(
- value);
+ auto cacheableObject =
+ CacheableArray<int8_t, GeodeTypeIds::CacheableBytes>::create(value);
m_FieldVsValues.emplace(fieldName, cacheableObject);
return shared_from_this();
}
@@ -254,8 +253,7 @@ std::shared_ptr<PdxInstanceFactory> PdxInstanceFactoryImpl::writeStringArray(
for (auto&& v : value) {
ptrArr.push_back(CacheableString::create(v));
}
- auto cacheableObject =
- CacheableStringArray::create(ptrArr);
+ auto cacheableObject = CacheableStringArray::create(ptrArr);
m_FieldVsValues.emplace(fieldName, cacheableObject);
}
return shared_from_this();
@@ -279,7 +277,8 @@ PdxInstanceFactoryImpl::writeArrayOfByteArrays(const std::string& fieldName,
PdxFieldTypes::ARRAY_OF_BYTE_ARRAYS);
auto cacheableObject = CacheableVector::create();
for (int i = 0; i < arrayLength; i++) {
- auto ptr = CacheableBytes::create(std::vector<int8_t>(value[i], value[i] + elementLength[i]));
+ auto ptr = CacheableBytes::create(
+ std::vector<int8_t>(value[i], value[i] + elementLength[i]));
cacheableObject->push_back(ptr);
}
m_FieldVsValues.emplace(fieldName, cacheableObject);
diff --git a/cppcache/src/PdxInstanceFactoryImpl.hpp b/cppcache/src/PdxInstanceFactoryImpl.hpp
index b8e6221..96e225f 100644
--- a/cppcache/src/PdxInstanceFactoryImpl.hpp
+++ b/cppcache/src/PdxInstanceFactoryImpl.hpp
@@ -101,7 +101,8 @@ class _GEODE_EXPORT PdxInstanceFactoryImpl
const std::string& fieldName, const std::vector<bool>& value) override;
virtual std::shared_ptr<PdxInstanceFactory> writeCharArray(
- const std::string& fieldName, const std::vector<char16_t>& value) override;
+ const std::string& fieldName,
+ const std::vector<char16_t>& value) override;
virtual std::shared_ptr<PdxInstanceFactory> writeByteArray(
const std::string& fieldName, const std::vector<int8_t>& value) override;
@@ -138,7 +139,7 @@ class _GEODE_EXPORT PdxInstanceFactoryImpl
PdxInstanceFactoryImpl(std::string className, CachePerfStats* cachePerfStats,
std::shared_ptr<PdxTypeRegistry> m_pdxTypeRegistry,
- const Cache* cache, bool enableTimeStatistics);
+ const CacheImpl* cache, bool enableTimeStatistics);
private:
bool m_created;
@@ -146,7 +147,7 @@ class _GEODE_EXPORT PdxInstanceFactoryImpl
FieldVsValues m_FieldVsValues;
CachePerfStats* m_cachePerfStats;
std::shared_ptr<PdxTypeRegistry> m_pdxTypeRegistry;
- const Cache* m_cache;
+ const CacheImpl* m_cacheImpl;
bool m_enableTimeStatistics;
void isFieldAdded(const std::string& fieldName);
};
diff --git a/cppcache/src/PdxInstanceImpl.cpp b/cppcache/src/PdxInstanceImpl.cpp
index dfb60be..d4baa19 100644
--- a/cppcache/src/PdxInstanceImpl.cpp
+++ b/cppcache/src/PdxInstanceImpl.cpp
@@ -75,11 +75,26 @@ PdxInstanceImpl::~PdxInstanceImpl() noexcept {
}
PdxInstanceImpl::PdxInstanceImpl(
+ uint8_t* buffer, int length, int typeId, CachePerfStats* cacheStats,
+ std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry,
+ const CacheImpl* cacheImpl, bool enableTimeStatistics)
+ : m_buffer(DataInput::getBufferCopy(buffer, length)),
+ m_bufferLength(length),
+ m_typeId(typeId),
+ m_pdxType(nullptr),
+ m_cacheStats(cacheStats),
+ m_pdxTypeRegistry(pdxTypeRegistry),
+ m_cacheImpl(cacheImpl),
+ m_enableTimeStatistics(enableTimeStatistics) {
+ LOGDEBUG("PdxInstanceImpl::m_bufferLength = %d ", m_bufferLength);
+}
+
+PdxInstanceImpl::PdxInstanceImpl(
apache::geode::client::FieldVsValues fieldVsValue,
std::shared_ptr<apache::geode::client::PdxType> pdxType,
CachePerfStats* cacheStats,
- std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry, const Cache* cache,
- bool enableTimeStatistics)
+ std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry,
+ const CacheImpl* cacheImpl, bool enableTimeStatistics)
: m_pdxType(pdxType),
m_updatedFields(fieldVsValue),
m_buffer(nullptr),
@@ -87,7 +102,7 @@ PdxInstanceImpl::PdxInstanceImpl(
m_typeId(0),
m_cacheStats(cacheStats),
m_pdxTypeRegistry(pdxTypeRegistry),
- m_cache(cache),
+ m_cacheImpl(cacheImpl),
m_enableTimeStatistics(enableTimeStatistics) {
m_pdxType->InitializeType(); // to generate static position map
}
@@ -253,7 +268,7 @@ std::shared_ptr<WritablePdxInstance> PdxInstanceImpl::createWriter() {
m_bufferLength, m_typeId);
return std::make_shared<PdxInstanceImpl>(
m_buffer, m_bufferLength, m_typeId, m_cacheStats, m_pdxTypeRegistry,
- m_cache,
+ m_cacheImpl,
m_enableTimeStatistics); // need to create duplicate byte stream);
}
@@ -668,7 +683,7 @@ int32_t PdxInstanceImpl::hashcode() const {
auto pdxIdentityFieldList = getIdentityPdxFields(pt);
- auto dataInput = m_cache->createDataInput(m_buffer, m_bufferLength);
+ auto dataInput = m_cacheImpl->createDataInput(m_buffer, m_bufferLength);
for (uint32_t i = 0; i < pdxIdentityFieldList.size(); i++) {
auto pField = pdxIdentityFieldList.at(i);
@@ -1100,7 +1115,7 @@ std::string PdxInstanceImpl::toString() const {
}
std::shared_ptr<PdxSerializable> PdxInstanceImpl::getObject() {
- auto dataInput = m_cache->createDataInput(m_buffer, m_bufferLength);
+ auto dataInput = m_cacheImpl->createDataInput(m_buffer, m_bufferLength);
int64_t sampleStartNanos =
m_enableTimeStatistics ? Utils::startStatOpTime() : 0;
//[ToDo] do we have to call incPdxDeSerialization here?
@@ -1177,9 +1192,9 @@ bool PdxInstanceImpl::operator==(const CacheableKey& other) const {
equatePdxFields(myPdxIdentityFieldList, otherPdxIdentityFieldList);
equatePdxFields(otherPdxIdentityFieldList, myPdxIdentityFieldList);
- auto myDataInput = m_cache->createDataInput(m_buffer, m_bufferLength);
- auto otherDataInput =
- m_cache->createDataInput(otherPdx->m_buffer, otherPdx->m_bufferLength);
+ auto myDataInput = m_cacheImpl->createDataInput(m_buffer, m_bufferLength);
+ auto otherDataInput = m_cacheImpl->createDataInput(otherPdx->m_buffer,
+ otherPdx->m_bufferLength);
PdxFieldTypes fieldTypeId;
for (size_t i = 0; i < myPdxIdentityFieldList.size(); i++) {
@@ -1390,7 +1405,7 @@ void PdxInstanceImpl::toDataMutable(PdxWriter& writer) {
if (m_buffer != nullptr) {
uint8_t* copy = apache::geode::client::DataInput::getBufferCopy(
m_buffer, m_bufferLength);
- auto dataInput = m_cache->createDataInput(copy, m_bufferLength);
+ auto dataInput = m_cacheImpl->createDataInput(copy, m_bufferLength);
for (size_t i = 0; i < pdxFieldList->size(); i++) {
auto currPf = pdxFieldList->at(i);
LOGDEBUG("toData filedname = %s , isVarLengthType = %d ",
@@ -2026,7 +2041,7 @@ std::unique_ptr<DataInput> PdxInstanceImpl::getDataInputForField(
throw IllegalStateException("PdxInstance doesn't have field " + fieldname);
}
- auto dataInput = m_cache->createDataInput(m_buffer, m_bufferLength);
+ auto dataInput = m_cacheImpl->createDataInput(m_buffer, m_bufferLength);
auto pos = getOffset(*dataInput, pt, pft->getSequenceId());
dataInput->reset();
diff --git a/cppcache/src/PdxInstanceImpl.hpp b/cppcache/src/PdxInstanceImpl.hpp
index 1577900..b6689cf 100644
--- a/cppcache/src/PdxInstanceImpl.hpp
+++ b/cppcache/src/PdxInstanceImpl.hpp
@@ -214,22 +214,12 @@ class _GEODE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
PdxInstanceImpl(uint8_t* buffer, int length, int typeId,
CachePerfStats* cacheStats,
std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry,
- const Cache* cache, bool enableTimeStatistics)
- : m_buffer(DataInput::getBufferCopy(buffer, length)),
- m_bufferLength(length),
- m_typeId(typeId),
- m_pdxType(nullptr),
- m_cacheStats(cacheStats),
- m_pdxTypeRegistry(pdxTypeRegistry),
- m_cache(cache),
- m_enableTimeStatistics(enableTimeStatistics) {
- LOGDEBUG("PdxInstanceImpl::m_bufferLength = %d ", m_bufferLength);
- }
+ const CacheImpl* cacheImpl, bool enableTimeStatistics);
PdxInstanceImpl(FieldVsValues fieldVsValue, std::shared_ptr<PdxType> pdxType,
CachePerfStats* cacheStats,
std::shared_ptr<PdxTypeRegistry> pdxTypeRegistry,
- const Cache* cache, bool enableTimeStatistics);
+ const CacheImpl* cacheImpl, bool enableTimeStatistics);
PdxInstanceImpl(const PdxInstanceImpl& other) = delete;
@@ -248,7 +238,7 @@ class _GEODE_EXPORT PdxInstanceImpl : public WritablePdxInstance {
CachePerfStats* m_cacheStats;
std::shared_ptr<PdxTypeRegistry> m_pdxTypeRegistry;
- const Cache* m_cache;
+ const CacheImpl* m_cacheImpl;
bool m_enableTimeStatistics;
std::vector<std::shared_ptr<PdxFieldType>> getIdentityPdxFields(
diff --git a/cppcache/src/Pool.cpp b/cppcache/src/Pool.cpp
index 1f54c2c..3104f3a 100644
--- a/cppcache/src/Pool.cpp
+++ b/cppcache/src/Pool.cpp
@@ -20,7 +20,7 @@
#include <geode/CacheFactory.hpp>
#include "PoolAttributes.hpp"
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
#include "ThinClientPoolHADM.hpp"
/**
@@ -95,7 +95,8 @@ bool Pool::getThreadLocalConnections() const {
bool Pool::getMultiuserAuthentication() const {
return m_attrs->getMultiuserSecureModeEnabled();
}
-std::shared_ptr<RegionService> Pool::createSecureUserCache(
+
+AuthenticatedView Pool::createAuthenticatedView(
std::shared_ptr<Properties> credentials, CacheImpl* cacheImpl) {
if (this->getMultiuserAuthentication()) {
if (cacheImpl == nullptr) {
@@ -111,20 +112,17 @@ std::shared_ptr<RegionService> Pool::createSecureUserCache(
credentials = nullptr;
}
- // TODO: this will return cache with userattribtes
- return std::make_shared<ProxyCache>(credentials, shared_from_this(),
- cacheImpl);
+ return AuthenticatedView(credentials, shared_from_this(), cacheImpl);
}
throw IllegalStateException(
"This operation is only allowed when attached pool is in "
"multiuserSecureMode");
- // return nullptr;
}
+
bool Pool::getPRSingleHopEnabled() const {
return m_attrs->getPRSingleHopEnabled();
}
-// void Pool::releaseThreadLocalConnection(){}
int Pool::getPendingEventCount() const {
const auto poolHADM = dynamic_cast<const ThinClientPoolHADM*>(this);
diff --git a/cppcache/src/ProxyRegion.hpp b/cppcache/src/ProxyRegion.hpp
index 9cfc53b..64bbcfb 100644
--- a/cppcache/src/ProxyRegion.hpp
+++ b/cppcache/src/ProxyRegion.hpp
@@ -40,7 +40,8 @@
#include <geode/Query.hpp>
#include "RegionInternal.hpp"
-#include "ProxyCache.hpp"
+#include "UserAttributes.hpp"
+#include <geode/AuthenticatedView.hpp>
namespace apache {
namespace geode {
@@ -91,13 +92,13 @@ class _GEODE_EXPORT ProxyRegion : public Region {
virtual void destroyRegion(const std::shared_ptr<Serializable>&
aCallbackArgument = nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
m_realRegion->destroyRegion(aCallbackArgument);
}
virtual void clear(const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
m_realRegion->clear(aCallbackArgument);
}
@@ -119,7 +120,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
if (rPtr == nullptr) return rPtr;
- return std::make_shared<ProxyRegion>(m_proxyCache, rPtr);
+ return std::make_shared<ProxyRegion>(*m_authenticatedView, rPtr);
}
virtual std::shared_ptr<Region> createSubregion(
@@ -135,15 +136,14 @@ class _GEODE_EXPORT ProxyRegion : public Region {
m_realRegion->subregions(recursive);
std::vector<std::shared_ptr<Region>> proxyRegions(realVectorRegion.size());
- std::transform(
- realVectorRegion.begin(), realVectorRegion.end(),
- std::back_inserter(proxyRegions),
- [this](const std::shared_ptr<Region>& realRegion)
- -> std::shared_ptr<ProxyRegion> {
- return std::make_shared<ProxyRegion>(
- m_proxyCache,
- std::static_pointer_cast<RegionInternal>(realRegion));
- });
+ std::transform(realVectorRegion.begin(), realVectorRegion.end(),
+ std::back_inserter(proxyRegions),
+ [this](const std::shared_ptr<Region>& realRegion)
+ -> std::shared_ptr<ProxyRegion> {
+ return std::make_shared<ProxyRegion>(
+ *m_authenticatedView,
+ std::static_pointer_cast<RegionInternal>(realRegion));
+ });
return proxyRegions;
}
@@ -163,7 +163,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->get(key, aCallbackArgument);
}
@@ -179,7 +179,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->put(key, value, aCallbackArgument);
}
@@ -210,7 +210,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
std::chrono::milliseconds timeout = DEFAULT_RESPONSE_TIMEOUT,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->putAll(map, timeout, aCallbackArgument);
}
@@ -248,7 +248,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
m_realRegion->create(key, value, aCallbackArgument);
}
@@ -308,7 +308,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
virtual void invalidate(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>&
aCallbackArgument = nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
m_realRegion->invalidate(key, aCallbackArgument);
}
@@ -335,7 +335,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
virtual void destroy(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
m_realRegion->destroy(key, aCallbackArgument);
}
@@ -363,7 +363,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->remove(key, value, aCallbackArgument);
}
@@ -393,7 +393,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
virtual bool removeEx(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->removeEx(key, aCallbackArgument);
}
@@ -460,7 +460,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
}
virtual std::vector<std::shared_ptr<CacheableKey>> serverKeys() override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->serverKeys();
}
@@ -474,7 +474,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
}
virtual RegionService& getRegionService() const override {
- return *m_proxyCache;
+ return *m_authenticatedView;
}
virtual bool isDestroyed() const override {
@@ -506,7 +506,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
virtual bool containsKeyOnServer(
const std::shared_ptr<CacheableKey>& keyPtr) const override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->containsKeyOnServer(keyPtr);
}
@@ -567,7 +567,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
const std::vector<std::shared_ptr<CacheableKey>>& keys,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->getAll_internal(keys, aCallbackArgument, false);
}
@@ -575,14 +575,14 @@ class _GEODE_EXPORT ProxyRegion : public Region {
const std::string& predicate,
std::chrono::milliseconds timeout =
DEFAULT_QUERY_RESPONSE_TIMEOUT) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->query(predicate, timeout);
}
virtual bool existsValue(const std::string& predicate,
std::chrono::milliseconds timeout =
DEFAULT_QUERY_RESPONSE_TIMEOUT) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->existsValue(predicate, timeout);
}
@@ -590,14 +590,14 @@ class _GEODE_EXPORT ProxyRegion : public Region {
const std::string& predicate,
std::chrono::milliseconds timeout =
DEFAULT_QUERY_RESPONSE_TIMEOUT) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
return m_realRegion->selectValue(predicate, timeout);
}
virtual void removeAll(const std::vector<std::shared_ptr<CacheableKey>>& keys,
const std::shared_ptr<Serializable>&
aCallbackArgument = nullptr) override {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
m_realRegion->removeAll(keys, aCallbackArgument);
}
@@ -607,10 +607,10 @@ class _GEODE_EXPORT ProxyRegion : public Region {
return m_realRegion->getPool();
}
- ProxyRegion(const std::shared_ptr<ProxyCache>& proxyCache,
+ ProxyRegion(AuthenticatedView& authenticatedView,
const std::shared_ptr<RegionInternal>& realRegion)
- : Region(&realRegion->getCache()) {
- m_proxyCache = proxyCache;
+ : Region(authenticatedView.m_cacheImpl) {
+ m_authenticatedView = &authenticatedView;
m_realRegion = realRegion;
}
@@ -620,7 +620,7 @@ class _GEODE_EXPORT ProxyRegion : public Region {
ProxyRegion& operator=(const ProxyRegion&) = delete;
private:
- std::shared_ptr<ProxyCache> m_proxyCache;
+ AuthenticatedView* m_authenticatedView;
std::shared_ptr<RegionInternal> m_realRegion;
friend class FunctionService;
diff --git a/cppcache/src/ProxyRemoteQueryService.cpp b/cppcache/src/ProxyRemoteQueryService.cpp
index 12cfa05..8fad96f 100644
--- a/cppcache/src/ProxyRemoteQueryService.cpp
+++ b/cppcache/src/ProxyRemoteQueryService.cpp
@@ -24,19 +24,18 @@ namespace apache {
namespace geode {
namespace client {
-ProxyRemoteQueryService::ProxyRemoteQueryService(
- std::shared_ptr<ProxyCache> cptr)
- : m_proxyCache(cptr) {}
+ProxyRemoteQueryService::ProxyRemoteQueryService(AuthenticatedView* cptr)
+ : m_authenticatedView(cptr) {}
std::shared_ptr<Query> ProxyRemoteQueryService::newQuery(
std::string querystring) {
- if (!m_proxyCache->isClosed()) {
- auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
- auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+ if (!m_authenticatedView->isClosed()) {
+ auto userAttachedPool = m_authenticatedView->m_userAttributes->getPool();
+ auto pool = m_authenticatedView->m_cacheImpl->getCache()->getPoolManager().find(
userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
if (!poolDM->isDestroyed()) {
return poolDM->getQueryServiceWithoutCheck()->newQuery(querystring);
@@ -57,13 +56,13 @@ void ProxyRemoteQueryService::unSupportedException(
std::shared_ptr<CqQuery> ProxyRemoteQueryService::newCq(
std::string querystr, const std::shared_ptr<CqAttributes>& cqAttr,
bool isDurable) {
- if (!m_proxyCache->isClosed()) {
- auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
- auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+ if (!m_authenticatedView->isClosed()) {
+ auto userAttachedPool = m_authenticatedView->m_userAttributes->getPool();
+ auto pool = m_authenticatedView->m_cacheImpl->getCache()->getPoolManager().find(
userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
auto pooDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
if (!pooDM->isDestroyed()) {
auto cqQuery = pooDM->getQueryServiceWithoutCheck()->newCq(
@@ -86,13 +85,13 @@ void ProxyRemoteQueryService::addCqQuery(
std::shared_ptr<CqQuery> ProxyRemoteQueryService::newCq(
std::string name, std::string querystr,
const std::shared_ptr<CqAttributes>& cqAttr, bool isDurable) {
- if (!m_proxyCache->isClosed()) {
- auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
- auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+ if (!m_authenticatedView->isClosed()) {
+ auto userAttachedPool = m_authenticatedView->m_userAttributes->getPool();
+ auto pool = m_authenticatedView->m_cacheImpl->getCache()->getPoolManager().find(
userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
if (!poolDM->isDestroyed()) {
auto cqQuery = poolDM->getQueryServiceWithoutCheck()->newCq(
@@ -137,13 +136,13 @@ QueryService::query_container_type ProxyRemoteQueryService::getCqs() const {
std::shared_ptr<CqQuery> ProxyRemoteQueryService::getCq(
const std::string& name) const {
- if (!m_proxyCache->isClosed()) {
- auto userAttachedPool = m_proxyCache->m_userAttributes->getPool();
- auto pool = m_proxyCache->m_cacheImpl->getCache()->getPoolManager().find(
+ if (!m_authenticatedView->isClosed()) {
+ auto userAttachedPool = m_authenticatedView->m_userAttributes->getPool();
+ auto pool = m_authenticatedView->m_cacheImpl->getCache()->getPoolManager().find(
userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
- GuardUserAttribures gua(m_proxyCache.get());
+ GuardUserAttributes gua(m_authenticatedView);
auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
if (!poolDM->isDestroyed()) {
return poolDM->getQueryServiceWithoutCheck()->getCq(name);
@@ -190,13 +189,13 @@ std::shared_ptr<CqServiceStatistics>
ProxyRemoteQueryService::getCqServiceStatistics() const {
unSupportedException("getCqServiceStatistics()");
return nullptr;
- }
- std::shared_ptr<CacheableArrayList>
- ProxyRemoteQueryService::getAllDurableCqsFromServer() const {
- unSupportedException("getAllDurableCqsFromServer()");
- return nullptr;
- }
-
- } // namespace client
- } // namespace geode
- } // namespace apache
+}
+std::shared_ptr<CacheableArrayList>
+ProxyRemoteQueryService::getAllDurableCqsFromServer() const {
+ unSupportedException("getAllDurableCqsFromServer()");
+ return nullptr;
+}
+
+} // namespace client
+} // namespace geode
+} // namespace apache
diff --git a/cppcache/src/ProxyRemoteQueryService.hpp b/cppcache/src/ProxyRemoteQueryService.hpp
index 3aad960..650d7f2 100644
--- a/cppcache/src/ProxyRemoteQueryService.hpp
+++ b/cppcache/src/ProxyRemoteQueryService.hpp
@@ -24,7 +24,7 @@
#include "CqService.hpp"
#include "UserAttributes.hpp"
#include <geode/QueryService.hpp>
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
#include "ThinClientCacheDistributionManager.hpp"
#include <ace/Recursive_Thread_Mutex.h>
@@ -38,7 +38,7 @@ class ThinClientPoolDM;
class _GEODE_EXPORT ProxyRemoteQueryService : public QueryService {
public:
- ProxyRemoteQueryService(std::shared_ptr<ProxyCache> cptr);
+ ProxyRemoteQueryService(AuthenticatedView* cptr);
virtual ~ProxyRemoteQueryService() = default;
std::shared_ptr<Query> newQuery(std::string querystring) override;
@@ -75,12 +75,12 @@ class _GEODE_EXPORT ProxyRemoteQueryService : public QueryService {
void closeCqs(bool keepAlive);
std::shared_ptr<QueryService> m_realQueryService;
- std::shared_ptr<ProxyCache> m_proxyCache;
+ AuthenticatedView* m_authenticatedView;
query_container_type m_cqQueries;
// lock for cqQuery list;
mutable ACE_Recursive_Thread_Mutex m_cqQueryListLock;
- friend class ProxyCache;
+ friend class AuthenticatedView;
};
} // namespace client
diff --git a/cppcache/src/Region.cpp b/cppcache/src/Region.cpp
index f834efb..08d1314 100644
--- a/cppcache/src/Region.cpp
+++ b/cppcache/src/Region.cpp
@@ -16,12 +16,18 @@
*/
#include <geode/Region.hpp>
+#include "CacheImpl.hpp"
namespace apache {
namespace geode {
namespace client {
-Region::Region(Cache* cache) : m_cache(cache) {}
+
+Region::Region(CacheImpl* cacheImpl) : m_cacheImpl(cacheImpl) {}
+
Region::~Region() {}
+
+Cache& Region::getCache() { return *m_cacheImpl->getCache(); }
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/RegionInternal.cpp b/cppcache/src/RegionInternal.cpp
index b8a9262..9bc1e59 100644
--- a/cppcache/src/RegionInternal.cpp
+++ b/cppcache/src/RegionInternal.cpp
@@ -38,10 +38,9 @@ const CacheEventFlags CacheEventFlags::CACHE_CLOSE(
const CacheEventFlags CacheEventFlags::NOCACHEWRITER(
CacheEventFlags::GF_NOCACHEWRITER);
-RegionInternal::RegionInternal(
- Cache* cache,
- RegionAttributes attributes)
- : Region(cache), m_regionAttributes(attributes) {}
+RegionInternal::RegionInternal(CacheImpl* cacheImpl,
+ RegionAttributes attributes)
+ : Region(cacheImpl), m_regionAttributes(attributes) {}
RegionInternal::~RegionInternal() {}
@@ -60,8 +59,7 @@ void RegionInternal::unregisterKeys(
"Thin Client Region.");
}
-void RegionInternal::registerAllKeys(bool isDurable,
- bool getInitialValues,
+void RegionInternal::registerAllKeys(bool isDurable, bool getInitialValues,
bool receiveValues) {
throw UnsupportedOperationException(
"registerAllKeys only supported by Thin Client Region.");
@@ -149,7 +147,8 @@ void RegionInternal::setEntryIdleTimeout(const std::chrono::seconds& duration) {
m_regionAttributes.m_entryIdleTimeout = duration;
}
-void RegionInternal::setCacheListener(const std::shared_ptr<CacheListener>& aListener) {
+void RegionInternal::setCacheListener(
+ const std::shared_ptr<CacheListener>& aListener) {
m_regionAttributes.m_cacheListener = aListener;
}
@@ -168,7 +167,8 @@ void RegionInternal::setPartitionResolver(const std::string& libpath,
m_regionAttributes.setPartitionResolver(libpath, factoryFuncName);
}
-void RegionInternal::setCacheLoader(const std::shared_ptr<CacheLoader>& aLoader) {
+void RegionInternal::setCacheLoader(
+ const std::shared_ptr<CacheLoader>& aLoader) {
m_regionAttributes.m_cacheLoader = aLoader;
}
@@ -177,7 +177,8 @@ void RegionInternal::setCacheLoader(const std::string& libpath,
m_regionAttributes.setCacheLoader(libpath, factoryFuncName);
}
-void RegionInternal::setCacheWriter(const std::shared_ptr<CacheWriter>& aWriter) {
+void RegionInternal::setCacheWriter(
+ const std::shared_ptr<CacheWriter>& aWriter) {
m_regionAttributes.m_cacheWriter = aWriter;
}
diff --git a/cppcache/src/RegionInternal.hpp b/cppcache/src/RegionInternal.hpp
index 1e4b283..3b6ad4b 100644
--- a/cppcache/src/RegionInternal.hpp
+++ b/cppcache/src/RegionInternal.hpp
@@ -180,7 +180,8 @@ class RegionInternal : public Region {
/** @brief Public Methods
*/
virtual std::shared_ptr<PersistenceManager> getPersistenceManager() = 0;
- virtual void setPersistenceManager(std::shared_ptr<PersistenceManager>& pmPtr) = 0;
+ virtual void setPersistenceManager(
+ std::shared_ptr<PersistenceManager>& pmPtr) = 0;
virtual GfErrType getNoThrow(
const std::shared_ptr<CacheableKey>& key,
@@ -247,13 +248,16 @@ class RegionInternal : public Region {
const std::chrono::seconds& duration) = 0;
virtual std::chrono::seconds adjustEntryExpiryDuration(
const std::chrono::seconds& duration) = 0;
- virtual void adjustCacheListener(const std::shared_ptr<CacheListener>& aListener) = 0;
+ virtual void adjustCacheListener(
+ const std::shared_ptr<CacheListener>& aListener) = 0;
virtual void adjustCacheListener(const std::string& libpath,
const std::string& factoryFuncName) = 0;
- virtual void adjustCacheLoader(const std::shared_ptr<CacheLoader>& aLoader) = 0;
+ virtual void adjustCacheLoader(
+ const std::shared_ptr<CacheLoader>& aLoader) = 0;
virtual void adjustCacheLoader(const std::string& libpath,
const std::string& factoryFuncName) = 0;
- virtual void adjustCacheWriter(const std::shared_ptr<CacheWriter>& aWriter) = 0;
+ virtual void adjustCacheWriter(
+ const std::shared_ptr<CacheWriter>& aWriter) = 0;
virtual void adjustCacheWriter(const std::string& libpath,
const std::string& factoryFuncName) = 0;
@@ -292,7 +296,7 @@ class RegionInternal : public Region {
/**
* @brief constructor
*/
- RegionInternal(Cache* cache, RegionAttributes attributes);
+ RegionInternal(CacheImpl* cache, RegionAttributes attributes);
void setLruEntriesLimit(uint32_t limit);
void setRegionTimeToLiveExpirationAction(ExpirationAction action);
diff --git a/cppcache/src/RemoteQuery.cpp b/cppcache/src/RemoteQuery.cpp
index f549b4f..55f0d97 100644
--- a/cppcache/src/RemoteQuery.cpp
+++ b/cppcache/src/RemoteQuery.cpp
@@ -15,16 +15,11 @@
* limitations under the License.
*/
-#include <geode/GeodeTypeIds.hpp>
-
#include "RemoteQuery.hpp"
-#include "TcrMessage.hpp"
#include "ResultSetImpl.hpp"
#include "StructSetImpl.hpp"
-#include "ReadWriteLock.hpp"
#include "ThinClientRegion.hpp"
#include "UserAttributes.hpp"
-#include "EventId.hpp"
#include "ThinClientPoolDM.hpp"
#include "util/bounds.hpp"
#include "util/exception.hpp"
@@ -36,36 +31,39 @@ namespace client {
RemoteQuery::RemoteQuery(
std::string querystr,
const std::shared_ptr<RemoteQueryService>& queryService,
- ThinClientBaseDM* tccdmptr, ProxyCache* proxyCache)
+ ThinClientBaseDM* tccdmptr, AuthenticatedView* authenticatedView)
: m_queryString(querystr),
m_queryService(queryService),
m_tccdm(tccdmptr),
- m_proxyCache(proxyCache) {
+ m_authenticatedView(authenticatedView) {
LOGFINEST("RemoteQuery: created a new query: " + querystr);
}
+
std::shared_ptr<SelectResults> RemoteQuery::execute(
std::chrono::milliseconds timeout) {
util::PROTOCOL_OPERATION_TIMEOUT_BOUNDS(timeout);
- GuardUserAttribures gua;
- if (m_proxyCache != nullptr) {
- gua.setProxyCache(m_proxyCache);
+ GuardUserAttributes gua;
+ if (m_authenticatedView != nullptr) {
+ gua.setAuthenticatedView(m_authenticatedView);
}
return execute(timeout, "Query::execute", m_tccdm, nullptr);
}
+
std::shared_ptr<SelectResults> RemoteQuery::execute(
std::shared_ptr<CacheableVector> paramList,
std::chrono::milliseconds timeout) {
util::PROTOCOL_OPERATION_TIMEOUT_BOUNDS(timeout);
- GuardUserAttribures gua;
- if (m_proxyCache != nullptr) {
- gua.setProxyCache(m_proxyCache);
+ GuardUserAttributes gua;
+ if (m_authenticatedView != nullptr) {
+ gua.setAuthenticatedView(m_authenticatedView);
}
return execute(timeout, "Query::execute", m_tccdm, paramList);
}
+
std::shared_ptr<SelectResults> RemoteQuery::execute(
std::chrono::milliseconds timeout, const char* func, ThinClientBaseDM* tcdm,
std::shared_ptr<CacheableVector> paramList) {
- ThinClientPoolDM* pool = dynamic_cast<ThinClientPoolDM*>(tcdm);
+ auto* pool = dynamic_cast<ThinClientPoolDM*>(tcdm);
if (pool != nullptr) {
pool->getStats().incQueryExecutionId();
}
@@ -78,7 +76,7 @@ std::shared_ptr<SelectResults> RemoteQuery::execute(
int64_t sampleStartNanos =
enableTimeStatistics ? Utils::startStatOpTime() : 0;
TcrMessageReply reply(true, tcdm);
- ChunkedQueryResponse* resultCollector = (new ChunkedQueryResponse(reply));
+ auto* resultCollector = (new ChunkedQueryResponse(reply));
reply.setChunkedResultHandler(
static_cast<TcrChunkedResult*>(resultCollector));
GfErrType err = executeNoThrow(timeout, reply, func, tcdm, paramList);
diff --git a/cppcache/src/RemoteQuery.hpp b/cppcache/src/RemoteQuery.hpp
index 6953c52..8a950b0 100644
--- a/cppcache/src/RemoteQuery.hpp
+++ b/cppcache/src/RemoteQuery.hpp
@@ -24,6 +24,7 @@
#include <memory>
#include <geode/internal/geode_globals.hpp>
+#include <geode/AuthenticatedView.hpp>
#include <geode/ExceptionTypes.hpp>
#include <geode/Query.hpp>
#include <geode/SelectResults.hpp>
@@ -32,7 +33,6 @@
#include "CacheImpl.hpp"
#include "ThinClientBaseDM.hpp"
-#include "ProxyCache.hpp"
/**
* @file
@@ -44,16 +44,15 @@ namespace client {
class _GEODE_EXPORT RemoteQuery : public Query {
std::string m_queryString;
-
std::shared_ptr<RemoteQueryService> m_queryService;
ThinClientBaseDM* m_tccdm;
- ProxyCache* m_proxyCache;
+ AuthenticatedView* m_authenticatedView;
public:
RemoteQuery(std::string querystr,
const std::shared_ptr<RemoteQueryService>& queryService,
ThinClientBaseDM* tccdmptr,
- ProxyCache* proxyCache = nullptr);
+ AuthenticatedView* authenticatedView = nullptr);
std::shared_ptr<SelectResults> execute(
std::chrono::milliseconds timeout =
diff --git a/cppcache/src/RemoteQueryService.cpp b/cppcache/src/RemoteQueryService.cpp
index f59431b..a940266 100644
--- a/cppcache/src/RemoteQueryService.cpp
+++ b/cppcache/src/RemoteQueryService.cpp
@@ -67,8 +67,10 @@ std::shared_ptr<Query> RemoteQueryService::newQuery(std::string querystring) {
throw CacheClosedException(
"QueryService::newQuery: Cache has been closed.");
}
+
LOGDEBUG("RemoteQueryService: creating a new query: " + querystring);
- return std::shared_ptr<Query>(new RemoteQuery(querystring, shared_from_this(), m_tccdm));
+ return std::shared_ptr<Query>(
+ new RemoteQuery(querystring, shared_from_this(), m_tccdm));
} else {
auto ua =
TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes();
@@ -78,21 +80,24 @@ std::shared_ptr<Query> RemoteQueryService::newQuery(std::string querystring) {
throw CacheClosedException(
"QueryService::newQuery: Cache has been closed.");
}
+
LOGDEBUG("RemoteQueryService: creating a new query: " + querystring);
return std::shared_ptr<Query>(new RemoteQuery(
- querystring, shared_from_this(), m_tccdm, ua->getProxyCache()));
+ querystring, shared_from_this(), m_tccdm, ua->getAuthenticatedView()));
}
}
void RemoteQueryService::close() {
LOGFINEST("RemoteQueryService::close: starting close");
TryWriteGuard guard(m_rwLock, m_invalid);
+
if (m_cqService != nullptr) {
LOGFINEST("RemoteQueryService::close: starting CQ service close");
m_cqService->closeCqService();
m_cqService = nullptr;
LOGFINEST("RemoteQueryService::close: completed CQ service close");
}
+
if (dynamic_cast<ThinClientCacheDistributionManager*>(m_tccdm)) {
if (!m_invalid) {
LOGFINEST("RemoteQueryService::close: destroying DM");
@@ -101,9 +106,11 @@ void RemoteQueryService::close() {
_GEODE_SAFE_DELETE(m_tccdm);
m_invalid = true;
}
+
if (!m_CqPoolsConnected.empty()) {
m_CqPoolsConnected.clear();
}
+
LOGFINEST("RemoteQueryService::close: completed");
}
@@ -136,6 +143,7 @@ void RemoteQueryService::executeAllCqs(bool failover) {
LOGFINE("QueryService::executeAllCqs: Not initialized.");
return;
}
+
/*if cq has not been started, then failover will not start it.*/
if (m_cqService != nullptr) {
LOGFINE("RemoteQueryService: execute all cqs after failover");
@@ -159,6 +167,7 @@ std::shared_ptr<CqQuery> RemoteQueryService::newCq(
name += querystr;
return m_cqService->newCq(name, querystr, cqAttr, isDurable);
}
+
std::shared_ptr<CqQuery> RemoteQueryService::newCq(
std::string name, std::string querystr,
const std::shared_ptr<CqAttributes>& cqAttr, bool isDurable) {
@@ -167,6 +176,7 @@ std::shared_ptr<CqQuery> RemoteQueryService::newCq(
if (m_invalid) {
throw CacheClosedException("QueryService::newCq: Cache has been closed.");
}
+
initCqService();
return m_cqService->newCq(name, querystr, cqAttr, isDurable);
}
@@ -178,6 +188,7 @@ void RemoteQueryService::closeCqs() {
LOGFINE("QueryService::closeCqs: Cache has been closed.");
return;
}
+
// If cqService has not started, then no cq exists
if (m_cqService != nullptr) {
m_cqService->closeAllCqs();
@@ -199,6 +210,7 @@ CqService::query_container_type RemoteQueryService::getCqs() const {
return vec;
}
+
std::shared_ptr<CqQuery> RemoteQueryService::getCq(
const std::string& name) const {
TryReadGuard guard(m_rwLock, m_invalid);
@@ -222,6 +234,7 @@ void RemoteQueryService::executeCqs() {
throw CacheClosedException(
"QueryService::executeCqs: Cache has been closed.");
}
+
// If cqService has not started, then no cq exists
if (m_cqService != nullptr) {
m_cqService->executeAllClientCqs();
@@ -235,6 +248,7 @@ void RemoteQueryService::stopCqs() {
LOGFINE("QueryService::stopCqs: Cache has been closed.");
return;
}
+
// If cqService has not started, then no cq exists
if (m_cqService != nullptr) {
m_cqService->stopAllClientCqs();
diff --git a/cppcache/src/TXState.cpp b/cppcache/src/TXState.cpp
index 12036ec..0561d48 100644
--- a/cppcache/src/TXState.cpp
+++ b/cppcache/src/TXState.cpp
@@ -28,14 +28,14 @@ namespace apache {
namespace geode {
namespace client {
-TXState::TXState(Cache* cache) {
+TXState::TXState(CacheImpl* cacheImpl) {
m_txId = TXId();
m_closed = false;
m_modSerialNum = 0;
m_dirty = false;
m_replay = false;
m_prepared = false;
- m_cache = cache;
+ m_cache = cacheImpl;
/* adongre
* Non-static class member "m_suspendedExpiryTaskId" is not initialized in
* this constructor nor in any functions that it calls.
diff --git a/cppcache/src/TXState.hpp b/cppcache/src/TXState.hpp
index b53b4ac..f9e2ced 100644
--- a/cppcache/src/TXState.hpp
+++ b/cppcache/src/TXState.hpp
@@ -37,7 +37,7 @@ namespace client {
class ThinClientPoolDM;
class TXState {
public:
- TXState(Cache* cache);
+ TXState(CacheImpl* cacheImpl);
virtual ~TXState();
TXId& getTransactionId();
@@ -82,7 +82,7 @@ class TXState {
int32_t nextModSerialNum();
bool m_replay;
std::vector<std::shared_ptr<TransactionalOperation>> m_operations;
- Cache* m_cache;
+ CacheImpl* m_cache;
ThinClientPoolDM* m_pooldm;
long m_suspendedExpiryTaskId;
class ReplayControl {
diff --git a/cppcache/src/TcrChunkedContext.hpp b/cppcache/src/TcrChunkedContext.hpp
index a3e741f..c1fa41c 100644
--- a/cppcache/src/TcrChunkedContext.hpp
+++ b/cppcache/src/TcrChunkedContext.hpp
@@ -53,7 +53,7 @@ class TcrChunkedResult {
/** handle a chunk of response message from server */
virtual void handleChunk(const uint8_t* bytes, int32_t len,
uint8_t isLastChunkWithSecurity,
- const Cache* cache) = 0;
+ const CacheImpl* cacheImpl) = 0;
public:
inline TcrChunkedResult()
@@ -75,14 +75,15 @@ class TcrChunkedResult {
virtual void reset() = 0;
void fireHandleChunk(const uint8_t* bytes, int32_t len,
- uint8_t isLastChunkWithSecurity, const Cache* cache) {
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl) {
if (appDomainContext) {
appDomainContext->run(
- [this, bytes, len, isLastChunkWithSecurity, &cache]() {
- handleChunk(bytes, len, isLastChunkWithSecurity, cache);
+ [this, bytes, len, isLastChunkWithSecurity, cacheImpl]() {
+ handleChunk(bytes, len, isLastChunkWithSecurity, cacheImpl);
});
} else {
- handleChunk(bytes, len, isLastChunkWithSecurity, cache);
+ handleChunk(bytes, len, isLastChunkWithSecurity, cacheImpl);
}
}
@@ -120,9 +121,7 @@ class TcrChunkedResult {
inline bool exceptionOccurred() const { return (m_ex != nullptr); }
- inline void setException(std::shared_ptr<Exception> ex) {
- m_ex = ex;
- }
+ inline void setException(std::shared_ptr<Exception> ex) { m_ex = ex; }
inline std::shared_ptr<Exception>& getException() { return m_ex; }
};
@@ -136,17 +135,18 @@ class TcrChunkedContext {
const uint8_t* m_bytes;
const int32_t m_len;
const uint8_t m_isLastChunkWithSecurity;
- const Cache* m_cache;
+ const CacheImpl* m_cache;
TcrChunkedResult* m_result;
public:
inline TcrChunkedContext(const uint8_t* bytes, int32_t len,
TcrChunkedResult* result,
- uint8_t isLastChunkWithSecurity, const Cache* cache)
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl)
: m_bytes(bytes),
m_len(len),
m_isLastChunkWithSecurity(isLastChunkWithSecurity),
- m_cache(cache),
+ m_cache(cacheImpl),
m_result(result) {}
inline ~TcrChunkedContext() { _GEODE_SAFE_DELETE_ARRAY(m_bytes); }
diff --git a/cppcache/src/TcrConnection.cpp b/cppcache/src/TcrConnection.cpp
index 78e9729..b8b6ae5 100644
--- a/cppcache/src/TcrConnection.cpp
+++ b/cppcache/src/TcrConnection.cpp
@@ -1111,7 +1111,7 @@ void TcrConnection::close() {
}
TcrMessage* closeMsg = TcrMessage::getCloseConnMessage(
- m_poolDM->getConnectionManager().getCacheImpl()->getCache());
+ m_poolDM->getConnectionManager().getCacheImpl());
try {
if (!TcrConnectionManager::TEST_DURABLE_CLIENT_CRASH &&
!m_connectionManager->isNetDown()) {
diff --git a/cppcache/src/TcrEndpoint.cpp b/cppcache/src/TcrEndpoint.cpp
index c6503fb..6721f67 100644
--- a/cppcache/src/TcrEndpoint.cpp
+++ b/cppcache/src/TcrEndpoint.cpp
@@ -35,10 +35,10 @@ namespace apache {
namespace geode {
namespace client {
-#define throwException(ex) \
- { \
+#define throwException(ex) \
+ { \
LOGFINEST("%s: %s", ex.getName(), ex.what()); \
- throw ex; \
+ throw ex; \
}
/*
This is replaced by the connect-timeout (times 3) system property for SR # 6525.
@@ -551,8 +551,7 @@ void TcrEndpoint::pingServer(ThinClientPoolDM* poolDM) {
}
if (!m_msgSent && !m_pingSent) {
- TcrMessagePing* pingMsg =
- TcrMessage::getPingMessage(m_cacheImpl->getCache());
+ TcrMessagePing* pingMsg = TcrMessage::getPingMessage(m_cacheImpl);
TcrMessageReply reply(true, nullptr);
LOGFINEST("Sending ping message to endpoint %s", m_name.c_str());
GfErrType error;
@@ -697,11 +696,11 @@ int TcrEndpoint::receiveNotification(volatile bool& isRunning) {
}
} else {
LOGDEBUG("receive cq notification %d", msg->getMessageType());
- auto queryService = getQueryService();
- if (queryService != nullptr) {
- static_cast<RemoteQueryService*>(queryService.get())
- ->receiveNotification(msg);
- }
+ auto queryService = getQueryService();
+ if (queryService != nullptr) {
+ static_cast<RemoteQueryService*>(queryService.get())
+ ->receiveNotification(msg);
+ }
}
}
}
@@ -781,7 +780,8 @@ inline bool TcrEndpoint::handleIOException(const std::string& message,
// EAGAIN =11, EWOULDBLOCK = 10035L, EPIPE = 32, ECONNRESET =10054L(An
// existing connection was forcibly closed by the remote host.)
if (!(lastError == EAGAIN || lastError == EWOULDBLOCK /*||
- lastError == ECONNRESET */ /*|| lastError == EPIPE*/)) {
+ lastError == ECONNRESET */
+ /*|| lastError == EPIPE*/)) {
// break from enclosing loop without retries
// something wrong try connect in lock
m_needToConnectInLock = true;
@@ -1336,16 +1336,16 @@ bool TcrEndpoint::isQueueHosted() { return m_isQueueHosted; }
void TcrEndpoint::processMarker() {
m_cacheImpl->tcrConnectionManager().processMarker();
}
- std::shared_ptr<QueryService> TcrEndpoint::getQueryService() {
- return m_cacheImpl->getQueryService(true);
- }
- void TcrEndpoint::sendRequestForChunkedResponse(const TcrMessage& request,
- TcrMessageReply& reply,
- TcrConnection* conn) {
- conn->sendRequestForChunkedResponse(request, request.getMsgLength(), reply);
- }
- void TcrEndpoint::closeFailedConnection(TcrConnection*& conn) {
- closeConnection(conn);
+std::shared_ptr<QueryService> TcrEndpoint::getQueryService() {
+ return m_cacheImpl->getQueryService(true);
+}
+void TcrEndpoint::sendRequestForChunkedResponse(const TcrMessage& request,
+ TcrMessageReply& reply,
+ TcrConnection* conn) {
+ conn->sendRequestForChunkedResponse(request, request.getMsgLength(), reply);
+}
+void TcrEndpoint::closeFailedConnection(TcrConnection*& conn) {
+ closeConnection(conn);
}
} // namespace client
diff --git a/cppcache/src/TcrMessage.cpp b/cppcache/src/TcrMessage.cpp
index 3a4583a..daf7937 100644
--- a/cppcache/src/TcrMessage.cpp
+++ b/cppcache/src/TcrMessage.cpp
@@ -52,8 +52,8 @@ uint8_t* TcrMessage::m_keepalive = nullptr;
const int TcrMessage::m_flag_empty = 0x01;
const int TcrMessage::m_flag_concurrency_checks = 0x02;
-TcrMessagePing* TcrMessage::getPingMessage(Cache* cache) {
- static auto pingMsg = new TcrMessagePing(cache->createDataOutput(), true);
+TcrMessagePing* TcrMessage::getPingMessage(CacheImpl* cacheImpl) {
+ static auto pingMsg = new TcrMessagePing(cacheImpl->createDataOutput(), true);
return pingMsg;
}
@@ -62,9 +62,9 @@ TcrMessage* TcrMessage::getAllEPDisMess() {
return allEPDisconnected;
}
-TcrMessage* TcrMessage::getCloseConnMessage(Cache* cache) {
+TcrMessage* TcrMessage::getCloseConnMessage(CacheImpl* cacheImpl) {
static auto closeConnMsg =
- new TcrMessageCloseConnection(cache->createDataOutput(), true);
+ new TcrMessageCloseConnection(cacheImpl->createDataOutput(), true);
return closeConnMsg;
}
@@ -765,7 +765,7 @@ void TcrMessage::processChunk(const uint8_t* bytes, int32_t len,
m_msgTypeRequest == TcrMessage::PUT_ALL_WITH_CALLBACK) {
TcrChunkedContext* chunk = new TcrChunkedContext(
bytes, len, m_chunkedResult, isLastChunkAndisSecurityHeader,
- m_tcdm->getConnectionManager().getCacheImpl()->getCache());
+ m_tcdm->getConnectionManager().getCacheImpl());
m_chunkedResult->setEndpointMemId(endpointmemId);
m_tcdm->queueChunk(chunk);
if (bytes == nullptr) {
@@ -789,7 +789,7 @@ void TcrMessage::processChunk(const uint8_t* bytes, int32_t len,
LOGDEBUG("tcrmessage in case22 ");
TcrChunkedContext* chunk = new TcrChunkedContext(
bytes, len, m_chunkedResult, isLastChunkAndisSecurityHeader,
- m_tcdm->getConnectionManager().getCacheImpl()->getCache());
+ m_tcdm->getConnectionManager().getCacheImpl());
m_chunkedResult->setEndpointMemId(endpointmemId);
m_tcdm->queueChunk(chunk);
if (bytes == nullptr) {
diff --git a/cppcache/src/TcrMessage.hpp b/cppcache/src/TcrMessage.hpp
index 8d1b2d1..18d95cd 100644
--- a/cppcache/src/TcrMessage.hpp
+++ b/cppcache/src/TcrMessage.hpp
@@ -346,11 +346,11 @@ class _GEODE_EXPORT TcrMessage {
/* we need a static method to generate ping */
/* The caller should not delete the message since it is global. */
- static TcrMessagePing* getPingMessage(Cache* cache);
+ static TcrMessagePing* getPingMessage(CacheImpl* cacheImpl);
static TcrMessage* getAllEPDisMess();
/* we need a static method to generate close connection message */
/* The caller should not delete the message since it is global. */
- static TcrMessage* getCloseConnMessage(Cache* cache);
+ static TcrMessage* getCloseConnMessage(CacheImpl* cacheImpl);
static void setKeepAlive(bool keepalive);
bool isDurable() const { return m_isDurable; }
bool receiveValues() const { return m_receiveValues; }
diff --git a/cppcache/src/ThinClientBaseDM.cpp b/cppcache/src/ThinClientBaseDM.cpp
index 9e57689..525bc66 100644
--- a/cppcache/src/ThinClientBaseDM.cpp
+++ b/cppcache/src/ThinClientBaseDM.cpp
@@ -14,17 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <geode/internal/geode_globals.hpp>
#include "ThinClientBaseDM.hpp"
+
+#include <geode/AuthenticatedView.hpp>
+
#include "ThinClientRegion.hpp"
-#include "TcrMessage.hpp"
-#include "TcrEndpoint.hpp"
-#include <geode/ExceptionTypes.hpp>
-#include "Utils.hpp"
-#include "CacheImpl.hpp"
-#include <geode/SystemProperties.hpp>
-//#include "UserAttributes.hpp"
-#include "ProxyCache.hpp"
+#include "UserAttributes.hpp"
using namespace apache::geode::client;
@@ -40,7 +35,7 @@ ThinClientBaseDM::ThinClientBaseDM(TcrConnectionManager& connManager,
m_chunks(true),
m_chunkProcessor(nullptr) {}
-ThinClientBaseDM::~ThinClientBaseDM() {}
+ThinClientBaseDM::~ThinClientBaseDM() = default;
void ThinClientBaseDM::init() {
const auto& systemProperties = m_connManager.getCacheImpl()
@@ -97,14 +92,10 @@ GfErrType ThinClientBaseDM::sendSyncRequestRegisterInterest(
break;
case TcrMessage::REGISTER_INTEREST_DATA_ERROR:
- // LOGERROR( "An error occurred while registering interest "
- // "on the endpoint %s", getActiveEndpoint( )->name( ).c_str( ) );
err = GF_CACHESERVER_EXCEPTION;
break;
case TcrMessage::UNREGISTER_INTEREST_DATA_ERROR:
- // LOGERROR( "An error occurred while un-registering interest "
- // "on the endpoint %s", getActiveEndpoint( )->name( ).c_str( ) );
err = GF_CACHESERVER_EXCEPTION;
break;
@@ -144,9 +135,7 @@ GfErrType ThinClientBaseDM::handleEPError(TcrEndpoint* ep,
}
}
}
- } /*else if ( !ep->connected( ) ) {
- error = GF_NOTCON;
- }*/
+ }
}
return error;
}
@@ -176,8 +165,6 @@ bool ThinClientBaseDM::unrecoverableServerError(const char* exceptStr) {
return (
(strstr(exceptStr, "org.apache.geode.cache.CacheClosedException") !=
nullptr) ||
- /*(strstr(exceptStr,
- "org.apache.geode.cache.execute.FunctionException") != nullptr) ||*/
(strstr(exceptStr, "org.apache.geode.distributed.ShutdownException") !=
nullptr) ||
(strstr(exceptStr, "java.lang.OutOfMemoryError") != nullptr));
@@ -198,9 +185,7 @@ bool ThinClientBaseDM::nonFatalServerError(const char* exceptStr) {
(strstr(exceptStr, "java.lang.IllegalStateException") != nullptr));
}
-void ThinClientBaseDM::failover() {
- // Empty Implementation
-}
+void ThinClientBaseDM::failover() {}
void ThinClientBaseDM::queueChunk(TcrChunkedContext* chunk) {
LOGDEBUG("ThinClientBaseDM::queueChunk");
@@ -291,15 +276,16 @@ void ThinClientBaseDM::beforeSendingRequest(const TcrMessage& request,
}
if (request.getMessageType() == TcrMessage::USER_CREDENTIAL_MESSAGE) {
- TcrMessage* req = const_cast<TcrMessage*>(&request);
+ auto* req = const_cast<TcrMessage*>(&request);
req->createUserCredentialMessage(conn);
req->addSecurityPart(connId, conn);
} else if (TcrMessage::isUserInitiativeOps(request)) {
- TcrMessage* req = const_cast<TcrMessage*>(&request);
+ auto* req = const_cast<TcrMessage*>(&request);
req->addSecurityPart(connId, uniqueId, conn);
}
}
}
+
void ThinClientBaseDM::afterSendingRequest(const TcrMessage& request,
TcrMessageReply& reply,
TcrConnection* conn) {
diff --git a/cppcache/src/ThinClientHARegion.cpp b/cppcache/src/ThinClientHARegion.cpp
index 6e33c1d..6881bda 100644
--- a/cppcache/src/ThinClientHARegion.cpp
+++ b/cppcache/src/ThinClientHARegion.cpp
@@ -28,8 +28,7 @@ namespace client {
ThinClientHARegion::ThinClientHARegion(
const std::string& name, CacheImpl* cache,
- const std::shared_ptr<RegionInternal>& rPtr,
- RegionAttributes attributes,
+ const std::shared_ptr<RegionInternal>& rPtr, RegionAttributes attributes,
const std::shared_ptr<CacheStatistics>& stats, bool shared,
bool enableNotification)
: ThinClientRegion(name, cache, rPtr, attributes, stats, shared),
@@ -157,7 +156,7 @@ void ThinClientHARegion::addDisMessToQueue() {
if (poolDM->m_redundancyManager->m_globalProcessedMarker &&
!m_processedMarker) {
TcrMessage* regionMsg =
- new TcrMessageClientMarker(m_cache->createDataOutput(), true);
+ new TcrMessageClientMarker(m_cacheImpl->createDataOutput(), true);
receiveNotification(regionMsg);
}
}
@@ -166,7 +165,7 @@ void ThinClientHARegion::addDisMessToQueue() {
GfErrType ThinClientHARegion::getNoThrow_FullObject(
std::shared_ptr<EventId> eventId, std::shared_ptr<Cacheable>& fullObject,
std::shared_ptr<VersionTag>& versionTag) {
- TcrMessageRequestEventValue fullObjectMsg(m_cache->createDataOutput(),
+ TcrMessageRequestEventValue fullObjectMsg(m_cacheImpl->createDataOutput(),
eventId);
TcrMessageReply reply(true, nullptr);
diff --git a/cppcache/src/ThinClientPoolDM.cpp b/cppcache/src/ThinClientPoolDM.cpp
index d92bd10..a0a7131 100644
--- a/cppcache/src/ThinClientPoolDM.cpp
+++ b/cppcache/src/ThinClientPoolDM.cpp
@@ -112,10 +112,10 @@ class GetAllWork : public PooledWork<GfErrType>,
void init() {}
GfErrType execute(void) {
- GuardUserAttribures gua;
+ GuardUserAttributes gua;
if (m_userAttribute != nullptr) {
- gua.setProxyCache(m_userAttribute->getProxyCache());
+ gua.setAuthenticatedView(m_userAttribute->getAuthenticatedView());
}
m_request->InitializeGetallMsg(
m_request->getCallbackArgument()); // now init getall msg
diff --git a/cppcache/src/ThinClientPoolDM.hpp b/cppcache/src/ThinClientPoolDM.hpp
index dc72b88..fec3d85 100644
--- a/cppcache/src/ThinClientPoolDM.hpp
+++ b/cppcache/src/ThinClientPoolDM.hpp
@@ -41,7 +41,7 @@
#include "ThreadPool.hpp"
#include "ThinClientStickyManager.hpp"
#include "TXState.hpp"
-
+#include "UserAttributes.hpp"
#include "NonCopyable.hpp"
namespace apache {
@@ -487,9 +487,10 @@ class FunctionExecution : public PooledWork<GfErrType> {
GfErrType execute(void) {
// TSSUserAttributesWrapper::s_geodeTSSUserAttributes->setUserAttributes(m_userAttr);
- GuardUserAttribures gua;
+ GuardUserAttributes gua;
- if (m_userAttr != nullptr) gua.setProxyCache(m_userAttr->getProxyCache());
+ if (m_userAttr != nullptr)
+ gua.setAuthenticatedView(m_userAttr->getAuthenticatedView());
std::string funcName(m_func);
TcrMessageExecuteFunction request(m_poolDM->getConnectionManager()
@@ -616,9 +617,10 @@ class OnRegionFunctionExecution : public PooledWork<GfErrType> {
}
GfErrType execute(void) {
- GuardUserAttribures gua;
+ GuardUserAttributes gua;
- if (m_userAttr != nullptr) gua.setProxyCache(m_userAttr->getProxyCache());
+ if (m_userAttr != nullptr)
+ gua.setAuthenticatedView(m_userAttr->getAuthenticatedView());
return m_poolDM->sendSyncRequest(*m_request, *m_reply, !(m_getResult & 1),
m_isBGThread, m_serverLocation);
diff --git a/cppcache/src/ThinClientRedundancyManager.cpp b/cppcache/src/ThinClientRedundancyManager.cpp
index 2f45256..f1534ad 100644
--- a/cppcache/src/ThinClientRedundancyManager.cpp
+++ b/cppcache/src/ThinClientRedundancyManager.cpp
@@ -34,7 +34,7 @@
#include "ServerLocation.hpp"
#include "ThinClientLocatorHelper.hpp"
#include "UserAttributes.hpp"
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
#include <set>
#include <algorithm>
@@ -866,13 +866,13 @@ GfErrType ThinClientRedundancyManager::sendSyncRequestCq(
? 5
: attempts; // at least 5 attempts if ep lists are small.
- ProxyCache* proxyCache = nullptr;
+ AuthenticatedView* authenticatedView = nullptr;
while (attempts--) {
if (err != GF_NOERR || m_redundantEndpoints.empty()) {
auto userAttr = TSSUserAttributesWrapper::s_geodeTSSUserAttributes
->getUserAttributes();
- if (userAttr != nullptr) proxyCache = userAttr->getProxyCache();
+ if (userAttr != nullptr) authenticatedView = userAttr->getAuthenticatedView();
err = maintainRedundancyLevel();
// we continue on fatal error because MRL only tries a handshake without
// sending a request (no params passed) so no need to check
@@ -889,9 +889,9 @@ GfErrType ThinClientRedundancyManager::sendSyncRequestCq(
LOGDEBUG(
"ThinClientRedundancyManager::sendSyncRequestCq: to primary [%s]",
primaryEndpoint->name().c_str());
- GuardUserAttribures gua;
- if (proxyCache != nullptr) {
- gua.setProxyCache(proxyCache);
+ GuardUserAttributes gua;
+ if (authenticatedView != nullptr) {
+ gua.setAuthenticatedView(authenticatedView);
}
err = theHADM->sendRequestToEP(request, reply, primaryEndpoint);
if (err == GF_NOERR || err == GF_TIMOUT ||
diff --git a/cppcache/src/ThinClientRegion.cpp b/cppcache/src/ThinClientRegion.cpp
index 91ccb7d..835f0de 100644
--- a/cppcache/src/ThinClientRegion.cpp
+++ b/cppcache/src/ThinClientRegion.cpp
@@ -145,10 +145,10 @@ class PutAllWork : public PooledWork<GfErrType>,
void init() {}
GfErrType execute(void) {
- GuardUserAttribures gua;
+ GuardUserAttributes gua;
if (m_userAttribute != nullptr) {
- gua.setProxyCache(m_userAttribute->getProxyCache());
+ gua.setAuthenticatedView(m_userAttribute->getAuthenticatedView());
}
GfErrType err = GF_NOERR;
@@ -284,10 +284,10 @@ class RemoveAllWork : public PooledWork<GfErrType>,
void init() {}
GfErrType execute(void) {
- GuardUserAttribures gua;
+ GuardUserAttributes gua;
if (m_userAttribute != nullptr) {
- gua.setProxyCache(m_userAttribute->getProxyCache());
+ gua.setAuthenticatedView(m_userAttribute->getAuthenticatedView());
}
GfErrType err = GF_NOERR;
@@ -784,7 +784,7 @@ bool ThinClientRegion::containsKeyOnServer(
/** @brief Create message and send to bridge server */
TcrMessageContainsKey request(
- m_cache->createDataOutput(), this, keyPtr,
+ m_cacheImpl->createDataOutput(), this, keyPtr,
static_cast<std::shared_ptr<Serializable>>(nullptr), true, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
reply.setMessageTypeRequest(TcrMessage::CONTAINS_KEY);
@@ -831,7 +831,7 @@ bool ThinClientRegion::containsValueForKey_remote(
/** @brief Create message and send to bridge server */
TcrMessageContainsKey request(
- m_cache->createDataOutput(), this, keyPtr,
+ m_cacheImpl->createDataOutput(), this, keyPtr,
static_cast<std::shared_ptr<Serializable>>(nullptr), false, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
reply.setMessageTypeRequest(TcrMessage::CONTAINS_KEY);
@@ -878,7 +878,7 @@ void ThinClientRegion::clear(
/** @brief Create message and send to bridge server */
- TcrMessageClearRegion request(m_cache->createDataOutput(), this,
+ TcrMessageClearRegion request(m_cacheImpl->createDataOutput(), this,
aCallbackArgument,
std::chrono::milliseconds(-1), m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
@@ -922,7 +922,7 @@ GfErrType ThinClientRegion::getNoThrow_remote(
/** @brief Create message and send to bridge server */
- TcrMessageRequest request(m_cache->createDataOutput(), this, keyPtr,
+ TcrMessageRequest request(m_cacheImpl->createDataOutput(), this, keyPtr,
aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
@@ -963,7 +963,7 @@ GfErrType ThinClientRegion::invalidateNoThrow_remote(
/** @brief Create message and send to bridge server */
- TcrMessageInvalidate request(m_cache->createDataOutput(), this, keyPtr,
+ TcrMessageInvalidate request(m_cacheImpl->createDataOutput(), this, keyPtr,
aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
@@ -1013,7 +1013,7 @@ GfErrType ThinClientRegion::putNoThrow_remote(
auto&& temp = std::dynamic_pointer_cast<Delta>(valuePtr);
delta = temp && temp->hasDelta();
}
- TcrMessagePut request(m_cache->createDataOutput(), this, keyPtr, valuePtr,
+ TcrMessagePut request(m_cacheImpl->createDataOutput(), this, keyPtr, valuePtr,
aCallbackArgument, delta, m_tcrdm);
TcrMessageReply* reply = new TcrMessageReply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, *reply);
@@ -1022,8 +1022,9 @@ GfErrType ThinClientRegion::putNoThrow_remote(
.incDeltaPut(); // Does not chcek whether success of failure..
if (reply->getMessageType() ==
TcrMessage::PUT_DELTA_ERROR) { // Try without delta
- TcrMessagePut request(m_cache->createDataOutput(), this, keyPtr, valuePtr,
- aCallbackArgument, false, m_tcrdm, false, true);
+ TcrMessagePut request(m_cacheImpl->createDataOutput(), this, keyPtr,
+ valuePtr, aCallbackArgument, false, m_tcrdm, false,
+ true);
delete reply;
reply = new TcrMessageReply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, *reply);
@@ -1074,8 +1075,8 @@ GfErrType ThinClientRegion::destroyNoThrow_remote(
GfErrType err = GF_NOERR;
// do TCR destroy
- TcrMessageDestroy request(m_cache->createDataOutput(), this, keyPtr, nullptr,
- aCallbackArgument, m_tcrdm);
+ TcrMessageDestroy request(m_cacheImpl->createDataOutput(), this, keyPtr,
+ nullptr, aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) return err;
@@ -1117,8 +1118,8 @@ GfErrType ThinClientRegion::removeNoThrow_remote(
GfErrType err = GF_NOERR;
// do TCR remove
- TcrMessageDestroy request(m_cache->createDataOutput(), this, keyPtr, cvalue,
- aCallbackArgument, m_tcrdm);
+ TcrMessageDestroy request(m_cacheImpl->createDataOutput(), this, keyPtr,
+ cvalue, aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) {
@@ -1159,8 +1160,8 @@ GfErrType ThinClientRegion::removeNoThrowEX_remote(
GfErrType err = GF_NOERR;
// do TCR remove
- TcrMessageDestroy request(m_cache->createDataOutput(), this, keyPtr, nullptr,
- aCallbackArgument, m_tcrdm);
+ TcrMessageDestroy request(m_cacheImpl->createDataOutput(), this, keyPtr,
+ nullptr, aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
if (err != GF_NOERR) {
@@ -1223,7 +1224,7 @@ GfErrType ThinClientRegion::getAllNoThrow_remote(
}
// create the GET_ALL request
TcrMessageGetAll request(
- m_cache->createDataOutput(), this, keys, m_tcrdm,
+ m_cacheImpl->createDataOutput(), this, keys, m_tcrdm,
aCallbackArgument); // now we need to initialize later
TcrMessageReply reply(true, m_tcrdm);
@@ -1595,7 +1596,7 @@ GfErrType ThinClientRegion::multiHopPutAllNoThrow_remote(
auto err = GF_NOERR;
// Construct request/reply for putAll
- TcrMessagePutAll request(m_cache->createDataOutput(), this, map, timeout,
+ TcrMessagePutAll request(m_cacheImpl->createDataOutput(), this, map, timeout,
m_tcrdm, aCallbackArgument);
TcrMessageReply reply(true, m_tcrdm);
request.setTimeout(timeout);
@@ -1934,7 +1935,7 @@ GfErrType ThinClientRegion::multiHopRemoveAllNoThrow_remote(
GfErrType err = GF_NOERR;
// Construct request/reply for putAll
- TcrMessageRemoveAll request(m_cache->createDataOutput(), this, keys,
+ TcrMessageRemoveAll request(m_cacheImpl->createDataOutput(), this, keys,
aCallbackArgument, m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
@@ -2011,7 +2012,7 @@ uint32_t ThinClientRegion::size_remote() {
GfErrType err = GF_NOERR;
// do TCR size
- TcrMessageSize request(m_cache->createDataOutput(), m_fullPath.c_str());
+ TcrMessageSize request(m_cacheImpl->createDataOutput(), m_fullPath.c_str());
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
@@ -2218,7 +2219,7 @@ GfErrType ThinClientRegion::destroyRegionNoThrow_remote(
GfErrType err = GF_NOERR;
// do TCR destroyRegion
- TcrMessageDestroyRegion request(m_cache->createDataOutput(), this,
+ TcrMessageDestroyRegion request(m_cacheImpl->createDataOutput(), this,
aCallbackArgument,
std::chrono::milliseconds(-1), m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
@@ -2276,7 +2277,7 @@ GfErrType ThinClientRegion::registerKeysNoThrow(
interestPolicy.ordinal);
TcrMessageRegisterInterestList request(
- m_cache->createDataOutput(), this, keys, isDurable,
+ m_cacheImpl->createDataOutput(), this, keys, isDurable,
getAttributes().getCachingEnabled(), receiveValues, interestPolicy,
m_tcrdm);
ACE_Recursive_Thread_Mutex responseLock;
@@ -2342,8 +2343,8 @@ GfErrType ThinClientRegion::unregisterKeysNoThrow(
return GF_CACHE_ILLEGAL_STATE_EXCEPTION;
}
- TcrMessageUnregisterInterestList request(m_cache->createDataOutput(), this,
- keys, false, false, true,
+ TcrMessageUnregisterInterestList request(m_cacheImpl->createDataOutput(),
+ this, keys, false, false, true,
InterestResultPolicy::NONE, m_tcrdm);
err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply);
if (err == GF_NOERR /*|| err == GF_CACHE_REDUNDANCY_FAILURE*/) {
@@ -2378,8 +2379,8 @@ GfErrType ThinClientRegion::unregisterKeysNoThrowLocalDestroy(
return GF_CACHE_ILLEGAL_STATE_EXCEPTION;
}
- TcrMessageUnregisterInterestList request(m_cache->createDataOutput(), this,
- keys, false, false, true,
+ TcrMessageUnregisterInterestList request(m_cacheImpl->createDataOutput(),
+ this, keys, false, false, true,
InterestResultPolicy::NONE, m_tcrdm);
err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply);
if (err == GF_NOERR) {
@@ -2453,8 +2454,9 @@ GfErrType ThinClientRegion::registerRegexNoThrow(
// TODO:
TcrMessageRegisterInterest request(
- m_cache->createDataOutput(), m_fullPath, regex.c_str(), interestPolicy,
- isDurable, getAttributes().getCachingEnabled(), receiveValues, m_tcrdm);
+ m_cacheImpl->createDataOutput(), m_fullPath, regex.c_str(),
+ interestPolicy, isDurable, getAttributes().getCachingEnabled(),
+ receiveValues, m_tcrdm);
ACE_Recursive_Thread_Mutex responseLock;
if (reply == nullptr) {
TcrMessageReply replyLocal(true, m_tcrdm);
@@ -2532,7 +2534,7 @@ GfErrType ThinClientRegion::unregisterRegexNoThrow(const std::string& regex,
if (err == GF_NOERR) {
TcrMessageReply reply(false, m_tcrdm);
TcrMessageUnregisterInterest request(
- m_cache->createDataOutput(), m_fullPath, regex,
+ m_cacheImpl->createDataOutput(), m_fullPath, regex,
InterestResultPolicy::NONE, false, false, true, m_tcrdm);
err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply);
if (err == GF_NOERR /*|| err == GF_CACHE_REDUNDANCY_FAILURE*/) {
@@ -2578,7 +2580,7 @@ GfErrType ThinClientRegion::unregisterRegexNoThrowLocalDestroy(
if (err == GF_NOERR) {
TcrMessageReply reply(false, m_tcrdm);
TcrMessageUnregisterInterest request(
- m_cache->createDataOutput(), m_fullPath, regex,
+ m_cacheImpl->createDataOutput(), m_fullPath, regex,
InterestResultPolicy::NONE, false, false, true, m_tcrdm);
err = m_tcrdm->sendSyncRequestRegisterInterest(request, reply);
if (err == GF_NOERR) {
@@ -2992,12 +2994,12 @@ void ThinClientRegion::executeFunction(
TcrMessage* msg;
if (reExecuteForServ) {
msg = new TcrMessageExecuteRegionFunction(
- m_cache->createDataOutput(), func, this, args, routingObj, getResult,
- failedNodes, timeout, m_tcrdm, static_cast<int8_t>(1));
+ m_cacheImpl->createDataOutput(), func, this, args, routingObj,
+ getResult, failedNodes, timeout, m_tcrdm, static_cast<int8_t>(1));
} else {
msg = new TcrMessageExecuteRegionFunction(
- m_cache->createDataOutput(), func, this, args, routingObj, getResult,
- failedNodes, timeout, m_tcrdm, static_cast<int8_t>(0));
+ m_cacheImpl->createDataOutput(), func, this, args, routingObj,
+ getResult, failedNodes, timeout, m_tcrdm, static_cast<int8_t>(0));
}
TcrMessageReply reply(true, m_tcrdm);
// need to check
@@ -3089,8 +3091,8 @@ std::shared_ptr<CacheableVector> ThinClientRegion::reExecuteFunction(
do {
reExecute = false;
- TcrMessageExecuteRegionFunction msg(m_cache->createDataOutput(), func, this,
- args, routingObj, getResult,
+ TcrMessageExecuteRegionFunction msg(m_cacheImpl->createDataOutput(), func,
+ this, args, routingObj, getResult,
failedNodes, timeout, m_tcrdm,
/*reExecute*/ static_cast<int8_t>(1));
TcrMessageReply reply(true, m_tcrdm);
@@ -3259,7 +3261,7 @@ GfErrType ThinClientRegion::getFuncAttributes(const std::string& func,
// do TCR GET_FUNCTION_ATTRIBUTES
LOGDEBUG("Tcrmessage request GET_FUNCTION_ATTRIBUTES ");
- TcrMessageGetFunctionAttributes request(m_cache->createDataOutput(), func,
+ TcrMessageGetFunctionAttributes request(m_cacheImpl->createDataOutput(), func,
m_tcrdm);
TcrMessageReply reply(true, m_tcrdm);
err = m_tcrdm->sendSyncRequest(request, reply);
@@ -3288,7 +3290,7 @@ GfErrType ThinClientRegion::getFuncAttributes(const std::string& func,
GfErrType ThinClientRegion::getNoThrow_FullObject(
std::shared_ptr<EventId> eventId, std::shared_ptr<Cacheable>& fullObject,
std::shared_ptr<VersionTag>& versionTag) {
- TcrMessageRequestEventValue fullObjectMsg(m_cache->createDataOutput(),
+ TcrMessageRequestEventValue fullObjectMsg(m_cacheImpl->createDataOutput(),
eventId);
TcrMessageReply reply(true, nullptr);
@@ -3343,8 +3345,8 @@ void ChunkedInterestResponse::reset() {
void ChunkedInterestResponse::handleChunk(const uint8_t* chunk,
int32_t chunkLen,
uint8_t isLastChunkWithSecurity,
- const Cache* cache) {
- auto input = cache->createDataInput(chunk, chunkLen);
+ const CacheImpl* cacheImpl) {
+ auto input = cacheImpl->createDataInput(chunk, chunkLen);
DataInputInternal::setPoolName(*input, m_replyMsg.getPoolName());
@@ -3375,8 +3377,8 @@ void ChunkedKeySetResponse::reset() {
void ChunkedKeySetResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
uint8_t isLastChunkWithSecurity,
- const Cache* cache) {
- auto input = cache->createDataInput(chunk, chunkLen);
+ const CacheImpl* cacheImpl) {
+ auto input = cacheImpl->createDataInput(chunk, chunkLen);
DataInputInternal::setPoolName(*input, m_replyMsg.getPoolName());
@@ -3450,9 +3452,9 @@ void ChunkedQueryResponse::readObjectPartList(DataInput& input,
void ChunkedQueryResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
uint8_t isLastChunkWithSecurity,
- const Cache* cache) {
+ const CacheImpl* cacheImpl) {
LOGDEBUG("ChunkedQueryResponse::handleChunk..");
- auto input = cache->createDataInput(chunk, chunkLen);
+ auto input = cacheImpl->createDataInput(chunk, chunkLen);
DataInputInternal::setPoolName(*input, m_msg.getPoolName());
uint32_t partLen;
TcrMessageHelper::ChunkObjectType objType;
@@ -3592,9 +3594,9 @@ void ChunkedFunctionExecutionResponse::reset() {
void ChunkedFunctionExecutionResponse::handleChunk(
const uint8_t* chunk, int32_t chunkLen, uint8_t isLastChunkWithSecurity,
- const Cache* cache) {
+ const CacheImpl* cacheImpl) {
LOGDEBUG("ChunkedFunctionExecutionResponse::handleChunk");
- auto input = cache->createDataInput(chunk, chunkLen);
+ auto input = cacheImpl->createDataInput(chunk, chunkLen);
DataInputInternal::setPoolName(*input, m_msg.getPoolName());
uint32_t partLen;
@@ -3726,8 +3728,8 @@ void ChunkedGetAllResponse::reset() {
// process a GET_ALL response chunk
void ChunkedGetAllResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
uint8_t isLastChunkWithSecurity,
- const Cache* cache) {
- auto input = cache->createDataInput(chunk, chunkLen);
+ const CacheImpl* cacheImpl) {
+ auto input = cacheImpl->createDataInput(chunk, chunkLen);
DataInputInternal::setPoolName(*input, m_msg.getPoolName());
uint32_t partLen;
if (TcrMessageHelper::readChunkPartHeader(
@@ -3780,8 +3782,8 @@ void ChunkedPutAllResponse::reset() {
// process a PUT_ALL response chunk
void ChunkedPutAllResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
uint8_t isLastChunkWithSecurity,
- const Cache* cache) {
- auto input = cache->createDataInput(chunk, chunkLen);
+ const CacheImpl* cacheImpl) {
+ auto input = cacheImpl->createDataInput(chunk, chunkLen);
DataInputInternal::setPoolName(*input, m_msg.getPoolName());
uint32_t partLen;
int8_t chunkType;
@@ -3815,7 +3817,7 @@ void ChunkedPutAllResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
const auto byte1 = input->read();
m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
- auto pool = cache->getPoolManager().find(m_msg.getPoolName());
+ auto pool = cacheImpl->getPoolManager().find(m_msg.getPoolName());
if (pool != nullptr && !pool->isDestroyed() &&
pool->getPRSingleHopEnabled()) {
ThinClientPoolDM* poolDM = dynamic_cast<ThinClientPoolDM*>(pool.get());
@@ -3840,8 +3842,8 @@ void ChunkedRemoveAllResponse::reset() {
void ChunkedRemoveAllResponse::handleChunk(const uint8_t* chunk,
int32_t chunkLen,
uint8_t isLastChunkWithSecurity,
- const Cache* cache) {
- auto input = cache->createDataInput(chunk, chunkLen);
+ const CacheImpl* cacheImpl) {
+ auto input = cacheImpl->createDataInput(chunk, chunkLen);
DataInputInternal::setPoolName(*input, m_msg.getPoolName());
uint32_t partLen;
int8_t chunkType;
@@ -3876,7 +3878,7 @@ void ChunkedRemoveAllResponse::handleChunk(const uint8_t* chunk,
const auto byte1 = input->read();
m_msg.readSecureObjectPart(*input, false, true, isLastChunkWithSecurity);
- auto pool = cache->getPoolManager().find(m_msg.getPoolName());
+ auto pool = cacheImpl->getPoolManager().find(m_msg.getPoolName());
if (pool != nullptr && !pool->isDestroyed() &&
pool->getPRSingleHopEnabled()) {
ThinClientPoolDM* poolDM = dynamic_cast<ThinClientPoolDM*>(pool.get());
@@ -3901,8 +3903,8 @@ void ChunkedDurableCQListResponse::reset() {
void ChunkedDurableCQListResponse::handleChunk(const uint8_t* chunk,
int32_t chunkLen,
uint8_t isLastChunkWithSecurity,
- const Cache* cache) {
- auto input = cache->createDataInput(chunk, chunkLen);
+ const CacheImpl* cacheImpl) {
+ auto input = cacheImpl->createDataInput(chunk, chunkLen);
DataInputInternal::setPoolName(*input, m_msg.getPoolName());
// read part length
diff --git a/cppcache/src/ThinClientRegion.hpp b/cppcache/src/ThinClientRegion.hpp
index cdd85bf..edf0bed 100644
--- a/cppcache/src/ThinClientRegion.hpp
+++ b/cppcache/src/ThinClientRegion.hpp
@@ -415,7 +415,8 @@ class ChunkedInterestResponse : public TcrChunkedResult {
}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity, const Cache* cache);
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl);
virtual void reset();
};
@@ -451,7 +452,8 @@ class ChunkedQueryResponse : public TcrChunkedResult {
}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity, const Cache* cache);
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl);
virtual void reset();
void readObjectPartList(DataInput& input, bool isResultSet);
@@ -502,7 +504,8 @@ class ChunkedFunctionExecutionResponse : public TcrChunkedResult {
inline bool getResult() const { return m_getResult; }
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity, const Cache* cache);
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl);
virtual void reset();
};
@@ -515,7 +518,7 @@ class ChunkedGetAllResponse : public TcrChunkedResult {
private:
TcrMessage& m_msg;
ThinClientRegion* m_region;
- const std::vector<std::shared_ptr<CacheableKey>> * m_keys;
+ const std::vector<std::shared_ptr<CacheableKey>>* m_keys;
std::shared_ptr<HashMapOfCacheable> m_values;
std::shared_ptr<HashMapOfException> m_exceptions;
std::shared_ptr<std::vector<std::shared_ptr<CacheableKey>>> m_resultKeys;
@@ -552,14 +555,17 @@ class ChunkedGetAllResponse : public TcrChunkedResult {
m_responseLock(responseLock) {}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity, const Cache* cache);
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl);
virtual void reset();
void add(const ChunkedGetAllResponse* other);
bool getAddToLocalCache() { return m_addToLocalCache; }
std::shared_ptr<HashMapOfCacheable> getValues() { return m_values; }
std::shared_ptr<HashMapOfException> getExceptions() { return m_exceptions; }
- std::shared_ptr<std::vector<std::shared_ptr<CacheableKey>> > getResultKeys() { return m_resultKeys; }
+ std::shared_ptr<std::vector<std::shared_ptr<CacheableKey>>> getResultKeys() {
+ return m_resultKeys;
+ }
MapOfUpdateCounters& getUpdateCounters() { return m_trackerMap; }
ACE_Recursive_Thread_Mutex& getResponseLock() { return m_responseLock; }
};
@@ -589,7 +595,8 @@ class ChunkedPutAllResponse : public TcrChunkedResult {
m_list(list) {}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity, const Cache* cache);
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl);
virtual void reset();
std::shared_ptr<VersionedCacheableObjectPartList> getList() { return m_list; }
ACE_Recursive_Thread_Mutex& getResponseLock() { return m_responseLock; }
@@ -620,7 +627,8 @@ class ChunkedRemoveAllResponse : public TcrChunkedResult {
m_list(list) {}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity, const Cache* cache);
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl);
virtual void reset();
std::shared_ptr<VersionedCacheableObjectPartList> getList() { return m_list; }
ACE_Recursive_Thread_Mutex& getResponseLock() { return m_responseLock; }
@@ -635,7 +643,7 @@ class ChunkedKeySetResponse : public TcrChunkedResult {
private:
TcrMessage& m_msg;
TcrMessage& m_replyMsg;
- std::vector<std::shared_ptr<CacheableKey>> & m_resultKeys;
+ std::vector<std::shared_ptr<CacheableKey>>& m_resultKeys;
// disabled
ChunkedKeySetResponse(const ChunkedKeySetResponse&);
@@ -651,11 +659,11 @@ class ChunkedKeySetResponse : public TcrChunkedResult {
m_resultKeys(resultKeys) {}
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity, const Cache* cache);
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl);
virtual void reset();
};
-
class ChunkedDurableCQListResponse : public TcrChunkedResult {
private:
TcrMessage& m_msg;
@@ -670,10 +678,13 @@ class ChunkedDurableCQListResponse : public TcrChunkedResult {
: TcrChunkedResult(),
m_msg(msg),
m_resultList(CacheableArrayList::create()) {}
- inline std::shared_ptr<CacheableArrayList> getResults() { return m_resultList; }
+ inline std::shared_ptr<CacheableArrayList> getResults() {
+ return m_resultList;
+ }
virtual void handleChunk(const uint8_t* chunk, int32_t chunkLen,
- uint8_t isLastChunkWithSecurity, const Cache* cache);
+ uint8_t isLastChunkWithSecurity,
+ const CacheImpl* cacheImpl);
virtual void reset();
};
diff --git a/cppcache/src/TransactionalOperation.cpp b/cppcache/src/TransactionalOperation.cpp
index 7989dd2..98506ac 100644
--- a/cppcache/src/TransactionalOperation.cpp
+++ b/cppcache/src/TransactionalOperation.cpp
@@ -22,6 +22,7 @@
#include "TransactionalOperation.hpp"
#include "RegionInternal.hpp"
#include "util/exception.hpp"
+#include "CacheImpl.hpp"
namespace apache {
namespace geode {
@@ -37,13 +38,15 @@ TransactionalOperation::TransactionalOperation(
m_arguments(arguments) {}
TransactionalOperation::~TransactionalOperation() {}
-std::shared_ptr<Cacheable> TransactionalOperation::replay(Cache* cache) {
+std::shared_ptr<Cacheable> TransactionalOperation::replay(
+ CacheImpl* cacheImpl) {
std::shared_ptr<Cacheable> result = nullptr;
switch (m_operation) {
case GF_CONTAINS_KEY:
- result = CacheableBoolean::create(
- cache->getRegion(m_regionName)->containsKeyOnServer(m_key));
+ result = CacheableBoolean::create(cacheImpl->getCache()
+ ->getRegion(m_regionName)
+ ->containsKeyOnServer(m_key));
break;
case GF_CONTAINS_VALUE:
GfErrTypeThrowException("Contains value not supported in transaction",
@@ -51,18 +54,22 @@ std::shared_ptr<Cacheable> TransactionalOperation::replay(Cache* cache) {
// result = Boolean.valueOf(containsValue(args[0], true));
break;
case GF_CONTAINS_VALUE_FOR_KEY:
- result = CacheableBoolean::create(
- cache->getRegion(m_regionName)->containsValueForKey(m_key));
+ result = CacheableBoolean::create(cacheImpl->getCache()
+ ->getRegion(m_regionName)
+ ->containsValueForKey(m_key));
break;
case GF_DESTROY: // includes REMOVE(k,v)
- cache->getRegion(m_regionName)->destroy(m_key, m_arguments->at(0));
+ cacheImpl->getCache()
+ ->getRegion(m_regionName)
+ ->destroy(m_key, m_arguments->at(0));
break;
case GF_EXECUTE_FUNCTION: {
Execution execution;
if (m_regionName == nullptr) {
- execution = FunctionService::onServer(std::shared_ptr<Cache>(cache));
+ execution = FunctionService::onServer(*cacheImpl->getCache());
} else {
- execution = FunctionService::onRegion(cache->getRegion(m_regionName));
+ execution = FunctionService::onRegion(
+ cacheImpl->getCache()->getRegion(m_regionName));
}
result = std::dynamic_pointer_cast<Cacheable>(
execution.withArgs(m_arguments->at(0))
@@ -77,7 +84,9 @@ std::shared_ptr<Cacheable> TransactionalOperation::replay(Cache* cache) {
->value())));
} break;
case GF_GET:
- result = cache->getRegion(m_regionName)->get(m_key, m_arguments->at(0));
+ result = cacheImpl->getCache()
+ ->getRegion(m_regionName)
+ ->get(m_key, m_arguments->at(0));
break;
case GF_GET_ENTRY:
GfErrTypeThrowException("getEntry not supported in transaction",
@@ -86,7 +95,7 @@ std::shared_ptr<Cacheable> TransactionalOperation::replay(Cache* cache) {
case GF_GET_ALL: {
const auto result =
std::static_pointer_cast<RegionInternal>(
- cache->getRegion(m_regionName))
+ cacheImpl->getCache()->getRegion(m_regionName))
->getAll_internal(
*std::dynamic_pointer_cast<
std::vector<std::shared_ptr<CacheableKey>>>(
@@ -101,14 +110,17 @@ std::shared_ptr<Cacheable> TransactionalOperation::replay(Cache* cache) {
break;
}
case GF_INVALIDATE:
- cache->getRegion(m_regionName)->invalidate(m_key, m_arguments->at(0));
+ cacheImpl->getCache()
+ ->getRegion(m_regionName)
+ ->invalidate(m_key, m_arguments->at(0));
break;
case GF_REMOVE:
- cache->getRegion(m_regionName)
+ cacheImpl->getCache()
+ ->getRegion(m_regionName)
->remove(m_key, m_arguments->at(0), m_arguments->at(1));
break;
case GF_KEY_SET: {
- auto tmp = cache->getRegion(m_regionName)->serverKeys();
+ auto tmp = cacheImpl->getCache()->getRegion(m_regionName)->serverKeys();
auto serverKeys =
std::dynamic_pointer_cast<std::vector<std::shared_ptr<CacheableKey>>>(
m_arguments->at(0));
@@ -116,15 +128,18 @@ std::shared_ptr<Cacheable> TransactionalOperation::replay(Cache* cache) {
break;
}
case GF_CREATE: // includes PUT_IF_ABSENT
- cache->getRegion(m_regionName)
+ cacheImpl->getCache()
+ ->getRegion(m_regionName)
->create(m_key, m_arguments->at(0), m_arguments->at(1));
break;
case GF_PUT: // includes PUT_IF_ABSENT
- cache->getRegion(m_regionName)
+ cacheImpl->getCache()
+ ->getRegion(m_regionName)
->put(m_key, m_arguments->at(0), m_arguments->at(1));
break;
case GF_PUT_ALL:
- cache->getRegion(m_regionName)
+ cacheImpl->getCache()
+ ->getRegion(m_regionName)
->putAll(
*std::dynamic_pointer_cast<HashMapOfCacheable>(
m_arguments->at(0)),
diff --git a/cppcache/src/TransactionalOperation.hpp b/cppcache/src/TransactionalOperation.hpp
index b083420..9309935 100644
--- a/cppcache/src/TransactionalOperation.hpp
+++ b/cppcache/src/TransactionalOperation.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_TRANSACTIONALOPERATION_H_
-#define GEODE_TRANSACTIONALOPERATION_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,16 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * TransactionalOperation.hpp
- *
- * Created on: 10-May-2011
- * Author: ankurs
- */
+
+#pragma once
+
+#ifndef GEODE_TRANSACTIONALOPERATION_H_
+#define GEODE_TRANSACTIONALOPERATION_H_
#include <geode/internal/geode_globals.hpp>
#include <geode/Serializable.hpp>
#include <vector>
+
namespace apache {
namespace geode {
namespace client {
@@ -51,19 +46,23 @@ enum ServerRegionOperation {
};
class CacheableKey;
+class CacheImpl;
+
class TransactionalOperation {
public:
- TransactionalOperation(ServerRegionOperation op, const char* regionName,
- std::shared_ptr<CacheableKey> key, std::shared_ptr<std::vector<std::shared_ptr<Cacheable>> > arguments);
+ TransactionalOperation(
+ ServerRegionOperation op, const char* regionName,
+ std::shared_ptr<CacheableKey> key,
+ std::shared_ptr<std::vector<std::shared_ptr<Cacheable>>> arguments);
virtual ~TransactionalOperation();
- std::shared_ptr<Cacheable> replay(Cache* cache);
+ std::shared_ptr<Cacheable> replay(CacheImpl* cache);
private:
ServerRegionOperation m_operation;
const char* m_regionName;
std::shared_ptr<CacheableKey> m_key;
- std::shared_ptr<std::vector<std::shared_ptr<Cacheable>> > m_arguments;
+ std::shared_ptr<std::vector<std::shared_ptr<Cacheable>>> m_arguments;
};
} // namespace client
} // namespace geode
diff --git a/cppcache/src/UserAttributes.cpp b/cppcache/src/UserAttributes.cpp
index 7d12710..44dec80 100644
--- a/cppcache/src/UserAttributes.cpp
+++ b/cppcache/src/UserAttributes.cpp
@@ -15,20 +15,20 @@
* limitations under the License.
*/
#include "UserAttributes.hpp"
-#include "ProxyCache.hpp"
+#include <geode/AuthenticatedView.hpp>
using namespace apache::geode::client;
UserAttributes::UserAttributes(std::shared_ptr<Properties> credentials,
std::shared_ptr<Pool> pool,
- ProxyCache* proxyCache)
+ AuthenticatedView* authenticatedView)
: m_isUserAuthenticated(false), m_pool(pool) {
m_credentials = credentials;
- m_proxyCache = proxyCache;
+ m_authenticatedView = authenticatedView;
}
-bool UserAttributes::isCacheClosed() { return m_proxyCache->isClosed(); }
+bool UserAttributes::isCacheClosed() { return m_authenticatedView->isClosed(); }
UserAttributes::~UserAttributes() {
std::map<std::string, UserConnectionAttributes*>::iterator it;
@@ -113,7 +113,7 @@ bool UserAttributes::isEndpointAuthenticated(TcrEndpoint* ep) {
return false;
}
std::shared_ptr<Properties> UserAttributes::getCredentials() {
- if (m_proxyCache->isClosed()) {
+ if (m_authenticatedView->isClosed()) {
throw IllegalStateException("User cache has been closed");
}
if (m_credentials == nullptr) {
@@ -123,32 +123,33 @@ std::shared_ptr<Properties> UserAttributes::getCredentials() {
}
return m_credentials;
}
-ProxyCache* UserAttributes::getProxyCache() { return m_proxyCache; }
-
- ACE_TSS<TSSUserAttributesWrapper>
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes;
-
- GuardUserAttribures::GuardUserAttribures(
- ProxyCache* proxyCache) {
- setProxyCache(proxyCache);
- }
-
- void GuardUserAttribures::setProxyCache(
- ProxyCache* proxyCache) {
- m_proxyCache = proxyCache;
- LOGDEBUG("GuardUserAttribures::GuardUserAttribures:");
- if (m_proxyCache != nullptr && !proxyCache->isClosed()) {
- TSSUserAttributesWrapper::s_geodeTSSUserAttributes->setUserAttributes(
- proxyCache->m_userAttributes);
- } else {
- throw CacheClosedException("User Cache has been closed");
- }
+AuthenticatedView* UserAttributes::getAuthenticatedView() {
+ return m_authenticatedView;
}
-GuardUserAttribures::GuardUserAttribures() { m_proxyCache = nullptr; }
+ACE_TSS<TSSUserAttributesWrapper>
+ TSSUserAttributesWrapper::s_geodeTSSUserAttributes;
-GuardUserAttribures::~GuardUserAttribures() {
- if (m_proxyCache != nullptr) {
+GuardUserAttributes::GuardUserAttributes(AuthenticatedView* authenticatedView) {
+ setAuthenticatedView(authenticatedView);
+}
+
+void GuardUserAttributes::setAuthenticatedView(
+ AuthenticatedView* authenticatedView) {
+ m_authenticatedView = authenticatedView;
+ LOGDEBUG("GuardUserAttributes::GuardUserAttributes:");
+ if (m_authenticatedView != nullptr && !authenticatedView->isClosed()) {
+ TSSUserAttributesWrapper::s_geodeTSSUserAttributes->setUserAttributes(
+ authenticatedView->m_userAttributes);
+ } else {
+ throw CacheClosedException("User Cache has been closed");
+ }
+}
+
+GuardUserAttributes::GuardUserAttributes() { m_authenticatedView = nullptr; }
+
+GuardUserAttributes::~GuardUserAttributes() {
+ if (m_authenticatedView != nullptr) {
TSSUserAttributesWrapper::s_geodeTSSUserAttributes->setUserAttributes(
nullptr);
}
diff --git a/cppcache/src/UserAttributes.hpp b/cppcache/src/UserAttributes.hpp
index da16951..65ec95b 100644
--- a/cppcache/src/UserAttributes.hpp
+++ b/cppcache/src/UserAttributes.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_USERATTRIBUTES_H_
-#define GEODE_USERATTRIBUTES_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_USERATTRIBUTES_H_
+#define GEODE_USERATTRIBUTES_H_
+
#include <geode/internal/geode_globals.hpp>
#include <geode/Properties.hpp>
#include "TcrEndpoint.hpp"
@@ -30,7 +30,7 @@
namespace apache {
namespace geode {
namespace client {
-class ProxyCache;
+class AuthenticatedView;
class ThinClientPoolDM;
class UserConnectionAttributes {
public:
@@ -75,11 +75,11 @@ class _GEODE_EXPORT UserAttributes {
~UserAttributes();
UserAttributes(std::shared_ptr<Properties> credentials,
std::shared_ptr<Pool> pool,
- ProxyCache* proxyCache);
+ AuthenticatedView* authenticatedView);
bool isCacheClosed();
- ProxyCache* getProxyCache();
+ AuthenticatedView* getAuthenticatedView();
std::shared_ptr<Pool> getPool();
@@ -112,7 +112,7 @@ class _GEODE_EXPORT UserAttributes {
// ThinClientPoolDM m_pool;
ACE_Recursive_Thread_Mutex m_listLock;
bool m_isUserAuthenticated;
- ProxyCache* m_proxyCache;
+ AuthenticatedView* m_authenticatedView;
std::shared_ptr<Pool> m_pool;
// Disallow copy constructor and assignment operator.
@@ -128,7 +128,9 @@ class TSSUserAttributesWrapper {
public:
static ACE_TSS<TSSUserAttributesWrapper> s_geodeTSSUserAttributes;
- std::shared_ptr<UserAttributes> getUserAttributes() { return m_userAttribute; }
+ std::shared_ptr<UserAttributes> getUserAttributes() {
+ return m_userAttribute;
+ }
void setUserAttributes(std::shared_ptr<UserAttributes> userAttr) {
m_userAttribute = userAttr;
}
@@ -136,18 +138,18 @@ class TSSUserAttributesWrapper {
~TSSUserAttributesWrapper() {}
};
-class GuardUserAttribures {
+class GuardUserAttributes {
public:
- GuardUserAttribures();
+ GuardUserAttributes();
- GuardUserAttribures(ProxyCache* proxyCache);
+ GuardUserAttributes(AuthenticatedView* const authenticatedView);
- void setProxyCache(ProxyCache* proxyCache);
+ void setAuthenticatedView(AuthenticatedView* const authenticatedView);
- ~GuardUserAttribures();
+ ~GuardUserAttributes();
private:
- ProxyCache* m_proxyCache;
+ AuthenticatedView* m_authenticatedView;
};
} // namespace client
} // namespace geode
diff --git a/tests/cpp/testobject/DeltaFastAssetAccount.cpp b/tests/cpp/testobject/DeltaFastAssetAccount.cpp
index 4f59701..8060784 100644
--- a/tests/cpp/testobject/DeltaFastAssetAccount.cpp
+++ b/tests/cpp/testobject/DeltaFastAssetAccount.cpp
@@ -24,7 +24,7 @@ using namespace testobject;
DeltaFastAssetAccount::DeltaFastAssetAccount(int index, bool encodeTimestp,
int maxVal, int asstSize,
bool getbfrUpdate)
- : Delta(nullptr), encodeTimestamp(encodeTimestp), acctId(index) {
+ : Delta(), encodeTimestamp(encodeTimestp), acctId(index) {
customerName = CacheableString::create("Milton Moneybags");
netWorth = 0.0;
assets = CacheableHashMap::create();
diff --git a/tests/cpp/testobject/DeltaFastAssetAccount.hpp b/tests/cpp/testobject/DeltaFastAssetAccount.hpp
index b31c2ba..723a789 100644
--- a/tests/cpp/testobject/DeltaFastAssetAccount.hpp
+++ b/tests/cpp/testobject/DeltaFastAssetAccount.hpp
@@ -65,7 +65,7 @@ class TESTOBJECT_EXPORT DeltaFastAssetAccount : public Cacheable, public Delta {
public:
DeltaFastAssetAccount()
- : Delta(nullptr),
+ : Delta(),
encodeTimestamp(0),
acctId(0),
customerName(nullptr),
diff --git a/tests/cpp/testobject/DeltaPSTObject.cpp b/tests/cpp/testobject/DeltaPSTObject.cpp
index e4e1562..8a02a27 100644
--- a/tests/cpp/testobject/DeltaPSTObject.cpp
+++ b/tests/cpp/testobject/DeltaPSTObject.cpp
@@ -24,7 +24,7 @@ using namespace testframework;
using namespace testobject;
DeltaPSTObject::DeltaPSTObject(int size, bool encodeKey, bool encodeTimestamp)
- : Delta(nullptr) {
+ : Delta() {
ACE_Time_Value startTime;
startTime = ACE_OS::gettimeofday();
ACE_UINT64 tusec = 0;
diff --git a/tests/cpp/testobject/DeltaPSTObject.hpp b/tests/cpp/testobject/DeltaPSTObject.hpp
index e18d050..c6e050c 100644
--- a/tests/cpp/testobject/DeltaPSTObject.hpp
+++ b/tests/cpp/testobject/DeltaPSTObject.hpp
@@ -54,7 +54,7 @@ class TESTOBJECT_EXPORT DeltaPSTObject : public Cacheable, public Delta {
std::shared_ptr<CacheableBytes> valueData;
public:
- DeltaPSTObject() : Delta(nullptr), timestamp(0), valueData(nullptr) {}
+ DeltaPSTObject() : Delta(), timestamp(0), valueData(nullptr) {}
DeltaPSTObject(int size, bool encodeKey, bool encodeTimestamp);
~DeltaPSTObject() noexcept override {}
void toData(apache::geode::client::DataOutput& output) const override;
@@ -75,7 +75,9 @@ class TESTOBJECT_EXPORT DeltaPSTObject : public Cacheable, public Delta {
incrementField1();
resetTimestamp();
}
+
uint64_t getTimestamp() { return timestamp; }
+
void resetTimestamp() {
ACE_Time_Value startTime;
startTime = ACE_OS::gettimeofday();
@@ -84,10 +86,7 @@ class TESTOBJECT_EXPORT DeltaPSTObject : public Cacheable, public Delta {
timestamp = tusec * 1000;
}
- // std::shared_ptr<Delta> clone() const override {
- // // TODO shared_ptr - this isn't actually cloning.
- // return shared_from_this();
- // }
+ inline std::shared_ptr<Delta> clone() const override { return nullptr; }
static Serializable* createDeserializable() { return new DeltaPSTObject(); }
};
diff --git a/tests/cpp/testobject/DeltaTestImpl.cpp b/tests/cpp/testobject/DeltaTestImpl.cpp
index eac100e..f738232 100644
--- a/tests/cpp/testobject/DeltaTestImpl.cpp
+++ b/tests/cpp/testobject/DeltaTestImpl.cpp
@@ -14,14 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- *DeltaTestImpl.cpp
- *
- *Created on: Jul 14, 2009
- *Author: abhaware
- */
+
#include "DeltaTestImpl.hpp"
-#include <ace/Guard_T.h>
+
using namespace testobject;
uint8_t DeltaTestImpl::INT_MASK = 0x1;
@@ -31,7 +26,7 @@ uint8_t DeltaTestImpl::BYTE_ARR_MASK = 0x8;
uint8_t DeltaTestImpl::TEST_OBJ_MASK = 0x10;
uint8_t DeltaTestImpl::COMPLETE_MASK = 0x1F;
-DeltaTestImpl::DeltaTestImpl() : Delta(nullptr) {
+DeltaTestImpl::DeltaTestImpl() : Delta() {
intVar = 1;
str = CacheableString::create("test");
doubleVar = 1.1;
@@ -43,15 +38,17 @@ DeltaTestImpl::DeltaTestImpl() : Delta(nullptr) {
toDeltaCounter = 0;
fromDeltaCounter = 0;
}
+
DeltaTestImpl::DeltaTestImpl(int intValue,
std::shared_ptr<CacheableString> strptr)
- : Delta(nullptr),
+ : Delta(),
intVar(intValue),
str(strptr),
doubleVar(0),
toDeltaCounter(0),
fromDeltaCounter(0) {}
-DeltaTestImpl::DeltaTestImpl(const DeltaTestImpl& rhs) : Delta(nullptr) {
+
+DeltaTestImpl::DeltaTestImpl(const DeltaTestImpl& rhs) : Delta() {
intVar = rhs.intVar;
str = CacheableString::create(rhs.str->value().c_str());
doubleVar = rhs.doubleVar;
@@ -111,7 +108,9 @@ void DeltaTestImpl::fromDelta(DataInput& input) {
ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_lock);
fromDeltaCounter++;
}
+
deltaBits = input.read();
+
if ((deltaBits & INT_MASK) == INT_MASK) {
intVar = input.readInt32();
}
@@ -123,13 +122,6 @@ void DeltaTestImpl::fromDelta(DataInput& input) {
}
if ((deltaBits & BYTE_ARR_MASK) == BYTE_ARR_MASK) {
byteArr = std::static_pointer_cast<CacheableBytes>(input.readObject());
- /*
- uint8_t* bytes;
- int32_t len;
- input.readBytes( &bytes, &len );
- byteArr = CacheableBytes::create( bytes, len );
- delete bytes;
- */
}
if ((deltaBits & TEST_OBJ_MASK) == TEST_OBJ_MASK) {
testObj = std::static_pointer_cast<TestObject1>(input.readObject());
diff --git a/tests/cpp/testobject/DeltaTestImpl.hpp b/tests/cpp/testobject/DeltaTestImpl.hpp
index b9fdda8..ffb0f0c 100644
--- a/tests/cpp/testobject/DeltaTestImpl.hpp
+++ b/tests/cpp/testobject/DeltaTestImpl.hpp
@@ -81,7 +81,7 @@ class TESTOBJECT_EXPORT DeltaTestImpl : public Cacheable, public Delta {
size_t objectSize() const override { return 0; }
- std::shared_ptr<Delta> clone() const override {
+ inline std::shared_ptr<Delta> clone() const override {
return std::make_shared<DeltaTestImpl>(*this);
}
--
To stop receiving notification emails like this one, please contact
jbarrett@apache.org.