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:28 UTC

[21/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/cclient/src/data_io.c
----------------------------------------------------------------------
diff --git a/geode-client-native/src/cclient/src/data_io.c b/geode-client-native/src/cclient/src/data_io.c
new file mode 100644
index 0000000..59d48bc
--- /dev/null
+++ b/geode-client-native/src/cclient/src/data_io.c
@@ -0,0 +1,312 @@
+#include "data_io.h"
+#include <stdio.h>
+/**
+ * Write an unsigned byte to the <code>DataOutput</code>.
+ *
+ * @param value the unsigned byte to be written
+ */
+inline void writeUnsigned(Buffer* buf, uint8_t value)
+{
+    ensureCapacity(buf,1);
+    writeNoCheck(buf, value);
+}
+
+/**
+ * Write a signed byte to the <code>DataOutput</code>.
+ *
+ * @param value the signed byte to be written
+ */
+inline void writeByte(Buffer* buf, int8_t value)
+{
+    writeUnsigned(buf, (uint8_t)value);
+}
+
+/**
+ * Read a signed byte from the <code>DataInput</code>.
+ *
+ * @param value output parameter to hold the signed byte read from stream
+ */
+inline void readByte(Buffer* buf, int8_t* value )
+{
+    //checkBufferSize(1);
+    *value = *(buf->m_buf++);
+}
+
+/**
+ *    * Read a 16-bit signed integer from the <code>DataInput</code>.
+ *       *
+ *          * @param value output parameter to hold the 16-bit signed integer
+ *             *   read from stream
+ *                */
+inline void readShort(Buffer* buf, int16_t* value )
+{
+//    checkBufferSize(2);
+    readUnsignedShort(buf, (uint16_t*)value );
+}
+
+
+/**
+ *    * Read a 16-bit unsigned integer from the <code>DataInput</code>.
+ *       *
+ *          * @param value output parameter to hold the 16-bit unsigned integer
+ *             *   read from stream
+ *                */
+inline void readUnsignedShort(Buffer* buf, uint16_t* value )
+{
+//    checkBufferSize(2);
+    uint16_t tmp = *(buf->m_buf++);
+    tmp = (tmp << 8) | *(buf->m_buf++);
+    *value = tmp;
+}
+
+
+/**
+ * Read a 32-bit signed integer from the <code>DataInput</code>.
+ *
+ * @param value output parameter to hold the 32-bit signed integer
+ *   read from stream
+ */
+inline void readInt(Buffer* buf, int32_t* value )
+{
+    //checkBufferSize(4);
+    readUnsignedInt(buf, (uint32_t*)value );
+}
+
+
+/**
+ * Read a 32-bit unsigned integer from the <code>DataInput</code>.
+ *
+ * @param value output parameter to hold the 32-bit unsigned integer
+ *   read from stream
+ */
+inline void readUnsignedInt(Buffer* buf, uint32_t* value )
+{
+    //checkBufferSize(4);
+    uint32_t tmp = *(buf->m_buf++);
+    tmp = (tmp << 8) | *(buf->m_buf++);
+    tmp = (tmp << 8) | *(buf->m_buf++);
+    tmp = (tmp << 8) | *(buf->m_buf++);
+    *value = tmp;
+}
+
+
+
+
+/**
+ * Write an array of unsigned bytes to the <code>DataOutput</code>.
+ *
+ * @param value the array of unsigned bytes to be written
+ * @param len the number of bytes from the start of array to be written
+ */
+inline void writeUnsignedBytes(Buffer* buf,  const uint8_t* bytes, int32_t len )
+{
+    if (len >= 0) {
+        ensureCapacity(buf, len + 5 );
+        writeArrayLen(buf,  bytes==NULL ? 0 : len ); // length of bytes...
+        if ( len > 0 && bytes != NULL) {
+            memcpy( buf->m_buf, bytes, len );
+            buf->m_buf += len;
+        }
+    } else {
+        writeByte(buf, (int8_t) -1 );
+    }
+}
+
+/**
+ * Write an array of signed bytes to the <code>DataOutput</code>.
+ *
+ * @param value the array of signed bytes to be written
+ * @param len the number of bytes from the start of array to be written
+ */
+inline void writeBytes(Buffer* buf,  const int8_t* bytes, int32_t len )
+{
+   // printf("bytes length: %d\n", len);
+    writeUnsignedBytes(buf, (const uint8_t*)bytes, len );
+}
+/**
+ * Write a 32-bit unsigned integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 32-bit unsigned integer value to be written
+ */
+inline void writeUnsignedInt( Buffer* buf,uint32_t value )
+{
+    ensureCapacity(buf, 4 );
+    *(buf->m_buf++) = (uint8_t)(value >> 24);
+    *(buf->m_buf++) = (uint8_t)(value >> 16);
+    *(buf->m_buf++) = (uint8_t)(value >> 8);
+    *(buf->m_buf++) = (uint8_t)value;
+}
+
+/**
+ * Write a 32-bit signed integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 32-bit signed integer value to be written
+ */
+inline void writeInt(Buffer* buf,  int32_t value )
+{
+    writeUnsignedInt(buf, (uint32_t)value );
+}
+
+/**
+ * Write a 64-bit unsigned integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 64-bit unsigned integer value to be written
+ */
+inline void writeUnsignedLong( Buffer* buf,uint64_t value )
+{
+    ensureCapacity(buf, 8 );
+    *(buf->m_buf++) = (uint8_t)(value >> 56);
+    *(buf->m_buf++) = (uint8_t)(value >> 48);
+    *(buf->m_buf++) = (uint8_t)(value >> 40);
+    *(buf->m_buf++) = (uint8_t)(value >> 32);
+    *(buf->m_buf++) = (uint8_t)(value >> 24);
+    *(buf->m_buf++) = (uint8_t)(value >> 16);
+    *(buf->m_buf++) = (uint8_t)(value >> 8);
+    *(buf->m_buf++) = (uint8_t)value;
+}
+
+/**
+ * Write a 64-bit signed integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 64-bit signed integer value to be written
+ */
+inline void writeLong(Buffer* buf,  int64_t value )
+{
+    writeUnsignedLong(buf, (uint64_t)value );
+}
+
+/**
+ * Write a 16-bit unsigned integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 16-bit unsigned integer value to be written
+ */
+inline void writeUnsignedShort( Buffer* buf,uint16_t value )
+{
+    ensureCapacity(buf, 2 );
+    *(buf->m_buf++) = (uint8_t)(value >> 8);
+    *(buf->m_buf++) = (uint8_t)value;
+}
+
+/**
+ * Write a 16-bit signed integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 16-bit signed integer value to be written
+ */
+inline void writeShort(Buffer* buf,  int16_t value )
+{
+    writeUnsignedShort(buf, (uint16_t)value );
+}
+
+/**
+ * Write a 32-bit signed integer array length value to the
+ * <code>DataOutput</code> in a manner compatible with java server's
+ * <code>DataSerializer.writeArrayLength</code>.
+ *
+ * @param value the 32-bit signed integer array length to be written
+ */
+inline void writeArrayLen(Buffer* buf,  int32_t len )
+{
+    if (len == -1) {
+        writeByte(buf, (int8_t) -1);
+    } else if (len <= 252) { // 252 is java's ((byte)-4 && 0xFF)
+        writeUnsigned(buf, (uint8_t)len);
+    } else if (len <= 0xFFFF) {
+        writeByte(buf, (int8_t) -2);
+        writeUnsignedShort(buf, (uint16_t)len);
+    } else {
+        writeByte(buf, (int8_t) -3);
+        writeInt(buf, len);
+    }
+}
+
+/**
+ * Advance the buffer cursor by the given offset.
+ *
+ * @param offset the offset by which to advance the cursor
+ */
+void advanceCursor(Buffer* buf, uint32_t offset)
+{
+    buf->m_buf += offset;
+}
+
+/**
+ * Rewind the buffer cursor by the given offset.
+ *
+ * @param offset the offset by which to rewind the cursor
+ */
+void rewindCursor(Buffer* buf, uint32_t offset)
+{
+    buf->m_buf -= offset;
+}
+
+/**
+ * Get the length of current data in the internal buffer of
+ * <code>DataOutput</code>.
+ */
+inline uint32_t getBufferLength(Buffer* buf) {
+    return (uint32_t)( buf->m_buf - buf->m_bytes );
+}
+
+inline uint8_t* getBuffer(Buffer* buf)
+{
+    return buf->m_bytes;
+}
+
+inline uint8_t* getCursor(Buffer* buf) {
+    return buf->m_buf;
+}
+
+// make sure there is room left for the requested size item.
+inline void ensureCapacity(Buffer* buf,  uint32_t size )
+{
+    uint32_t offset = (uint32_t)( buf->m_buf - buf->m_bytes );
+    if ( (buf->m_size - offset) < size ) {
+        uint32_t newSize = buf->m_size * 2 + (8192 * (size / 8192));
+        buf->m_size = newSize;
+        GF_RESIZE( buf->m_bytes, uint8_t, buf->m_size );
+        buf->m_buf = buf->m_bytes + offset;
+    }
+}
+
+inline void writeNoCheck(Buffer* buf, uint8_t value)
+{
+    //uint32_t offset = (uint32_t)( buf->m_buf - buf->m_bytes );
+    //printf("%d:%d\n",offset, buf->m_size);
+    *(buf->m_buf++) = value;
+}
+
+
+inline void initBuf(Buffer* buf)
+{
+    GF_ALLOC( buf->m_bytes, uint8_t, 8192 );
+    buf->m_buf = buf->m_bytes;
+    buf->m_size = 8192;
+}
+
+inline void clearBuf(Buffer* buf)
+{
+    GF_FREE(buf->m_bytes);
+    buf->m_bytes = NULL;
+    buf->m_buf = NULL;
+    buf->m_size = 0;
+}
+
+inline void writeASCII(Buffer* buf, const char* value)
+{
+    if ( value != NULL ) {
+      uint32_t length = (uint32_t)strlen( value );
+      uint16_t len = (uint16_t)( length > 0xFFFF ? 0xFFFF : length );
+      writeUnsignedShort(buf, len);
+      writeBytesOnly(buf, (int8_t*)value, len ); // K64
+    } else {
+      writeShort(buf, (uint16_t)0);
+    }
+}
+
+inline void writeBytesOnly(Buffer* buf,  const int8_t* bytes, int32_t len)
+{
+    ensureCapacity(buf, len);
+    memcpy(buf->m_buf, bytes, len);
+    buf->m_buf += len;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/cclient/src/data_io.h
----------------------------------------------------------------------
diff --git a/geode-client-native/src/cclient/src/data_io.h b/geode-client-native/src/cclient/src/data_io.h
new file mode 100644
index 0000000..0e07320
--- /dev/null
+++ b/geode-client-native/src/cclient/src/data_io.h
@@ -0,0 +1,80 @@
+//=========================================================================
+// 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.
+//========================================================================
+
+#ifndef __C_GEMFIRE_DATAOUTPUT_H__
+#define __C_GEMFIRE_DATAOUTPUT_H__
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+/**
+ * @file
+ */
+
+/**
+ * C style memory allocation that throws OutOfMemoryException
+ * if it fails
+ */
+#define GF_ALLOC(v,t,s) \
+{ \
+    v = (t*)malloc((s) * sizeof(t)); \
+}
+
+/**
+ * C style memory re-allocation that throws OutOfMemoryException
+ * if it fails
+ */
+#define GF_RESIZE(v,t,s) \
+{ \
+    v = (t*)realloc(v, (s) * sizeof(t)); \
+}
+
+#define GF_FREE(v) free(v)
+
+typedef struct {
+  // memory m_buffer to encode to.
+  uint8_t* m_bytes;
+  // cursor.
+  uint8_t* m_buf;
+  // size of m_bytes.
+  uint32_t m_size;
+} Buffer;
+
+inline void writeUnsigned(Buffer* buf, uint8_t value);
+inline void writeByte(Buffer* buf, int8_t value);
+inline void writeUnsignedBytes(Buffer* buf,  const uint8_t* bytes, int32_t len );
+inline void writeBytes(Buffer* buf,  const int8_t* bytes, int32_t len );
+inline void writeBytesOnly(Buffer* buf,  const int8_t* bytes, int32_t len );
+inline void writeUnsignedInt( Buffer* buf,uint32_t value );
+inline void writeInt(Buffer* buf,  int32_t value );
+inline void writeUnsignedLong( Buffer* buf,uint64_t value );
+inline void writeLong(Buffer* buf,  int64_t value );
+inline void writeUnsignedShort( Buffer* buf,uint16_t value );
+inline void writeShort(Buffer* buf,  int16_t value );
+inline void writeArrayLen(Buffer* buf,  int32_t len );
+inline void writeASCII(Buffer* buf, const char* value);
+inline void writeNoCheck(Buffer* buf, uint8_t value);
+
+inline void readByte(Buffer* buf, int8_t* value );
+inline void readShort(Buffer* buf, int16_t* value );
+inline void readUnsignedShort(Buffer* buf, uint16_t* value );
+inline void readInt(Buffer* buf, int32_t* value );
+inline void readUnsignedInt(Buffer* buf, uint32_t* value );
+
+void advanceCursor(Buffer* buf, uint32_t offset);
+void rewindCursor(Buffer* buf, uint32_t offset);
+
+inline void initBuf(Buffer* buf);
+inline void clearBuf(Buffer* buf);
+inline uint32_t getBufferLength(Buffer* buf) ;
+inline uint8_t* getBuffer(Buffer* buf) ;
+inline uint8_t* getCursor(Buffer* buf) ;
+
+inline void ensureCapacity(Buffer* buf,  uint32_t size );
+
+#endif // __C_GEMFIRE_DATAOUTPUT_H__

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/cclient/src/gf_client.c
----------------------------------------------------------------------
diff --git a/geode-client-native/src/cclient/src/gf_client.c b/geode-client-native/src/cclient/src/gf_client.c
new file mode 100644
index 0000000..179dc5c
--- /dev/null
+++ b/geode-client-native/src/cclient/src/gf_client.c
@@ -0,0 +1,805 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include<pthread.h>
+#include "data_io.h"
+#include "gf_client.h"
+
+
+#define RECIEVE_DATA(context, request, reply, len, resultcode) \
+    recieveData(context, &reply, len, resultcode);\
+if(*resultcode != NO_ERROR)\
+{\
+    clearBuf(&request);\
+    clearBuf(&reply);\
+    return;\
+}
+
+#define SEND_DATA(context, request, reply, resultcode) \
+    sendData(context, getBuffer(&request), getBufferLength(&request), resultcode);\
+if(*resultcode != NO_ERROR)\
+{\
+    clearBuf(&request);\
+    clearBuf(&reply);\
+    return;\
+}
+
+
+#define CLIENT_TO_SERVER 100
+#define REPLY_OK          59
+#define SECURITY_CREDENTIALS_NONE      0
+#define VERSION_ORDINAL_651   7 // since NC 3510
+#define CONFLATEBYTE 0
+#define ADDRSIZE 4
+#define DCPORT 12334
+#define VMKIND 13
+#define ROLEARRLENGTH 0
+#define REGION_NAME "/ROOT-REGION"
+#define TIMEOUT 5
+#define RAND_STRING_LEN 10
+const int32_t HEADER_LENGTH = 17;
+static int32_t synch_counter = 2;
+//static int32_t transactioID = 0;
+
+
+#define MAXBUF          1024
+
+enum TypeIdValues {
+    // Do not use IDs 5 and 6 which are used by .NET
+    // ManagedObject and ManagedObjectXml. If those are
+    // required then change those in GemfireTypeIdsM.hpp
+
+    // keep the following in alphabetical order please.
+    Properties = 11,
+    BooleanArray = 26,
+    CharArray = 27,
+    RegionAttributes = 30, // because there's no equivalence in java
+    CacheableUndefined = 31,
+    Struct = 32,
+    NullObj = 41,
+    CacheableString = 42,
+    CacheableBytes = 46,
+    CacheableInt16Array = 47,
+    CacheableInt32Array = 48,
+    CacheableInt64Array = 49,
+    CacheableFloatArray = 50,
+    CacheableDoubleArray = 51,
+    CacheableObjectArray = 52,
+    CacheableBoolean = 53,
+    CacheableWideChar = 54,
+    CacheableByte = 55,
+    CacheableInt16 = 56,
+    CacheableInt32 = 57,
+    CacheableInt64 = 58,
+    CacheableFloat = 59,
+    CacheableDouble = 60,
+    CacheableDate = 61,
+    CacheableFileName = 63,
+    CacheableStringArray = 64,
+    CacheableArrayList = 65,
+    CacheableHashSet = 66,
+    CacheableHashMap = 67,
+    CacheableTimeUnit = 68,
+    CacheableNullString = 69,
+    CacheableHashTable = 70,
+    CacheableVector = 71,
+    CacheableIdentityHashMap = 72,
+    CacheableLinkedHashSet = 73,
+    CacheableStack = 74,
+    CacheableASCIIString = 87,
+    CacheableASCIIStringHuge = 88,
+    CacheableStringHuge = 89
+};
+enum IdValues {
+    // keep the following in alphabetical order please.
+    ObjectTypeImpl = -61,
+    StructTypeImpl = -60,
+    CollectionTypeImpl = -59,
+    FixedIDDefault = 0,
+    FixedIDByte = 1,
+    FixedIDShort = 2,
+    FixedIDInt = 3,
+    FixedIDNone = 4,
+    CacheableToken = 14, // because there's no equivalence in java
+    CacheableObjectPartList = 25,
+    EventId = 36,
+    InterestResultPolicy = 37,
+    ClientProxyMembershipId = 38,
+    CacheableUserData4 = 37,
+    CacheableUserData2 = 38,
+    CacheableUserData = 39,
+    CacheableUserClass = 40,
+    Class = 43,
+    JavaSerializable = 44,
+    DataSerializable = 45,
+    InternalDistributedMember = 92,
+    EntryEventImpl = 105,
+    RegionEventImpl = 108,
+    ClientHealthStats = -126,
+    GatewayEventCallbackArgument = -56, // 0xC8
+    ClientConnectionRequest = -53,
+    ClientConnectionResponse = -50,
+    QueueConnectionRequest = -52,
+    QueueConnectionResponse = -49,
+    LocatorListRequest = -54,
+    LocatorListResponse = -51,
+    GetAllServersRequest = -43,
+    GetAllServersResponse = -42,
+    ClientReplacementRequest= -48
+};
+typedef enum {
+    /* Server couldn't read message; handle it like a server side
+       exception that needs retries */
+    INVALID = -1,
+    REQUEST = 0,
+    RESPONSE /* 1 */,
+    EXCEPTION /* 2 */,
+    REQUEST_DATA_ERROR /* 3 */,
+    DATA_NOT_FOUND_ERROR /* 4 Not in use */,
+    PING /* 5 */,
+    REPLY /* 6 */,
+    PUT /* 7 */,
+    PUT_DATA_ERROR /* 8 */,
+    DESTROY /* 9 */,
+    DESTROY_DATA_ERROR /* 10 */,
+    DESTROY_REGION /* 11 */,
+    DESTROY_REGION_DATA_ERROR /* 12 */,
+    CLIENT_NOTIFICATION /* 13 */,
+    UPDATE_CLIENT_NOTIFICATION /* 14 */,
+    LOCAL_INVALIDATE /* 15 */,
+    LOCAL_DESTROY /* 16 */,
+    LOCAL_DESTROY_REGION /* 17 */,
+    CLOSE_CONNECTION /* 18 */,
+    PROCESS_BATCH /* 19 */,
+    REGISTER_INTEREST /* 20 */,
+    REGISTER_INTEREST_DATA_ERROR /* 21 */,
+    UNREGISTER_INTEREST /* 22 */,
+    UNREGISTER_INTEREST_DATA_ERROR /* 23 */,
+    REGISTER_INTEREST_LIST /* 24 */,
+    UNREGISTER_INTEREST_LIST /* 25 */,
+    UNKNOWN_MESSAGE_TYPE_ERROR /* 26 */,
+    LOCAL_CREATE /* 27 */,
+    LOCAL_UPDATE /* 28 */,
+    CREATE_REGION /* 29 */,
+    CREATE_REGION_DATA_ERROR /* 30 */,
+    MAKE_PRIMARY /* 31 */,
+    RESPONSE_FROM_PRIMARY /* 32 */,
+    RESPONSE_FROM_SECONDARY /* 33 */,
+    QUERY /* 34 */,
+    QUERY_DATA_ERROR /* 35 */,
+    CLEAR_REGION /* 36 */,
+    CLEAR_REGION_DATA_ERROR /* 37 */,
+    CONTAINS_KEY /* 38 */,
+    CONTAINS_KEY_DATA_ERROR /* 39 */,
+    KEY_SET /* 40 */,
+    KEY_SET_DATA_ERROR /* 41 */,
+    EXECUTECQ_MSG_TYPE /* 42 */,
+    EXECUTECQ_WITH_IR_MSG_TYPE /*43 */,
+    STOPCQ_MSG_TYPE /*44*/,
+    CLOSECQ_MSG_TYPE /*45 */,
+    CLOSECLIENTCQS_MSG_TYPE /*46*/,
+    CQDATAERROR_MSG_TYPE /*47 */,
+    GETCQSTATS_MSG_TYPE /*48 */,
+    MONITORCQ_MSG_TYPE /*49 */,
+    CQ_EXCEPTION_TYPE /*50 */,
+    REGISTER_INSTANTIATORS = 51 /* 51 */,
+    PERIODIC_ACK = 52 /* 52 */,
+    CLIENT_READY /* 53 */,
+    CLIENT_MARKER /* 54 */,
+    INVALIDATE_REGION /* 55 */,
+    PUTALL /* 56 */,
+    GET_ALL = 57 /* 57 */,
+    GET_ALL_DATA_ERROR /* 58 */,
+    EXECUTE_REGION_FUNCTION = 59 /* 59 */,
+    EXECUTE_REGION_FUNCTION_RESULT /* 60 */,
+    EXECUTE_REGION_FUNCTION_ERROR /* 61 */,
+    EXECUTE_FUNCTION /* 62 */,
+    EXECUTE_FUNCTION_RESULT /* 63 */,
+    EXECUTE_FUNCTION_ERROR /* 64 */,
+    CLIENT_REGISTER_INTEREST = 65 /* 65 */,
+    CLIENT_UNREGISTER_INTEREST = 66,
+    REGISTER_DATASERIALIZERS = 67,
+    REQUEST_EVENT_VALUE = 68,
+    REQUEST_EVENT_VALUE_ERROR = 69, /*69*/
+    PUT_DELTA_ERROR = 70, /*70*/
+    GET_CLIENT_PR_METADATA = 71, /*71*/
+    RESPONSE_CLIENT_PR_METADATA = 72, /*72*/
+    GET_CLIENT_PARTITION_ATTRIBUTES = 73, /*73*/
+    RESPONSE_CLIENT_PARTITION_ATTRIBUTES =74, /*74*/
+    GET_CLIENT_PR_METADATA_ERROR = 75, /*75*/
+    GET_CLIENT_PARTITION_ATTRIBUTES_ERROR = 76, /*76*/
+    USER_CREDENTIAL_MESSAGE = 77,
+    REMOVE_USER_AUTH = 78, 
+    QUERY_WITH_PARAMETERS = 80
+
+} MsgType;
+/*
+int32_t incTransactionID()
+{
+    return 1;//transactioID++;
+}
+*/
+int64_t getAndIncEid(CONTEXT* context)
+{
+    return context->eidSeq++;
+}
+
+void printData(uint8_t* buf, int32_t len)
+{
+    int32_t i;
+    printf("\n");
+    for(i = 0; i < len; i++)
+    {
+        printf("%d ", buf[i]);
+    }
+    printf("\n");
+}
+
+void recieveData(CONTEXT* context, Buffer* buf, uint32_t len, int32_t* resultcode)
+{
+    time_t startTime = time(NULL); 
+    uint32_t origLen = len;
+
+    while(len > 0 && (time(NULL) - startTime) < TIMEOUT )
+    {
+        int8_t buffer[MAXBUF];
+        bzero(buffer, MAXBUF);
+        int32_t recLen = recv(context->sockfd, buffer, len > MAXBUF?MAXBUF:len, 0);
+        if(recLen > 0)
+        {
+            len -= recLen;
+            writeBytesOnly(buf, buffer, recLen);
+        } else if(recLen == 0)
+        {
+            *resultcode = CONNECTION_ERROR;
+            //printf("closed connection");
+            return;
+        }
+    }
+
+    //printf("recieve");
+    //printData(getBuffer(buf), getBufferLength(buf));
+
+    if(len == 0)
+        rewindCursor(buf, origLen);
+    *resultcode =  (len > 0)?CONNECTION_ERROR:NO_ERROR;
+}
+
+
+
+void sendData(CONTEXT* context, uint8_t* buf, int32_t len, int32_t* resultcode)
+{
+    time_t startTime = time(NULL); 
+    uint32_t sentLen = 0;
+    //printf("send[%d]", len);
+    //printData(buf, len);
+    while(len > 0 && (time(NULL) - startTime) < TIMEOUT )
+    {
+        int32_t sendLen = send(context->sockfd, (buf + sentLen), len, 0);
+        //printf("sent %d bytes\n", sendLen);
+        if(sendLen > 0)
+        {
+            len -= sendLen;
+            sentLen += sendLen;
+        } else if(sendLen == 0)
+        {
+            *resultcode = CONNECTION_ERROR;
+            //printf("closed connection");
+            return;
+        }
+
+    }
+
+    *resultcode = (len > 0)?CONNECTION_ERROR:NO_ERROR;
+}
+
+CONTEXT* createContext(char* host, char* port)
+{
+
+    struct addrinfo hints;
+    struct addrinfo *result, *rp;
+    int sfd, s;
+
+    /* Obtain address(es) matching host/port */
+
+    memset(&hints, 0, sizeof(struct addrinfo));
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+    hints.ai_flags = 0;
+    hints.ai_protocol = 0;
+
+    s = getaddrinfo(host, port, &hints, &result);
+    if (s != 0) {
+        return NULL;
+    }
+
+    /* getaddrinfo() returns a list of address structures.
+       Try each address until we successfully connect(2).
+       If socket(2) (or connect(2)) fails, we (close the socket
+       and) try the next address. */
+
+    for (rp = result; rp != NULL; rp = rp->ai_next) {
+        sfd = socket(rp->ai_family, rp->ai_socktype,
+                rp->ai_protocol);
+        struct timeval tv;
+        int32_t timeout=1000;
+
+        tv.tv_sec = timeout / 1000 ;
+        tv.tv_usec = ( timeout % 1000) * 1000  ;
+
+        setsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char 
+                    *)&tv, sizeof tv);
+        if (sfd == -1)
+            continue;
+
+        if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1)
+            break;                  /* Success */
+
+        close(sfd);
+    }
+
+    if (rp == NULL) {               /* No address succeeded */
+        //fprintf(stderr, "Could not connect\n");
+        //exit(EXIT_FAILURE);
+        return NULL;
+    }
+
+    CONTEXT* context = (CONTEXT*)malloc(sizeof(CONTEXT));
+    context->sockfd = sfd;
+    context->eidSeq = 0;
+
+    return context;
+}
+
+void createRandString(char *randString)
+{
+    const char selectChars[] =
+        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
+    const uint32_t numChars = (sizeof(selectChars) / sizeof(char)) - 1;
+    strcpy(randString, "GFNative_");
+    uint32_t startIndex = strlen(randString);
+    uint32_t seed = getpid() + time(NULL);
+    srand(seed);
+    uint32_t index;
+    for (index = 0; index < RAND_STRING_LEN; ++index) {
+        randString[startIndex + index] = selectChars[rand() % numChars];
+    }
+    randString[startIndex + RAND_STRING_LEN] = '\0';
+}
+
+void writeClientProxyMembershipId(Buffer* buf)
+{
+    struct hostent *host;     /* host information */
+    //struct in_addr h_addr;    /* internet address */
+    char hostName[1024];
+    gethostname(hostName, 1023);
+    host = gethostbyname(hostName);
+    char randString[1024];
+    createRandString(randString);
+
+    Buffer memId;
+    initBuf(&memId);
+
+    writeByte(&memId, (int8_t)FixedIDByte);
+    writeByte(&memId, (int8_t)InternalDistributedMember);
+    writeArrayLen(&memId, ADDRSIZE);
+    writeInt(&memId, (int32_t)(*(host->h_addr_list[0])));
+    //m_memID.writeInt((int32_t)hostPort);
+    writeInt(&memId, (int32_t)synch_counter);
+    writeByte(&memId, (int8_t)CacheableASCIIString);
+    writeASCII(&memId, host->h_name  );
+    writeByte(&memId, (int8_t)0); // splitbrain flags
+
+    writeInt(&memId, (int32_t)DCPORT);
+
+    writeInt(&memId, (int32_t)getpid());
+    writeByte(&memId, (int8_t)VMKIND);
+    writeArrayLen(&memId, ROLEARRLENGTH);
+    writeByte(&memId, (int8_t)CacheableASCIIString);
+    writeASCII(&memId, "default_GemfireDS");
+    writeByte(&memId, (int8_t)CacheableASCIIString);
+    writeASCII(&memId, randString);
+    writeByte(&memId, (int8_t)CacheableASCIIString);
+    writeASCII(&memId, "");
+    writeInt(&memId, (int32_t)300);
+    writeUnsignedBytes(buf, getBuffer(&memId), getBufferLength(&memId));
+
+
+    clearBuf(&memId);
+}
+
+void doHandshake(CONTEXT* context, int32_t* resultcode)
+{
+    Buffer request;
+    initBuf(&request);
+    Buffer reply;
+    initBuf(&reply);
+    *resultcode = NO_ERROR;
+
+    writeByte(&request, (int8_t)CLIENT_TO_SERVER );
+    writeByte(&request, (int8_t)VERSION_ORDINAL_651);
+    writeByte(&request, (int8_t)REPLY_OK);
+    writeInt(&request, (int32_t)0x7fffffff - 10000 );
+    // Write header for byte FixedID since GFE 5.7
+    writeByte(&request, (int8_t)FixedIDByte);
+    //Writing byte for ClientProxyMembershipID class id=38 as registered on the java server.
+    writeByte(&request, (int8_t)ClientProxyMembershipId);
+    /* calc memId */
+    writeClientProxyMembershipId(&request);
+    // writeBytes(&request, (int8_t *)memIdBuffer, memIdBufferLength);
+    writeInt(&request,(int32_t)1);
+    writeByte(&request, (int8_t)CONFLATEBYTE);
+    writeUnsigned(&request, (uint8_t)SECURITY_CREDENTIALS_NONE);
+
+    SEND_DATA(context, request, reply, resultcode)
+
+        //sendData(context, getBuffer(&buf), getBufferLength(&buf));
+        /*---Get "Hello?"---*/
+        //int recLen = 1;
+        //    recieveData(context, &reply, 7);
+        RECIEVE_DATA(context, request, reply, 7, resultcode)
+
+        int8_t acceptance_code;
+    int8_t serverQueueStatus;
+    int8_t recvMsgLenByte;
+    int32_t queueSize;
+    readByte(&reply, &acceptance_code);
+    readByte(&reply, &serverQueueStatus);
+    readInt(&reply, &queueSize);
+    readByte(&reply, &recvMsgLenByte);
+    int32_t recvMsgLen = recvMsgLenByte;
+    if (recvMsgLen== -2) {
+        int16_t recvMsgLenShort = 0;
+        //        recieveData(context, &reply, 2);
+        RECIEVE_DATA(context, request, reply, 2, resultcode)
+            readShort(&reply, &recvMsgLenShort);
+        recvMsgLen = recvMsgLenShort;
+    }
+    else if (recvMsgLen == -3) {
+        //        recieveData(context, &reply, 4);
+        RECIEVE_DATA(context, request, reply, 4, resultcode)
+            readInt(&reply, &recvMsgLen);
+    }
+    //recieveData(context, &reply, recvMsgLen);
+    RECIEVE_DATA(context, request, reply, recvMsgLen, resultcode)
+        advanceCursor(&reply, recvMsgLen);
+    uint16_t recvMsgLen2 = 0;
+    //recieveData(context, &reply, 2);
+    RECIEVE_DATA(context, request, reply,2, resultcode)
+        readUnsignedShort(&reply, &recvMsgLen2);
+    //recieveData(context, &reply, recvMsgLen2);
+    RECIEVE_DATA(context, request, reply, recvMsgLen2, resultcode)
+        advanceCursor(&reply, recvMsgLen2);
+    int8_t isDeltaEnabledOnServer;
+    //recieveData(context, &reply, 1);
+    RECIEVE_DATA(context, request, reply, 1, resultcode)
+        readByte(&reply, &isDeltaEnabledOnServer);
+    if(acceptance_code != REPLY_OK)
+    {
+        *resultcode = HANDSHAKE_ERROR;
+    }
+    clearBuf(&request);
+    clearBuf(&reply);
+}
+
+
+void gf_write_header(Buffer* buf, uint32_t msgType, uint32_t numOfParts)
+{
+
+    writeInt(buf, (int32_t)msgType);
+    writeInt(buf, (int32_t)0); // write a dummy message len('0' here). At the end write the length at the (buffer + 4) offset.
+    writeInt(buf, (int32_t)numOfParts);
+    writeInt(buf, (int32_t)1);
+    writeByte(buf, (int8_t)0x0);
+}
+
+void write_region_part(Buffer* buf, char* regionName)
+{
+    int32_t len = strlen(regionName);
+    writeInt(buf, len);
+    writeByte(buf, (int8_t)0); // isObject = 0
+    writeBytesOnly(buf, (int8_t *)regionName, len);
+}
+
+void write_null_object(Buffer* buf)
+{
+    //write size
+    writeInt(buf, (int32_t)1);
+    //write isobject
+    writeByte(buf, (int8_t)1);
+    //write actual object
+    writeByte(buf, (int8_t)NullObj);
+}
+
+void write_int_part(Buffer* buf,  int32_t intValue)
+{
+    writeInt(buf, (int32_t) 4);
+    writeByte(buf, (int8_t) 0);
+    writeInt(buf, intValue);
+}
+
+void write_string_part(Buffer* buf, const char* strValue)
+{
+    //write size
+    writeInt(buf, (int32_t)0);
+    //write isobject
+    writeByte(buf, (int8_t)1);
+    int32_t before = getBufferLength(buf);
+    writeByte(buf, (int8_t)CacheableASCIIString);
+    writeASCII(buf, strValue);
+    int32_t after = getBufferLength(buf);
+    int32_t sizeOfObj = after - before;
+    rewindCursor(buf, sizeOfObj + 1 + 4);
+    writeInt(buf, sizeOfObj);
+    advanceCursor(buf, sizeOfObj + 1);
+}
+
+void write_bool_part(Buffer* buf, int8_t boolValue)
+{
+    //write size
+    writeInt(buf, (int32_t)2);
+    //write isobject
+    writeByte(buf, (int8_t)1);
+    writeByte(buf, (int8_t)CacheableBoolean);
+    writeByte(buf, (int8_t)boolValue);
+}
+
+void write_bytes_part(Buffer* buf, const int8_t* bytes, int32_t len)
+{
+    //write size
+    writeInt(buf, (int32_t)1);
+    //write isobject
+    writeByte(buf, (int8_t)0);
+    int32_t before = getBufferLength(buf);
+    writeBytesOnly(buf, bytes, len);
+    int32_t after = getBufferLength(buf);
+    int32_t sizeOfObj = after - before;
+    rewindCursor(buf, sizeOfObj + 1 + 4);
+    writeInt(buf, sizeOfObj);
+    advanceCursor(buf, sizeOfObj + 1);
+}
+
+void write_id_part(CONTEXT* context, Buffer* buf)
+{
+    // ARB: Write EventId threadid and seqno.
+    int32_t idsBufferLength = 18;
+    writeInt(buf, idsBufferLength);
+    writeUnsigned(buf, (uint8_t) 0);
+    char longCode = 3;
+    writeUnsigned(buf, (uint8_t) longCode);
+    writeLong(buf, pthread_self());
+    writeUnsigned(buf, (uint8_t) longCode);
+    writeLong(buf, getAndIncEid(context));
+}
+
+void write_message_length(Buffer* buf)
+{
+    uint32_t totalLen = getBufferLength(buf);
+    uint32_t g_headerLen = 17;
+    uint32_t msgLen = totalLen - g_headerLen;
+    //printf("msglen: %d\n", msgLen);
+    rewindCursor(buf, totalLen - 4); // msg len is written after the msg type which is of 4 bytes ...
+    writeInt(buf, (int32_t)msgLen);
+    advanceCursor(buf, totalLen - 8); // after writing 4 bytes for msg len you are already 8 bytes ahead from the beginning.
+}
+
+void gf_put(CONTEXT * context, const char * uuid, const int8_t * data, int32_t len, int32_t * resultcode)
+{
+    Buffer request;
+    initBuf(&request);
+    Buffer reply;
+    initBuf(&reply);
+    *resultcode = NO_ERROR;
+
+    gf_write_header(&request, PUT, 7);
+    write_region_part(&request, REGION_NAME);
+    write_null_object(&request);
+    write_int_part(&request, 0);
+    write_string_part(&request, uuid);
+    write_bool_part(&request, 0);
+    write_bytes_part(&request, data, len);
+    write_id_part(context, &request);
+    write_message_length(&request);
+
+    SEND_DATA(context, request, reply, resultcode)
+        // int err = sendData(context, getBuffer(&buf), getBufferLength(&buf));
+        /*---Get "Hello?"---*/
+        //int recLen = 1;
+
+        RECIEVE_DATA(context, request, reply, HEADER_LENGTH, resultcode)
+        //err = recieveData(context, &reply, HEADER_LENGTH);
+        //printf("put error: %d\n", *resultcode);
+    int32_t msgType;
+    int32_t msgLen;
+
+    readInt(&reply, &msgType);
+    readInt(&reply, &msgLen);
+    advanceCursor(&reply, HEADER_LENGTH - 8);
+
+    RECIEVE_DATA(context, request, reply, msgLen, resultcode)
+        if(msgType != REPLY)
+        {
+            *resultcode = OPERATION_ERROR;
+            clearBuf(&request);
+            clearBuf(&reply);
+        }
+    //err = recieveData(context, &reply, msgLen);
+}
+
+void gf_get(CONTEXT * context, const char * uuid, int8_t* data, uint32_t len, int32_t * resultcode)
+{
+    Buffer request;
+    initBuf(&request);
+    Buffer reply;
+    initBuf(&reply);
+    *resultcode = NO_ERROR;
+
+    gf_write_header(&request, REQUEST, 2);
+    write_region_part(&request, REGION_NAME);
+    write_string_part(&request, uuid);
+    write_message_length(&request);
+
+    SEND_DATA(context, request, reply, resultcode)
+
+        //int err = sendData(context, getBuffer(&buf), getBufferLength(&buf));
+
+        RECIEVE_DATA(context, request, reply, HEADER_LENGTH, resultcode)
+        //err = recieveData(context, &reply, HEADER_LENGTH);
+        int32_t msgType;
+    int32_t msgLen;
+
+    readInt(&reply, &msgType);
+    readInt(&reply, &msgLen);
+    advanceCursor(&reply, HEADER_LENGTH - 8);
+
+    //err = recieveData(context, &reply, msgLen);
+    RECIEVE_DATA(context, request, reply, msgLen, resultcode)
+        if(msgType != RESPONSE)
+        {
+            *resultcode = OPERATION_ERROR;
+            clearBuf(&request);
+            clearBuf(&reply);
+            return;
+        }
+    uint32_t dataLen;
+    readUnsignedInt(&reply, &dataLen);
+    int8_t isObj;
+    readByte(&reply, &isObj);
+    memcpy(data, getCursor(&reply), dataLen);
+}
+
+void gf_destroy(CONTEXT * context, const char * uuid, int32_t * resultcode)
+{
+    Buffer request;
+    initBuf(&request);
+    Buffer reply;
+    initBuf(&reply);
+    *resultcode = NO_ERROR;
+
+    gf_write_header(&request, DESTROY, 5);
+    write_region_part(&request, REGION_NAME);
+    write_string_part(&request, uuid);
+    write_null_object(&request);
+    write_null_object(&request);
+    write_id_part(context, &request);
+    write_message_length(&request);
+
+    SEND_DATA(context, request, reply, resultcode)
+
+        //    int err = sendData(context, getBuffer(&buf), getBufferLength(&buf));
+        /*---Get "Hello?"---*/
+        //int recLen = 1;
+
+        RECIEVE_DATA(context, request, reply, HEADER_LENGTH, resultcode)
+
+        //    err = recieveData(context, &reply, HEADER_LENGTH);
+        //printf("destroy error: %d\n", *resultcode);
+    int32_t msgType;
+    int32_t msgLen;
+
+    readInt(&reply, &msgType);
+    readInt(&reply, &msgLen);
+    advanceCursor(&reply, HEADER_LENGTH - 8);
+
+    //    err = recieveData(context, &reply, msgLen);
+    RECIEVE_DATA(context, request, reply, msgLen, resultcode)
+        if(msgType != REPLY)
+        {
+            *resultcode = OPERATION_ERROR;
+            clearBuf(&request);
+            clearBuf(&reply);
+        }
+}
+
+void gf_ping(CONTEXT* context, int32_t* resultcode)
+{
+    Buffer request;
+    initBuf(&request);
+    Buffer reply;
+    initBuf(&reply);
+    *resultcode = NO_ERROR;
+
+    writeInt(&request, (int32_t)PING);
+    writeInt(&request, (int32_t)0);// 17 is fixed message len ...  PING only has a header.
+    writeInt(&request, (int32_t)0);// Number of parts.
+    writeInt(&request, (int32_t)0);
+    writeByte(&request, (int8_t)0);// Early ack is '0'.
+    SEND_DATA(context, request, reply, resultcode)
+        RECIEVE_DATA(context, request, reply, HEADER_LENGTH, resultcode)
+
+        int32_t msgType;
+    int32_t msgLen;
+
+    readInt(&reply, &msgType);
+    readInt(&reply, &msgLen);
+    advanceCursor(&reply, HEADER_LENGTH - 8);
+
+    //    err = recieveData(context, &reply, msgLen);
+    RECIEVE_DATA(context, request, reply, msgLen, resultcode)
+        if(msgType != REPLY)
+        {
+            *resultcode = OPERATION_ERROR;
+            clearBuf(&request);
+            clearBuf(&reply);
+        }
+}
+
+void gf_disconnect(CONTEXT * context, int32_t * resultcode)
+{
+    Buffer request;
+    initBuf(&request);
+    Buffer reply;
+    initBuf(&reply);
+    *resultcode = NO_ERROR;
+
+    writeInt(&request, (int32_t)CLOSE_CONNECTION);
+    writeInt(&request,(int32_t)6);
+    writeInt(&request,(int32_t)1);// Number of parts.
+    //int32_t txId = TcrMessage::m_transactionId++;
+    writeInt(&request,(int32_t)0);
+    writeByte(&request, (int8_t)0);// Early ack is '0'.
+    // last two parts are not used ... setting zero in both the parts.
+    writeInt(&request,(int32_t)1); // len is 1
+    writeByte(&request,(int8_t)0);// is obj is '0'.
+    // cast away constness here since we want to modify this
+    writeByte(&request,(int8_t)0);// keepalive is '0'. 
+    SEND_DATA(context, request, reply, resultcode)
+
+        int32_t error = close(context->sockfd);
+    if(error == 0) {
+        *resultcode = NO_ERROR;
+    } else {
+        *resultcode = CONNECTION_ERROR;
+    }
+
+    free(context);
+}
+
+CONTEXT* gf_connect(char* host, char* port, int32_t* resultcode)
+{
+    CONTEXT* context = createContext(host, port);
+
+    if(context == NULL)
+    {
+        *resultcode = CONNECTION_ERROR;
+        //printf("CONNECTION ERROR");
+    } else {
+        doHandshake(context, resultcode);
+        if(*resultcode != NO_ERROR)
+        {
+            int32_t error;
+            //printf("HANDSHAKE ERROR");
+            *resultcode = HANDSHAKE_ERROR;
+            gf_disconnect(context, &error);
+            context = NULL;
+        }
+    }
+
+    return context;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/cclient/src/gf_client.h
----------------------------------------------------------------------
diff --git a/geode-client-native/src/cclient/src/gf_client.h b/geode-client-native/src/cclient/src/gf_client.h
new file mode 100644
index 0000000..1728d2e
--- /dev/null
+++ b/geode-client-native/src/cclient/src/gf_client.h
@@ -0,0 +1,88 @@
+#ifndef __C_GEMFIRE_CLIENT_H__
+#define __C_GEMFIRE_CLIENT_H__
+
+#include <stdint.h>
+
+typedef struct 
+{
+    int32_t sockfd;
+    int64_t eidSeq;
+} CONTEXT;
+
+
+enum error_codes {
+    NO_ERROR,
+    CONNECTION_ERROR = 1,
+    HANDSHAKE_ERROR,
+    OPERATION_ERROR
+};
+
+/*
+ * Establish a connection with the specified GemFire endpoint.
+ *
+ * @param host the hostname to connect.
+ * @param port the port to connect.
+ * @param resultcode the result code returned to the caller.
+ * @returns a pointer to the context required for further operations.
+ */
+
+CONTEXT* gf_connect(char * host, char* port, int32_t * resultcode);
+
+/*
+ * Close down a connection previously established with a GemFire endpoint.
+ *
+ * @param CONTEXT the context of the connection to close.
+ * @param resultcode the result code returned to the caller.
+ */
+
+void gf_disconnect(CONTEXT * context, int32_t * resultcode);
+
+/*
+ * Store data associated with the specified UUID into the GemFire system.
+ * Callee does not free the data.
+ *
+ * @param CONTEXT the context of the connection to use.
+ * @param region the GemFire region where the data goes.
+ * @param uuid the UUID key associated with the data.
+ * @param data a pointer to the data to store.
+ * @param len the byte length of the data.
+ * @param resultcode the result code returned to the caller.
+ */
+
+void gf_put(CONTEXT * context, const char * uuid, const int8_t * data, int32_t len, int32_t * resultcode);
+
+/*
+ * Read data associated with the specified UUID from GemFire.
+ * Caller must free the returned data.
+ *
+ * @param CONTEXT the context of the connection to use.
+ * @param region the GemFire region from where the data is retrieved.
+ * @param uuid the UUID key associated with the data.
+ * @param len the byte length of the data being returned.
+ * @param resultcode the result code returned to the caller.
+ */
+
+void gf_get(CONTEXT * context, const char * uuid, int8_t* data, uint32_t len, int32_t * resultcode);
+
+/*
+ * Destroy the data associated with the specified UUID key from the GemFire system.
+ *
+ * @param CONTEXT the context of the connection to use.
+ * @param region the GemFire region from where the data is cleared.
+ * @param uuid the UUID key associated with the data.
+ * @param resultcode the result code returned to the caller.
+ */
+
+void gf_destroy(CONTEXT * context, const char * uuid, int32_t * resultcode);
+
+/*
+ * Send a ping message to the server 
+ *
+ * @param CONTEXT the context of the connection to use.
+ * @param resultcode the result code returned to the caller.
+ */
+
+void gf_ping(CONTEXT* context, int32_t* resultcode);
+
+#endif
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/AttributesFactoryM.cpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/AttributesFactoryM.cpp b/geode-client-native/src/clicache/AttributesFactoryM.cpp
new file mode 100644
index 0000000..b548380
--- /dev/null
+++ b/geode-client-native/src/clicache/AttributesFactoryM.cpp
@@ -0,0 +1,270 @@
+/*=========================================================================
+ * 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 "AttributesFactoryM.hpp"
+#include "RegionM.hpp"
+#include "impl/ManagedCacheLoader.hpp"
+#include "impl/ManagedCacheWriter.hpp"
+#include "impl/ManagedCacheListener.hpp"
+#include "impl/ManagedPartitionResolver.hpp"
+#include "impl/ManagedFixedPartitionResolver.hpp"
+#include "RegionAttributesM.hpp"
+#include "PropertiesM.hpp"
+#include "ICacheLoader.hpp"
+#include "ICacheWriter.hpp"
+#include "ICacheListener.hpp"
+#include "IPartitionResolver.hpp"
+#include "IFixedPartitionResolver.hpp"
+#include "impl/SafeConvert.hpp"
+
+
+using namespace System;
+
+namespace GemStone
+{
+  namespace GemFire
+  {
+    namespace Cache
+    {
+
+      AttributesFactory::AttributesFactory( RegionAttributes^ regionAttributes )
+        : UMWrap( )
+      {
+        gemfire::RegionAttributesPtr attribptr(
+          GetNativePtr<gemfire::RegionAttributes>( regionAttributes ) );
+        SetPtr( new gemfire::AttributesFactory( attribptr ), true );
+      }
+
+      // CALLBACKS
+
+      void AttributesFactory::SetCacheLoader( ICacheLoader^ cacheLoader )
+      {
+        gemfire::CacheLoaderPtr loaderptr;
+        if ( cacheLoader != nullptr ) {
+          loaderptr = new gemfire::ManagedCacheLoader( cacheLoader );
+        }
+        NativePtr->setCacheLoader( loaderptr );
+      }
+
+      void AttributesFactory::SetCacheWriter( ICacheWriter^ cacheWriter )
+      {
+        gemfire::CacheWriterPtr writerptr;
+        if ( cacheWriter != nullptr ) {
+          writerptr = new gemfire::ManagedCacheWriter( cacheWriter );
+        }
+        NativePtr->setCacheWriter( writerptr );
+      }
+
+      void AttributesFactory::SetCacheListener( ICacheListener^ cacheListener )
+      {
+        gemfire::CacheListenerPtr listenerptr;
+        if ( cacheListener != nullptr ) {
+          listenerptr = new gemfire::ManagedCacheListener( cacheListener );
+        }
+        NativePtr->setCacheListener( listenerptr );
+      }
+
+      void AttributesFactory::SetPartitionResolver( IPartitionResolver^ partitionresolver )
+      {
+        gemfire::PartitionResolverPtr resolverptr;
+        if ( partitionresolver != nullptr ) {
+          IFixedPartitionResolver^ resolver = dynamic_cast<IFixedPartitionResolver^>(partitionresolver);
+          if (resolver != nullptr) {
+            resolverptr = new gemfire::ManagedFixedPartitionResolver( resolver );            
+          }
+          else {
+            resolverptr = new gemfire::ManagedPartitionResolver( partitionresolver );
+          } 
+        }
+        NativePtr->setPartitionResolver( resolverptr );
+      }
+
+      void AttributesFactory::SetCacheLoader( String^ libPath, String^ factoryFunctionName )
+      {
+        ManagedString mg_libpath( libPath );
+        ManagedString mg_factoryFunctionName( factoryFunctionName );
+
+        NativePtr->setCacheLoader( mg_libpath.CharPtr,
+          mg_factoryFunctionName.CharPtr );
+      }
+
+      void AttributesFactory::SetCacheWriter( String^ libPath, String^ factoryFunctionName )
+      {
+        ManagedString mg_libpath( libPath );
+        ManagedString mg_factoryFunctionName( factoryFunctionName );
+
+        NativePtr->setCacheWriter( mg_libpath.CharPtr,
+          mg_factoryFunctionName.CharPtr );
+      }
+
+      void AttributesFactory::SetCacheListener( String^ libPath, String^ factoryFunctionName )
+      {
+        ManagedString mg_libpath( libPath );
+        ManagedString mg_factoryFunctionName( factoryFunctionName );
+
+        NativePtr->setCacheListener( mg_libpath.CharPtr,
+          mg_factoryFunctionName.CharPtr );
+      }
+
+      void AttributesFactory::SetPartitionResolver( String^ libPath, String^ factoryFunctionName )
+      {
+        ManagedString mg_libpath( libPath );
+        ManagedString mg_factoryFunctionName( factoryFunctionName );
+
+        NativePtr->setPartitionResolver( mg_libpath.CharPtr,
+          mg_factoryFunctionName.CharPtr );
+      }
+
+      // EXPIRATION ATTRIBUTES
+
+      void AttributesFactory::SetEntryIdleTimeout( ExpirationAction action, uint32_t idleTimeout )
+      {
+        NativePtr->setEntryIdleTimeout(
+          static_cast<gemfire::ExpirationAction::Action>( action ), idleTimeout );
+      }
+
+      void AttributesFactory::SetEntryTimeToLive( ExpirationAction action, uint32_t timeToLive )
+      {
+        NativePtr->setEntryTimeToLive(
+          static_cast<gemfire::ExpirationAction::Action>( action ), timeToLive );
+      }
+
+      void AttributesFactory::SetRegionIdleTimeout( ExpirationAction action, uint32_t idleTimeout )
+      {
+        NativePtr->setRegionIdleTimeout(
+          static_cast<gemfire::ExpirationAction::Action>( action ), idleTimeout );
+      }
+
+      void AttributesFactory::SetRegionTimeToLive( ExpirationAction action, uint32_t timeToLive )
+      {
+        NativePtr->setRegionTimeToLive(
+          static_cast<gemfire::ExpirationAction::Action>( action ), timeToLive );
+      }
+
+      // PERSISTENCE
+
+      void AttributesFactory::SetPersistenceManager( String^ libPath,
+        String^ factoryFunctionName )
+      {
+        SetPersistenceManager( libPath, factoryFunctionName, nullptr );
+      }
+
+      void AttributesFactory::SetPersistenceManager( String^ libPath,
+        String^ factoryFunctionName, Properties^ config )
+      {
+        ManagedString mg_libpath( libPath );
+        ManagedString mg_factoryFunctionName( factoryFunctionName );
+        gemfire::PropertiesPtr configptr(
+          GetNativePtr<gemfire::Properties>( config ) );
+
+        NativePtr->setPersistenceManager( mg_libpath.CharPtr,
+          mg_factoryFunctionName.CharPtr, configptr );
+      }
+
+      // DISTRIBUTION ATTRIBUTES
+
+      void AttributesFactory::SetScope( ScopeType scopeType )
+      {
+        NativePtr->setScope(
+          static_cast<gemfire::ScopeType::Scope>( scopeType ) );
+      }
+
+      // STORAGE ATTRIBUTES
+
+      void AttributesFactory::SetClientNotificationEnabled(
+        bool clientNotificationEnabled )
+      {
+        NativePtr->setClientNotificationEnabled( clientNotificationEnabled );
+      }
+
+      void AttributesFactory::SetEndpoints( String^ endpoints )
+      {
+        ManagedString mg_endpoints( endpoints );
+
+        NativePtr->setEndpoints( mg_endpoints.CharPtr );
+      }
+
+      void AttributesFactory::SetPoolName( String^ poolName )
+      {
+        ManagedString mg_poolName( poolName );
+
+        NativePtr->setPoolName( mg_poolName.CharPtr );
+      }
+
+      // MAP ATTRIBUTES
+
+      void AttributesFactory::SetInitialCapacity( int32_t initialCapacity )
+      {
+        _GF_MG_EXCEPTION_TRY
+
+          NativePtr->setInitialCapacity( initialCapacity );
+
+        _GF_MG_EXCEPTION_CATCH_ALL
+      }
+
+      void AttributesFactory::SetLoadFactor( Single loadFactor )
+      {
+        _GF_MG_EXCEPTION_TRY
+
+          NativePtr->setLoadFactor( loadFactor );
+
+        _GF_MG_EXCEPTION_CATCH_ALL
+      }
+
+      void AttributesFactory::SetConcurrencyLevel( int32_t concurrencyLevel )
+      {
+        _GF_MG_EXCEPTION_TRY
+
+          NativePtr->setConcurrencyLevel( concurrencyLevel );
+
+        _GF_MG_EXCEPTION_CATCH_ALL
+      }
+
+      void AttributesFactory::SetLruEntriesLimit( uint32_t entriesLimit )
+      {
+        NativePtr->setLruEntriesLimit( entriesLimit );
+      }
+
+      void AttributesFactory::SetDiskPolicy( DiskPolicyType diskPolicy )
+      {
+        NativePtr->setDiskPolicy(
+          static_cast<gemfire::DiskPolicyType::PolicyType>( diskPolicy ) );
+      }
+
+      void AttributesFactory::SetCachingEnabled( bool cachingEnabled )
+      {
+        NativePtr->setCachingEnabled( cachingEnabled );
+      }
+
+      void AttributesFactory::SetCloningEnabled( bool cloningEnabled )
+      {
+        NativePtr->setCloningEnabled( cloningEnabled );
+      }
+      
+      void AttributesFactory::SetConcurrencyChecksEnabled( bool concurrencyChecksEnabled )
+      {
+        NativePtr->setConcurrencyChecksEnabled( concurrencyChecksEnabled );
+      }
+
+      // FACTORY METHOD 
+
+      RegionAttributes^ AttributesFactory::CreateRegionAttributes( )
+      {
+        _GF_MG_EXCEPTION_TRY
+
+          gemfire::RegionAttributesPtr& nativeptr (
+            NativePtr->createRegionAttributes( ) );
+          return RegionAttributes::Create( nativeptr.ptr( ) );
+
+        _GF_MG_EXCEPTION_CATCH_ALL
+      }
+
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/AttributesFactoryM.hpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/AttributesFactoryM.hpp b/geode-client-native/src/clicache/AttributesFactoryM.hpp
new file mode 100644
index 0000000..a2510e8
--- /dev/null
+++ b/geode-client-native/src/clicache/AttributesFactoryM.hpp
@@ -0,0 +1,517 @@
+/*=========================================================================
+ * 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/AttributesFactory.hpp"
+#include "impl/NativeWrapper.hpp"
+#include "ExpirationActionM.hpp"
+#include "DiskPolicyTypeM.hpp"
+#include "ScopeTypeM.hpp"
+
+#include "ICacheLoader.hpp"
+#include "ICacheWriter.hpp"
+#include "ICacheListener.hpp"
+#include "IPartitionResolver.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+  namespace GemFire
+  {
+    namespace Cache 
+    {
+
+      ref class RegionAttributes;
+      ref class Properties;
+      //interface class ICacheLoader;
+      //interface class ICacheWriter;
+      //interface class ICacheListener;
+      //interface class IPartitionResolver;
+
+
+      /// <summary>
+      /// Factory class to create instances of <see cref="RegionAttributes" />.
+      /// </summary>
+      /// <remarks>
+      /// An <see cref="AttributesFactory" />
+      /// instance maintains state for creating <see cref="RegionAttributes" /> instances.
+      /// The setter methods are used to change the settings that will be used for
+      /// creating the next attributes instance with the <see cref="CreateRegionAttributes" />
+      /// method. If you create a factory with the default constructor, then the
+      /// factory is set up to create attributes with all default settings. You can
+      /// also create a factory by providing a preset <see cref="RegionAttributes" />.
+      /// <para>
+      /// Once a <see cref="RegionAttributes" /> is created, it can only be modified
+      /// after it has been used to create a <see cref="Region" />, and then only by
+      /// using an <see cref="AttributesMutator" /> obtained from the region.
+      /// </para><para>
+      /// <h3>Attributes</h3>
+      /// <h4>Callbacks</h4>
+      /// <dl>
+      /// <dt><see cref="ICacheLoader" /> [<em>default:</em> null]</dt>
+      ///     <dd>User-implemented plug-in for loading data on cache misses.<br />
+      ///        see <see cref="SetCacheLoader" />,
+      ///            <see cref="RegionAttributes.CacheLoader" /></dd>
+      ///
+      /// <dt><see cref="ICacheWriter" /> [<em>default:</em> null]</dt>
+      ///     <dd>User-implemented plug-in for intercepting cache modifications, e.g.
+      ///         for writing to an external data source.<br />
+      ///         see <see cref="SetCacheWriter" />,
+      ///             <see cref="RegionAttributes.CacheWriter" /></dd>
+      ///
+      /// <dt><see cref="ICacheListener" /> [<em>default:</em> null]</dt>
+      ///     <dd>User-implemented plug-in for receiving and handling cache-related events.<br />
+      ///         see <see cref="SetCacheListener" />,
+      ///             <see cref="RegionAttributes.CacheListener" /></dd>
+      ///
+      /// <dt><see cref="IPartitionResolver" /> [<em>default:</em> null]</dt>
+      ///     <dd>User-implemented plug-in for custom partitioning.<br />
+      ///         see <see cref="SetPartitionResolver" />,
+      ///             <see cref="RegionAttributes.PartitionResolver" /></dd>
+      /// </dl>
+      /// <h4>Expiration</h4>
+      /// <dl>
+      /// <dt>RegionTimeToLive [<em>default:</em> no expiration]</dt>
+      ///     <dd>Expiration configuration for the entire region based on the
+      ///     lastModifiedTime ( <see cref="CacheStatistics.LastModifiedTime" /> ).<br />
+      ///         see <see cref="SetRegionTimeToLive" />,
+      ///             <see cref="RegionAttributes.RegionTimeToLive" />,
+      ///             <see cref="AttributesMutator.SetRegionTimeToLive" /></dd>
+      ///
+      /// <dt>RegionIdleTimeout [<em>default:</em> no expiration]</dt>
+      ///     <dd>Expiration configuration for the entire region based on the
+      ///         lastAccessedTime ( <see cref="CacheStatistics.LastAccessedTime" /> ).<br />
+      ///         see <see cref="SetRegionIdleTimeout" />,
+      ///             <see cref="RegionAttributes.RegionIdleTimeout" />,
+      ///             <see cref="AttributesMutator.SetRegionIdleTimeout" /></dd>
+      ///
+      /// <dt>EntryTimeToLive [<em>default:</em> no expiration]</dt>
+      ///     <dd>Expiration configuration for individual entries based on the
+      ///     lastModifiedTime ( <see cref="CacheStatistics.LastModifiedTime" /> ).<br />
+      ///         see <see cref="SetEntryTimeToLive" />,
+      ///             <see cref="RegionAttributes.EntryTimeToLive" />,
+      ///             <see cref="AttributesMutator.SetEntryTimeToLive" /></dd>
+      ///
+      /// <dt>EntryIdleTimeout [<em>default:</em> no expiration]</dt>
+      ///     <dd>Expiration configuration for individual entries based on the
+      ///         lastAccessedTime ( <see cref="CacheStatistics.LastAccessedTime" /> ).<br />
+      ///         see <see cref="SetEntryIdleTimeout" />,
+      ///             <see cref="RegionAttributes.EntryIdleTimeout" />,
+      ///             <see cref="AttributesMutator.SetEntryIdleTimeout" /></dd>
+      /// </dl>
+      /// <h4>Distribution</h4>
+      /// <dl>
+      /// <dt><see cref="ScopeType" /> [<em>default:</em> <tt>ScopeType.DistributedNoAck</tt>]</dt>
+      ///     <dd>The C++ cache can contain either local regions or distributed regions. 
+      ///         Distributed regions are configured with servers that they distribute 
+      ///         their operations to upto. Locally scoped regions do not have any 
+      ///         distribution behavior. GFE native client regions scoped as 
+      ///         ScopeType.DistributedNoAck and ScopeType.DistributedAck have identical
+      ///         distribution behavior.<br />
+      ///         see <see cref="SetScope" />,
+      ///             <see cref="RegionAttributes.Scope" /></dd>
+      /// </dl>
+      /// <h4>Storage</h4>
+      /// <dl>
+      /// <dt>InitialCapacity [<em>default:</em> <tt>16</tt>]</dt>
+      ///     <dd>The initial capacity of the map used for storing the entries.<br />
+      ///         see <see cref="SetInitialCapacity" />,
+      ///             <see cref="RegionAttributes.InitialCapacity" /></dd>
+      ///
+      /// <dt>LoadFactor [<em>default:</em> <tt>0.75</tt>]</dt>
+      ///     <dd>The load factor of the map used for storing the entries.<br />
+      ///         see <see cref="SetLoadFactor" />,
+      ///             <see cref="RegionAttributes.LoadFactor" /></dd>
+      ///
+      /// <dt>ConcurrencyLevel [<em>default:</em> <tt>16</tt>]</dt>
+      ///     <dd>The allowed concurrency among updates to values in the region
+      ///         is guided by the <tt>concurrencyLevel</tt>, which is used as a hint
+      ///         for internal sizing. The actual concurrency will vary.
+      ///         Ideally, you should choose a value to accommodate as many
+      ///         threads as will ever concurrently modify values in the region. Using a
+      ///         significantly higher value than you need can waste space and time,
+      ///         and a significantly lower value can lead to thread contention. But
+      ///         overestimates and underestimates within an order of magnitude do
+      ///         not usually have much noticeable impact. A value of one is
+      ///         appropriate when it is known that only one thread will modify
+      ///         and all others will only read.<br />
+      ///         see <see cref="SetConcurrencyLevel" />,
+      ///             <see cref="RegionAttributes.ConcurrencyLevel" /></dd>
+      ///
+      /// </dl>
+      /// </para>
+      /// </remarks>
+      /// <seealso cref="RegionAttributes" />
+      /// <seealso cref="AttributesMutator" />
+      /// <seealso cref="Region.CreateSubRegion" />
+      [Obsolete("Use classes and APIs from the GemStone.GemFire.Cache.Generic namespace")]
+      public ref class AttributesFactory sealed
+        : public Internal::UMWrap<gemfire::AttributesFactory>
+      {
+      public:
+
+        /// <summary>
+        /// Creates a new <c>AttributesFactory</c> ready to create
+        /// a <c>RegionAttributes</c> with default settings.
+        /// </summary>
+        inline AttributesFactory( )
+          : UMWrap( new gemfire::AttributesFactory( ), true ) { }
+
+        /// <summary>
+        /// Creates a new instance of <c>AttributesFactory</c> ready to create
+        /// a <c>RegionAttributes</c> with the same settings as those in the
+        /// specified <c>RegionAttributes</c>.
+        /// </summary>
+        /// <param name="regionAttributes">
+        /// attributes used to initialize this AttributesFactory
+        /// </param>
+        AttributesFactory( RegionAttributes^ regionAttributes );
+
+        // CALLBACKS
+
+        /// <summary>
+        /// Sets the cache loader for the <c>RegionAttributes</c> being created.
+        /// </summary>
+        /// <param name="cacheLoader">
+        /// a user-defined cache loader, or null for no cache loader
+        /// </param>
+        void SetCacheLoader( ICacheLoader^ cacheLoader );
+
+        /// <summary>
+        /// Sets the cache writer for the <c>RegionAttributes</c> being created.
+        /// </summary>
+        /// <param name="cacheWriter">
+        /// user-defined cache writer, or null for no cache writer
+        /// </param>
+        void SetCacheWriter( ICacheWriter^ cacheWriter );
+
+        /// <summary>
+        /// Sets the CacheListener for the <c>RegionAttributes</c> being created.
+        /// </summary>
+        /// <param name="cacheListener">
+        /// user-defined cache listener, or null for no cache listener
+        /// </param>
+        void SetCacheListener( ICacheListener^ cacheListener );
+
+        /// <summary>
+        /// Sets the PartitionResolver for the <c>RegionAttributes</c> being created.
+        /// </summary>
+        /// <param name="partitionresolver">
+        /// user-defined partition resolver, or null for no partition resolver
+        /// </param>
+        void SetPartitionResolver( IPartitionResolver^ partitionresolver );
+
+        /// <summary>
+        /// Sets the library path for the library that will be invoked for the loader of the region.
+        /// </summary>
+        /// <param name="libPath">
+        /// library pathname containing the factory function.
+        /// </param>
+        /// <param name="factoryFunctionName">
+        /// Name of factory function that creates a <c>CacheLoader</c>
+        /// for a native library, or the name of the method in the form
+        /// {Namespace}.{Class Name}.{Method Name} that creates an
+        /// <c>ICacheLoader</c> for a managed library.
+        /// </param>
+        void SetCacheLoader( String^ libPath, String^ factoryFunctionName );
+
+        /// <summary>
+        /// Sets the library path for the library that will be invoked for the writer of the region.
+        /// </summary>
+        /// <param name="libPath">
+        /// library pathname containing the factory function.
+        /// </param>
+        /// <param name="factoryFunctionName">
+        /// Name of factory function that creates a <c>CacheWriter</c>
+        /// for a native library, or the name of the method in the form
+        /// {Namespace}.{Class Name}.{Method Name} that creates an
+        /// <c>ICacheWriter</c> for a managed library.
+        /// </param>
+        void SetCacheWriter( String^ libPath, String^ factoryFunctionName );
+
+        /// <summary>
+        /// Sets the library path for the library that will be invoked for the listener of the region.
+        /// </summary>
+        /// <param name="libPath">
+        /// library pathname containing the factory function.
+        /// </param>
+        /// <param name="factoryFunctionName">
+        /// Name of factory function that creates a <c>CacheListener</c>
+        /// for a native library, or the name of the method in the form
+        /// {Namespace}.{Class Name}.{Method Name} that creates an
+        /// <c>ICacheListener</c> for a managed library.
+        /// </param>
+        void SetCacheListener( String^ libPath, String^ factoryFunctionName );
+
+
+        /// <summary>
+        /// Sets the library path for the library that will be invoked for the partition resolver of the region.
+        /// </summary>
+        /// <param name="libPath">
+        /// library pathname containing the factory function.
+        /// </param>
+        /// <param name="factoryFunctionName">
+        /// Name of factory function that creates a <c>PartitionResolver</c>
+        /// for a native library, or the name of the method in the form
+        /// {Namespace}.{Class Name}.{Method Name} that creates an
+        /// <c>IPartitionResolver</c> for a managed library.
+        /// </param>
+        void SetPartitionResolver( String^ libPath, String^ factoryFunctionName );
+
+
+        // EXPIRATION ATTRIBUTES
+
+        /// <summary>
+        /// Sets the idleTimeout expiration attributes for region entries for the next
+        /// <c>RegionAttributes</c> created.
+        /// </summary>
+        /// <param name="action">
+        /// The expiration action for which to set the timeout.
+        /// </param>
+        /// <param name="idleTimeout">
+        /// the idleTimeout in seconds for entries in this region.
+        /// </param>
+        void SetEntryIdleTimeout( ExpirationAction action, uint32_t idleTimeout );
+
+        /// <summary>
+        /// Sets the timeToLive expiration attributes for region entries for the next
+        /// <c>RegionAttributes</c> created.
+        /// </summary>
+        /// <param name="action">
+        /// The expiration action for which to set the timeout.
+        /// </param>
+        /// <param name="timeToLive">
+        /// the timeToLive in seconds for entries in this region.
+        /// </param>
+        void SetEntryTimeToLive( ExpirationAction action, uint32_t timeToLive );
+
+        /// <summary>
+        /// Sets the idleTimeout expiration attributes for the region itself for the
+        /// next <c>RegionAttributes</c> created.
+        /// </summary>
+        /// <param name="action">
+        /// The expiration action for which to set the timeout.
+        /// </param>
+        /// <param name="idleTimeout">
+        /// the idleTimeout in seconds for the region as a whole.
+        /// </param>
+        void SetRegionIdleTimeout( ExpirationAction action, uint32_t idleTimeout );
+
+        /// <summary>
+        /// Sets the timeToLive expiration attributes for the region itself for the
+        /// next <c>RegionAttributes</c> created.
+        /// </summary>
+        /// <param name="action">
+        /// The expiration action for which to set the timeout.
+        /// </param>
+        /// <param name="timeToLive">
+        /// the timeToLive in seconds for the region as a whole.
+        /// </param>
+        void SetRegionTimeToLive( ExpirationAction action, uint32_t timeToLive );
+
+
+        // PERSISTENCE
+
+        /// <summary>
+        /// Sets the library path for the library that will be invoked for the persistence of the region.
+        /// If the region is being created from a client on a server, or on a server directly, then
+        /// This must be used to set the PersistenceManager.
+        /// </summary>
+        /// <param name="libPath">The path of the PersistenceManager shared library.</param>
+        /// <param name="factoryFunctionName">
+        /// The name of the factory function to create an instance of PersistenceManager object.
+        /// </param>
+        void SetPersistenceManager( String^ libPath, String^ factoryFunctionName );
+
+        /// <summary>
+        /// Sets the library path for the library that will be invoked for the persistence of the region.
+        /// If the region is being created from a client on a server, or on a server directly, then
+        /// This must be used to set the PersistenceManager.
+        /// </summary>
+        /// <param name="libPath">The path of the PersistenceManager shared library.</param>
+        /// <param name="factoryFunctionName">
+        /// The name of the factory function to create an instance of PersistenceManager object.
+        /// </param>
+        /// <param name="config">
+        /// The configuration properties to use for the PersistenceManager.
+        /// </param>
+        void SetPersistenceManager( String^ libPath, String^ factoryFunctionName,
+          Properties^ config );
+
+
+        // DISTRIBUTION ATTRIBUTES
+
+        /// <summary>
+        /// Sets the scope for the next <c>RegionAttributes</c> created.
+        /// </summary>
+        /// <param name="scopeType">
+        /// the type of scope to use for the region
+        /// </param>
+        [Obsolete("This method is obsolete since 3.5")]
+        void SetScope( ScopeType scopeType );
+
+
+        // STORAGE ATTRIBUTES
+
+        /// <summary>
+        /// Enables/disables client noficiations for a Thin client region.
+        /// </summary>
+        /// <param name="clientNotificationEnabled">
+        /// true if client notifications have to be enabled; false otherwise
+        /// </param>        
+        [Obsolete("This method is obsolete since 3.5; use PoolFactory.SetSubscriptionEnabled instead.")]
+        void SetClientNotificationEnabled(
+          bool clientNotificationEnabled );
+
+        /// <summary>
+        /// Set the endpoints for a Thin Client region.
+        /// </summary>
+        /// <remarks>
+        /// If the endpoints are set then the region is taken to be a Thin-client
+        /// region that interacts with the GemFire Java cacheserver.
+        /// </remarks>
+        /// <param name="endpoints">
+        /// The list of host:port pairs separated by commas.
+        /// </param>
+        [Obsolete("This method is obsolete since 3.5; use PoolFactory.AddServer or PoolFactory.AddLocator instead.")]
+        void SetEndpoints( String^ endpoints );
+
+        /// <summary>
+        /// Set the pool name for a Thin Client region.
+        /// </summary>
+        /// <remarks>
+        /// The pool with the name specified must be already created.
+        /// </remarks>
+        /// <param name="poolName">
+        /// The name of the pool to attach to this region.
+        /// </param>
+        void SetPoolName( String^ poolName );
+
+        // MAP ATTRIBUTES
+
+        /// <summary>
+        /// Sets the entry initial capacity for the <c>RegionAttributes</c>
+        /// being created. This value is used in initializing the map that
+        /// holds the entries.
+        /// </summary>
+        /// <param name="initialCapacity">the initial capacity of the entry map</param>
+        /// <exception cref="IllegalArgumentException">
+        /// if initialCapacity is nonpositive
+        /// </exception>
+        void SetInitialCapacity( int32_t initialCapacity );
+
+        /// <summary>
+        /// Sets the entry load factor for the next <c>RegionAttributes</c>
+        /// created. This value is
+        /// used in initializing the map that holds the entries.
+        /// </summary>
+        /// <param name="loadFactor">the load factor of the entry map</param>
+        /// <exception cref="IllegalArgumentException">
+        /// if loadFactor is nonpositive
+        /// </exception>
+        void SetLoadFactor( Single loadFactor );
+
+        /// <summary>
+        /// Sets the concurrency level of the next <c>RegionAttributes</c>
+        /// created. This value is used in initializing the map that holds the entries.
+        /// </summary>
+        /// <param name="concurrencyLevel">
+        /// the concurrency level of the entry map
+        /// </param>
+        /// <exception cref="IllegalArgumentException">
+        /// if concurrencyLevel is nonpositive
+        /// </exception>
+        void SetConcurrencyLevel( int32_t concurrencyLevel );
+
+        /// <summary>
+        /// Sets a limit on the number of entries that will be held in the cache.
+        /// If a new entry is added while at the limit, the cache will evict the
+        /// least recently used entry.
+        /// </summary>
+        /// <param name="entriesLimit">
+        /// The limit of the number of entries before eviction starts.
+        /// Defaults to 0, meaning no LRU actions will used.
+        /// </param>
+        void SetLruEntriesLimit( uint32_t entriesLimit );
+
+        /// <summary>
+        /// Sets the disk policy type for the next <c>RegionAttributes</c> created.
+        /// </summary>
+        /// <param name="diskPolicy">
+        /// the disk policy to use for the region
+        /// </param>
+        void SetDiskPolicy( DiskPolicyType diskPolicy );
+
+        /// <summary>
+        /// Set caching enabled flag for this region.
+        /// </summary>
+        /// <remarks>
+        /// <para>
+        /// If set to false, then no data is stored in the local process,
+        /// but events and distributions will still occur, and the region
+        /// can still be used to put and remove, etc...
+        /// </para><para>
+        /// The default if not set is 'true', 'false' is illegal for regions
+        /// of <c>ScopeType.Local</c> scope. 
+        /// </para>
+        /// </remarks>
+        /// <param name="cachingEnabled">
+        /// if true, cache data for this region in this process.
+        /// </param>
+        void SetCachingEnabled( bool cachingEnabled );
+        /// <summary>
+        /// Set cloning enabled flag for this region.
+        /// </summary>
+        /// <remarks>
+        /// <para>
+        /// If set to false, then there is no cloning will take place in case of delta.
+        /// Delta will be applied on the old value which will change old value in-place.
+        /// </para><para>
+        /// The default if not set is 'false'
+        /// of <c>ScopeType.Local</c> scope. 
+        /// </para>
+        /// </remarks>
+        /// <param name="cloningEnabled">
+        /// if true, clone old value before applying delta so that in-place change would not occour..
+        /// </param>
+        void SetCloningEnabled( bool cloningEnabled );
+
+         /// <summary>
+        /// Sets concurrency checks enabled flag for this region.
+        /// </summary>
+        /// <remarks>
+        /// <para>
+        /// If set to false, then the version checks will not occur.
+        /// </para><para>
+        /// The default if not set is 'true'
+        /// </para>
+        /// </remarks>
+        /// <param name="concurrencyChecksEnabled">
+        /// if true, version checks for region entries will occur.
+        /// </param>
+        void SetConcurrencyChecksEnabled( bool concurrencyChecksEnabled );
+
+        // FACTORY METHOD
+
+        /// <summary>
+        /// Creates a <c>RegionAttributes</c> with the current settings.
+        /// </summary>
+        /// <returns>the newly created <c>RegionAttributes</c></returns>
+        /// <exception cref="IllegalStateException">
+        /// if the current settings violate the <a href="compability.html">
+        /// compatibility</a> rules.
+        /// </exception>
+        RegionAttributes^ CreateRegionAttributes( );
+      };
+
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/AttributesMutatorM.cpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/AttributesMutatorM.cpp b/geode-client-native/src/clicache/AttributesMutatorM.cpp
new file mode 100644
index 0000000..f30f08d
--- /dev/null
+++ b/geode-client-native/src/clicache/AttributesMutatorM.cpp
@@ -0,0 +1,145 @@
+/*=========================================================================
+ * 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 "AttributesMutatorM.hpp"
+#include "RegionM.hpp"
+#include "impl/ManagedCacheListener.hpp"
+#include "impl/ManagedCacheLoader.hpp"
+#include "impl/ManagedCacheWriter.hpp"
+
+
+using namespace System;
+
+namespace GemStone
+{
+  namespace GemFire
+  {
+    namespace Cache
+    {
+
+      int32_t AttributesMutator::SetEntryIdleTimeout( int32_t idleTimeout )
+      {
+        return NativePtr->setEntryIdleTimeout( idleTimeout );
+      }
+
+      ExpirationAction AttributesMutator::SetEntryIdleTimeoutAction(
+        ExpirationAction action )
+      {
+        return static_cast<ExpirationAction>(
+          NativePtr->setEntryIdleTimeoutAction(
+          static_cast<gemfire::ExpirationAction::Action>( action ) ) );
+      }
+
+      int32_t AttributesMutator::SetEntryTimeToLive( int32_t timeToLive )
+      {
+        return NativePtr->setEntryTimeToLive( timeToLive );
+      }
+
+      ExpirationAction AttributesMutator::SetEntryTimeToLiveAction(
+        ExpirationAction action )
+      {
+        return static_cast<ExpirationAction>(
+          NativePtr->setEntryTimeToLiveAction(
+          static_cast<gemfire::ExpirationAction::Action>( action ) ) );
+      }
+
+      int32_t AttributesMutator::SetRegionIdleTimeout( int32_t idleTimeout )
+      {
+        return NativePtr->setRegionIdleTimeout( idleTimeout );
+      }
+
+      ExpirationAction AttributesMutator::SetRegionIdleTimeoutAction(
+        ExpirationAction action )
+      {
+        return static_cast<ExpirationAction>(
+          NativePtr->setRegionIdleTimeoutAction(
+          static_cast<gemfire::ExpirationAction::Action>( action ) ) );
+      }
+
+      int32_t AttributesMutator::SetRegionTimeToLive( int32_t timeToLive )
+      {
+        return NativePtr->setRegionTimeToLive( timeToLive );
+      }
+
+      ExpirationAction AttributesMutator::SetRegionTimeToLiveAction(
+        ExpirationAction action )
+      {
+        return static_cast<ExpirationAction>(
+          NativePtr->setRegionTimeToLiveAction(
+          static_cast<gemfire::ExpirationAction::Action>( action ) ) );
+      }
+
+      uint32_t AttributesMutator::SetLruEntriesLimit( uint32_t entriesLimit )
+      {
+        return NativePtr->setLruEntriesLimit( entriesLimit );
+      }
+
+      void AttributesMutator::SetCacheListener( ICacheListener^ cacheListener )
+      {
+        gemfire::CacheListenerPtr listenerptr;
+        if (cacheListener != nullptr)
+        {
+          listenerptr = new gemfire::ManagedCacheListener( cacheListener );
+        }
+        NativePtr->setCacheListener( listenerptr );
+      }
+
+      void AttributesMutator::SetCacheListener( String^ libPath,
+        String^ factoryFunctionName )
+      {
+        ManagedString mg_libpath( libPath );
+        ManagedString mg_factoryFunctionName( factoryFunctionName );
+
+        NativePtr->setCacheListener( mg_libpath.CharPtr,
+          mg_factoryFunctionName.CharPtr );
+      }
+
+      void AttributesMutator::SetCacheLoader( ICacheLoader^ cacheLoader )
+      {
+        gemfire::CacheLoaderPtr loaderptr;
+        if (cacheLoader != nullptr)
+        {
+          loaderptr = new gemfire::ManagedCacheLoader( cacheLoader );
+        }
+        NativePtr->setCacheLoader( loaderptr );
+      }
+
+      void AttributesMutator::SetCacheLoader( String^ libPath,
+        String^ factoryFunctionName )
+      {
+        ManagedString mg_libpath( libPath );
+        ManagedString mg_factoryFunctionName( factoryFunctionName );
+
+        NativePtr->setCacheLoader( mg_libpath.CharPtr,
+          mg_factoryFunctionName.CharPtr );
+      }
+
+      void AttributesMutator::SetCacheWriter( ICacheWriter^ cacheWriter )
+      {
+        gemfire::CacheWriterPtr writerptr;
+        if (cacheWriter != nullptr)
+        {
+          writerptr = new gemfire::ManagedCacheWriter( cacheWriter );
+        }
+        NativePtr->setCacheWriter( writerptr );
+      }
+
+      void AttributesMutator::SetCacheWriter( String^ libPath,
+        String^ factoryFunctionName )
+      {
+        ManagedString mg_libpath( libPath );
+        ManagedString mg_factoryFunctionName( factoryFunctionName );
+
+        NativePtr->setCacheWriter( mg_libpath.CharPtr,
+          mg_factoryFunctionName.CharPtr );
+      }
+
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ac967000/geode-client-native/src/clicache/AttributesMutatorM.hpp
----------------------------------------------------------------------
diff --git a/geode-client-native/src/clicache/AttributesMutatorM.hpp b/geode-client-native/src/clicache/AttributesMutatorM.hpp
new file mode 100644
index 0000000..69b1d53
--- /dev/null
+++ b/geode-client-native/src/clicache/AttributesMutatorM.hpp
@@ -0,0 +1,255 @@
+/*=========================================================================
+ * 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/AttributesMutator.hpp"
+#include "impl/NativeWrapper.hpp"
+#include "ExpirationActionM.hpp"
+#include "ICacheListener.hpp"
+#include "ICacheLoader.hpp"
+#include "ICacheWriter.hpp"
+
+
+using namespace System;
+
+namespace GemStone
+{
+  namespace GemFire
+  {
+    namespace Cache
+    {
+
+      /// <summary>
+      /// Supports modification of certain region attributes after the region
+      /// has been created.
+      /// </summary>
+      /// <remarks>
+      /// <para>
+      /// It is required that the attributes be completely initialized using an
+      /// <see cref="AttributesFactory" /> before creating the region.
+      /// AttributesMutator can be applied to adjusting and tuning a subset of
+      /// attributes that are modifiable at runtime.
+      /// </para><para>
+      /// The setter methods all return the previous value of the attribute.
+      /// </para>
+      /// </remarks>
+      /// <seealso cref="Region.GetAttributesMutator" />
+      /// <seealso cref="RegionAttributes" />
+      /// <seealso cref="AttributesFactory" />
+        [Obsolete("Use classes and APIs from the GemStone.GemFire.Cache.Generic namespace")]
+      public ref class AttributesMutator sealed
+        : public Internal::SBWrap<gemfire::AttributesMutator>
+      {
+      public:
+
+        /// <summary>
+        /// Sets the idleTimeout duration for region entries.
+        /// </summary>
+        /// <param name="idleTimeout">
+        /// the idleTimeout in seconds for entries in this region, or 0 for no idle timeout
+        /// </param>
+        /// <returns>the previous value</returns>
+        /// <exception cref="IllegalStateException">
+        /// if the new idleTimeout changes entry expiration from
+        /// disabled to enabled or enabled to disabled.
+        /// </exception>
+        int32_t SetEntryIdleTimeout( int32_t idleTimeout );
+
+        /// <summary>
+        /// Sets the idleTimeout action for region entries.
+        /// </summary>
+        /// <param name="action">
+        /// the idleTimeout action for entries in this region
+        /// </param>
+        /// <returns>the previous action</returns>
+        ExpirationAction SetEntryIdleTimeoutAction( ExpirationAction action );
+
+        /// <summary>
+        /// Sets the timeToLive duration for region entries.
+        /// </summary>
+        /// <param name="timeToLive">
+        /// the timeToLive in seconds for entries in this region, or 0 to disable time-to-live
+        /// </param>
+        /// <returns>the previous value</returns>
+        /// <exception cref="IllegalStateException">
+        /// if the new timeToLive changes entry expiration from
+        /// disabled to enabled or enabled to disabled
+        /// </exception>
+        int32_t SetEntryTimeToLive( int32_t timeToLive );
+
+        /// <summary>
+        /// Set the timeToLive action for region entries.
+        /// </summary>
+        /// <param name="action">
+        /// the timeToLive action for entries in this region
+        /// </param>
+        /// <returns>the previous action</returns>
+        ExpirationAction SetEntryTimeToLiveAction( ExpirationAction action );
+
+        /// <summary>
+        /// Sets the idleTimeout duration for the region itself.
+        /// </summary>
+        /// <param name="idleTimeout">
+        /// the idleTimeout for this region, in seconds, or 0 to disable idle timeout
+        /// </param>
+        /// <returns>the previous value</returns>
+        /// <exception cref="IllegalStateException">
+        /// if the new idleTimeout changes region expiration from
+        /// disabled to enabled or enabled to disabled.
+        /// </exception>
+        int32_t SetRegionIdleTimeout( int32_t idleTimeout );
+
+        /// <summary>
+        /// Sets the idleTimeout action for the region itself.
+        /// </summary>
+        /// <param name="action">
+        /// the idleTimeout action for this region
+        /// </param>
+        /// <returns>the previous action</returns>
+        ExpirationAction SetRegionIdleTimeoutAction( ExpirationAction action );
+
+        /// <summary>
+        /// Sets the timeToLive duration for the region itself.
+        /// </summary>
+        /// <param name="timeToLive">
+        /// the timeToLive for this region, in seconds, or 0 to disable time-to-live
+        /// </param>
+        /// <returns>the previous value</returns>
+        /// <exception cref="IllegalStateException">
+        /// if the new timeToLive changes region expiration from
+        /// disabled to enabled or enabled to disabled.
+        /// </exception>
+        int32_t SetRegionTimeToLive( int32_t timeToLive );
+
+        /// <summary>
+        /// Sets the timeToLive action for the region itself.
+        /// </summary>
+        /// <param name="action">
+        /// the timeToLiv eaction for this region
+        /// </param>
+        /// <returns>the previous action</returns>
+        ExpirationAction SetRegionTimeToLiveAction( ExpirationAction action );
+
+        /// <summary>
+        /// Sets the maximum entry count in the region before LRU eviction.
+        /// </summary>
+        /// <param name="entriesLimit">the number of entries to allow, or 0 to disable LRU</param>
+        /// <returns>the previous value</returns>
+        /// <exception cref="IllegalStateException">
+        /// if the new entriesLimit changes LRU from
+        /// disabled to enabled or enabled to disabled.
+        /// </exception>
+        uint32_t SetLruEntriesLimit( uint32_t entriesLimit );
+
+        /// <summary>
+        /// Sets the CacheListener for the region.
+        /// The previous cache listener (if any) will be replaced with the given <c>cacheListener</c>.
+        /// </summary>
+        /// <param name="cacheListener">
+        /// user-defined cache listener, or null for no cache listener
+        /// </param>
+        void SetCacheListener( ICacheListener^ cacheListener );
+
+        /// <summary>
+        /// Sets the library path for the library that will be invoked for the listener of the region.
+        /// The previous cache listener will be replaced with a listener created
+        /// using the factory function provided in the given library.
+        /// </summary>
+        /// <param name="libPath">
+        /// library pathname containing the factory function.
+        /// </param>
+        /// <param name="factoryFunctionName">
+        /// Name of factory function that creates a <c>CacheListener</c>
+        /// for a native library, or the name of the method in the form
+        /// {Namespace}.{Class Name}.{Method Name} that creates an
+        /// <c>ICacheListener</c> for a managed library.
+        /// </param>
+        void SetCacheListener( String^ libPath, String^ factoryFunctionName );
+
+        /// <summary>
+        /// Sets the CacheLoader for the region.
+        /// The previous cache loader (if any) will be replaced with the given <c>cacheLoader</c>.
+        /// </summary>
+        /// <param name="cacheLoader">
+        /// user-defined cache loader, or null for no cache loader
+        /// </param>
+        void SetCacheLoader( ICacheLoader^ cacheLoader );
+
+        /// <summary>
+        /// Sets the library path for the library that will be invoked for the loader of the region.
+        /// The previous cache loader will be replaced with a loader created
+        /// using the factory function provided in the given library.
+        /// </summary>
+        /// <param name="libPath">
+        /// library pathname containing the factory function.
+        /// </param>
+        /// <param name="factoryFunctionName">
+        /// Name of factory function that creates a <c>CacheLoader</c>
+        /// for a native library, or the name of the method in the form
+        /// {Namespace}.{Class Name}.{Method Name} that creates an
+        /// <c>ICacheLoader</c> for a managed library.
+        /// </param>
+        void SetCacheLoader( String^ libPath, String^ factoryFunctionName );
+
+        /// <summary>
+        /// Sets the CacheListener for the region.
+        /// The previous cache writer (if any) will be replaced with the given <c>cacheWriter</c>.
+        /// </summary>
+        /// <param name="cacheWriter">
+        /// user-defined cache writer, or null for no cache writer
+        /// </param>
+        void SetCacheWriter( ICacheWriter^ cacheWriter );
+
+        /// <summary>
+        /// Sets the library path for the library that will be invoked for the writer of the region.
+        /// The previous cache writer will be replaced with a writer created
+        /// using the factory function provided in the given library.
+        /// </summary>
+        /// <param name="libPath">
+        /// library pathname containing the factory function.
+        /// </param>
+        /// <param name="factoryFunctionName">
+        /// Name of factory function that creates a <c>CacheWriter</c>
+        /// for a native library, or the name of the method in the form
+        /// {Namespace}.{Class Name}.{Method Name} that creates an
+        /// <c>ICacheWriter</c> for a managed library.
+        /// </param>
+        void SetCacheWriter( String^ libPath, String^ factoryFunctionName );
+
+
+      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>
+        inline static AttributesMutator^ Create( gemfire::AttributesMutator* nativeptr )
+        {
+          return ( nativeptr != nullptr ?
+            gcnew AttributesMutator( nativeptr ) : nullptr );
+        }
+
+
+      private:
+
+        /// <summary>
+        /// Private constructor to wrap a native object pointer
+        /// </summary>
+        /// <param name="nativeptr">The native object pointer</param>
+        inline AttributesMutator( gemfire::AttributesMutator* nativeptr )
+          : SBWrap( nativeptr ) { }
+      };
+
+    }
+  }
+}