You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by rv...@apache.org on 2016/05/19 15:14:23 UTC
[16/51] [partial] incubator-geode git commit: Add source for geode
c++ and .net clients
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/DataOutputM.cpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/DataOutputM.cpp b/geode-client-native/src/clicache/DataOutputM.cpp
new file mode 100644
index 0000000..383ee30
--- /dev/null
+++ b/geode-client-native/src/clicache/DataOutputM.cpp
@@ -0,0 +1,586 @@
+/*=========================================================================
+ * 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.
+ *=========================================================================
+ */
+
+#include "gf_includes.hpp"
+#include "DataOutputM.hpp"
+#include <cppcache/impl/GemfireTypeIdsImpl.hpp>
+#include <vcclr.h>
+
+#include "IGFSerializable.hpp"
+
+using namespace System;
+using namespace System::Runtime::InteropServices;
+using namespace gemfire;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache
+ {
+
+ void DataOutput::WriteByte( Byte value )
+ {
+ EnsureCapacity(1);
+ m_bytes[m_cursor++] = value;
+ }
+
+ void DataOutput::WriteSByte( SByte value )
+ {
+ EnsureCapacity(1);
+ m_bytes[m_cursor++] = value;
+ }
+
+ void DataOutput::WriteBoolean( bool value )
+ {
+ EnsureCapacity(1);
+ if (value)
+ m_bytes[m_cursor++] = 0x01;
+ else
+ m_bytes[m_cursor++] = 0x00;
+ }
+
+ void DataOutput::WriteBytes( array<Byte>^ bytes, int32_t len )
+ {
+ //TODO::hitesh
+ if (bytes != nullptr && bytes->Length >= 0)
+ {
+ if ( len >= 0 && len <= bytes->Length )
+ {
+ WriteArrayLen(len);
+ EnsureCapacity(len);
+ for( int i = 0; i < len; i++ )
+ m_bytes[m_cursor++] = bytes[i];
+ }
+ else
+ {
+ throw gcnew GemFire::Cache::IllegalArgumentException("DataOutput::WriteBytes argument len is not in byte array range." );
+ }
+ }
+ else
+ {
+ WriteByte(0xFF);
+ }
+ }
+
+ /* void DataOutput::WriteArrayLen( int32_t len )
+ {
+ if (len == -1) {
+ WriteByte(0xFF);
+ } else if (len <= 252) { // 252 is java's ((byte)-4 && 0xFF)
+ WriteByte(Convert::ToByte(len));
+ } else if (len <= 0xFFFF) {
+ WriteByte(0xFE);
+ WriteInt16(Convert::ToInt16(len));
+ } else {
+ WriteByte(Convert::ToByte(-0xFD));
+ WriteInt32(len);
+ }
+ }*/
+
+ void DataOutput::WriteArrayLen( int32_t len )
+ {
+ if (len == -1) {//0xff
+ WriteByte(0xFF);
+ } else if (len <= 252) { // 252 is java's ((byte)-4 && 0xFF) or 0xfc
+ WriteByte(Convert::ToByte(len));
+ } else if (len <= 0xFFFF) {
+ WriteByte(0xFE);//0xfe
+ WriteUInt16((len));
+ } else {
+ WriteByte((0xFD));//0xfd
+ WriteUInt32(len);
+ }
+ }
+
+ void DataOutput::WriteSBytes( array<SByte>^ bytes, int32_t len )
+ {
+ //TODO::hitesh
+ if (bytes != nullptr && bytes->Length >= 0)
+ {
+ if ( len >= 0 && len <= bytes->Length )
+ {
+ WriteArrayLen(len);
+ EnsureCapacity(len);
+ for( int i = 0; i < len; i++ )
+ m_bytes[m_cursor++] = bytes[i];
+ }
+ else
+ {
+ throw gcnew GemFire::Cache::IllegalArgumentException("DataOutput::WriteSBytes argument len is not in SByte array range." );
+ }
+ }
+ else
+ {
+ WriteByte(0xFF);
+ }
+ }
+
+ void DataOutput::WriteBytesOnly( array<Byte>^ bytes, uint32_t len )
+ {
+ WriteBytesOnly(bytes, len, 0);
+ }
+
+ void DataOutput::WriteBytesOnly( array<Byte>^ bytes, uint32_t len, uint32_t offset )
+ {
+ //TODO::hitesh
+ if (bytes != nullptr)
+ {
+ if ( len >= 0 && len <= ((uint32_t)bytes->Length - offset) )
+ {
+ EnsureCapacity(len);
+ for( uint32_t i = 0; i < len; i++ )
+ m_bytes[m_cursor++] = bytes[offset + i];
+ }
+ else
+ {
+ throw gcnew GemFire::Cache::IllegalArgumentException("DataOutput::WriteBytesOnly argument len is not in Byte array range." );
+ }
+ }
+ }
+
+ void DataOutput::WriteSBytesOnly( array<SByte>^ bytes, uint32_t len )
+ {
+ //TODO::hitesh
+ if (bytes != nullptr)
+ {
+ if ( len >= 0 && len <= (uint32_t)bytes->Length )
+ {
+ EnsureCapacity(len);
+ for( uint32_t i = 0; i < len; i++ )
+ m_bytes[m_cursor++] = bytes[i];
+ }
+ else
+ {
+ throw gcnew GemFire::Cache::IllegalArgumentException("DataOutput::WriteSBytesOnly argument len is not in SByte array range." );
+ }
+ }
+ }
+
+ void DataOutput::WriteUInt16( uint16_t value )
+ {
+ EnsureCapacity(2);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 8);
+ m_bytes[m_cursor++] = (uint8_t)value;
+ }
+
+ void DataOutput::WriteUInt32( uint32_t value )
+ {
+ EnsureCapacity(4);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 24);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 16);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 8);
+ m_bytes[m_cursor++] = (uint8_t)value;
+ }
+
+ void DataOutput::WriteUInt64( uint64_t value )
+ {
+ EnsureCapacity(8);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 56);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 48);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 40);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 32);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 24);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 16);
+ m_bytes[m_cursor++] = (uint8_t)(value >> 8);
+ m_bytes[m_cursor++] = (uint8_t)value;
+ }
+
+ void DataOutput::WriteInt16( int16_t value )
+ {
+ WriteUInt16(value);
+ }
+
+ void DataOutput::WriteInt32( int32_t value )
+ {
+ WriteUInt32(value);
+ }
+
+ void DataOutput::WriteInt64( int64_t value )
+ {
+ WriteUInt64(value);
+ }
+
+ void DataOutput::WriteFloat( float value )
+ {
+ array<Byte>^ bytes = BitConverter::GetBytes(value);
+ EnsureCapacity(4);
+ for(int i = bytes->Length - 1; i >=0 ; i--)
+ m_bytes[m_cursor++] = bytes[i];
+ }
+
+ void DataOutput::WriteDouble( double value )
+ {
+ array<Byte>^ bytes = BitConverter::GetBytes(value);
+ EnsureCapacity(8);
+ for(int i = bytes->Length - 1; i >=0 ; i--)
+ m_bytes[m_cursor++] = bytes[i];
+ }
+
+ void DataOutput::WriteUTF( String^ value )
+ {
+ if (value != nullptr) {
+ int len = value->Length*3;
+
+ if (len > 8192) //approx check
+ len = getEncodedLength(value);
+
+ if (len > 0xffff)
+ len = 0xffff;
+
+ EnsureCapacity(len);
+
+ m_cursor += 2;
+ int strLen = EncodeString(value, len);
+ m_cursor -= (strLen + 2);
+ WriteUInt16(strLen);
+ m_cursor += strLen;
+ }
+ else {
+ WriteUInt16(0);
+ }
+ }
+
+ void DataOutput::WriteASCIIHuge( String^ value )
+ {
+ //TODO::hitesh
+ if (value != nullptr) {
+ EnsureCapacity(value->Length);
+ m_cursor += 4;
+ int strLen = EncodeString(value, value->Length);
+ m_cursor -= (strLen + 4);
+ WriteUInt32(strLen);
+ m_cursor += strLen;
+ }
+ else {
+ WriteUInt32(0);
+ }
+ }
+
+ void DataOutput::WriteUTFHuge( String^ value )
+ {
+ if (value != nullptr) {
+ WriteUInt32(value->Length);
+ EnsureCapacity(value->Length * 2);
+ for( int i = 0; i < value->Length; i++)
+ {
+ Char ch = value[i];
+ m_bytes[m_cursor++] = (Byte)((ch & 0xff00) >> 8);
+ m_bytes[m_cursor++] = (Byte)(ch & 0xff);
+ }
+ }
+ else {
+ WriteUInt32(0);
+ }
+ }
+
+ void DataOutput::WriteObject( IGFSerializable^ obj )
+ {
+ WriteObjectInternal(obj);
+ }
+
+ void DataOutput::WriteObject( Serializable^ obj )
+ {
+ WriteObject( (IGFSerializable^)obj );
+ }
+
+ int8_t DataOutput::GetTypeId(uint32_t classId )
+ {
+ if (classId >= 0x80000000) {
+ return (int8_t)((classId - 0x80000000) % 0x20000000);
+ }
+ else if (classId <= 0x7F) {
+ return (int8_t)GemfireTypeIdsImpl::CacheableUserData;
+ }
+ else if (classId <= 0x7FFF) {
+ return (int8_t)GemfireTypeIdsImpl::CacheableUserData2;
+ }
+ else {
+ return (int8_t)GemfireTypeIdsImpl::CacheableUserData4;
+ }
+ }
+
+ int8_t DataOutput::DSFID(uint32_t classId)
+ {
+ // 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 (classId >= 0x80000000) {
+ return (int8_t)((classId - 0x80000000) / 0x20000000);
+ }
+ return 0;
+ }
+
+ /*
+ void DataOutput::WriteGenericObject(Object^ obj)
+ {
+ if ( obj == nullptr )
+ {
+ WriteByte( (int8_t) GemfireTypeIds::NullObj );
+ return;
+ }
+
+ Byte typeId = GemStone::GemFire::Cache::Generic::Serializable::GetManagedTypeMappingGeneric(obj->GetType());
+
+ switch(typeId)
+ {
+ case gemfire::GemfireTypeIds::CacheableByte:
+ {
+ WriteByte(typeId);
+ WriteByte((Byte)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableBoolean:
+ {
+ WriteByte(typeId);
+ WriteBoolean((bool)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableWideChar:
+ {
+ WriteByte(typeId);
+ WriteObject((Char)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableDouble:
+ {
+ WriteByte(typeId);
+ WriteDouble((Double)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableASCIIString:
+ {
+ GemStone::GemFire::Cache::CacheableString^ cStr = GemStone::GemFire::Cache::CacheableString::Create((String^)obj);
+ WriteObjectInternal(cStr);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableFloat:
+ {
+ WriteByte(typeId);
+ WriteFloat((float)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableInt16:
+ {
+ WriteByte(typeId);
+ WriteInt16((Int16)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableInt32:
+ {
+ WriteByte(typeId);
+ WriteInt32((Int32)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableInt64:
+ {
+ WriteByte(typeId);
+ WriteInt64((Int64)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableDate:
+ {
+ GemStone::GemFire::Cache::CacheableDate^ cd = gcnew GemStone::GemFire::Cache::CacheableDate((DateTime)obj);
+ WriteObjectInternal(cd);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableBytes:
+ {
+ WriteByte(typeId);
+ WriteBytes((array<Byte>^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableDoubleArray:
+ {
+ WriteByte(typeId);
+ WriteObject((array<Double>^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableFloatArray:
+ {
+ WriteByte(typeId);
+ WriteObject((array<float>^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableInt16Array:
+ {
+ WriteByte(typeId);
+ WriteObject((array<Int16>^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableInt32Array:
+ {
+ WriteByte(typeId);
+ WriteObject((array<Int32>^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableInt64Array:
+ {
+ WriteByte(typeId);
+ WriteObject((array<Int64>^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::BooleanArray:
+ {
+ WriteByte(typeId);
+ WriteObject((array<bool>^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CharArray:
+ {
+ WriteByte(typeId);
+ WriteObject((array<char>^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableStringArray:
+ {
+ WriteByte(typeId);
+ WriteObject((array<String^>^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableHashTable:
+ case gemfire::GemfireTypeIds::CacheableHashMap:
+ case gemfire::GemfireTypeIds::CacheableIdentityHashMap:
+ {
+ WriteByte(typeId);
+ WriteDictionary((System::Collections::IDictionary^)obj);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableVector:
+ {
+ GemStone::GemFire::Cache::CacheableVector^ cv = gcnew GemStone::GemFire::Cache::CacheableVector((System::Collections::IList^)obj);
+ WriteObjectInternal(cv);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableArrayList:
+ {
+ GemStone::GemFire::Cache::CacheableArrayList^ cal = gcnew GemStone::GemFire::Cache::CacheableArrayList((System::Collections::IList^)obj);
+ WriteObjectInternal(cal);
+ return;
+ }
+ case gemfire::GemfireTypeIds::CacheableStack:
+ {
+ GemStone::GemFire::Cache::CacheableStack^ cs = gcnew GemStone::GemFire::Cache::CacheableStack((System::Collections::ICollection^)obj);
+ WriteObjectInternal(cs);
+ return;
+ }
+ default:
+ {
+ IGFSerializable^ ct = safe_cast<IGFSerializable^>(obj);
+ if(ct != nullptr) {
+ WriteObjectInternal(ct);
+ return ;
+ }
+ throw gcnew System::Exception("DataOutput not found appropriate type to write it.");
+ }
+ }
+ }
+ */
+
+ /*
+ void DataOutput::WriteStringArray(array<String^>^ strArray)
+ {
+ this->WriteArrayLen(strArray->Length);
+ for(int i = 0; i < strArray->Length; i++)
+ {
+ this->WriteUTF(strArray[i]);
+ }
+ }
+ */
+
+ void DataOutput::WriteObjectInternal( IGFSerializable^ obj )
+ {
+ //CacheableKey^ key = gcnew CacheableKey();
+ if ( obj == nullptr ) {
+ WriteByte( (int8_t) GemfireTypeIds::NullObj );
+ } else {
+ int8_t typeId = DataOutput::GetTypeId( obj->ClassId);
+ switch (DataOutput::DSFID(obj->ClassId)) {
+ case GemfireTypeIdsImpl::FixedIDByte:
+ WriteByte((int8_t)GemfireTypeIdsImpl::FixedIDByte);
+ WriteByte( typeId ); // write the type ID.
+ break;
+ case GemfireTypeIdsImpl::FixedIDShort:
+ WriteByte((int8_t)GemfireTypeIdsImpl::FixedIDShort);
+ WriteInt16( (int16_t)typeId ); // write the type ID.
+ break;
+ case GemfireTypeIdsImpl::FixedIDInt:
+ WriteByte((int8_t)GemfireTypeIdsImpl::FixedIDInt);
+ WriteInt32( (int32_t)typeId ); // write the type ID.
+ break;
+ default:
+ WriteByte( typeId ); // write the type ID.
+ break;
+ }
+
+ if ( (int32_t)typeId == GemfireTypeIdsImpl::CacheableUserData ) {
+ WriteByte( (int8_t) obj->ClassId );
+ } else if ( (int32_t)typeId == GemfireTypeIdsImpl::CacheableUserData2 ) {
+ WriteInt16( (int16_t) obj->ClassId );
+ } else if ( (int32_t)typeId == GemfireTypeIdsImpl::CacheableUserData4 ) {
+ WriteInt32( (int32_t) obj->ClassId );
+ }
+ obj->ToData( this ); // let the obj serialize itself.
+ }
+ }
+
+ void DataOutput::AdvanceCursor( uint32_t offset )
+ {
+ m_cursor += offset;
+ }
+
+ void DataOutput::RewindCursor( uint32_t offset )
+ {
+ //first set native one
+ WriteBytesToUMDataOutput();
+ NativePtr->rewindCursor(offset);
+ SetBuffer();
+ //m_cursor -= offset;
+ }
+
+ array<Byte>^ DataOutput::GetBuffer( )
+ {
+ //TODO::hitesh
+ // return m_bytes;
+ //first set native one
+ WriteBytesToUMDataOutput();
+ SetBuffer();
+
+ int buffLen = NativePtr->getBufferLength();
+ array<Byte>^ buffer = gcnew array<Byte>( buffLen );
+
+ if ( buffLen > 0 ) {
+ pin_ptr<Byte> pin_buffer = &buffer[ 0 ];
+ memcpy( (void*)pin_buffer, NativePtr->getBuffer( ), buffLen );
+ }
+ return buffer;
+ }
+
+ uint32_t DataOutput::BufferLength::get( )
+ {
+ //first set native one
+ WriteBytesToUMDataOutput();
+ SetBuffer();
+
+ return NativePtr->getBufferLength();
+ }
+
+ void DataOutput::Reset( )
+ {
+ //first set native one
+ WriteBytesToUMDataOutput();
+ NativePtr->reset();
+ SetBuffer();
+ }
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/DataOutputM.hpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/DataOutputM.hpp b/geode-client-native/src/clicache/DataOutputM.hpp
new file mode 100644
index 0000000..7bca848
--- /dev/null
+++ b/geode-client-native/src/clicache/DataOutputM.hpp
@@ -0,0 +1,531 @@
+/*=========================================================================
+ * 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.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "cppcache/DataOutput.hpp"
+#include "impl/NativeWrapper.hpp"
+#include "LogM.hpp"
+#include "ExceptionTypesM.hpp"
+#include "SerializableM.hpp"
+#include "SerializableM.hpp"
+
+#include "CacheableStringM.hpp"
+#include "CacheableDateM.hpp"
+#include "CacheableVectorM.hpp"
+#include "CacheableArrayListM.hpp"
+#include "CacheableStackM.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache
+ {
+
+ interface class IGFSerializable;
+
+ /// <summary>
+ /// Provides operations for writing primitive data values, and
+ /// user-defined objects implementing IGFSerializable, to a byte stream.
+ /// This class is intentionally not thread safe.
+ /// </summary>
+ [Obsolete("Use classes and APIs from the GemStone.GemFire.Cache.Generic namespace")]
+ public ref class DataOutput sealed
+ : public Internal::UMWrap<gemfire::DataOutput>
+ {
+ private:
+ int m_cursor;
+ bool m_isManagedObject;
+ uint8_t * m_bytes;
+ uint32_t m_remainingBufferLength;
+ public:
+
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ inline DataOutput( )
+ : UMWrap( new gemfire::DataOutput( ), true )
+ {
+ m_isManagedObject = true;
+ m_cursor = 0;
+ m_bytes = const_cast<uint8_t *>(NativePtr->getCursor());
+ m_remainingBufferLength = NativePtr->getRemainingBufferLength();
+ }
+
+ /// <summary>
+ /// Write length of the array to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="len">Array len to write.</param>
+ void WriteArrayLen( int32_t len );
+
+ /// <summary>
+ /// Write a byte to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">The byte to write.</param>
+ void WriteByte( Byte value );
+
+ /// <summary>
+ /// Write a signed byte to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">The signed byte to write.</param>
+ void WriteSByte( SByte value );
+
+ /// <summary>
+ /// Write a boolean value to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">The boolean value to write.</param>
+ void WriteBoolean( bool value );
+
+ /// <summary>
+ /// Write a given length of bytes to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="bytes">The array of bytes to write.</param>
+ /// <param name="len">
+ /// The number of bytes from the start of array to write.
+ /// </param>
+ void WriteBytes( array<Byte>^ bytes, int32_t len );
+
+ /// <summary>
+ /// Write an array of bytes to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="bytes">The array of bytes to write.</param>
+ inline void WriteBytes( array<Byte>^ bytes )
+ {
+ WriteBytes( bytes, ( bytes == nullptr ? -1 : bytes->Length ) );
+ }
+
+ /// <summary>
+ /// Write a given length of signed bytes to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="bytes">The array of signed bytes to write.</param>
+ /// <param name="len">
+ /// The number of bytes from the start of array to write.
+ /// </param>
+ void WriteSBytes( array<SByte>^ bytes, int32_t len );
+
+ /// <summary>
+ /// Write an array of signed bytes to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="bytes">The array of signed bytes to write.</param>
+ inline void WriteSBytes( array<SByte>^ bytes )
+ {
+ WriteSBytes( bytes, ( bytes == nullptr ? -1 : bytes->Length ) );
+ }
+
+ /// <summary>
+ /// Write a given length of bytes without its length to the
+ /// <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="bytes">The array of bytes to write.</param>
+ /// <param name="len">
+ /// The number of bytes from the start of array to write.
+ /// </param>
+ void WriteBytesOnly( array<Byte>^ bytes, uint32_t len );
+
+ void WriteBytesOnly( array<Byte>^ bytes, uint32_t len, uint32_t offset );
+
+ /// <summary>
+ /// Write an array of bytes without its length to the
+ /// <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="bytes">The array of bytes to write.</param>
+ inline void WriteBytesOnly( array<Byte>^ bytes )
+ {
+ WriteBytesOnly( bytes, ( bytes == nullptr ? 0 : bytes->Length ) );
+ }
+
+ /// <summary>
+ /// Write a given length of signed bytes without its length
+ /// to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="bytes">The array of signed bytes to write.</param>
+ /// <param name="len">
+ /// The number of bytes from the start of array to write.
+ /// </param>
+ void WriteSBytesOnly( array<SByte>^ bytes, uint32_t len );
+
+ /// <summary>
+ /// Write an array of signed bytes without its length
+ /// to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="bytes">The array of signed bytes to write.</param>
+ inline void WriteSBytesOnly( array<SByte>^ bytes )
+ {
+ WriteSBytesOnly( bytes, ( bytes == nullptr ? 0 : bytes->Length ) );
+ }
+
+ /// <summary>
+ /// Write an unsigned short integer (int16_t) to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">The unsigned 16-bit integer to write.</param>
+ void WriteUInt16( uint16_t value );
+
+ /// <summary>
+ /// Write an unsigned 32-bit integer to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">The unsigned 32-bit integer to write.</param>
+ void WriteUInt32( uint32_t value );
+
+ /// <summary>
+ /// Write an unsigned 64-bit integer to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">The unsigned 64-bit integer to write.</param>
+ void WriteUInt64( uint64_t value );
+
+ /// <summary>
+ /// Write a 16-bit integer to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">The 16-bit integer to write.</param>
+ void WriteInt16( int16_t value );
+
+ /// <summary>
+ /// Write a 32-bit integer to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">The 32-bit integer to write.</param>
+ void WriteInt32( int32_t value );
+
+ /// <summary>
+ /// Write a 64-bit integer to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">The 64-bit integer to write.</param>
+ void WriteInt64( int64_t value );
+
+ /// <summary>
+ /// Write a float to the DataOutput.
+ /// </summary>
+ /// <param name="value">The float value to write.</param>
+ void WriteFloat( float value );
+
+ /// <summary>
+ /// Write a double precision real number to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="value">
+ /// The double precision real number to write.
+ /// </param>
+ void WriteDouble( double value );
+
+ /// <summary>
+ /// Write a string using java-modified UTF-8 encoding to
+ /// <c>DataOutput</c>.
+ /// The maximum length supported is 2^16-1 beyond which the string
+ /// shall be truncated.
+ /// </summary>
+ /// <param name="value">The UTF encoded string to write.</param>
+ void WriteUTF( String^ value );
+
+ /// <summary>
+ /// Write a string using java-modified UTF-8 encoding to
+ /// <c>DataOutput</c>.
+ /// Length should be more than 2^16 -1.
+ /// </summary>
+ /// <param name="value">The UTF encoded string to write.</param>
+ void WriteUTFHuge( String^ value );
+
+ /// <summary>
+ /// Write a string(only ASCII char) to
+ /// <c>DataOutput</c>.
+ /// Length should be more than 2^16 -1.
+ /// </summary>
+ /// <param name="value">The UTF encoded string to write.</param>
+ void WriteASCIIHuge( String^ value );
+
+ /// <summary>
+ /// Write an <c>IGFSerializable</c> object to the <c>DataOutput</c>.
+ /// </summary>
+ /// <param name="obj">The object to write.</param>
+ void WriteObject( IGFSerializable^ obj );
+
+ /// <summary>
+ /// Write a <c>Serializable</c> object to the <c>DataOutput</c>.
+ /// This is provided to conveniently pass primitive types (like string)
+ /// that shall be implicitly converted to corresponding
+ /// <c>IGFSerializable</c> wrapper types.
+ /// </summary>
+ /// <param name="obj">The object to write.</param>
+ void WriteObject( GemStone::GemFire::Cache::Serializable^ obj );
+
+ /// <summary>
+ /// Advance the buffer cursor by the given offset.
+ /// </summary>
+ /// <param name="offset">
+ /// The offset by which to advance the cursor.
+ /// </param>
+ void AdvanceCursor( uint32_t offset );
+
+ /// <summary>
+ /// Rewind the buffer cursor by the given offset.
+ /// </summary>
+ /// <param name="offset">
+ /// The offset by which to rewind the cursor.
+ /// </param>
+ void RewindCursor( uint32_t offset );
+
+ /// <summary>
+ /// Get a copy of the current buffer.
+ /// </summary>
+ array<Byte>^ GetBuffer( );
+
+ /// <summary>
+ /// Get the length of current data in the buffer.
+ /// </summary>
+ property uint32_t BufferLength
+ {
+ uint32_t get( );
+ }
+
+ /// <summary>
+ /// Reset the cursor to the start of the buffer.
+ /// </summary>
+ void Reset( );
+
+ /// <summary>
+ /// Get the underlying native unmanaged pointer.
+ /// </summary>
+ property IntPtr NativeIntPtr
+ {
+ inline IntPtr get()
+ {
+ return IntPtr(_NativePtr);
+ }
+ }
+
+ // void WriteGenericObject(Object^ obj);
+
+ void WriteDictionary(System::Collections::IDictionary^ dict)
+ {
+ if(dict != nullptr)
+ {
+ this->WriteArrayLen(dict->Count);
+ for each( System::Collections::DictionaryEntry^ entry in dict)
+ {
+ //TODO::splir
+ //this->WriteGenericObject(entry->Key);
+ //this->WriteGenericObject(entry->Value);
+ }
+ }
+ else
+ {
+ WriteByte( (int8_t) -1);
+ }
+ }
+
+ void WriteDate(System::DateTime dt)
+ {
+ if(dt.Ticks != 0L)
+ {
+ CacheableDate^ cd = CacheableDate::Create(dt);
+ cd->ToData(this);
+ }else
+ this->WriteInt64(-1L);
+ }
+
+ internal:
+
+ int EncodeString( String^ input, int length )
+ {
+ int j = m_cursor;
+
+ for ( int i = 0; i < input->Length; i++ )
+ {
+ //EnsureCapacity(3);
+ unsigned short c = (unsigned short)input[i];
+
+ if( c == 0 )
+ {
+ m_bytes[m_cursor++] = 0xc0;
+ m_bytes[m_cursor++] = 0x80;
+ }
+ else if ( c < 0x80 )//ASCII character
+ {
+ // 7-bits done in one byte.
+ m_bytes[m_cursor++] = (uint8_t)c;
+ }
+ else if ( c < 0x800 )
+ {
+ // 8-11 bits done in 2 bytes
+ m_bytes[m_cursor++] = ( 0xC0 | c >> 6 );
+ m_bytes[m_cursor++] = ( 0x80 | c & 0x3F );
+ }
+ else
+ {
+ // 12-16 bits done in 3 bytes
+ m_bytes[m_cursor++] = ( 0xE0 | c >> 12 );
+ m_bytes[m_cursor++] = ( 0x80 | c >> 6 & 0x3F );
+ m_bytes[m_cursor++] = ( 0x80 | c & 0x3F );
+ }
+ }
+
+ if(length < (m_cursor - j))//extra byte after 0xffff
+ return length;
+ return m_cursor - j; //number of bytes
+ }
+
+ static int getEncodedLength(String^ input)
+ {
+ int count = 0;
+ for ( int i = 0; i < input->Length; i++ )
+ {
+ unsigned short c = (unsigned short)input[i];
+
+ if( c == 0)
+ {
+ count += 2;
+ }
+ else if ( c < 0x80 )//ASCII character
+ {
+ count++;
+ }
+ else if ( c < 0x800 )
+ {
+ count += 2;
+ }
+ else
+ {
+ count += 3;
+ }
+ }// end for
+
+ return count;
+ }
+
+ static int8_t GetTypeId(uint32_t classId );
+
+ static int8_t DSFID(uint32_t classId);
+
+ void WriteObjectInternal( IGFSerializable^ obj );
+
+ void WriteBytesToUMDataOutput()
+ {
+ NativePtr->advanceCursor(m_cursor);
+ m_cursor = 0;
+ m_remainingBufferLength = 0;
+ m_bytes = nullptr;
+ }
+
+ void WriteObject(bool% obj)
+ {
+ WriteBoolean(obj);
+ }
+
+ void WriteObject(Byte% obj)
+ {
+ WriteByte(obj);
+ }
+
+ void WriteObject(Char% obj)
+ {
+ unsigned short us = (unsigned short)obj;
+ m_bytes[m_cursor++] = us >> 8;
+ m_bytes[m_cursor++] = (Byte)us;
+ }
+
+ void WriteObject(Double% obj)
+ {
+ WriteDouble(obj);
+ }
+
+ void WriteObject(Single% obj)
+ {
+ WriteFloat(obj);
+ }
+
+ void WriteObject(int16_t% obj)
+ {
+ WriteInt16(obj);
+ }
+
+ void WriteObject(int32_t% obj)
+ {
+ WriteInt32(obj);
+ }
+
+ void WriteObject(int64_t% obj)
+ {
+ WriteInt64(obj);
+ }
+
+
+ template <typename mType>
+ void WriteObject(array<mType>^ %objArray)
+ {
+ if(objArray != nullptr) {
+ int arrayLen = objArray->Length;
+ WriteArrayLen(arrayLen);
+ if(arrayLen > 0) {
+ int i = 0;
+ for( i = 0; i < arrayLen; i++ ){
+ WriteObject(objArray[i]);
+ }
+ }
+ }
+ else {
+ WriteByte(0xff);
+ }
+ }
+
+ bool IsManagedObject()
+ {
+ //TODO::HItesh
+ return m_isManagedObject;
+ }
+
+ void SetBuffer()
+ {
+ m_cursor = 0;
+ m_bytes = const_cast<uint8_t *>(NativePtr->getCursor());
+ m_remainingBufferLength = NativePtr->getRemainingBufferLength();
+ }
+
+ inline void EnsureCapacity( int32_t size )
+ {
+ int32_t bytesLeft = m_remainingBufferLength - m_cursor;
+ if ( bytesLeft < size ) {
+ try
+ {
+ NativePtr->ensureCapacity(m_cursor + size);
+ m_bytes = const_cast<uint8_t *>( NativePtr->getCursor());
+ m_remainingBufferLength = NativePtr->getRemainingBufferLength();
+ }
+ catch(gemfire::OutOfMemoryException ex )
+ {
+ throw gcnew GemStone::GemFire::Cache::OutOfMemoryException(ex);
+ }
+ }
+ }
+
+
+ /// <summary>
+ /// Internal constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ inline DataOutput( gemfire::DataOutput* nativeptr, bool managedObject )
+ : UMWrap( nativeptr, false )
+ {
+ m_isManagedObject = managedObject;
+ m_cursor = 0;
+ m_bytes = const_cast<uint8_t *>(nativeptr->getCursor());
+ m_remainingBufferLength = nativeptr->getRemainingBufferLength();
+ }
+
+ /*inline DataOutput( gemfire::DataOutput* nativeptr )
+ : UMWrap( nativeptr, false )
+ {
+ m_isManagedObject = false;
+ m_cursor = 0;
+ m_bytes = const_cast<uint8_t *>(nativeptr->getCursor());
+ m_remainingBufferLength = nativeptr->getRemainingBufferLength();
+ }*/
+ };
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/DiskPolicyTypeM.hpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/DiskPolicyTypeM.hpp b/geode-client-native/src/clicache/DiskPolicyTypeM.hpp
new file mode 100644
index 0000000..a0f82dd
--- /dev/null
+++ b/geode-client-native/src/clicache/DiskPolicyTypeM.hpp
@@ -0,0 +1,76 @@
+/*=========================================================================
+ * 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.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "cppcache/DiskPolicyType.hpp"
+
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache
+ {
+
+ /// <summary>
+ /// Enumerated type for disk policy.
+ /// Contains values for setting the disk policy type.
+ /// </summary>
+ [Obsolete("Use classes and APIs from the GemStone.GemFire.Cache.Generic namespace")]
+ public enum class DiskPolicyType
+ {
+ /// <summary>No policy.</summary>
+ None = 0,
+
+ /// <summary>Overflow to disk.</summary>
+ Overflows
+ };
+
+
+ /// <summary>
+ /// Static class containing convenience methods for <c>DiskPolicyType</c>.
+ /// </summary>
+ /// <seealso cref="RegionAttributes.DiskPolicy" />
+ /// <seealso cref="AttributesFactory.SetDiskPolicy" />
+ [Obsolete("Use classes and APIs from the GemStone.GemFire.Cache.Generic namespace")]
+ public ref class DiskPolicy STATICCLASS
+ {
+ public:
+
+ /// <summary>
+ /// True if the current policy is <c>Overflows</c>.
+ /// </summary>
+ inline static bool IsOverflow( DiskPolicyType type )
+ {
+ return (type == DiskPolicyType::Overflows);
+ }
+
+ /// <summary>
+ /// True if the current policy is <c>None</c>.
+ /// </summary>
+ inline static bool IsNone( DiskPolicyType type )
+ {
+ return (type == DiskPolicyType::None);
+ }
+
+ ///// <summary>
+ ///// True if the current policy is <c>Persist</c>.
+ ///// </summary> -- Persist is NOT YET IMPLEMENTED IN C++
+ //inline static bool IsPersist( DiskPolicyType type )
+ //{
+ // return (type == DiskPolicyType::Persist);
+ //}
+ };
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/DistributedSystemM.cpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/DistributedSystemM.cpp b/geode-client-native/src/clicache/DistributedSystemM.cpp
new file mode 100644
index 0000000..68395e6
--- /dev/null
+++ b/geode-client-native/src/clicache/DistributedSystemM.cpp
@@ -0,0 +1,586 @@
+/*=========================================================================
+ * 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.
+ *=========================================================================
+ */
+
+#include "gf_includes.hpp"
+#include "version.h"
+#include "DistributedSystemM.hpp"
+#include "SystemPropertiesM.hpp"
+#include "PropertiesM.hpp"
+#include "CacheFactoryM.hpp"
+#include "CacheableDateM.hpp"
+#include "CacheableFileNameM.hpp"
+#include "CacheableHashMapM.hpp"
+#include "CacheableHashSetM.hpp"
+#include "CacheableHashTableM.hpp"
+#include "CacheableIdentityHashMapM.hpp"
+#include "CacheableObjectArrayM.hpp"
+#include "CacheableStringM.hpp"
+#include "CacheableStringArrayM.hpp"
+#include "CacheableUndefinedM.hpp"
+#include "CacheableVectorM.hpp"
+#include "CacheableArrayListM.hpp"
+#include "CacheableStackM.hpp"
+#include "CacheableObject.hpp"
+#include "CacheableObjectXml.hpp"
+#include "LogM.hpp"
+#include "StructM.hpp"
+#include "impl/MemoryPressureHandler.hpp"
+#include "cppcache/CacheLoader.hpp"
+#include "cppcache/CacheListener.hpp"
+#include "cppcache/PartitionResolver.hpp"
+#include "cppcache/CacheWriter.hpp"
+#include "cppcache/GemfireTypeIds.hpp"
+#include "cppcache/impl/CacheImpl.hpp"
+#include "cppcache/impl/PooledBasePool.hpp"
+#include "cppcache/impl/CacheXmlParser.hpp"
+#include "impl/SafeConvert.hpp"
+#include "cppcache/impl/DistributedSystemImpl.hpp"
+#include "CacheableBuiltinsM.hpp"
+// disable spurious warning
+#pragma warning(disable:4091)
+#include <msclr/lock.h>
+#pragma warning(default:4091)
+#include <ace/Process.h> // Added to get rid of unresolved token warning
+
+
+using namespace System;
+
+namespace gemfire
+{
+
+ class ManagedCacheLoader
+ : public CacheLoader
+ {
+ public:
+
+ static CacheLoader* create(const char* assemblyPath,
+ const char* factoryFunctionName);
+ };
+
+ class ManagedCacheListener
+ : public CacheListener
+ {
+ public:
+
+ static CacheListener* create(const char* assemblyPath,
+ const char* factoryFunctionName);
+ };
+
+ class ManagedPartitionResolver
+ : public PartitionResolver
+ {
+ public:
+
+ static PartitionResolver* create(const char* assemblyPath,
+ const char* factoryFunctionName);
+ };
+
+ class ManagedCacheWriter
+ : public CacheWriter
+ {
+ public:
+
+ static CacheWriter* create(const char* assemblyPath,
+ const char* factoryFunctionName);
+ };
+
+ class ManagedAuthInitialize
+ : public AuthInitialize
+ {
+ public:
+
+ static AuthInitialize* create(const char* assemblyPath,
+ const char* factoryFunctionName);
+ };
+}
+
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache
+ {
+ DistributedSystem^ DistributedSystem::Connect(String^ name)
+ {
+ return DistributedSystem::Connect(name, nullptr);
+ }
+
+ DistributedSystem^ DistributedSystem::Connect(String^ name,
+ Properties^ config)
+ {
+ gemfire::DistributedSystemImpl::acquireDisconnectLock();
+
+ _GF_MG_EXCEPTION_TRY
+
+ ManagedString mg_name(name);
+ gemfire::PropertiesPtr nativepropsptr(
+ GetNativePtr<gemfire::Properties>(config));
+ DistributedSystem::AppDomainInstanceInitialization(nativepropsptr);
+
+ // this we are calling after all .NET initialization required in
+ // each AppDomain
+ gemfire::DistributedSystemPtr& nativeptr(
+ gemfire::DistributedSystem::connect(mg_name.CharPtr,
+ nativepropsptr));
+
+ ManagedPostConnect();
+
+// DistributedSystem::AppDomainInstancePostInitialization();
+
+ return Create(nativeptr.ptr());
+
+ _GF_MG_EXCEPTION_CATCH_ALL
+
+ finally {
+ gemfire::DistributedSystemImpl::releaseDisconnectLock();
+ }
+ }
+
+ void DistributedSystem::Disconnect()
+ {
+ gemfire::DistributedSystemImpl::acquireDisconnectLock();
+
+ _GF_MG_EXCEPTION_TRY
+
+ if (gemfire::DistributedSystem::isConnected()) {
+ // gemfire::CacheImpl::expiryTaskManager->cancelTask(
+ // s_memoryPressureTaskID);
+ Serializable::UnregisterNatives();
+ DistributedSystem::UnregisterBuiltinManagedTypes();
+ }
+ gemfire::DistributedSystem::disconnect();
+
+ _GF_MG_EXCEPTION_CATCH_ALL
+
+ finally {
+ gemfire::DistributedSystemImpl::releaseDisconnectLock();
+ }
+ }
+
+
+ /* DistributedSystem^ DistributedSystem::ConnectOrGetInstance(String^ name)
+ {
+ return DistributedSystem::ConnectOrGetInstance(name, nullptr);
+ }
+
+ DistributedSystem^ DistributedSystem::ConnectOrGetInstance(String^ name,
+ Properties^ config)
+ {
+ gemfire::DistributedSystemImpl::acquireDisconnectLock();
+
+ _GF_MG_EXCEPTION_TRY
+
+ ManagedString mg_name(name);
+ gemfire::PropertiesPtr nativepropsptr(
+ GetNativePtr<gemfire::Properties>(config));
+ DistributedSystem::AppDomainInstanceInitialization(nativepropsptr);
+
+ // this we are calling after all .NET initialization required in
+ // each AppDomain
+ gemfire::DistributedSystemPtr& nativeptr(
+ gemfire::DistributedSystem::connectOrGetInstance(mg_name.CharPtr,
+ nativepropsptr));
+
+ if (gemfire::DistributedSystem::currentInstances() == 1) {
+ // stuff to be done only for the first connect
+ ManagedPostConnect();
+ }
+
+ DistributedSystem::AppDomainInstancePostInitialization();
+
+ return Create(nativeptr.ptr());
+
+ _GF_MG_EXCEPTION_CATCH_ALL
+
+ finally {
+ gemfire::DistributedSystemImpl::releaseDisconnectLock();
+ }
+ }
+*/
+ /* int DistributedSystem::DisconnectInstance()
+ {
+ gemfire::DistributedSystemImpl::acquireDisconnectLock();
+
+ _GF_MG_EXCEPTION_TRY
+
+ int remainingInstances =
+ gemfire::DistributedSystem::currentInstances();
+ if (remainingInstances <= 0) {
+ throw gcnew NotConnectedException("DistributedSystem."
+ "DisconnectInstance: no remaining instance connections");
+ }
+
+ //gemfire::CacheImpl::expiryTaskManager->cancelTask(
+ //s_memoryPressureTaskID);
+ Serializable::UnregisterNatives();
+
+ if (remainingInstances == 1) { // last instance
+ DistributedSystem::UnregisterBuiltinManagedTypes();
+ }
+ return gemfire::DistributedSystem::disconnectInstance();
+
+ _GF_MG_EXCEPTION_CATCH_ALL
+
+ finally {
+ gemfire::DistributedSystemImpl::releaseDisconnectLock();
+ }
+ }
+*/
+
+ void DistributedSystem::AppDomainInstanceInitialization(
+ const gemfire::PropertiesPtr& nativepropsptr)
+ {
+ _GF_MG_EXCEPTION_TRY
+
+ // Register wrapper types for built-in types, this are still cpp wrapper
+
+ Serializable::RegisterWrapper(
+ gcnew WrapperDelegate(GemStone::GemFire::Cache::CacheableHashSet::Create),
+ gemfire::GemfireTypeIds::CacheableHashSet);
+
+ Serializable::RegisterWrapper(
+ gcnew WrapperDelegate(GemStone::GemFire::Cache::CacheableLinkedHashSet::Create),
+ gemfire::GemfireTypeIds::CacheableLinkedHashSet);
+
+ Serializable::RegisterWrapper(
+ gcnew WrapperDelegate(GemStone::GemFire::Cache::Struct::Create),
+ gemfire::GemfireTypeIds::Struct);
+
+ Serializable::RegisterWrapper(
+ gcnew WrapperDelegate(GemStone::GemFire::Cache::Properties::CreateDeserializable),
+ gemfire::GemfireTypeIds::Properties);
+
+ // End register wrapper types for built-in types
+
+ // Register with cpp using unmanaged Cacheablekey wrapper
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableByte,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableByte::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableBoolean,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableBoolean::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableBytes,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableBytes::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::BooleanArray,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::BooleanArray::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableWideChar,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableCharacter::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CharArray,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CharArray::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableDouble,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableDouble::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableDoubleArray,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableDoubleArray::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableFloat,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableFloat::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableFloatArray,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableFloatArray::CreateDeserializable));
+
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableHashSet,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableHashSet::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableLinkedHashSet,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableLinkedHashSet::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableInt16,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableInt16::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableInt16Array,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableInt16Array::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableInt32,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableInt32::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableInt32Array,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableInt32Array::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableInt64,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableInt64::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableInt64Array,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableInt64Array::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableASCIIString,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableString::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableASCIIStringHuge,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableString::createDeserializableHuge));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableString,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableString::createUTFDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableStringHuge,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableString::createUTFDeserializableHuge));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableNullString,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableString::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableStringArray,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableStringArray::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::Struct,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::Struct::CreateDeserializable));
+
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::Properties,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::Properties::CreateDeserializable));
+
+
+ // End register other built-in types
+
+ if (!gemfire::DistributedSystem::isConnected())
+ {
+ // Set the ManagedAuthInitialize factory function
+ gemfire::SystemProperties::managedAuthInitializeFn =
+ gemfire::ManagedAuthInitialize::create;
+
+ // Set the ManagedCacheLoader/Listener/Writer factory functions.
+ gemfire::CacheXmlParser::managedCacheLoaderFn =
+ gemfire::ManagedCacheLoader::create;
+ gemfire::CacheXmlParser::managedCacheListenerFn =
+ gemfire::ManagedCacheListener::create;
+ gemfire::CacheXmlParser::managedCacheWriterFn =
+ gemfire::ManagedCacheWriter::create;
+
+ // Set the ManagedPartitionResolver factory function
+ gemfire::CacheXmlParser::managedPartitionResolverFn =
+ gemfire::ManagedPartitionResolver::create;
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL
+ }
+
+ void DistributedSystem::ManagedPostConnect()
+ {
+ // [sumedh] The registration into the native map should be after
+ // native connect since it can be invoked only once
+
+ // Register other built-in types
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableDate,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableDate::CreateDeserializable));
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableFileName,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableFileName::CreateDeserializable));
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableHashMap,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableHashMap::CreateDeserializable));
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableHashTable,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableHashTable::CreateDeserializable));
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableIdentityHashMap,
+ gcnew TypeFactoryMethod(
+ GemStone::GemFire::Cache::CacheableIdentityHashMap::CreateDeserializable));
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableUndefined,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableUndefined::CreateDeserializable));
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableVector,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableVector::CreateDeserializable));
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableObjectArray,
+ gcnew TypeFactoryMethod(
+ GemStone::GemFire::Cache::CacheableObjectArray::CreateDeserializable));
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableArrayList,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableArrayList::CreateDeserializable));
+ Serializable::RegisterType(
+ gemfire::GemfireTypeIds::CacheableStack,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableStack::CreateDeserializable));
+ Serializable::RegisterType(
+ GemFireClassIds::CacheableManagedObject - 0x80000000,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableObject::CreateDeserializable));
+ Serializable::RegisterType(
+ GemFireClassIds::CacheableManagedObjectXml - 0x80000000,
+ gcnew TypeFactoryMethod(GemStone::GemFire::Cache::CacheableObjectXml::CreateDeserializable));
+ // End register other built-in types
+
+ // TODO: what will happen for following if first appDomain unload ??
+ // Testing shows that there are problems; need to discuss -- maybe
+ // maintain per AppDomainID functions in C++ layer.
+
+ // Log the version of the C# layer being used
+ Log::Config(".NET layer assembly version: {0}({1})", System::Reflection::
+ Assembly::GetExecutingAssembly()->GetName()->Version->ToString(),
+ System::Reflection::Assembly::GetExecutingAssembly()->ImageRuntimeVersion);
+
+ Log::Config(".NET runtime version: {0} ",System::Environment::Version);
+
+ Log::Config(".NET layer source repository (revision): {0} ({1})",
+ GEMFIRE_SOURCE_REPOSITORY, GEMFIRE_SOURCE_REVISION);
+ }
+
+ void DistributedSystem::AppDomainInstancePostInitialization()
+ {
+ //to create .net memory pressure handler
+ Create(gemfire::DistributedSystem::getInstance().ptr());
+ }
+
+ void DistributedSystem::UnregisterBuiltinManagedTypes()
+ {
+ _GF_MG_EXCEPTION_TRY
+
+ gemfire::DistributedSystemImpl::acquireDisconnectLock();
+
+ Serializable::UnregisterNatives();
+
+ int remainingInstances =
+ gemfire::DistributedSystemImpl::currentInstances();
+
+ if (remainingInstances == 0) { // last instance
+
+ Serializable::UnregisterType(
+ gemfire::GemfireTypeIds::CacheableDate);
+ Serializable::UnregisterType(
+ gemfire::GemfireTypeIds::CacheableFileName);
+ Serializable::UnregisterType(
+ gemfire::GemfireTypeIds::CacheableHashMap);
+ Serializable::UnregisterType(
+ gemfire::GemfireTypeIds::CacheableHashTable);
+ Serializable::UnregisterType(
+ gemfire::GemfireTypeIds::CacheableIdentityHashMap);
+ Serializable::UnregisterType(
+ gemfire::GemfireTypeIds::CacheableVector);
+ Serializable::UnregisterType(
+ gemfire::GemfireTypeIds::CacheableObjectArray);
+ Serializable::UnregisterType(
+ gemfire::GemfireTypeIds::CacheableArrayList);
+ Serializable::UnregisterType(
+ gemfire::GemfireTypeIds::CacheableStack);
+ Serializable::UnregisterType(
+ GemFireClassIds::CacheableManagedObject - 0x80000000);
+ Serializable::UnregisterType(
+ GemFireClassIds::CacheableManagedObjectXml - 0x80000000);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL
+
+ finally {
+ gemfire::DistributedSystemImpl::releaseDisconnectLock();
+ }
+ }
+
+ SystemProperties^ DistributedSystem::SystemProperties::get()
+ {
+ _GF_MG_EXCEPTION_TRY
+
+ return GemStone::GemFire::Cache::SystemProperties::Create(
+ gemfire::DistributedSystem::getSystemProperties());
+
+ _GF_MG_EXCEPTION_CATCH_ALL
+ }
+
+ String^ DistributedSystem::Name::get()
+ {
+ return ManagedString::Get(NativePtr->getName());
+ }
+
+ bool DistributedSystem::IsConnected::get()
+ {
+ return gemfire::DistributedSystem::isConnected();
+ }
+
+ DistributedSystem^ DistributedSystem::GetInstance()
+ {
+ gemfire::DistributedSystemPtr& nativeptr(
+ gemfire::DistributedSystem::getInstance());
+ return Create(nativeptr.ptr());
+ }
+
+ void DistributedSystem::HandleMemoryPressure(System::Object^ state)
+ {
+ ACE_Time_Value dummy(1);
+ MemoryPressureHandler handler;
+ handler.handle_timeout(dummy, nullptr);
+ }
+
+ DistributedSystem^ DistributedSystem::Create(
+ gemfire::DistributedSystem* nativeptr)
+ {
+ if (m_instance == nullptr) {
+ msclr::lock lockInstance(m_singletonSync);
+ if (m_instance == nullptr) {
+ m_instance = (nativeptr != nullptr
+ ? gcnew DistributedSystem(nativeptr) : nullptr);
+ }
+ }
+ DistributedSystem^ instance = (DistributedSystem^)m_instance;
+ return instance;
+ }
+
+ DistributedSystem::DistributedSystem(gemfire::DistributedSystem* nativeptr)
+ : SBWrap(nativeptr)
+ {
+ System::Threading::TimerCallback^ timerCallback = gcnew System::
+ Threading::TimerCallback(&DistributedSystem::HandleMemoryPressure);
+ m_memoryPressureHandler = gcnew System::Threading::Timer(
+ timerCallback, "MemoryPressureHandler", 3*60000, 3*60000);
+ }
+
+ DistributedSystem::~DistributedSystem()
+ {
+ m_memoryPressureHandler->Dispose(nullptr);
+ }
+
+ void DistributedSystem::acquireDisconnectLock()
+ {
+ gemfire::DistributedSystemImpl::acquireDisconnectLock();
+ }
+
+ void DistributedSystem::disconnectInstance()
+ {
+ gemfire::DistributedSystemImpl::disconnectInstance();
+ }
+
+ void DistributedSystem::releaseDisconnectLock()
+ {
+ gemfire::DistributedSystemImpl::releaseDisconnectLock();
+ }
+
+ void DistributedSystem::connectInstance()
+ {
+ gemfire::DistributedSystemImpl::connectInstance();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/DistributedSystemM.hpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/DistributedSystemM.hpp b/geode-client-native/src/clicache/DistributedSystemM.hpp
new file mode 100644
index 0000000..8855c50
--- /dev/null
+++ b/geode-client-native/src/clicache/DistributedSystemM.hpp
@@ -0,0 +1,203 @@
+/*=========================================================================
+ * 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.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "cppcache/DistributedSystem.hpp"
+#include "impl/NativeWrapper.hpp"
+
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache
+ {
+
+ ref class Properties;
+ ref class SystemProperties;
+
+ /// <summary>
+ /// DistributedSystem encapsulates this applications "connection" into the
+ /// GemFire Java servers.
+ /// </summary>
+ /// <remarks>
+ /// In order to participate as a client in the GemFire Java servers
+ /// distributed system, each application needs to connect to the
+ /// DistributedSystem.
+ /// </remarks>
+ [Obsolete("Use classes and APIs from the GemStone.GemFire.Cache.Generic namespace")]
+ public ref class DistributedSystem sealed
+ : public Internal::SBWrap<gemfire::DistributedSystem>
+ {
+ public:
+
+ /// <summary>
+ /// Initializes the Native Client system to be able to connect to the GemFire Java servers.
+ /// </summary>
+ /// <param name="name">the name of the system to connect to</param>
+ /// <exception cref="IllegalArgumentException">if name is null</exception>
+ /// <exception cref="NoSystemException">
+ /// if the connecting target is not running
+ /// </exception>
+ /// <exception cref="AlreadyConnectedException">
+ /// if trying a second connect.
+ /// An application can have one only one connection to a DistributedSystem.
+ /// </exception>
+ /// <exception cref="UnknownException">otherwise</exception>
+ static DistributedSystem^ Connect( String^ name );
+
+ /// <summary>
+ /// Initializes the Native Client system to be able to connect to the
+ /// GemFire Java servers.
+ /// </summary>
+ /// <param name="name">the name of the system to connect to</param>
+ /// <param name="config">the set of properties</param>
+ /// <exception cref="IllegalArgumentException">if name is null</exception>
+ /// <exception cref="NoSystemException">
+ /// if the connecting target is not running
+ /// </exception>
+ /// <exception cref="AlreadyConnectedException">
+ /// if trying a second connect.
+ /// An application can have one only one connection to a DistributedSystem.
+ /// </exception>
+ /// <exception cref="UnknownException">otherwise</exception>
+ static DistributedSystem^ Connect( String^ name, Properties^ config );
+
+ /// <summary>
+ /// Disconnect from the distributed system.
+ /// </summary>
+ /// <exception cref="IllegalStateException">if not connected</exception>
+ static void Disconnect();
+
+ /// <summary>
+ /// Returns the SystemProperties used to create this instance of a
+ /// <c>DistributedSystem</c>.
+ /// </summary>
+ /// <returns>the SystemProperties</returns>
+ static property GemStone::GemFire::Cache::SystemProperties^ SystemProperties
+ {
+ static GemStone::GemFire::Cache::SystemProperties^ get( );
+ }
+
+ /// <summary>
+ /// Get the name that identifies this DistributedSystem instance.
+ /// </summary>
+ /// <returns>the name of the DistributedSystem instance.</returns>
+ property String^ Name
+ {
+ String^ get( );
+ }
+
+ /// <summary>
+ /// The current connection status of this client to the <c>DistributedSystem</c>.
+ /// </summary>
+ /// <returns>true if connected, false otherwise</returns>
+ static property bool IsConnected
+ {
+ static bool get( );
+ }
+
+ /// <summary>
+ /// Returns a reference to this DistributedSystem instance.
+ /// </summary>
+ /// <returns>the DistributedSystem instance</returns>
+ static DistributedSystem^ GetInstance( );
+
+
+ internal:
+
+ /// <summary>
+ /// Internal factory function to wrap a native object pointer inside
+ /// this managed class with null pointer check.
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ /// <returns>
+ /// The managed wrapper object; null if the native pointer is null.
+ /// </returns>
+ static DistributedSystem^ Create(gemfire::DistributedSystem* nativeptr);
+
+ static void acquireDisconnectLock();
+
+ static void disconnectInstance();
+
+ static void releaseDisconnectLock();
+
+ static void connectInstance();
+
+ /// <summary>
+ /// Stuff that needs to be done for Connect in each AppDomain.
+ /// </summary>
+ static void AppDomainInstanceInitialization(
+ const gemfire::PropertiesPtr& nativepropsptr);
+
+ /// <summary>
+ /// Managed registrations and other stuff to be done for the manage
+ /// layer after the first connect.
+ /// </summary>
+ static void ManagedPostConnect();
+
+ /// <summary>
+ /// Stuff that needs to be done for Connect in each AppDomain but
+ /// only after the first Connect has completed.
+ /// </summary>
+ static void AppDomainInstancePostInitialization();
+
+ /// <summary>
+ /// Unregister the builtin managed types like CacheableObject.
+ /// </summary>
+ static void UnregisterBuiltinManagedTypes();
+
+ private:
+
+ ///// <summary>
+ ///// Stores the task ID of the task that adjusts unmanaged memory
+ ///// pressure in managed GC.
+ ///// </summary>
+ //static long s_memoryPressureTaskID = -1;
+
+ /// <summary>
+ /// Private constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ DistributedSystem(gemfire::DistributedSystem* nativeptr);
+
+ /// <summary>
+ /// Finalizer for the singleton instance of this class.
+ /// </summary>
+ ~DistributedSystem();
+
+
+
+ /// <summary>
+ /// Periodically adjust memory pressure of unmanaged heap for GC.
+ /// </summary>
+ static void HandleMemoryPressure(System::Object^ state);
+
+ /// <summary>
+ /// Timer task to periodically invoke <c>HandleMemoryPressure</c>.
+ /// </summary>
+ System::Threading::Timer^ m_memoryPressureHandler;
+
+ /// <summary>
+ /// Singleton instance of this class.
+ /// </summary>
+ static volatile DistributedSystem^ m_instance;
+
+ /// <summary>
+ /// Static lock object to protect the singleton instance of this class.
+ /// </summary>
+ static System::Object^ m_singletonSync = gcnew System::Object();
+ };
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/EntryEventM.cpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/EntryEventM.cpp b/geode-client-native/src/clicache/EntryEventM.cpp
new file mode 100644
index 0000000..890ae4f
--- /dev/null
+++ b/geode-client-native/src/clicache/EntryEventM.cpp
@@ -0,0 +1,78 @@
+/*=========================================================================
+ * 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.
+ *=========================================================================
+ */
+
+#include "gf_includes.hpp"
+#include "EntryEventM.hpp"
+#include "RegionM.hpp"
+#include "impl/SafeConvert.hpp"
+
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache
+ {
+
+ EntryEvent::EntryEvent(GemStone::GemFire::Cache::Region^ region,
+ GemStone::GemFire::Cache::ICacheableKey^ key, IGFSerializable^ oldValue,
+ IGFSerializable^ newValue, IGFSerializable^ aCallbackArgument,
+ bool remoteOrigin)
+ : UMWrap( )
+ {
+ gemfire::RegionPtr regionptr( GetNativePtr<gemfire::Region>( region ) );
+ gemfire::CacheableKeyPtr keyptr( SafeMKeyConvert( key ) );
+ gemfire::CacheablePtr oldptr( SafeMSerializableConvert( oldValue ) );
+ gemfire::CacheablePtr newptr( SafeMSerializableConvert( newValue ) );
+ gemfire::UserDataPtr callbackptr(SafeMSerializableConvert(
+ aCallbackArgument));
+
+ SetPtr(new gemfire::EntryEvent(regionptr, keyptr,
+ oldptr, newptr, callbackptr, remoteOrigin), true);
+ }
+
+ GemStone::GemFire::Cache::Region^ EntryEvent::Region::get( )
+ {
+ gemfire::RegionPtr& regionptr( NativePtr->getRegion( ) );
+ return GemStone::GemFire::Cache::Region::Create( regionptr.ptr( ) );
+ }
+
+ GemStone::GemFire::Cache::ICacheableKey^ EntryEvent::Key::get( )
+ {
+ gemfire::CacheableKeyPtr& keyptr( NativePtr->getKey( ) );
+ return SafeUMKeyConvert( keyptr.ptr( ) );
+ }
+
+ IGFSerializable^ EntryEvent::OldValue::get( )
+ {
+ gemfire::CacheablePtr& valptr( NativePtr->getOldValue( ) );
+ return SafeUMSerializableConvert( valptr.ptr( ) );
+ }
+
+ IGFSerializable^ EntryEvent::NewValue::get( )
+ {
+ gemfire::CacheablePtr& valptr( NativePtr->getNewValue( ) );
+ return SafeUMSerializableConvert( valptr.ptr( ) );
+ }
+
+ IGFSerializable^ EntryEvent::CallbackArgument::get()
+ {
+ gemfire::UserDataPtr& valptr(NativePtr->getCallbackArgument());
+ return SafeUMSerializableConvert(valptr.ptr());
+ }
+
+ bool EntryEvent::RemoteOrigin::get( )
+ {
+ return NativePtr->remoteOrigin( );
+ }
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/EntryEventM.hpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/EntryEventM.hpp b/geode-client-native/src/clicache/EntryEventM.hpp
new file mode 100644
index 0000000..9455297
--- /dev/null
+++ b/geode-client-native/src/clicache/EntryEventM.hpp
@@ -0,0 +1,112 @@
+/*=========================================================================
+ * 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.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "cppcache/EntryEvent.hpp"
+#include "impl/NativeWrapper.hpp"
+
+#include "ICacheableKey.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache
+ {
+
+ ref class Region;
+ interface class IGFSerializable;
+ //interface class ICacheableKey;
+
+ /// <summary>
+ /// This class encapsulates events that occur for an entry in a region.
+ /// </summary>
+ [Obsolete("Use classes and APIs from the GemStone.GemFire.Cache.Generic namespace")]
+ public ref class EntryEvent sealed
+ : public Internal::UMWrap<gemfire::EntryEvent>
+ {
+ public:
+
+ /// <summary>
+ /// Constructor to create an <c>EntryEvent</c> for the given region.
+ /// </summary>
+ EntryEvent( Region^ region, ICacheableKey^ key, IGFSerializable^ oldValue,
+ IGFSerializable^ newValue, IGFSerializable^ aCallbackArgument,
+ bool remoteOrigin );
+
+ /// <summary>
+ /// Return the region this event occurred in.
+ /// </summary>
+ property Region^ Region
+ {
+ GemStone::GemFire::Cache::Region^ get( );
+ }
+
+ /// <summary>
+ /// Returns the key this event describes.
+ /// </summary>
+ property ICacheableKey^ Key
+ {
+ ICacheableKey^ get( );
+ }
+
+ /// <summary>
+ /// Returns 'null' if there was no value in the cache. If the prior state
+ /// of the entry was invalid, or non-existent/destroyed, then the old
+ /// value will be 'null'.
+ /// </summary>
+ property IGFSerializable^ OldValue
+ {
+ IGFSerializable^ get( );
+ }
+
+ /// <summary>
+ /// Return the updated value from this event. If the event is a destroy
+ /// or invalidate operation, then the new value will be NULL.
+ /// </summary>
+ property IGFSerializable^ NewValue
+ {
+ IGFSerializable^ get( );
+ }
+
+ /// <summary>
+ /// Returns the callbackArgument passed to the method that generated
+ /// this event. See the <see cref="Region" /> interface methods
+ /// that take a callbackArgument parameter.
+ /// </summary>
+ property IGFSerializable^ CallbackArgument
+ {
+ IGFSerializable^ get();
+ }
+
+ /// <summary>
+ /// If the event originated in a remote process, returns true.
+ /// </summary>
+ property bool RemoteOrigin
+ {
+ bool get( );
+ }
+
+
+ internal:
+
+ /// <summary>
+ /// Private constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ inline EntryEvent( const gemfire::EntryEvent* nativeptr )
+ : UMWrap( const_cast<gemfire::EntryEvent*>( nativeptr ), false ) { }
+ };
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/ExceptionTypesM.cpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/ExceptionTypesM.cpp b/geode-client-native/src/clicache/ExceptionTypesM.cpp
new file mode 100644
index 0000000..6239918
--- /dev/null
+++ b/geode-client-native/src/clicache/ExceptionTypesM.cpp
@@ -0,0 +1,173 @@
+/*=========================================================================
+ * 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.
+ *=========================================================================
+ */
+
+#include "gf_includes.hpp"
+#include <cppcache/SignalHandler.hpp>
+#include "ExceptionTypesM.hpp"
+
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache
+ {
+
+#define _GF_MG_EXCEPTION_ADD(x) { "gemfire::" #x, gcnew CreateException( x::Create ) }
+#define _GF_MG_EXCEPTION_ADD2(x,y) { "gemfire::" #y, gcnew CreateException( x::Create ) }
+
+ Dictionary<String^, CreateException^>^ GemFireException::Init( )
+ {
+ if (Native2ManagedExMap != nullptr)
+ {
+ return Native2ManagedExMap;
+ }
+ array<NameDelegatePair>^ exNamesDelegates = gcnew array<NameDelegatePair> {
+ _GF_MG_EXCEPTION_ADD( AssertionException ),
+ _GF_MG_EXCEPTION_ADD( IllegalArgumentException ),
+ _GF_MG_EXCEPTION_ADD( IllegalStateException ),
+ _GF_MG_EXCEPTION_ADD( CacheExistsException ),
+ _GF_MG_EXCEPTION_ADD( CacheXmlException ),
+ _GF_MG_EXCEPTION_ADD( TimeoutException ),
+ _GF_MG_EXCEPTION_ADD( CacheWriterException ),
+ _GF_MG_EXCEPTION_ADD( CacheListenerException ),
+ _GF_MG_EXCEPTION_ADD( RegionExistsException ),
+ _GF_MG_EXCEPTION_ADD( CacheClosedException ),
+ _GF_MG_EXCEPTION_ADD( LeaseExpiredException ),
+ _GF_MG_EXCEPTION_ADD( CacheLoaderException ),
+ _GF_MG_EXCEPTION_ADD( RegionDestroyedException ),
+ _GF_MG_EXCEPTION_ADD( EntryDestroyedException ),
+ _GF_MG_EXCEPTION_ADD( NoSystemException ),
+ _GF_MG_EXCEPTION_ADD( AlreadyConnectedException ),
+ _GF_MG_EXCEPTION_ADD( FileNotFoundException ),
+ _GF_MG_EXCEPTION_ADD( InterruptedException ),
+ _GF_MG_EXCEPTION_ADD( UnsupportedOperationException ),
+ _GF_MG_EXCEPTION_ADD( StatisticsDisabledException ),
+ _GF_MG_EXCEPTION_ADD( ConcurrentModificationException ),
+ _GF_MG_EXCEPTION_ADD( UnknownException ),
+ _GF_MG_EXCEPTION_ADD( ClassCastException ),
+ _GF_MG_EXCEPTION_ADD( EntryNotFoundException ),
+ _GF_MG_EXCEPTION_ADD2( GemFireIOException, GemfireIOException ),
+ _GF_MG_EXCEPTION_ADD2( GemFireConfigException, GemfireConfigException ),
+ _GF_MG_EXCEPTION_ADD( NullPointerException ),
+ _GF_MG_EXCEPTION_ADD( EntryExistsException ),
+ _GF_MG_EXCEPTION_ADD( NotConnectedException ),
+ _GF_MG_EXCEPTION_ADD( CacheProxyException ),
+ _GF_MG_EXCEPTION_ADD( OutOfMemoryException ),
+ _GF_MG_EXCEPTION_ADD( NotOwnerException ),
+ _GF_MG_EXCEPTION_ADD( WrongRegionScopeException ),
+ _GF_MG_EXCEPTION_ADD( BufferSizeExceededException ),
+ _GF_MG_EXCEPTION_ADD( RegionCreationFailedException ),
+ _GF_MG_EXCEPTION_ADD( FatalInternalException ),
+ _GF_MG_EXCEPTION_ADD( DiskFailureException ),
+ _GF_MG_EXCEPTION_ADD( DiskCorruptException ),
+ _GF_MG_EXCEPTION_ADD( InitFailedException ),
+ _GF_MG_EXCEPTION_ADD( ShutdownFailedException ),
+ _GF_MG_EXCEPTION_ADD( CacheServerException ),
+ _GF_MG_EXCEPTION_ADD( OutOfRangeException ),
+ _GF_MG_EXCEPTION_ADD( QueryException ),
+ _GF_MG_EXCEPTION_ADD( MessageException ),
+ _GF_MG_EXCEPTION_ADD( NotAuthorizedException ),
+ _GF_MG_EXCEPTION_ADD( AuthenticationFailedException ),
+ _GF_MG_EXCEPTION_ADD( AuthenticationRequiredException ),
+ _GF_MG_EXCEPTION_ADD( DuplicateDurableClientException ),
+ _GF_MG_EXCEPTION_ADD( NoAvailableLocatorsException ),
+ _GF_MG_EXCEPTION_ADD( FunctionExecutionException ),
+ _GF_MG_EXCEPTION_ADD( CqInvalidException ),
+ _GF_MG_EXCEPTION_ADD( CqExistsException ),
+ _GF_MG_EXCEPTION_ADD( CqQueryException ),
+ _GF_MG_EXCEPTION_ADD( CqClosedException ),
+ _GF_MG_EXCEPTION_ADD( CqException ),
+ _GF_MG_EXCEPTION_ADD( AllConnectionsInUseException ),
+ _GF_MG_EXCEPTION_ADD( InvalidDeltaException ),
+ _GF_MG_EXCEPTION_ADD( KeyNotFoundException ),
+ _GF_MG_EXCEPTION_ADD( CommitConflictException ),
+ _GF_MG_EXCEPTION_ADD( TransactionDataNodeHasDepartedException ),
+ _GF_MG_EXCEPTION_ADD( TransactionDataRebalancedException )
+
+ #ifdef CSTX_COMMENTED
+ ,_GF_MG_EXCEPTION_ADD( TransactionWriterException )
+ #endif
+ };
+
+ Native2ManagedExMap = gcnew Dictionary<String^, CreateException^>( );
+ for (int32_t index = 0; index < exNamesDelegates->Length; index++)
+ {
+ Native2ManagedExMap[ exNamesDelegates[ index ].m_name ] =
+ exNamesDelegates[ index ].m_delegate;
+ }
+ return Native2ManagedExMap;
+ }
+
+ System::Exception^ GemFireException::Get(const gemfire::Exception& nativeEx)
+ {
+ Exception^ innerException = nullptr;
+ const gemfire::ExceptionPtr& cause = nativeEx.getCause();
+ if (cause != NULLPTR) {
+ innerException = GemFireException::Get(*cause);
+ }
+ String^ exName = gcnew String( nativeEx.getName( ) );
+ CreateException^ exDelegate;
+ if (Native2ManagedExMap->TryGetValue(exName, exDelegate)) {
+ return exDelegate(nativeEx, innerException);
+ }
+ String^ exMsg = ManagedString::Get( nativeEx.getMessage( ) );
+ if ( exMsg->StartsWith( GemFireException::MgSysExPrefix ) ) {
+ // Get the exception type
+ String^ mgExStr = exMsg->Substring(
+ GemFireException::MgSysExPrefix->Length );
+ int32_t colonIndex = mgExStr->IndexOf( ':' );
+ if ( colonIndex > 0 ) {
+ String^ mgExName = mgExStr->Substring( 0, colonIndex )->Trim( );
+ // Try to load this class by reflection
+ Type^ mgExType = Type::GetType( mgExName, false, true );
+ if ( mgExType != nullptr ) {
+ System::Reflection::ConstructorInfo^ cInfo = mgExType->
+ GetConstructor(gcnew array<Type^>{ String::typeid, Exception::typeid });
+ if ( cInfo != nullptr ) {
+ String^ mgMsg = mgExStr->Substring( colonIndex + 1 );
+ Exception^ mgEx = dynamic_cast<Exception^>(cInfo->Invoke(
+ gcnew array<Object^>{ mgMsg, innerException }));
+ if ( mgEx != nullptr ) {
+ return mgEx;
+ }
+ }
+ }
+ }
+ }
+ if (innerException == nullptr) {
+ return gcnew GemFireException(exName + ": " + exMsg,
+ gcnew GemFireException(GetStackTrace(nativeEx)));
+ }
+ else {
+ return gcnew GemFireException(exName + ": " + exMsg, innerException);
+ }
+ }
+
+ String^ GemFireException::GenerateMiniDump()
+ {
+ char dumpFile[_MAX_PATH];
+ gemfire::SignalHandler::dumpStack(dumpFile, _MAX_PATH - 1);
+ return ManagedString::Get(dumpFile);
+ }
+
+ String^ GemFireException::GenerateMiniDump(int32_t exceptionCode,
+ IntPtr exceptionPointers)
+ {
+ char dumpFile[_MAX_PATH];
+ gemfire::SignalHandler::dumpStack((unsigned int)exceptionCode,
+ (EXCEPTION_POINTERS*)(void*)exceptionPointers, dumpFile,
+ _MAX_PATH - 1);
+ return ManagedString::Get(dumpFile);
+ }
+
+ }
+ }
+}