http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/CliCallbackDelgate.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/CliCallbackDelgate.cpp b/src/clicache/src/impl/CliCallbackDelgate.cpp new file mode 100644 index 0000000..acb0c6c --- /dev/null +++ b/src/clicache/src/impl/CliCallbackDelgate.cpp @@ -0,0 +1,40 @@ +/* + * 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 "CliCallbackDelgate.hpp" + +#include "begin_native.hpp" +#include "CacheRegionHelper.hpp" +#include "end_native.hpp" + +#include "../Cache.hpp" +using namespace System; + +namespace Apache +{ + namespace Geode + { + namespace Client + { + void CliCallbackDelegate::Callback(apache::geode::client::Cache& cache) + { + Apache::Geode::Client::Log::Fine("CliCallbackDelgate::Callback( ) "); + CacheRegionHelper::getCacheImpl(&cache)->getPdxTypeRegistry()->clear(); + } + } // namespace Client + } // namespace Geode +} // namespace Apache \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/CliCallbackDelgate.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/CliCallbackDelgate.hpp b/src/clicache/src/impl/CliCallbackDelgate.hpp index 2bb688a..4029652 100755 --- a/src/clicache/src/impl/CliCallbackDelgate.hpp +++ b/src/clicache/src/impl/CliCallbackDelgate.hpp @@ -24,6 +24,7 @@ #include "../Log.hpp" #include "PdxTypeRegistry.hpp" + using namespace System; namespace Apache @@ -32,7 +33,7 @@ namespace Apache { namespace Client { - + ref class Cache; /// <summary> /// to get the callback from c++ layer /// </summary> @@ -40,17 +41,12 @@ namespace Apache { public: - inline CliCallbackDelegate( ) - { - } - - void Callback( ) - { - Apache::Geode::Client::Log::Fine("CliCallbackDelgate::Callback( ) "); - Apache::Geode::Client::Internal::PdxTypeRegistry::clear(); - } - + CliCallbackDelegate() + {} + void Callback(apache::geode::client::Cache& cache); + + CliCallbackDelegate(const CliCallbackDelegate^ other){} private: }; http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/DelegateWrapper.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/DelegateWrapper.hpp b/src/clicache/src/impl/DelegateWrapper.hpp index 45a1550..68da9f9 100644 --- a/src/clicache/src/impl/DelegateWrapper.hpp +++ b/src/clicache/src/impl/DelegateWrapper.hpp @@ -17,6 +17,12 @@ #pragma once +#include "begin_native.hpp" +#include "CacheImpl.hpp" +#include "CacheRegionHelper.hpp" +#include "end_native.hpp" + +#include "Cache.hpp" #include "../geode_defs.hpp" #include "../Serializable.hpp" #include "ManagedCacheableKey.hpp" @@ -31,7 +37,7 @@ namespace Apache { namespace Client { - + namespace native = apache::geode::client; /// <summary> /// Template class to wrap a managed <see cref="TypeFactoryMethod" /> /// delegate that returns an <see cref="IGeodeSerializable" /> object. It contains @@ -63,8 +69,8 @@ namespace Apache /// <summary> /// Constructor to wrap the given managed delegate. /// </summary> - inline DelegateWrapperGeneric( TypeFactoryMethodGeneric^ typeDelegate ) - : m_delegate( typeDelegate ) { } + inline DelegateWrapperGeneric( TypeFactoryMethodGeneric^ typeDelegate, Cache^ cache ) + : m_delegate( typeDelegate ), m_cache(cache) { } /// <summary> /// Returns the native <c>apache::geode::client::Serializable</c> object by invoking the @@ -87,7 +93,7 @@ namespace Apache return new apache::geode::client::ManagedCacheableDeltaBytesGeneric( tempDelta, false ); } else if(!SafeConvertClassGeneric::isAppDomainEnabled) - return new apache::geode::client::ManagedCacheableKeyGeneric( tempObj); + return new apache::geode::client::ManagedCacheableKeyGeneric( tempObj, CacheRegionHelper::getCacheImpl(m_cache->GetNative().get())->getSerializationRegistry().get()); else return new apache::geode::client::ManagedCacheableKeyBytesGeneric( tempObj, false); } @@ -96,6 +102,8 @@ namespace Apache private: TypeFactoryMethodGeneric^ m_delegate; + + Cache^ m_cache; }; } // namespace Client } // namespace Geode http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/FixedPartitionResolver.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/FixedPartitionResolver.hpp b/src/clicache/src/impl/FixedPartitionResolver.hpp index 03f57c9..38a3fa3 100644 --- a/src/clicache/src/impl/FixedPartitionResolver.hpp +++ b/src/clicache/src/impl/FixedPartitionResolver.hpp @@ -60,7 +60,7 @@ namespace Apache { EntryEvent<TKey, TValue> gevent(&ev); Object^ groutingobject = m_resolver->GetRoutingObject(%gevent); - return Serializable::GetUnmanagedValueGeneric<Object^>(groutingobject); + return Serializable::GetUnmanagedValueGeneric<Object^>(groutingobject, nullptr); } virtual const char * getName() http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedAuthInitialize.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedAuthInitialize.cpp b/src/clicache/src/impl/ManagedAuthInitialize.cpp index 4ad28bb..61e0683 100644 --- a/src/clicache/src/impl/ManagedAuthInitialize.cpp +++ b/src/clicache/src/impl/ManagedAuthInitialize.cpp @@ -170,7 +170,7 @@ namespace apache return NULL; } - PropertiesPtr ManagedAuthInitializeGeneric::getCredentials(PropertiesPtr& + PropertiesPtr ManagedAuthInitializeGeneric::getCredentials(const PropertiesPtr& securityprops, const char* server) { try { http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedAuthInitialize.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedAuthInitialize.hpp b/src/clicache/src/impl/ManagedAuthInitialize.hpp index 482a9e7..83f7961 100644 --- a/src/clicache/src/impl/ManagedAuthInitialize.hpp +++ b/src/clicache/src/impl/ManagedAuthInitialize.hpp @@ -101,7 +101,7 @@ namespace apache /// </param> /// <param name="server">It is the ID of the endpoint /// </param> - virtual PropertiesPtr getCredentials(PropertiesPtr& securityprops, const char* server); + virtual PropertiesPtr getCredentials(const PropertiesPtr& securityprops, const char* server); virtual ~ManagedAuthInitializeGeneric() { } http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableDelta.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedCacheableDelta.cpp b/src/clicache/src/impl/ManagedCacheableDelta.cpp index 75fc5cf..8c0c0d1 100644 --- a/src/clicache/src/impl/ManagedCacheableDelta.cpp +++ b/src/clicache/src/impl/ManagedCacheableDelta.cpp @@ -59,7 +59,7 @@ namespace apache { try { int pos = input.getBytesRead(); - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); m_managedSerializableptr->FromData(%mg_input); //this will move the cursor in c++ layer @@ -178,7 +178,7 @@ namespace apache void ManagedCacheableDeltaGeneric::fromDelta(DataInput& input) { try { - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); m_managedptr->FromDelta(%mg_input); //this will move the cursor in c++ layer http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableDelta.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedCacheableDelta.hpp b/src/clicache/src/impl/ManagedCacheableDelta.hpp index a531178..9211a8d 100644 --- a/src/clicache/src/impl/ManagedCacheableDelta.hpp +++ b/src/clicache/src/impl/ManagedCacheableDelta.hpp @@ -72,7 +72,7 @@ namespace apache /// </param> inline ManagedCacheableDeltaGeneric( Apache::Geode::Client::IGeodeDelta^ managedptr) - : m_managedptr(managedptr) + : Delta(nullptr), m_managedptr(managedptr) { m_managedSerializableptr = dynamic_cast <Apache::Geode::Client::IGeodeSerializable^> (managedptr); m_classId = m_managedSerializableptr->ClassId; @@ -81,7 +81,7 @@ namespace apache inline ManagedCacheableDeltaGeneric( Apache::Geode::Client::IGeodeDelta^ managedptr, int hashcode, int classId) - : m_managedptr(managedptr) { + :Delta(nullptr), m_managedptr(managedptr) { m_hashcode = hashcode; m_classId = classId; m_managedSerializableptr = dynamic_cast <Apache::Geode::Client::IGeodeSerializable^> (managedptr); http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp b/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp index e7f590c..18472c4 100644 --- a/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp +++ b/src/clicache/src/impl/ManagedCacheableDeltaBytes.cpp @@ -54,7 +54,7 @@ namespace apache { try { Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromData: classid " + m_classId); - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); const System::Byte* objStartPos = input.currentBufferPosition(); Apache::Geode::Client::IGeodeSerializable^ obj = @@ -179,7 +179,7 @@ namespace apache try { Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromDelta:"); Apache::Geode::Client::IGeodeDelta^ deltaObj = this->getManagedObject(); - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); deltaObj->FromDelta(%mg_input); Apache::Geode::Client::IGeodeSerializable^ managedptr = @@ -188,8 +188,8 @@ namespace apache { Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromDelta: current domain ID: " + System::Threading::Thread::GetDomainID() + " for object: " + System::Convert::ToString((uint64_t) this) + " with its domain ID: " + m_domainId); Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromDelta: classid " + managedptr->ClassId + " : " + managedptr->ToString()); - apache::geode::client::DataOutput dataOut; - Apache::Geode::Client::DataOutput mg_output(&dataOut, true); + auto dataOut = input.getCache()->createDataOutput(); + Apache::Geode::Client::DataOutput mg_output(dataOut.get(), true); managedptr->ToData(%mg_output); //move cursor @@ -197,8 +197,8 @@ namespace apache mg_output.WriteBytesToUMDataOutput(); GF_SAFE_DELETE(m_bytes); - m_bytes = dataOut.getBufferCopy(); - m_size = dataOut.getBufferLength(); + m_bytes = dataOut->getBufferCopy(); + m_size = dataOut->getBufferLength(); Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::fromDelta objectSize = " + m_size + " m_hashCode = " + m_hashCode); m_hashCode = managedptr->GetHashCode(); } @@ -241,8 +241,8 @@ namespace apache Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytes::getManagedObject"); - apache::geode::client::DataInput dinp(m_bytes, m_size); - Apache::Geode::Client::DataInput mg_dinp(&dinp, true); + auto dinp = m_cache->createDataInput(m_bytes, m_size); + Apache::Geode::Client::DataInput mg_dinp(dinp.get(), true, m_cache); Apache::Geode::Client::TypeFactoryMethodGeneric^ creationMethod = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId); Apache::Geode::Client::IGeodeSerializable^ newObj = creationMethod(); @@ -261,8 +261,8 @@ namespace apache const ManagedCacheableDeltaBytesGeneric* p_other = dynamic_cast<const ManagedCacheableDeltaBytesGeneric*>(&other); if (p_other != NULL) { - apache::geode::client::DataInput di(m_bytes, m_size); - Apache::Geode::Client::DataInput mg_input(&di, true); + auto di = m_cache->createDataInput(m_bytes, m_size); + Apache::Geode::Client::DataInput mg_input(di.get(), true, m_cache); Apache::Geode::Client::IGeodeSerializable^ obj = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)(); obj->FromData(%mg_input); @@ -285,8 +285,8 @@ namespace apache { try { Apache::Geode::Client::Log::Debug("ManagedCacheableDeltaBytesGeneric::equal. "); - apache::geode::client::DataInput di(m_bytes, m_size); - Apache::Geode::Client::DataInput mg_input(&di, true); + auto di = m_cache->createDataInput(m_bytes, m_size); + Apache::Geode::Client::DataInput mg_input(di.get(), true, m_cache); Apache::Geode::Client::IGeodeSerializable^ obj = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)(); obj->FromData(%mg_input); http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp b/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp index 905d08a..c5fcbb2 100644 --- a/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp +++ b/src/clicache/src/impl/ManagedCacheableDeltaBytes.hpp @@ -20,7 +20,10 @@ #include "../geode_defs.hpp" #include <vcclr.h> #include "begin_native.hpp" +#include "SerializationRegistry.hpp" +#include <geode/Cache.hpp> #include <geode/Delta.hpp> +#include <geode/DataOutput.hpp> #include "end_native.hpp" #include "../Log.hpp" @@ -67,7 +70,7 @@ namespace apache /// </param> inline ManagedCacheableDeltaBytesGeneric( Apache::Geode::Client::IGeodeDelta^ managedDeltaptr, bool storeBytes) - : m_domainId(System::Threading::Thread::GetDomainID()), + :Delta(nullptr), m_domainId(System::Threading::Thread::GetDomainID()), m_classId(0), m_bytes(NULL), m_size(0), @@ -85,48 +88,22 @@ namespace apache Apache::Geode::Client::Log::Finer("ManagedCacheableDeltaBytes::Constructor: class ID " + managedptr->ClassId + " : " + managedptr->ToString() + " storeBytes:" + storeBytes); if (storeBytes) { - apache::geode::client::DataOutput dataOut; - Apache::Geode::Client::DataOutput mg_output(&dataOut, true); + auto dataOut = m_cache->createDataOutput(); + Apache::Geode::Client::DataOutput mg_output(dataOut.get(), true); managedptr->ToData(%mg_output); //move cursor //dataOut.advanceCursor(mg_output.BufferLength); mg_output.WriteBytesToUMDataOutput(); - m_bytes = dataOut.getBufferCopy(); - m_size = dataOut.getBufferLength(); + m_bytes = dataOut->getBufferCopy(); + m_size = dataOut->getBufferLength(); m_hashCode = managedptr->GetHashCode(); Apache::Geode::Client::Log::Finer("ManagedCacheableDeltaBytes::Constructor objectSize = " + m_size + " m_hashCode = " + m_hashCode); } } } - /* - inline ManagedCacheableDeltaBytes( - Apache::Geode::Client::IGeodeDelta^ managedDeltaptr, bool storeBytes) - : m_domainId(System::Threading::Thread::GetDomainID()), - m_classId(0), - m_bytes(NULL), - m_size(0), - m_hashCode(0) - { - Apache::Geode::Client::Log::Fine("ManagedCacheableDeltaBytes::Constructor: not storing bytes "); - Apache::Geode::Client::IGeodeSerializable^ managedptr = dynamic_cast <Apache::Geode::Client::IGeodeSerializable^> ( managedDeltaptr ); - if(managedptr != nullptr) - { - m_classId = managedptr->ClassId; - Apache::Geode::Client::Log::Fine("ManagedCacheableDeltaBytes::Constructor: current AppDomain ID: " + System::Threading::Thread::GetDomainID() + " for object: " + System::Convert::ToString((uint64_t) this) + " with its AppDomain ID: " + m_domainId); - Apache::Geode::Client::Log::Fine("ManagedCacheableDeltaBytes::Constructor: class ID " + managedptr->ClassId + " : " + managedptr->ToString()); - apache::geode::client::DataOutput dataOut; - Apache::Geode::Client::DataOutput mg_output( &dataOut); - managedptr->ToData( %mg_output ); - m_bytes = dataOut.getBufferCopy(); - m_size = dataOut.getBufferLength(); - Apache::Geode::Client::Log::Fine("ManagedCacheableDeltaBytes::Constructor objectSize = " + m_size + " m_hashCode = " + m_hashCode); - m_hashCode = managedptr->GetHashCode(); - } - }*/ - - + /// <summary> /// serialize this object /// </summary> http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableKey.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedCacheableKey.cpp b/src/clicache/src/impl/ManagedCacheableKey.cpp index d30d41e..8cefef9 100644 --- a/src/clicache/src/impl/ManagedCacheableKey.cpp +++ b/src/clicache/src/impl/ManagedCacheableKey.cpp @@ -62,7 +62,7 @@ namespace apache try { int pos = input.getBytesRead(); //Apache::Geode::Client::Log::Debug("ManagedCacheableKeyGeneric::fromData"); - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); m_managedptr = m_managedptr->FromData(%mg_input); //this will move the cursor in c++ layer @@ -102,28 +102,15 @@ namespace apache System::Int32 ManagedCacheableKeyGeneric::classId() const { - //Apache::Geode::Client::Log::Debug("ManagedCacheableKeyGeneric::classid " + m_classId); - /*System::UInt32 classId; - try { - classId = m_managedptr->ClassId; - } - catch (GeodeException^ ex) { - ex->ThrowNative(); - } - catch (System::Exception^ ex) { - GeodeException::ThrowNative(ex); - }*/ return (m_classId >= 0x80000000 ? 0 : m_classId); } int8_t ManagedCacheableKeyGeneric::typeId() const { - //Apache::Geode::Client::Log::Debug("ManagedCacheableKeyGeneric::typeId " + m_classId); if (m_classId >= 0x80000000) { return (int8_t)((m_classId - 0x80000000) % 0x20000000); } else if (m_classId <= 0x7F) { - //Apache::Geode::Client::Log::Debug("ManagedCacheableKeyGeneric::typeId inin"); return (int8_t)GeodeTypeIdsImpl::CacheableUserData; } else if (m_classId <= 0x7FFF) { @@ -136,12 +123,6 @@ namespace apache int8_t ManagedCacheableKeyGeneric::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); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableKey.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedCacheableKey.hpp b/src/clicache/src/impl/ManagedCacheableKey.hpp index 27fa215..1f3c27f 100644 --- a/src/clicache/src/impl/ManagedCacheableKey.hpp +++ b/src/clicache/src/impl/ManagedCacheableKey.hpp @@ -22,6 +22,7 @@ #include "begin_native.hpp" #include <geode/CacheableKey.hpp> #include <GeodeTypeIdsImpl.hpp> +#include "SerializationRegistry.hpp" #include "end_native.hpp" #include "../IGeodeSerializable.hpp" @@ -34,6 +35,7 @@ namespace apache { namespace client { + namespace native = apache::geode::client; /// <summary> /// Wraps the managed <see cref="Apache.Geode.Client.IGeodeSerializable" /> @@ -45,14 +47,16 @@ namespace apache private: int m_hashcode; int m_classId; + native::SerializationRegistry* m_serializationRegistry; int m_objectSize; public: inline ManagedCacheableKeyGeneric( - Apache::Geode::Client::IGeodeSerializable^ managedptr, int hashcode, int classId) + Apache::Geode::Client::IGeodeSerializable^ managedptr, int hashcode, int classId, native::SerializationRegistry * serializationRegistry) : m_managedptr(managedptr) { m_hashcode = hashcode; m_classId = classId; + m_serializationRegistry = serializationRegistry; m_objectSize = 0; } /// <summary> @@ -61,11 +65,12 @@ namespace apache /// <param name="managedptr"> /// The managed object. /// </param> - inline ManagedCacheableKeyGeneric(Apache::Geode::Client::IGeodeSerializable^ managedptr) + inline ManagedCacheableKeyGeneric(Apache::Geode::Client::IGeodeSerializable^ managedptr, native::SerializationRegistry * serializationRegistry) : m_managedptr(managedptr) { // m_hashcode = managedptr->GetHashCode(); m_hashcode = 0; m_classId = managedptr->ClassId; + m_serializationRegistry = serializationRegistry; m_objectSize = 0; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp b/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp index 5d39280..93e01bc 100644 --- a/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp +++ b/src/clicache/src/impl/ManagedCacheableKeyBytes.cpp @@ -16,7 +16,9 @@ */ #include "begin_native.hpp" +#include <geode/Cache.hpp> #include <GeodeTypeIdsImpl.hpp> +#include "DataInputInternal.hpp" #include "end_native.hpp" #include "ManagedCacheableKeyBytes.hpp" @@ -56,7 +58,7 @@ namespace apache try { Apache::Geode::Client::Log::Debug("ManagedCacheableKeyBytesGeneric::fromData: classid " + m_classId + "aid = " + +System::Threading::Thread::GetDomainID()); - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); const System::Byte* objStartPos = input.currentBufferPosition(); Apache::Geode::Client::IGeodeSerializable^ obj = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)(); @@ -187,8 +189,8 @@ namespace apache const ManagedCacheableKeyBytesGeneric* p_other = dynamic_cast<const ManagedCacheableKeyBytesGeneric*>(&other); if (p_other != NULL) { - apache::geode::client::DataInput di(m_bytes, m_size); - Apache::Geode::Client::DataInput mg_input(&di, true); + DataInputInternal di(m_bytes, m_size, nullptr); + Apache::Geode::Client::DataInput mg_input(&di, true, nullptr); Apache::Geode::Client::IGeodeSerializable^ obj = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)(); obj->FromData(%mg_input); @@ -211,8 +213,8 @@ namespace apache { try { Apache::Geode::Client::Log::Debug("ManagedCacheableKeyBytesGeneric::equal. "); - apache::geode::client::DataInput di(m_bytes, m_size); - Apache::Geode::Client::DataInput mg_input(&di, true); + DataInputInternal di(m_bytes, m_size, nullptr); + Apache::Geode::Client::DataInput mg_input(&di, true, nullptr); Apache::Geode::Client::IGeodeSerializable^ obj = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)(); obj->FromData(%mg_input); @@ -274,8 +276,8 @@ namespace apache //} // Apache::Geode::Client::Log::Debug("ManagedCacheableKeyBytesGeneric::getManagedObject " + sb); - apache::geode::client::DataInput dinp(m_bytes, m_size); - Apache::Geode::Client::DataInput mg_dinp(&dinp, true); + DataInputInternal dinp(m_bytes, m_size, nullptr); + Apache::Geode::Client::DataInput mg_dinp(&dinp, true, nullptr); Apache::Geode::Client::TypeFactoryMethodGeneric^ creationMethod = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId); Apache::Geode::Client::IGeodeSerializable^ newObj = creationMethod(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp b/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp index e0b4ecf..10f0466 100644 --- a/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp +++ b/src/clicache/src/impl/ManagedCacheableKeyBytes.hpp @@ -21,6 +21,7 @@ #include <vcclr.h> #include "begin_native.hpp" #include <geode/CacheableKey.hpp> +#include "DataOutputInternal.hpp" #include "end_native.hpp" #include "../Log.hpp" @@ -76,7 +77,7 @@ namespace apache { if (storeBytes)//if value is from app { - apache::geode::client::DataOutput dataOut; + DataOutputInternal dataOut; Apache::Geode::Client::DataOutput mg_output(&dataOut, true); managedptr->ToData(%mg_output); http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/ManagedString.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/ManagedString.hpp b/src/clicache/src/impl/ManagedString.hpp index d869ad9..ed67695 100644 --- a/src/clicache/src/impl/ManagedString.hpp +++ b/src/clicache/src/impl/ManagedString.hpp @@ -22,7 +22,8 @@ #include "../geode_defs.hpp" #ifdef _WIN32 -#define snprintf _snprintf +// FIXME: Why is this needed? +//#define snprintf _snprintf #endif http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PartitionResolver.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PartitionResolver.hpp b/src/clicache/src/impl/PartitionResolver.hpp index 543ea07..8223e19 100644 --- a/src/clicache/src/impl/PartitionResolver.hpp +++ b/src/clicache/src/impl/PartitionResolver.hpp @@ -59,7 +59,7 @@ namespace Apache { EntryEvent<TKey, TValue> gevent(&ev); Object^ groutingobject = m_resolver->GetRoutingObject(%gevent); - return Serializable::GetUnmanagedValueGeneric<Object^>(groutingobject); + return Serializable::GetUnmanagedValueGeneric<Object^>(groutingobject, nullptr); } virtual const char * getName() http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxHelper.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxHelper.cpp b/src/clicache/src/impl/PdxHelper.cpp index 1d35467..f611146 100644 --- a/src/clicache/src/impl/PdxHelper.cpp +++ b/src/clicache/src/impl/PdxHelper.cpp @@ -45,20 +45,6 @@ namespace Apache namespace Internal { - - CacheImpl* getCacheImpl() - { - CachePtr cache = CacheFactory::getAnyInstance(); - if (cache == nullptr) - { - throw gcnew IllegalStateException("cache has not been created yet.");; - } - if (cache->isClosed()) - { - throw gcnew IllegalStateException("cache has been closed. "); - } - return CacheRegionHelper::getCacheImpl(cache.get()); - } void PdxHelper::SerializePdx(DataOutput^ dataOutput, IPdxSerializable^ pdxObject) { @@ -84,7 +70,7 @@ namespace Apache PdxType^ piPt = pdxII->getPdxType(); if(piPt != nullptr && piPt->TypeId == 0)//from pdxInstance factory need to get typeid from server { - int typeId = PdxTypeRegistry::GetPDXIdForType(piPt, dataOutput->GetPoolName()); + int typeId = PdxTypeRegistry::GetPDXIdForType(piPt, dataOutput->GetPoolName(), dataOutput->GetNative()->getCache()); pdxII->setPdxId(typeId); } PdxLocalWriter^ plw = gcnew PdxLocalWriter(dataOutput, piPt); @@ -117,20 +103,20 @@ namespace Apache //get type id from server and then set it int nTypeId = PdxTypeRegistry::GetPDXIdForType(pdxType, - dataOutput->GetPoolName(), nType, true); + dataOutput->GetPoolName(), nType, true, dataOutput->GetNative()->getCache()); nType->TypeId = nTypeId; ptc->EndObjectWriting();//now write typeid PdxTypeRegistry::AddLocalPdxType(pdxClassname, nType);//add classname VS pdxType PdxTypeRegistry::AddPdxType(nTypeId, nType);//add typeid vs pdxtype - //This is for pdx Statistics - CacheImpl* cacheImpl = getCacheImpl(); - if (cacheImpl != NULL) { - System::Byte* stPos = dataOutput->GetStartBufferPosition() + ptc->getStartPositionOffset(); - int pdxLen = PdxHelper::ReadInt32(stPos); - cacheImpl->m_cacheStats->incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID - } + + //This is for pdx Statistics + System::Byte* stPos = dataOutput->GetStartBufferPosition() + ptc->getStartPositionOffset(); + int pdxLen = PdxHelper::ReadInt32(stPos); + // TODO global - Figure out why dataInput cache is nullptr + // CacheRegionHelper::getCacheImpl(dataOutput->GetNative()->getCache())->getCachePerfStats().incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID + // GC::KeepAlive(dataOutput); } else//we know locasl type, need to see preerved data { @@ -154,18 +140,18 @@ namespace Apache pdxObject->ToData(prw); prw->EndObjectWriting(); - //This is for pdx Statistics - CacheImpl* cacheImpl = getCacheImpl(); - if (cacheImpl != NULL) { - System::Byte* stPos = dataOutput->GetStartBufferPosition() + prw->getStartPositionOffset(); - int pdxLen = PdxHelper::ReadInt32(stPos); - cacheImpl->m_cacheStats->incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID - } + + //This is for pdx Statistics + System::Byte* stPos = dataOutput->GetStartBufferPosition() + prw->getStartPositionOffset(); + int pdxLen = PdxHelper::ReadInt32(stPos); + // TODO global - Figure out why dataInput cache is nullptr + // CacheRegionHelper::getCacheImpl(dataOutput->GetNative()->getCache())->getCachePerfStats().incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID + // GC::KeepAlive(dataOutput); } } - IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int len ) + IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int len, const native::SerializationRegistry* serializationRegistry) { dataInput->setPdxdeserialization(true); String^ pdxClassname = nullptr; @@ -208,7 +194,7 @@ namespace Apache { if(pType == nullptr) { - pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId)); + pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId, dataInput->GetNative()->getCache())); pdxLocalType = PdxTypeRegistry::GetLocalPdxType(pType->PdxClassName);//this should be fine for IPdxTypeMappers } @@ -254,7 +240,7 @@ namespace Apache pdxLocalType->InitializeType(); pdxLocalType->TypeId = PdxTypeRegistry::GetPDXIdForType(pdxObject->GetType(), dataInput->GetPoolName(), - pdxLocalType, true); + pdxLocalType, true, dataInput->GetNative()->getCache()); pdxLocalType->IsLocal = true; PdxTypeRegistry::AddLocalPdxType(pdxClassname, pdxLocalType);//added local type PdxTypeRegistry::AddPdxType(pdxLocalType->TypeId, pdxLocalType); @@ -265,7 +251,7 @@ namespace Apache //pdxLocalType->AddOtherVersion(pdxLocalType);//no need to add local type //need to create merge type - CreateMergedType(pdxLocalType, pType, dataInput); + CreateMergedType(pdxLocalType, pType, dataInput, serializationRegistry); PdxType^ mergedVersion = PdxTypeRegistry::GetMergedType(pType->TypeId); PdxRemotePreservedData^ preserveData = prtc->GetPreservedData(mergedVersion, pdxObject); @@ -289,7 +275,7 @@ namespace Apache pdxRealObject = pdxWrapper->GetObject(); //need to create merge type - CreateMergedType(pdxLocalType, pType, dataInput); + CreateMergedType(pdxLocalType, pType, dataInput, serializationRegistry); PdxType^ mergedVersion = PdxTypeRegistry::GetMergedType(pType->TypeId); PdxRemotePreservedData^ preserveData = prr->GetPreservedData(mergedVersion, pdxObject); @@ -301,7 +287,7 @@ namespace Apache return pdxObject; } - IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize ) + IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, const native::SerializationRegistry* serializationRegistry) { try { @@ -313,13 +299,10 @@ namespace Apache int len = dataInput->ReadInt32(); int typeId= dataInput->ReadInt32(); - //This is for pdx Statistics - CacheImpl* cacheImpl = getCacheImpl(); - if (cacheImpl != NULL) { - cacheImpl->m_cacheStats->incPdxDeSerialization(len + 9);//pdxLen + 1 + 2*4 - } + //This is for pdx Statistics + CacheRegionHelper::getCacheImpl(dataInput->GetNative()->getCache())->getCachePerfStats().incPdxDeSerialization(len + 9);//pdxLen + 1 + 2*4 - return DeserializePdx(dataInput, forceDeserialize, typeId, len); + return DeserializePdx(dataInput, forceDeserialize, typeId, len, serializationRegistry); }//create PdxInstance else { @@ -334,7 +317,7 @@ namespace Apache if(pType == nullptr) { - PdxType^ pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId)); + PdxType^ pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId, dataInput->GetNative()->getCache())); //this should be fine for IPdxTypeMapper PdxTypeRegistry::AddLocalPdxType(pType->PdxClassName, pType); PdxTypeRegistry::AddPdxType(pType->TypeId, pType); @@ -342,7 +325,7 @@ namespace Apache } // pdxObject = gcnew PdxInstanceImpl(gcnew DataInput(dataInput->GetBytes(dataInput->GetCursor(), len + 8 ), len + 8)); - pdxObject = gcnew PdxInstanceImpl(dataInput->GetBytes(dataInput->GetCursor(), len ), len, typeId, true ); + pdxObject = gcnew PdxInstanceImpl(dataInput->GetBytes(dataInput->GetCursor(), len ), len, typeId, true, dataInput->GetNative()->getCache()); dataInput->AdvanceCursorPdx(len ); @@ -351,10 +334,7 @@ namespace Apache dataInput->SetBuffer(); //This is for pdxinstance Statistics - CacheImpl* cacheImpl = getCacheImpl(); - if (cacheImpl != NULL) { - cacheImpl->m_cacheStats->incPdxInstanceCreations(); - } + CacheRegionHelper::getCacheImpl(dataInput->GetNative()->getCache())->getCachePerfStats().incPdxInstanceCreations(); return pdxObject; } }finally @@ -363,21 +343,21 @@ namespace Apache } } - Int32 PdxHelper::GetEnumValue(String^ enumClassName, String^ enumName, int hashcode) + Int32 PdxHelper::GetEnumValue(String^ enumClassName, String^ enumName, int hashcode, const native::Cache* cache) { //in case app want different name enumClassName = Serializable::GetPdxTypeName(enumClassName); EnumInfo^ ei = gcnew EnumInfo(enumClassName, enumName, hashcode); - return PdxTypeRegistry::GetEnumValue(ei); + return PdxTypeRegistry::GetEnumValue(ei, cache); } - Object^ PdxHelper::GetEnum(int enumId) + Object^ PdxHelper::GetEnum(int enumId, const native::Cache* cache) { - EnumInfo^ ei = PdxTypeRegistry::GetEnum(enumId); + EnumInfo^ ei = PdxTypeRegistry::GetEnum(enumId, cache); return ei->GetEnum(); } - void PdxHelper::CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput) + void PdxHelper::CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput, const native::SerializationRegistry* serializationRegistry) { PdxType^ mergedVersion = localType->MergeVersion(remoteType); @@ -393,7 +373,7 @@ namespace Apache {//need to create new version mergedVersion->InitializeType(); if(mergedVersion->TypeId == 0) - mergedVersion->TypeId = Serializable::GetPDXIdForType(dataInput->GetPoolName(), mergedVersion); + mergedVersion->TypeId = Serializable::GetPDXIdForType(dataInput->GetPoolName(), mergedVersion, dataInput->GetNative()->getCache()); // PdxTypeRegistry::AddPdxType(remoteType->TypeId, mergedVersion); PdxTypeRegistry::AddPdxType(mergedVersion->TypeId, mergedVersion); http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxHelper.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxHelper.hpp b/src/clicache/src/impl/PdxHelper.hpp index 80b2b80..7cc9c82 100644 --- a/src/clicache/src/impl/PdxHelper.hpp +++ b/src/clicache/src/impl/PdxHelper.hpp @@ -19,6 +19,7 @@ //#include "../DataOutput.hpp" #include "begin_native.hpp" #include <geode/DataOutput.hpp> +#include "SerializationRegistry.hpp" #include "end_native.hpp" #include "../IPdxSerializable.hpp" @@ -30,7 +31,7 @@ namespace Apache { namespace Client { - + namespace native = apache::geode::client; ref class DataOutput; ref class DataInput; namespace Internal @@ -42,9 +43,9 @@ namespace Apache static void SerializePdx(DataOutput^ dataOutput, IPdxSerializable^ pdxObject); - static IPdxSerializable^ DeserializePdx(DataInput^ dataOutput, bool forceDeserialize); + static IPdxSerializable^ DeserializePdx(DataInput^ dataOutput, bool forceDeserialize, const native::SerializationRegistry* serializationRegistry); - static IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int length ); + static IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int length, const native::SerializationRegistry* serializationRegistry); literal Byte PdxHeader = 8; @@ -64,12 +65,12 @@ namespace Apache static Int32 ReadInt(System::Byte* offsetPosition, int size); - static Int32 GetEnumValue(String^ enumClassName, String^ enumName, int hashcode); + static Int32 GetEnumValue(String^ enumClassName, String^ enumName, int hashcode, const native::Cache* cache); - static Object^ GetEnum(int enumId); + static Object^ GetEnum(int enumId, const native::Cache* cache); private: - static void CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput); + static void CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput, const native::SerializationRegistry* serializationRegistry); }; } // namespace Client } // namespace Geode http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp b/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp index 885dab6..230972a 100644 --- a/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp +++ b/src/clicache/src/impl/PdxInstanceFactoryImpl.cpp @@ -16,6 +16,10 @@ */ #pragma once +#include "begin_native.hpp" +#include "CacheRegionHelper.hpp" +#include "CacheImpl.hpp" +#include "end_native.hpp" #include "PdxInstanceFactoryImpl.hpp" #include "PdxInstanceImpl.hpp" #include "DotNetTypes.hpp" @@ -30,7 +34,7 @@ namespace Apache namespace Internal { - PdxInstanceFactoryImpl::PdxInstanceFactoryImpl(String^ className) + PdxInstanceFactoryImpl::PdxInstanceFactoryImpl(String^ className, native::Cache* cache) { if (className == nullptr) throw gcnew IllegalStateException( @@ -38,6 +42,7 @@ namespace Apache m_pdxType = gcnew PdxType(className, false); m_FieldVsValues = gcnew Dictionary<String^, Object^>(); m_created = false; + m_cache = cache; } IPdxInstance^ PdxInstanceFactoryImpl::Create() @@ -48,7 +53,7 @@ namespace Apache "The IPdxInstanceFactory.Create() method can only be called once."); } //need to get typeid; - IPdxInstance^ pi = gcnew PdxInstanceImpl(m_FieldVsValues, m_pdxType); + IPdxInstance^ pi = gcnew PdxInstanceImpl(m_FieldVsValues, m_pdxType, &CacheRegionHelper::getCacheImpl(m_cache)->getCachePerfStats(), m_cache); m_created = true; return pi; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp b/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp index 91b38d1..cce22e4 100644 --- a/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp +++ b/src/clicache/src/impl/PdxInstanceFactoryImpl.hpp @@ -16,6 +16,9 @@ */ #pragma once +#include "begin_native.hpp" +#include <geode/Cache.hpp> +#include "end_native.hpp" #include "../IPdxInstanceFactory.hpp" #include "../IPdxSerializable.hpp" @@ -31,17 +34,23 @@ namespace Apache namespace Internal { + + namespace native = apache::geode::client; + ref class PdxInstanceFactoryImpl : IPdxInstanceFactory { private: bool m_created; PdxType^ m_pdxType; Dictionary<String^, Object^>^ m_FieldVsValues; + native::Cache* m_cache; internal: - PdxInstanceFactoryImpl(String^ className); + PdxInstanceFactoryImpl(String^ className, native::Cache* cache); void isFieldAdded(String^ fieldName); + + public: - /// <summary> + /// <summary> /// Create a {@link PdxInstance}. The instance /// will contain any data written to this factory /// using the write methods. http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxInstanceImpl.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxInstanceImpl.cpp b/src/clicache/src/impl/PdxInstanceImpl.cpp index b4092f9..785d997 100755 --- a/src/clicache/src/impl/PdxInstanceImpl.cpp +++ b/src/clicache/src/impl/PdxInstanceImpl.cpp @@ -45,7 +45,7 @@ namespace Apache namespace Internal { //this is for PdxInstanceFactory - PdxInstanceImpl::PdxInstanceImpl(Dictionary<String^, Object^>^ fieldVsValue, PdxType^ pdxType) + PdxInstanceImpl::PdxInstanceImpl(Dictionary<String^, Object^>^ fieldVsValue, PdxType^ pdxType, CachePerfStats* cachePerfStats, const native::Cache* cache) { m_updatedFields = fieldVsValue; m_typeId = 0; @@ -53,21 +53,15 @@ namespace Apache m_buffer = NULL; m_bufferLength = 0; m_pdxType = pdxType; - + m_cache = cache; + m_cachePerfStats = cachePerfStats; m_pdxType->InitializeType();//to generate static position map //need to initiailize stream. this will call todata and in toData we will have stream - apache::geode::client::DataOutput* output = apache::geode::client::DataOutput::getDataOutput(); + auto output = m_cache->createDataOutput(); - try - { - Apache::Geode::Client::DataOutput mg_output(&(*output), true); - Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, this); - } - finally - { - apache::geode::client::DataOutput::releaseDataOutput(output); - } + Apache::Geode::Client::DataOutput mg_output(output.get(), true); + Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, this); } String^ PdxInstanceImpl::GetClassName() @@ -84,27 +78,18 @@ namespace Apache } Object^ PdxInstanceImpl::GetObject() { - DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength); + DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength, m_cache); dataInput->setRootObjectPdx(true); System::Int64 sampleStartNanos = Utils::startStatOpTime(); - Object^ ret = Internal::PdxHelper::DeserializePdx(dataInput, true, m_typeId, m_bufferLength); + Object^ ret = Internal::PdxHelper::DeserializePdx(dataInput, true, m_typeId, m_bufferLength, CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry().get()); //dataInput->ResetPdx(0); - CachePtr cache = CacheFactory::getAnyInstance(); - if (cache == nullptr) - { - throw gcnew IllegalStateException("cache has not been created yet.");; - } - if (cache->isClosed()) + if(m_cachePerfStats) { - throw gcnew IllegalStateException("cache has been closed. "); - } - CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get()); - if (cacheImpl != NULL) { - Utils::updateStatOpTime(cacheImpl->m_cacheStats->getStat(), - cacheImpl->m_cacheStats->getPdxInstanceDeserializationTimeId(), + Utils::updateStatOpTime(m_cachePerfStats->getStat(), + m_cachePerfStats->getPdxInstanceDeserializationTimeId(), sampleStartNanos); - cacheImpl->m_cacheStats->incPdxInstanceDeserializations(); + m_cachePerfStats->incPdxInstanceDeserializations(); } return ret; } @@ -152,7 +137,7 @@ namespace Apache } { - DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength); + DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength, m_cache); dataInput->setPdxdeserialization(true); int pos = getOffset(dataInput, pt, pft->SequenceId); @@ -246,9 +231,9 @@ namespace Apache equatePdxFields(myPdxIdentityFieldList, otherPdxIdentityFieldList); equatePdxFields(otherPdxIdentityFieldList, myPdxIdentityFieldList); - DataInput^ myDataInput = gcnew DataInput(m_buffer, m_bufferLength); + DataInput^ myDataInput = gcnew DataInput(m_buffer, m_bufferLength, m_cache); myDataInput->setPdxdeserialization(true); - DataInput^ otherDataInput = gcnew DataInput(otherPdx->m_buffer, otherPdx->m_bufferLength); + DataInput^ otherDataInput = gcnew DataInput(otherPdx->m_buffer, otherPdx->m_bufferLength, m_cache); otherDataInput->setPdxdeserialization(true); bool isEqual = false; @@ -578,7 +563,7 @@ namespace Apache IList<PdxFieldType^>^ pdxIdentityFieldList = getIdentityPdxFields(pt); - DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength); + DataInput^ dataInput = gcnew DataInput(m_buffer, m_bufferLength, m_cache); dataInput->setPdxdeserialization(true); for (int i = 0; i < pdxIdentityFieldList->Count; i++) @@ -964,7 +949,7 @@ namespace Apache IWritablePdxInstance^ PdxInstanceImpl::CreateWriter() { //dataInput->ResetPdx(0); - return gcnew PdxInstanceImpl(m_buffer, m_bufferLength, m_typeId, false);//need to create duplicate byte stream + return gcnew PdxInstanceImpl(m_buffer, m_bufferLength, m_typeId, false, m_cache);//need to create duplicate byte stream } void PdxInstanceImpl::SetField(String^ fieldName, Object^ value) @@ -1001,7 +986,7 @@ namespace Apache if (!m_own) copy = apache::geode::client::DataInput::getBufferCopy(m_buffer, m_bufferLength); - DataInput^ dataInput = gcnew DataInput(copy, m_bufferLength);//this will delete buffer + DataInput^ dataInput = gcnew DataInput(copy, m_bufferLength, m_cache);//this will delete buffer dataInput->setPdxdeserialization(true); //but new stream is set for this from pdxHelper::serialize function http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxInstanceImpl.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxInstanceImpl.hpp b/src/clicache/src/impl/PdxInstanceImpl.hpp index ebab9a5..4e44022 100755 --- a/src/clicache/src/impl/PdxInstanceImpl.hpp +++ b/src/clicache/src/impl/PdxInstanceImpl.hpp @@ -16,6 +16,10 @@ */ #pragma once +#include "begin_native.hpp" +#include "CachePerfStats.hpp" +#include "SerializationRegistry.hpp" +#include "end_native.hpp" #include "../IPdxInstance.hpp" #include "../IPdxSerializable.hpp" @@ -64,11 +68,13 @@ namespace Apache //DataInput^ m_dataInput; + CachePerfStats* m_cachePerfStats; System::Byte* m_buffer; int m_bufferLength; int m_typeId; bool m_own; PdxType^ m_pdxType; + const native::Cache* m_cache; internal: Dictionary<String^, Object^>^ m_updatedFields; @@ -119,7 +125,7 @@ namespace Apache void updatePdxStream(System::Byte* newPdxStream, int len); public: - PdxInstanceImpl(System::Byte* buffer, int length, int typeId, bool own) + PdxInstanceImpl(System::Byte* buffer, int length, int typeId, bool own, const native::Cache* cache) { //m_dataInput = dataInput; m_buffer = buffer; @@ -128,10 +134,11 @@ namespace Apache m_updatedFields = nullptr; m_own = own; m_pdxType = nullptr; + m_cache = cache; } //for pdxInstance factory - PdxInstanceImpl(Dictionary<String^, Object^>^ fieldVsValue, PdxType^ pdxType); + PdxInstanceImpl(Dictionary<String^, Object^>^ fieldVsValue, PdxType^ pdxType, CachePerfStats* cachePerfStats, const native::Cache* cache); ~PdxInstanceImpl() { http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxManagedCacheableKey.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxManagedCacheableKey.cpp b/src/clicache/src/impl/PdxManagedCacheableKey.cpp index 81fa5d2..2764b36 100644 --- a/src/clicache/src/impl/PdxManagedCacheableKey.cpp +++ b/src/clicache/src/impl/PdxManagedCacheableKey.cpp @@ -20,6 +20,7 @@ #include "begin_native.hpp" #include <GeodeTypeIdsImpl.hpp> +#include "CacheRegionHelper.hpp" #include "end_native.hpp" #include "PdxManagedCacheableKey.hpp" @@ -62,9 +63,9 @@ namespace apache { try { int pos = input.getBytesRead(); - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); //m_managedptr = m_managedptr->FromData( %mg_input ); - Apache::Geode::Client::IPdxSerializable^ tmp = Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_input, false); + 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); @@ -259,10 +260,10 @@ namespace apache } } - void PdxManagedCacheableKey::fromDelta(DataInput& input) + void PdxManagedCacheableKey::fromDelta(native::DataInput& input) { try { - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); m_managedDeltaptr->FromDelta(%mg_input); //this will move the cursor in c++ layer @@ -287,7 +288,7 @@ namespace apache Apache::Geode::Client::IPdxSerializable^ Mclone = dynamic_cast<Apache::Geode::Client::IPdxSerializable^>(cloneable->Clone()); return DeltaPtr(static_cast<PdxManagedCacheableKey*>( - SafeGenericM2UMConvert(Mclone))); + SafeGenericM2UMConvert(Mclone, m_cache))); } else { return Delta::clone(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxManagedCacheableKey.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxManagedCacheableKey.hpp b/src/clicache/src/impl/PdxManagedCacheableKey.hpp index 859319b..02bea8c 100644 --- a/src/clicache/src/impl/PdxManagedCacheableKey.hpp +++ b/src/clicache/src/impl/PdxManagedCacheableKey.hpp @@ -63,14 +63,14 @@ namespace apache public: inline PdxManagedCacheableKey() - : m_managedptr(nullptr), m_hashcode(0), m_objectSize(0), m_managedDeltaptr(nullptr) + : Delta(nullptr), m_managedptr(nullptr), m_hashcode(0), m_objectSize(0), m_managedDeltaptr(nullptr) { } inline PdxManagedCacheableKey( Apache::Geode::Client::IPdxSerializable^ managedptr, int hashcode) - : m_managedptr(managedptr), m_objectSize(0) { + :Delta(nullptr), m_managedptr(managedptr), m_objectSize(0) { m_hashcode = hashcode; m_managedDeltaptr = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(managedptr); } @@ -82,7 +82,7 @@ namespace apache /// </param> inline PdxManagedCacheableKey( Apache::Geode::Client::IPdxSerializable^ managedptr) - : m_managedptr(managedptr), m_objectSize(0) { + : 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); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp b/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp index cabe7d9..f811449 100644 --- a/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp +++ b/src/clicache/src/impl/PdxManagedCacheableKeyBytes.cpp @@ -55,24 +55,17 @@ namespace apache { try { - //Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromData: classid " + m_classId); - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); const System::Byte* objStartPos = input.currentBufferPosition(); - Apache::Geode::Client::IPdxSerializable^ obj = Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_input, false); - - //Apache::Geode::Client::IGeodeSerializable^ obj = Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)(); - //obj->FromData(%mg_input); - + Apache::Geode::Client::IPdxSerializable^ obj = Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_input, false, CacheRegionHelper::getCacheImpl(input.getCache())->getSerializationRegistry().get()); input.advanceCursor(mg_input.BytesReadInternally); m_hashCode = obj->GetHashCode(); const System::Byte* objEndPos = input.currentBufferPosition(); - //m_size = mg_input.BytesRead; m_size = (System::UInt32)(objEndPos - objStartPos); - // Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromData: objectSize = " + m_size + " m_hashCode = " + m_hashCode); m_bytes = input.getBufferCopyFrom(objStartPos, m_size); } @@ -88,7 +81,6 @@ namespace apache System::UInt32 PdxManagedCacheableKeyBytes::objectSize() const { try { - //return m_managedptr->ObjectSize; return m_size; } catch (Apache::Geode::Client::GeodeException^ ex) { @@ -102,62 +94,18 @@ namespace apache System::Int32 PdxManagedCacheableKeyBytes::classId() const { - //System::UInt32 classId; - //try { - // //classId = m_managedptr->ClassId; - // classId = m_classId; - //} - //catch (Apache::Geode::Client::GeodeException^ ex) { - // ex->ThrowNative(); - //} - //catch (System::Exception^ ex) { - // Apache::Geode::Client::GeodeException::ThrowNative(ex); - //} - //return (classId >= 0x80000000 ? 0 : classId); return 0; } int8_t PdxManagedCacheableKeyBytes::typeId() const { - //try { - // //System::UInt32 classId = m_managedptr->ClassId; - // System::UInt32 classId = m_classId; - // if (classId >= 0x80000000) { - // return (int8_t)((classId - 0x80000000) % 0x20000000); - // } - // else if (classId <= 0x7F) { - // return (int8_t)apache::geode::client::GeodeTypeIdsImpl::CacheableUserData; - // } - // else if (classId <= 0x7FFF) { - // return (int8_t)apache::geode::client::GeodeTypeIdsImpl::CacheableUserData2; - // } - // else { - // return (int8_t)apache::geode::client::GeodeTypeIdsImpl::CacheableUserData4; - // } - //} - //catch (Apache::Geode::Client::GeodeException^ ex) { - // ex->ThrowNative(); - //} - //catch (System::Exception^ ex) { - // Apache::Geode::Client::GeodeException::ThrowNative(ex); - //} + return (int8_t)GeodeTypeIdsImpl::PDX; } int8_t PdxManagedCacheableKeyBytes::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 - //System::UInt32 classId = m_managedptr->ClassId; - /* System::UInt32 classId = m_classId; - if (classId >= 0x80000000) { - return (int8_t)((classId - 0x80000000) / 0x20000000); - }*/ - return 0; + return 0; } apache::geode::client::CacheableStringPtr PdxManagedCacheableKeyBytes::toString() const @@ -190,14 +138,8 @@ namespace apache const PdxManagedCacheableKeyBytes* p_other = dynamic_cast<const PdxManagedCacheableKeyBytes*>(&other); if (p_other != NULL) { - apache::geode::client::DataInput di(m_bytes, m_size); - Apache::Geode::Client::DataInput mg_input(&di, true); - /* Apache::Geode::Client::IGeodeSerializable^ obj = - Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)(); - obj->FromData(%mg_input);*/ Apache::Geode::Client::IPdxSerializable^ obj = getManagedObject(); bool ret = obj->Equals(p_other->ptr()); - // Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::equal return VAL = " + ret); return ret; } } @@ -215,16 +157,9 @@ namespace apache { try { //Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::equal. "); - apache::geode::client::DataInput di(m_bytes, m_size); - Apache::Geode::Client::DataInput mg_input(&di, true); - /*Apache::Geode::Client::IGeodeSerializable^ obj = - Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId)(); - obj->FromData(%mg_input);*/ Apache::Geode::Client::IPdxSerializable^ obj = getManagedObject(); bool ret = obj->Equals(other.ptr()); - // Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::equal return VAL = " + ret); return ret; - //return obj->Equals(other.get()); } catch (Apache::Geode::Client::GeodeException^ ex) { ex->ThrowNative(); @@ -267,25 +202,14 @@ namespace apache Apache::Geode::Client::IPdxSerializable^ PdxManagedCacheableKeyBytes::getManagedObject() const { - - // Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::getManagedObject " + m_size); - - apache::geode::client::DataInput dinp(m_bytes, m_size); - Apache::Geode::Client::DataInput mg_dinp(&dinp, true); - /*TypeFactoryMethodGeneric^ creationMethod = - Apache::Geode::Client::Serializable::GetTypeFactoryMethodGeneric(m_classId); - Apache::Geode::Client::IGeodeSerializable^ newObj = creationMethod(); - return newObj->FromData(%mg_dinp);*/ - return Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_dinp, false); + auto dinp = m_cache->createDataInput(m_bytes, m_size); + Apache::Geode::Client::DataInput mg_dinp(dinp.get(), true, m_cache); + return Apache::Geode::Client::Internal::PdxHelper::DeserializePdx(%mg_dinp, false, CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry().get()); } bool PdxManagedCacheableKeyBytes::hasDelta() { - /* Apache::Geode::Client::IGeodeDelta^ deltaObj = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(this->getManagedObject()); - - if(deltaObj) - return deltaObj->HasDelta();*/ - return m_hasDelta; + return m_hasDelta; } void PdxManagedCacheableKeyBytes::toDelta(DataOutput& output) const @@ -310,29 +234,21 @@ namespace apache try { Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromDelta:"); Apache::Geode::Client::IGeodeDelta^ deltaObj = dynamic_cast<Apache::Geode::Client::IGeodeDelta^>(this->getManagedObject()); - Apache::Geode::Client::DataInput mg_input(&input, true); + Apache::Geode::Client::DataInput mg_input(&input, true, input.getCache()); deltaObj->FromDelta(%mg_input); Apache::Geode::Client::IPdxSerializable^ managedptr = dynamic_cast <Apache::Geode::Client::IPdxSerializable^> (deltaObj); - // if(managedptr != nullptr) { Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromDelta: current domain ID: " + System::Threading::Thread::GetDomainID() + " for object: " + System::Convert::ToString((uint64_t) this) + " with its domain ID: " + m_domainId); - //Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromDelta: classid " + managedptr->ClassId + " : " + managedptr->ToString()); - apache::geode::client::DataOutput dataOut; - Apache::Geode::Client::DataOutput mg_output(&dataOut, true); - //managedptr->ToData( %mg_output ); + auto dataOut = m_cache->createDataOutput(); + Apache::Geode::Client::DataOutput mg_output(dataOut.get(), true); Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, managedptr); - //m_managedptr->ToData( %mg_output ); - //this will move the cursor in c++ layer mg_output.WriteBytesToUMDataOutput(); - //move cursor - // dataOut.advanceCursor(mg_output.BufferLength); - - GF_SAFE_DELETE(m_bytes); - m_bytes = dataOut.getBufferCopy(); - m_size = dataOut.getBufferLength(); + GF_SAFE_DELETE(m_bytes); + m_bytes = dataOut->getBufferCopy(); + m_size = dataOut->getBufferLength(); Apache::Geode::Client::Log::Debug("PdxManagedCacheableKeyBytes::fromDelta objectSize = " + m_size + " m_hashCode = " + m_hashCode); m_hashCode = managedptr->GetHashCode(); } @@ -354,7 +270,7 @@ namespace apache Apache::Geode::Client::IPdxSerializable^ Mclone = dynamic_cast<Apache::Geode::Client::IPdxSerializable^>(cloneable->Clone()); return DeltaPtr(static_cast<PdxManagedCacheableKeyBytes*>( - SafeGenericM2UMConvert(Mclone))); + SafeGenericM2UMConvert(Mclone, m_cache))); } else { return Delta::clone(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp b/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp index d388200..4480268 100644 --- a/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp +++ b/src/clicache/src/impl/PdxManagedCacheableKeyBytes.hpp @@ -22,6 +22,8 @@ #include "begin_native.hpp" #include <geode/CacheableKey.hpp> #include <geode/Delta.hpp> +#include "CacheRegionHelper.hpp" +#include "CacheImpl.hpp" #include "end_native.hpp" #include "../Log.hpp" @@ -67,10 +69,11 @@ namespace apache /// The managed object. /// </param> inline PdxManagedCacheableKeyBytes( - Apache::Geode::Client::IPdxSerializable^ managedptr, bool storeBytes ) - : m_domainId(System::Threading::Thread::GetDomainID()), + Apache::Geode::Client::IPdxSerializable^ managedptr, bool storeBytes, Cache* cache) + : Delta(cache), m_domainId(System::Threading::Thread::GetDomainID()), m_bytes(NULL), m_size(0), + m_cache(cache), m_hashCode(0) { m_hasDelta = false; @@ -85,17 +88,19 @@ namespace apache { if(storeBytes)//if value is from app { - apache::geode::client::DataOutput dataOut; - Apache::Geode::Client::DataOutput mg_output( &dataOut, true); - Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, managedptr); + auto dataOut = m_cache->createDataOutput(); + Apache::Geode::Client::DataOutput mg_output(dataOut.get(), true); + SerializationRegistry defaultSerializationRegistry; + + Apache::Geode::Client::Internal::PdxHelper::SerializePdx(%mg_output, managedptr); // managedptr->ToData( %mg_output ); //move cursor //dataOut.advanceCursor(mg_output.BufferLength); mg_output.WriteBytesToUMDataOutput(); - m_bytes = dataOut.getBufferCopy(); - m_size = dataOut.getBufferLength(); + m_bytes = dataOut->getBufferCopy(); + m_size = dataOut->getBufferLength(); m_hashCode = managedptr->GetHashCode(); Apache::Geode::Client::Log::Fine( @@ -104,10 +109,11 @@ namespace apache } } - inline PdxManagedCacheableKeyBytes( ) - : m_domainId(System::Threading::Thread::GetDomainID()), + inline PdxManagedCacheableKeyBytes(Cache* cache) + : Delta(cache), m_domainId(System::Threading::Thread::GetDomainID()), m_bytes(NULL), m_size(0), + m_cache(cache), m_hashCode(0) { m_hasDelta = false; @@ -198,9 +204,9 @@ namespace apache return getManagedObject(); } - static Serializable* CreateDeserializable() + static Serializable* CreateDeserializable(Cache* cache) { - return new PdxManagedCacheableKeyBytes(); + return new PdxManagedCacheableKeyBytes(cache); } inline ~PdxManagedCacheableKeyBytes() @@ -227,6 +233,7 @@ namespace apache UInt32 m_classId; System::Byte * m_bytes; System::UInt32 m_size; + Cache* m_cache; bool m_hasDelta; System::Int32 m_hashCode; // Disable the copy and assignment constructors http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxTypeRegistry.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxTypeRegistry.cpp b/src/clicache/src/impl/PdxTypeRegistry.cpp index dae9c5f..de739a0 100644 --- a/src/clicache/src/impl/PdxTypeRegistry.cpp +++ b/src/clicache/src/impl/PdxTypeRegistry.cpp @@ -40,7 +40,7 @@ namespace Apache return preserveData->Count; } - Int32 PdxTypeRegistry::GetPDXIdForType(Type^ pdxType, const char* poolname, PdxType^ nType, bool checkIfThere) + Int32 PdxTypeRegistry::GetPDXIdForType(Type^ pdxType, const char* poolname, PdxType^ nType, bool checkIfThere, const native::Cache* cache) { if(checkIfThere) { @@ -62,7 +62,7 @@ namespace Apache return lpdx->TypeId; } } - return Serializable::GetPDXIdForType(poolname, nType); + return Serializable::GetPDXIdForType(poolname, nType, cache); } finally { @@ -71,7 +71,7 @@ namespace Apache } - Int32 PdxTypeRegistry::GetPDXIdForType(PdxType^ pType, const char* poolname) + Int32 PdxTypeRegistry::GetPDXIdForType(PdxType^ pType, const char* poolname, const native::Cache* cache) { IDictionary<PdxType^, Int32>^ tmp = pdxTypeToTypeId; Int32 typeId = 0; @@ -92,7 +92,7 @@ namespace Apache return typeId; } - typeId = Serializable::GetPDXIdForType(poolname, pType); + typeId = Serializable::GetPDXIdForType(poolname, pType, cache); pType->TypeId = typeId; IDictionary<PdxType^, Int32>^ newDict = gcnew Dictionary<PdxType^, Int32>(pdxTypeToTypeId); @@ -255,7 +255,7 @@ namespace Apache return nullptr; } - Int32 PdxTypeRegistry::GetEnumValue(EnumInfo^ ei) + Int32 PdxTypeRegistry::GetEnumValue(EnumInfo^ ei, const native::Cache* cache) { IDictionary<EnumInfo^, Int32>^ tmp = enumToInt; if(tmp->ContainsKey(ei)) @@ -267,7 +267,7 @@ namespace Apache if(tmp->ContainsKey(ei)) return tmp[ei]; - int val = Serializable::GetEnumValue(ei); + int val = Serializable::GetEnumValue(ei, cache); tmp = gcnew Dictionary<EnumInfo^, Int32>(enumToInt); tmp[ei] = val; enumToInt = tmp; @@ -280,7 +280,7 @@ namespace Apache return 0; } - EnumInfo^ PdxTypeRegistry::GetEnum(Int32 enumVal) + EnumInfo^ PdxTypeRegistry::GetEnum(Int32 enumVal, const native::Cache* cache) { IDictionary<Int32, EnumInfo^>^ tmp = intToEnum; EnumInfo^ ret = nullptr; @@ -298,7 +298,7 @@ namespace Apache if(ret != nullptr) return ret; - ret = Serializable::GetEnum(enumVal); + ret = Serializable::GetEnum(enumVal, cache); tmp = gcnew Dictionary<Int32, EnumInfo^>(intToEnum); tmp[enumVal] = ret; intToEnum = tmp; http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PdxTypeRegistry.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PdxTypeRegistry.hpp b/src/clicache/src/impl/PdxTypeRegistry.hpp index e45d7a5..a35fd81 100644 --- a/src/clicache/src/impl/PdxTypeRegistry.hpp +++ b/src/clicache/src/impl/PdxTypeRegistry.hpp @@ -16,6 +16,9 @@ */ #pragma once +#include "begin_native.hpp" +#include "SerializationRegistry.hpp" +#include "end_native.hpp" #include "PdxType.hpp" #include "PdxRemotePreservedData.hpp" #include "../IPdxSerializable.hpp" @@ -37,33 +40,35 @@ namespace Apache public ref class PdxTypeRegistry { public: + + PdxTypeRegistry(Cache^ cache) :m_cache(cache) {} //test hook; - static int testGetNumberOfPdxIds(); + static int testGetNumberOfPdxIds(); //test hook - static int testNumberOfPreservedData(); + static int testNumberOfPreservedData(); - static void AddPdxType(Int32 typeId, PdxType^ pdxType); + static void AddPdxType(Int32 typeId, PdxType^ pdxType); - static PdxType^ GetPdxType(Int32 typeId); + static PdxType^ GetPdxType(Int32 typeId); - static void AddLocalPdxType(String^ localType, PdxType^ pdxType); + static void AddLocalPdxType(String^ localType, PdxType^ pdxType); - static PdxType^ GetLocalPdxType(String^ localType); + static PdxType^ GetLocalPdxType(String^ localType); - static void SetMergedType(Int32 remoteTypeId, PdxType^ mergedType); + static void SetMergedType(Int32 remoteTypeId, PdxType^ mergedType); - static PdxType^ GetMergedType(Int32 remoteTypeId); + static PdxType^ GetMergedType(Int32 remoteTypeId); - static void SetPreserveData(IPdxSerializable^ obj, PdxRemotePreservedData^ preserveData); + static void SetPreserveData(IPdxSerializable^ obj, PdxRemotePreservedData^ preserveData); - static PdxRemotePreservedData^ GetPreserveData(IPdxSerializable^ obj); + static PdxRemotePreservedData^ GetPreserveData(IPdxSerializable^ obj); - static void clear(); + void clear(); - static Int32 GetPDXIdForType(Type^ type, const char* poolname, PdxType^ nType, bool checkIfThere); + static Int32 GetPDXIdForType(Type^ type, const char* poolname, PdxType^ nType, bool checkIfThere, const native::Cache* cache); - static Int32 GetPDXIdForType(PdxType^ type, const char* poolname); + static Int32 GetPDXIdForType(PdxType^ type, const char* poolname, const native::Cache* cache); static property bool PdxIgnoreUnreadFields { @@ -71,25 +76,26 @@ namespace Apache void set(bool value){pdxIgnoreUnreadFields = value;} } - static property bool PdxReadSerialized + static property bool PdxReadSerialized { bool get() {return pdxReadSerialized;} void set(bool value){pdxReadSerialized= value;} } - static Int32 GetEnumValue(EnumInfo^ ei); + static Int32 GetEnumValue(EnumInfo^ ei, const native::Cache* cache); - static EnumInfo^ GetEnum(Int32 enumVal); + static EnumInfo^ GetEnum(Int32 enumVal, const native::Cache* cache); private: + Cache^ m_cache; - static IDictionary<Int32, PdxType^>^ typeIdToPdxType = gcnew Dictionary<Int32, PdxType^>(); + static IDictionary<Int32, PdxType^>^ typeIdToPdxType = gcnew Dictionary<Int32, PdxType^>(); - static IDictionary<PdxType^, Int32>^ pdxTypeToTypeId = gcnew Dictionary<PdxType^, Int32>(); + static IDictionary<PdxType^, Int32>^ pdxTypeToTypeId = gcnew Dictionary<PdxType^, Int32>(); - static IDictionary<Int32, PdxType^>^ remoteTypeIdToMergedPdxType = gcnew Dictionary<Int32, PdxType^>(); + static IDictionary<Int32, PdxType^>^ remoteTypeIdToMergedPdxType = gcnew Dictionary<Int32, PdxType^>(); - static IDictionary<String^, PdxType^>^ localTypeToPdxType = gcnew Dictionary<String^, PdxType^>(); + static IDictionary<String^, PdxType^>^ localTypeToPdxType = gcnew Dictionary<String^, PdxType^>(); static IDictionary<EnumInfo^, Int32>^ enumToInt = gcnew Dictionary<EnumInfo^, Int32>(); @@ -97,7 +103,7 @@ namespace Apache //TODO: this will be weak hashmap //static IDictionary<IPdxSerializable^ , PdxRemotePreservedData^>^ preserveData = gcnew Dictionary<IPdxSerializable^ , PdxRemotePreservedData^>(); - static WeakHashMap^ preserveData = gcnew WeakHashMap(); + static WeakHashMap^ preserveData = gcnew WeakHashMap(); static ReaderWriterLock^ g_readerWriterLock = gcnew ReaderWriterLock(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/PersistenceManagerProxy.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/PersistenceManagerProxy.hpp b/src/clicache/src/impl/PersistenceManagerProxy.hpp index a88d0bd..6b519f6 100644 --- a/src/clicache/src/impl/PersistenceManagerProxy.hpp +++ b/src/clicache/src/impl/PersistenceManagerProxy.hpp @@ -72,7 +72,7 @@ namespace Apache virtual CacheablePtr read(const CacheableKeyPtr& key/*, void *& PersistenceInfo*/) { TKey gKey = Serializable::GetManagedValueGeneric<TKey>(key); - return Serializable::GetUnmanagedValueGeneric<TValue>(m_persistenceManager->Read(gKey)); + return Serializable::GetUnmanagedValueGeneric<TValue>(m_persistenceManager->Read(gKey), nullptr); } virtual bool readAll() http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/impl/SafeConvert.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/impl/SafeConvert.hpp b/src/clicache/src/impl/SafeConvert.hpp index 69fe885..200c5d0 100644 --- a/src/clicache/src/impl/SafeConvert.hpp +++ b/src/clicache/src/impl/SafeConvert.hpp @@ -19,6 +19,10 @@ #include "../geode_defs.hpp" +#include "begin_native.hpp" +#include "CacheImpl.hpp" +#include "end_native.hpp" + #include "ManagedCacheableKey.hpp" #include "ManagedCacheableDelta.hpp" #include "ManagedCacheableKeyBytes.hpp" @@ -155,9 +159,9 @@ namespace Apache } else{ if(!SafeConvertClassGeneric::isAppDomainEnabled) - return new ManagedWrapper(mg_obj, mg_obj->GetHashCode(), mg_obj->ClassId); + return new ManagedWrapper(mg_obj, mg_obj->GetHashCode(), mg_obj->ClassId, nullptr); else - return new native::ManagedCacheableKeyBytesGeneric( mg_obj, true); + return new native::ManagedCacheableKeyBytesGeneric(mg_obj, true); } } //if (mg_obj == nullptr) return NULL; @@ -230,7 +234,7 @@ namespace Apache } generic<class TValue> - inline static native::Cacheable* SafeGenericM2UMConvert( TValue mg_val ) + inline static native::Cacheable* SafeGenericM2UMConvert( TValue mg_val, native::Cache* cache ) { if (mg_val == nullptr) return NULL; @@ -254,7 +258,7 @@ namespace Apache if(!SafeConvertClassGeneric::isAppDomainEnabled) return new native::PdxManagedCacheableKey(pdxType); else - return new native::PdxManagedCacheableKeyBytes(pdxType, true); + return new native::PdxManagedCacheableKeyBytes(pdxType, true, cache); } Apache::Geode::Client::IGeodeDelta^ sDelta = @@ -274,7 +278,7 @@ namespace Apache { if(!SafeConvertClassGeneric::isAppDomainEnabled) { - return new native::ManagedCacheableKeyGeneric( tmpIGFS ); + return new native::ManagedCacheableKeyGeneric( tmpIGFS, nullptr); } else { @@ -288,16 +292,16 @@ namespace Apache if(!SafeConvertClassGeneric::isAppDomainEnabled) return new native::PdxManagedCacheableKey(gcnew PdxWrapper(mg_obj)); else - return new native::PdxManagedCacheableKeyBytes(gcnew PdxWrapper(mg_obj), true); + return new native::PdxManagedCacheableKeyBytes(gcnew PdxWrapper(mg_obj), true, nullptr); } throw gcnew Apache::Geode::Client::IllegalStateException(String::Format("Unable to map object type {0}. Possible Object type may not be registered or PdxSerializer is not registered. ", mg_obj->GetType())); } } generic<class TValue> - inline static native::Cacheable* SafeGenericMSerializableConvert( TValue mg_obj ) + inline static native::Cacheable* SafeGenericMSerializableConvert( TValue mg_obj, native::Cache* cache ) { - return SafeGenericM2UMConvert<TValue>( mg_obj ); + return SafeGenericM2UMConvert<TValue>( mg_obj, cache ); } inline static IPdxSerializable^ SafeUMSerializablePDXConvert( native::SerializablePtr obj ) @@ -345,7 +349,7 @@ namespace Apache inline static native::CacheableKey* SafeGenericMKeyConvert( TKey mg_obj ) { if (mg_obj == nullptr) return NULL; - auto obj = Apache::Geode::Client::Serializable::GetUnmanagedValueGeneric<TKey>( mg_obj ); + auto obj = Apache::Geode::Client::Serializable::GetUnmanagedValueGeneric<TKey>( mg_obj, nullptr ); if (obj.get() != nullptr) { return obj.get(); @@ -353,9 +357,9 @@ namespace Apache else { if(!SafeConvertClassGeneric::isAppDomainEnabled) - return new native::ManagedCacheableKeyGeneric( SafeUMSerializableConvertGeneric(obj) ); + return new native::ManagedCacheableKeyGeneric(SafeUMSerializableConvertGeneric(obj), nullptr); else - return new native::ManagedCacheableKeyBytesGeneric( SafeUMSerializableConvertGeneric(obj), true ); + return new native::ManagedCacheableKeyBytesGeneric(SafeUMSerializableConvertGeneric(obj), true); } } @@ -369,7 +373,7 @@ namespace Apache if(!SafeConvertClassGeneric::isAppDomainEnabled) return new native::ManagedCacheableKeyGeneric( mg_obj, mg_obj->GetHashCode(), mg_obj->ClassId ); else - return new native::ManagedCacheableKeyBytesGeneric( mg_obj, true ); + return new native::ManagedCacheableKeyBytesGeneric( mg_obj, true, nullptr); } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/cppcache/include/geode/AuthInitialize.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/AuthInitialize.hpp b/src/cppcache/include/geode/AuthInitialize.hpp index 569af59..0978b22 100644 --- a/src/cppcache/include/geode/AuthInitialize.hpp +++ b/src/cppcache/include/geode/AuthInitialize.hpp @@ -54,7 +54,7 @@ class CPPCACHE_EXPORT AuthInitialize { * @remarks This method can modify the given set of properties. For * example it may invoke external agents or even interact with the user. */ - virtual PropertiesPtr getCredentials(PropertiesPtr& securityprops, + virtual PropertiesPtr getCredentials(const PropertiesPtr& securityprops, const char* server) = 0; /**@brief Invoked before the cache goes down. */