You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/03 11:28:35 UTC

[07/14] ignite git commit: IGNITE-1364: WIP.

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/grid_error.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/grid_error.h b/modules/platform/src/main/cpp/core/include/gridgain/grid_error.h
new file mode 100644
index 0000000..17ae686
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/grid_error.h
@@ -0,0 +1,255 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_GRID_ERROR
+#define _GRIDGAIN_GRID_ERROR
+
+#include <sstream>
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#define GG_ERROR_1(code, part1) { \
+    std::stringstream stream; \
+    stream << (part1); \
+    throw gridgain::GridError(code, stream.str().c_str()); \
+}
+
+#define GG_ERROR_2(code, part1, part2) { \
+    std::stringstream stream; \
+    stream << (part1) << (part2); \
+    throw gridgain::GridError(code, stream.str().c_str()); \
+}
+
+#define GG_ERROR_3(code, part1, part2, part3) { \
+    std::stringstream stream; \
+    stream << (part1) << (part2) << (part3); \
+    throw gridgain::GridError(code, stream.str().c_str()); \
+}
+
+#define GG_ERROR_FORMATTED_1(code, msg, key1, val1) { \
+    std::stringstream stream; \
+    stream << msg << " [" << key1 << "=" << (val1) << "]"; \
+    throw gridgain::GridError(code, stream.str().c_str()); \
+}
+
+#define GG_ERROR_FORMATTED_2(code, msg, key1, val1, key2, val2) { \
+    std::stringstream stream; \
+    stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << "]"; \
+    throw gridgain::GridError(code, stream.str().c_str()); \
+}
+
+#define GG_ERROR_FORMATTED_3(code, msg, key1, val1, key2, val2, key3, val3) { \
+    std::stringstream stream; \
+    stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << "]"; \
+    throw gridgain::GridError(code, stream.str().c_str()); \
+}
+
+#define GG_ERROR_FORMATTED_4(code, msg, key1, val1, key2, val2, key3, val3, key4, val4) { \
+    std::stringstream stream; \
+    stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << ", " << key4 << "=" << (val4) << "]"; \
+    throw gridgain::GridError(code, stream.str().c_str()); \
+}
+
+namespace gridgain
+{
+    /**
+     * Grid error information.
+     */
+    class IGNITE_IMPORT_EXPORT GridError
+    {
+    public:
+        /** Success. */
+        static const int GG_SUCCESS = 0;
+
+        /** Failed to initialize JVM. */
+        static const int GG_ERR_JVM_INIT = 1;
+
+        /** Failed to attach to JVM. */
+        static const int GG_ERR_JVM_ATTACH = 2;
+        
+        /** JVM library is not found. */
+        static const int GG_ERR_JVM_LIB_NOT_FOUND = 3;
+
+        /** Failed to load JVM library. */
+        static const int GG_ERR_JVM_LIB_LOAD_FAILED = 4;
+        
+        /** JVM classpath is not provided. */
+        static const int GG_ERR_JVM_NO_CLASSPATH = 5;
+
+        /** JVM error: no class definition found. */
+        static const int GG_ERR_JVM_NO_CLASS_DEF_FOUND = 6;
+
+        /** JVM error: no such method. */
+        static const int GG_ERR_JVM_NO_SUCH_METHOD = 7;
+
+        /** Memory operation error. */
+        static const int GG_ERR_MEMORY = 1001;
+
+        /** Portable error. */
+        static const int GG_ERR_PORTABLE = 1002;
+
+        /** Generic GridGain error. */
+        static const int GG_ERR_GENERIC = 2000;
+
+        /** Illegal argument passed. */
+        static const int GG_ERR_ILLEGAL_ARGUMENT = 2001;
+
+        /** Illegal state. */
+        static const int GG_ERR_ILLEGAL_STATE = 2002;
+
+        /** Unsupported operation. */
+        static const int GG_ERR_UNSUPPORTED_OPERATION = 2003;
+
+        /** Thread has been interrup. */
+        static const int GG_ERR_INTERRUPTED = 2004;
+
+        /** Cluster group is empty. */
+        static const int GG_ERR_CLUSTER_GROUP_EMPTY = 2005;
+
+        /** Cluster topology problem. */
+        static const int GG_ERR_CLUSTER_TOPOLOGY = 2006;
+
+        /** Compute execution rejected. */
+        static const int GG_ERR_COMPUTE_EXECUTION_REJECTED = 2007;
+
+        /** Compute job failover. */
+        static const int GG_ERR_COMPUTE_JOB_FAILOVER = 2008;
+
+        /** Compute task cancelled. */
+        static const int GG_ERR_COMPUTE_TASK_CANCELLED = 2009;
+
+        /** Compute task timeout. */
+        static const int GG_ERR_COMPUTE_TASK_TIMEOUT = 2010;
+
+        /** Compute user undeclared exception. */
+        static const int GG_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011;
+
+        /** Generic cache error. */
+        static const int GG_ERR_CACHE = 2012;
+
+        /** Generic cache loader error. */
+        static const int GG_ERR_CACHE_LOADER = 2013;
+
+        /** Generic cache writer error. */
+        static const int GG_ERR_CACHE_WRITER = 2014;
+        
+        /** Generic cache entry processor error. */
+        static const int GG_ERR_ENTRY_PROCESSOR = 2015;
+
+        /** Cache atomic update timeout. */
+        static const int GG_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016;
+
+        /** Cache partial update. */
+        static const int GG_ERR_CACHE_PARTIAL_UPDATE = 2017;
+        
+        /** Transaction optimisitc exception. */
+        static const int GG_ERR_TX_OPTIMISTIC = 2018;
+
+        /** Transaction timeout. */
+        static const int GG_ERR_TX_TIMEOUT = 2019;
+
+        /** Transaction rollback. */
+        static const int GG_ERR_TX_ROLLBACK = 2020;
+
+        /** Transaction heuristic exception. */
+        static const int GG_ERR_TX_HEURISTIC = 2021;
+
+        /** Authentication error. */
+        static const int GG_ERR_AUTHENTICATION = 2022;
+
+        /** Security error. */
+        static const int GG_ERR_SECURITY = 2023;
+        
+        /** Product license error. */
+        static const int GG_ERR_PRODUCT_LICENSE = 2024;
+
+        /** Unknown error. */
+        static const int GG_ERR_UNKNOWN = -1;
+
+        /**
+         * Throw an error if code is not GG_SUCCESS.
+         *
+         * @param err Error.
+         */
+        static void ThrowIfNeeded(GridError& err);
+
+        /**
+         * Create empty error.
+         */
+        GridError();
+
+        /**
+         * Create error with specific code.
+         *
+         * @param code Error code.
+         */
+        GridError(const int32_t code);
+
+        /**
+         * Create error with specific code and message.
+         *
+         * @param code Error code.
+         * @param msg Message.
+         */
+        GridError(const int32_t code, const char* msg);
+        
+        /**
+         * Copy constructor.
+         *
+         * @param other Other instance.
+         */
+        GridError(const GridError& other);
+
+        /**
+         * Assignment operator.
+         *
+         * @param other Other instance.
+         * @return Assignment result.
+         */
+        GridError& operator=(const GridError& other);
+
+        /**
+         * Destructor.
+         */
+        ~GridError();
+
+        /**
+         * Get error code.
+         *
+         * @return Error code.
+         */
+        int32_t GetCode();
+
+        /**
+         * Get error message.
+         *
+         * @return Error message.
+         */
+        const char* GetText();
+        
+        /**
+         * Set error.
+         *
+         * @param jniCode Error code.
+         * @param jniCls Error class.
+         * @param jniMsg Error message.
+         * @param err Error.
+         */
+        static void SetError(const int jniCode, const char* jniCls, const char* jniMsg, GridError* err);
+    private:
+        /** Error code. */
+        int32_t code;    
+        
+        /** Error message. */
+        char* msg;       
+    };    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/grid_factory.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/grid_factory.h b/modules/platform/src/main/cpp/core/include/gridgain/grid_factory.h
new file mode 100644
index 0000000..c67e193
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/grid_factory.h
@@ -0,0 +1,187 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+/**
+ * \mainpage GridGain for C++ Library
+ *
+ * The GridGain In-Memory Data Fabric is a proven software solution, which delivers unprecedented speed
+ * and unlimited scale to accelerate your business and time to insights. It enables high-performance transactions,
+ * real-time streaming and fast analytics in a single, comprehensive data access and processing layer. The In-Memory
+ * Data Fabric is designed to easily power both existing and new applications in a distributed, massively
+ * parallel architecture on affordable, industry-standard hardware.
+ * <p>
+ * The GridGain In-Memory Data Fabric provides a unified API that spans all key types of applications
+ * (Java, .NET, C++) and connects them with multiple data stores containing structured, semi-structured and
+ * unstructured data (SQL, NoSQL, Hadoop). It offers a secure, highly available and manageable data environment
+ * that allows companies to process full ACID transactions and generate valuable insights from real-time,
+ * interactive and batch queries.
+ * <p>
+ * The In-Memory Data Fabric offers a strategic approach to in-memory computing that delivers performance,
+ * scale and comprehensive capabilities far above and beyond what traditional in-memory databases,
+ * data grids or other in-memory-based point solutions can offer by themselves.
+ *
+ * \section ultimate_speed_and_scale Ultimate Speed and Scale
+ *
+ * The GridGain In-Memory Data Fabric accesses and processes data from distributed enterprise and
+ * cloud-based data stores orders of magnitudes faster, and shares them with today's most demanding transactional,
+ * analytical and hybrid applications. The In-Memory Data Fabric delivers unprecedented throughput
+ * and low latency performance in a virtually unlimited, global scale-out architecture for both new and
+ * existing applications.
+ *
+ * \section comprehensive_and_proven Comprehensive and Proven
+ *
+ * The GridGain In-Memory Data Fabric is the product of seven years of meticulous research and development,
+ * built from the ground up (i.e. no bolt-on's), and run successfully by hundreds of organizations worldwide.
+ * It is a comprehensive in-memory solution that includes a clustering and compute grid, a database-agnostic data grid,
+ * a real-time streaming engine as well as plug-and-play Hadoop acceleration. The In-Memory Data Fabric
+ * connects multiple data sources (relational, NoSQL, Hadoop) with Java, .NET and C++ applications, and offers
+ * a secure and highly available architecture; it also provides a fully-featured, graphical management interface.
+ * <p>
+ * The GridGain Data Fabric is used today by Fortune 500 companies, top government agencies as well as
+ * innovative mobile and web companies in a broad range of business scenarios, such as automated trading systems,
+ * fraud detection, big data analytics, social networks, online gaming, and bioinformatics.
+ */
+
+#ifndef _GRIDGAIN_GRID_FACTORY
+#define _GRIDGAIN_GRID_FACTORY
+
+#include "gridgain/grid.h"
+#include "gridgain/grid_configuration.h"
+#include "gridgain/grid_error.h"
+
+namespace gridgain
+{
+    /**
+     * This class defines a factory for the main GridGain API.
+     */
+    class IGNITE_IMPORT_EXPORT GridFactory
+    {
+    public:
+        /**
+         * Start grid instance.
+         *
+         * @param cfg Configuration.
+         * @return Grid instance or null in case of error.
+         */
+        static Grid Start(const GridConfiguration& cfg);
+
+        /*
+         * Start grid instance.
+         *
+         * @param cfg Configuration.
+         * @param err Error.
+         * @return Grid instance or null in case of error.
+         */
+        static Grid Start(const GridConfiguration& cfg, GridError* err);
+
+        /**
+         * Start grid instance with specific name.
+         *
+         * @param cfg Configuration.
+         * @param name Grid name.
+         * @return Grid instance or null in case of error.
+         */
+        static Grid Start(const GridConfiguration& cfg, const char* name);
+
+        /**
+         * Start grid instance with specific name.
+         *
+         * @param cfg Configuration.
+         * @param name Grid name.
+         * @param err Error.
+         * @return Grid instance or null in case of error.
+         */
+        static Grid Start(const GridConfiguration& cfg, const char* name, GridError* err);
+
+        /**
+         * Get default grid instance.
+         *
+         * @return Grid instance.
+         */
+        static Grid Get();
+
+        /**
+         * Get default grid instance.
+         *
+         * @param err Error.
+         * @return Grid instance.
+         */
+        static Grid Get(GridError* err);
+
+        /**
+         * Get grid instance with the given name.
+         *
+         * @param name Grid name.
+         * @return Grid instance.
+         */
+        static Grid Get(const char* name);
+
+        /**
+         * Get grid instance with the given name.
+         *
+         * @param name Grid name.
+         * @param err Error.
+         * @return Grid instance.
+         */
+        static Grid Get(const char* name, GridError* err);
+
+        /**
+         * Stop default grid instance.
+         *
+         * @param cancel Cancel flag.
+         * @return True if grid instance was stopped by this call.
+         */
+        static bool Stop(const bool cancel);
+
+        /**
+         * Stop default grid instance.
+         *
+         * @param cancel Cancel flag.
+         * @param err Error.
+         * @return True if grid instance was stopped by this call.
+         */
+        static bool Stop(const bool cancel, GridError* err);
+
+        /**
+         * Stop grid instance with the given name.
+         *
+         * @param name Grid name.
+         * @param cancel Cancel flag.
+         * @return True if grid instance was stopped by this call.
+         */
+        static bool Stop(const char* name, const bool cancel);
+
+        /**
+         * Stop grid instance with the given name.
+         *
+         * @param name Grid name.
+         * @param cancel Cancel flag.
+         * @param err Error.
+         * @return True if grid instance was stopped by this call.
+         */
+        static bool Stop(const char* name, const bool cancel, GridError* err);
+
+        /**
+         * Stop all running grid instances.
+         *
+         * @param cancel Cancel flag.
+         */
+        static void StopAll(const bool cancel);
+
+        /**
+         * Stop all running grid instances.
+         *
+         * @param cancel Cancel flag.
+         * @param err Error.
+         */
+        static void StopAll(const bool cancel, GridError* err);
+    };    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/guid.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/guid.h b/modules/platform/src/main/cpp/core/include/gridgain/guid.h
new file mode 100644
index 0000000..f6d2214
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/guid.h
@@ -0,0 +1,104 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_GUID
+#define _GRIDGAIN_GUID
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+namespace gridgain
+{
+    /**
+     * Global universally unique identifier (GUID).
+     */
+    class IGNITE_IMPORT_EXPORT Guid
+    {
+    public:
+        /**
+         * Default constructor.
+         */
+        Guid();
+
+        /**
+         * Constructor.
+         *
+         * @param most Most significant bits.
+         * @param least Least significant bits.
+         */
+        Guid(int64_t most, int64_t least);
+
+        /**
+         * Returns the most significant 64 bits of this instance.
+         *
+         * @return The most significant 64 bits of this instance.
+         */
+        int64_t GetMostSignificantBits() const;
+
+        /**
+         * Returns the least significant 64 bits of this instance.
+         *  
+         * @return The least significant 64 bits of this instance.
+         */
+        int64_t GetLeastSignificantBits() const;
+
+        /**
+         * The version number associated with this instance.  The version
+         * number describes how this Guid was generated.
+         *
+         * The version number has the following meaning:
+         * 1    Time-based UUID;
+         * 2    DCE security UUID;
+         * 3    Name-based UUID;
+         * 4    Randomly generated UUID.
+         *
+         * @return The version number of this instance.
+         */
+        int32_t GetVersion() const;
+
+        /**
+         * The variant number associated with this instance. The variant
+         * number describes the layout of the Guid.
+         *
+         * The variant number has the following meaning:
+         * 0    Reserved for NCS backward compatibility;
+         * 2    IETF RFC 4122 (Leach-Salz), used by this class;
+         * 6    Reserved, Microsoft Corporation backward compatibility;
+         * 7    Reserved for future definition.
+         *
+         * @return The variant number of this instance.
+         */
+        int32_t GetVariant() const;
+
+        /**
+         * Get hash code of this instance (used in serialization).
+         *
+         * @return Hash code.
+         */
+        int32_t GetHashCode() const;
+
+        /**
+         * Comparison operator override.
+         *
+         * @param val1 First value.
+         * @param val2 Second value.
+         * @return True if equal.
+         */
+        friend bool IGNITE_IMPORT_EXPORT operator== (Guid& val1, Guid& val2);
+    private:
+        /** Most significant bits. */
+        int64_t most;  
+
+        /** Least significant bits. */
+        int64_t least; 
+    };
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/impl/cache/cache_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/impl/cache/cache_impl.h b/modules/platform/src/main/cpp/core/include/gridgain/impl/cache/cache_impl.h
new file mode 100644
index 0000000..5dbb8c0
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/impl/cache/cache_impl.h
@@ -0,0 +1,410 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_CACHE_IMPL
+#define _GRIDGAIN_CACHE_IMPL
+
+#include "gridgain/cache/query/query_scan.h"
+#include "gridgain/cache/query/query_sql.h"
+#include "gridgain/cache/query/query_text.h"
+#include "gridgain/impl/grid_environment.h"
+#include "gridgain/impl/cache/query/query_impl.h"
+#include "gridgain/impl/operations.h"
+
+namespace gridgain
+{    
+    namespace impl 
+    {
+        namespace cache
+        {
+            /**
+             * Cache implementation.
+             */
+            class IGNITE_IMPORT_EXPORT CacheImpl
+            {
+            public:
+                /**
+                 * Constructor used to create new instance.
+                 *
+                 * @param name Name.
+                 * @param env Environment.
+                 * @param javaRef Reference to java object.
+                 */
+                CacheImpl(char* name, ignite::common::concurrent::SharedPointer<GridEnvironment> env, jobject javaRef);
+                
+                /**
+                 * Destructor.
+                 */
+                ~CacheImpl();
+                
+                /**
+                 * Get name.
+                 *
+                 * @return Cache name.
+                 */
+                char* GetName();
+
+                /**
+                 * Perform IsEmpty.
+                 *
+                 * @param err Error.
+                 * @return Result.
+                 */
+                bool IsEmpty(GridError* err);
+
+                /**
+                 * Perform ContainsKey.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                bool ContainsKey(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform ContainsKeys.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                bool ContainsKeys(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform LocalPeek.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param peekModes Peek modes.
+                 * @param err Error.
+                 */
+                void LocalPeek(InputOperation& inOp, OutputOperation& outOp, 
+                    int32_t peekModes, GridError* err);
+
+                /**
+                 * Perform Get.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void Get(InputOperation& inOp, OutputOperation& outOp, GridError* err);
+                
+                /**
+                 * Perform GetAll.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAll(InputOperation& inOp, OutputOperation& outOp, GridError* err);
+
+                /**
+                 * Perform Put.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void Put(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform PutAll.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void PutAll(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform GetAndPut.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAndPut(InputOperation& inOp, OutputOperation& outOp, GridError* err);
+
+                /**
+                 * Perform GetAndReplace.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAndReplace(InputOperation& inOp, OutputOperation& outOp, GridError* err);
+
+                /**
+                 * Perform GetAndRemove.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAndRemove(InputOperation& inOp, OutputOperation& outOp, GridError* err);
+
+                /**
+                 * Perform PutIfAbsent.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool PutIfAbsent(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform GetAndPutIfAbsent.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAndPutIfAbsent(InputOperation& inOp, OutputOperation& outOp, GridError* err);
+
+                /**
+                 * Perform Replace(K, V).
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool Replace(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform Replace(K, V, V).
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool ReplaceIfEqual(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform LocalEvict.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void LocalEvict(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform Clear.
+                 *
+                 * @param err Error.
+                 */
+                void Clear(GridError* err);
+
+                /**
+                 * Perform Clear.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void Clear(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform ClearAll.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void ClearAll(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform LocalClear.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void LocalClear(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform LocalClearAll.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void LocalClearAll(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform Remove(K).
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool Remove(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform Remove(K, V).
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool RemoveIfEqual(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform RemoveAll.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void RemoveAll(InputOperation& inOp, GridError* err);
+
+                /**
+                 * Perform RemoveAll.
+                 *
+                 * @param err Error.
+                 */
+                void RemoveAll(GridError* err);
+
+                /**
+                 * Perform Size.
+                 *
+                 * @param peekModes Peek modes.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                int32_t Size(const int32_t peekModes, GridError* err);
+
+                /**
+                 * Perform LocalSize.
+                 * 
+                 * @param peekModes Peek modes.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                int32_t LocalSize(const int32_t peekModes, GridError* err);
+
+                /**
+                 * Invoke query.
+                 *
+                 * @param qry Query.
+                 * @param err Error.
+                 * @return Query cursor.
+                 */
+                query::QueryCursorImpl* QuerySql(const gridgain::cache::query::SqlQuery& qry, GridError* err);
+
+                /*
+                 * Invoke text query.
+                 *
+                 * @param qry Query.
+                 * @param err Error.
+                 * @return Query cursor.
+                 */
+                query::QueryCursorImpl* QueryText(const gridgain::cache::query::TextQuery& qry, GridError* err);
+
+                /*
+                 * Invoke scan query.
+                 *
+                 * @param qry Query.
+                 * @param err Error.
+                 * @return Query cursor.
+                 */
+                query::QueryCursorImpl* QueryScan(const gridgain::cache::query::ScanQuery& qry, GridError* err);
+                
+            private:
+                /** Name. */
+                char* name; 
+                
+                /** Environment. */
+                ignite::common::concurrent::SharedPointer<GridEnvironment> env;
+                
+                /** Handle to Java object. */
+                jobject javaRef;                     
+
+                IGNITE_NO_COPY_ASSIGNMENT(CacheImpl)
+
+                /**
+                 * Write data to memory.
+                 *
+                 * @param mem Memory.
+                 * @param inOp Input opeartion.
+                 * @param err Error.
+                 * @return Memory pointer.
+                 */
+                int64_t WriteTo(interop::InteropMemory* mem, InputOperation& inOp, GridError* err);
+
+                /**
+                 * Read data from memory.
+                 *
+                 * @param mem Memory.
+                 * @param outOp Output operation.
+                 */
+                void ReadFrom(interop::InteropMemory* mem, OutputOperation& outOp);
+
+                /**
+                 * Internal cache size routine.
+                 *
+                 * @param peekModes Peek modes.
+                 * @param loc Local flag.
+                 * @param err Error.
+                 * @return Size.
+                 */
+                int SizeInternal(const int32_t peekModes, const bool loc, GridError* err);
+
+                /**
+                 * Internal out operation.
+                 *
+                 * @param opType Operation type.
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                bool OutOpInternal(const int32_t opType, InputOperation& inOp, GridError* err);
+
+                /**
+                 * Internal out-in operation.
+                 *
+                 * @param opType Operation type.
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void OutInOpInternal(const int32_t opType, InputOperation& inOp, OutputOperation& outOp, 
+                    GridError* err);
+
+                /**
+                 * Internal query execution routine.
+                 *
+                 * @param qry Query.
+                 * @param typ Query type.
+                 * @param err Error.
+                 */
+                template<typename T>
+                query::QueryCursorImpl* QueryInternal(const T& qry, int32_t typ, GridError* err)
+                {
+                    ignite::common::java::JniErrorInfo jniErr;
+
+                    ignite::common::concurrent::SharedPointer<interop::InteropMemory> mem = env.Get()->AllocateMemory();
+                    interop::InteropMemory* mem0 = mem.Get();
+                    interop::InteropOutputStream out(mem0);
+                    portable::PortableWriterImpl writer(&out, env.Get()->GetMetadataManager());
+                    gridgain::portable::PortableRawWriter rawWriter(&writer);
+
+                    qry.Write(rawWriter);
+
+                    out.Synchronize();
+
+                    jobject qryJavaRef = env.Get()->Context()->CacheOutOpQueryCursor(javaRef, typ, mem.Get()->PointerLong(), 
+                        &jniErr);
+
+                    GridError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    if (jniErr.code == ignite::common::java::IGNITE_JNI_ERR_SUCCESS)
+                        return new query::QueryCursorImpl(env, qryJavaRef);
+                    else
+                        return NULL;
+                }
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/impl/cache/query/query_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/impl/cache/query/query_impl.h b/modules/platform/src/main/cpp/core/include/gridgain/impl/cache/query/query_impl.h
new file mode 100644
index 0000000..8b2ca21
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/impl/cache/query/query_impl.h
@@ -0,0 +1,107 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_CACHE_QUERY_IMPL
+#define _GRIDGAIN_CACHE_QUERY_IMPL
+
+#include <gridgain/impl/grid_environment.h>
+#include <gridgain/grid_error.h>
+#include <gridgain/impl/operations.h>
+
+namespace gridgain
+{
+    namespace impl
+    {
+        namespace cache
+        {
+            namespace query
+            {
+                /**
+                 * Query cursor implementation.
+                 */
+                class IGNITE_IMPORT_EXPORT QueryCursorImpl
+                {
+                public:
+                    /**
+                     * Constructor.
+                     * 
+                     * @param env Environment.
+                     * @param javaRef Java reference.
+                     */
+                    QueryCursorImpl(ignite::common::concurrent::SharedPointer<GridEnvironment> env, jobject javaRef);
+
+                    /**
+                     * Destructor.
+                     */
+                    ~QueryCursorImpl();
+
+                    /**
+                     * Check whether next result exists.
+                     *
+                     * @param err Error.
+                     * @return True if exists.
+                     */
+                    bool HasNext(GridError* err);
+
+                    /**
+                     * Get next object.
+                     * 
+                     * @param op Operation.
+                     * @param err Error.
+                     */
+                    void GetNext(OutputOperation& op, GridError* err);
+
+                    /**
+                     * Get all cursor entries.
+                     *
+                     * @param op Operation.
+                     * @param err Error.
+                     */
+                    void GetAll(OutputOperation& op, GridError* err);
+
+                private:
+                    /** Environment. */
+                    ignite::common::concurrent::SharedPointer<impl::GridEnvironment> env;
+
+                    /** Handle to Java object. */
+                    jobject javaRef;
+
+                    /** Whether iteration methods were called. */
+                    bool iterCalled;
+
+                    /** Whether GetAll() method was called. */
+                    bool getAllCalled;
+
+                    /** Whether next entry is available. */
+                    bool hasNext;
+
+                    IGNITE_NO_COPY_ASSIGNMENT(QueryCursorImpl);
+
+                    /**
+                     * Create Java-side iterator if needed.
+                     *
+                     * @param err Error.
+                     * @return True in case of success, false if an error is thrown.
+                     */
+                    bool CreateIteratorIfNeeded(GridError* err);
+
+                    /**
+                     * Check whether Java-side iterator has next element.
+                     *
+                     * @param err Error.
+                     * @return True if the next element is available.
+                     */
+                    bool IteratorHasNext(GridError* err);
+                };
+            }
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/impl/grid_environment.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/impl/grid_environment.h b/modules/platform/src/main/cpp/core/include/gridgain/impl/grid_environment.h
new file mode 100644
index 0000000..3754509
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/impl/grid_environment.h
@@ -0,0 +1,122 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_GRID_ENVIRONMENT
+#define _GRIDGAIN_GRID_ENVIRONMENT
+
+#include <ignite/common/concurrent.h>
+#include <ignite/common/java.h>
+
+#include "gridgain/impl/interop/interop_memory.h"
+#include "portable/portable_metadata_manager.h"
+
+namespace gridgain 
+{    
+    namespace impl 
+    {
+        /**
+         * Defines environment in which Ignite operates.
+         */
+        class IGNITE_IMPORT_EXPORT GridEnvironment
+        {                
+        public:
+            /**
+             * Default constructor.
+             */
+            GridEnvironment();
+
+            /**
+             * Destructor.
+             */
+            ~GridEnvironment();
+
+            /**
+             * Populate callback handlers.
+             *
+             * @param Target (current env wrapped into a shared pointer).
+             * @return JNI handlers.
+             */
+            ignite::common::java::JniHandlers GetJniHandlers(ignite::common::concurrent::SharedPointer<GridEnvironment>* target);
+                
+            /**
+             * Perform initialization on successful start.
+             *
+             * @param ctx Context.
+             */
+            void Initialize(ignite::common::concurrent::SharedPointer<ignite::common::java::JniContext> ctx);
+
+            /**
+             * Start callback.
+             *
+             * @param memPtr Memory pointer.
+             */
+            void OnStartCallback(long long memPtr);        
+            
+            /**
+             * Get name of the grid.
+             *
+             * @return Name.
+             */
+            char* GridName();
+
+            /**
+             * Get JNI context.
+             *
+             * @return Context.
+             */
+            ignite::common::java::JniContext* Context();
+
+            /**
+             * Get memory for interop operations.
+             *
+             * @return Memory.
+             */
+            ignite::common::concurrent::SharedPointer<interop::InteropMemory> AllocateMemory();
+
+            /**
+             * Get memory chunk for interop operations with desired capacity.
+             *
+             * @param cap Capacity.
+             * @return Memory.
+             */
+            ignite::common::concurrent::SharedPointer<interop::InteropMemory> AllocateMemory(int32_t cap);
+
+            /**
+             * Get memory chunk located at the given pointer.
+             *
+             * @param memPtr Memory pointer.
+             * @retrun Memory.
+             */
+            ignite::common::concurrent::SharedPointer<interop::InteropMemory> GetMemory(int64_t memPtr);
+
+            /**
+             * Get metadata manager.
+             *
+             * @param Metadata manager.
+             */
+            portable::PortableMetadataManager* GetMetadataManager();
+        private:
+            /** Context to access Java. */
+            ignite::common::concurrent::SharedPointer<ignite::common::java::JniContext> ctx;
+
+            /** Startup latch. */
+            ignite::common::concurrent::SingleLatch* latch;
+
+            /** Grid name. */
+            char* gridName;                                   
+
+            /** Metadata manager. */
+            portable::PortableMetadataManager* metaMgr;       
+
+            IGNITE_NO_COPY_ASSIGNMENT(GridEnvironment);
+        };
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/impl/grid_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/impl/grid_impl.h b/modules/platform/src/main/cpp/core/include/gridgain/impl/grid_impl.h
new file mode 100644
index 0000000..1dce41d
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/impl/grid_impl.h
@@ -0,0 +1,138 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_GRID_IMPL
+#define _GRIDGAIN_GRID_IMPL
+
+#include <ignite/common/concurrent.h>
+#include <ignite/common/java.h>
+
+#include "gridgain/impl/cache/cache_impl.h"
+#include "gridgain/impl/grid_environment.h"
+#include "gridgain/impl/utils.h"
+
+namespace gridgain 
+{    
+    namespace impl 
+    {            
+        /**
+         * Grid implementation.
+         */
+        class GridImpl
+        {
+            friend class Grid;
+        public:
+            /**
+             * Constructor used to create new instance.
+             *
+             * @param env Environment.
+             * @param javaRef Reference to java object.
+             */
+            GridImpl(ignite::common::concurrent::SharedPointer<GridEnvironment> env, jobject javaRef);
+            
+            /**
+             * Destructor.
+             */
+            ~GridImpl();
+
+            /**
+             * Get name of the grid.
+             *
+             * @param Name.
+             */
+            char* GetName();
+
+            /**
+             * Get cache.
+             *
+             * @param name Cache name.
+             * @param err Error.
+             */
+            template<typename K, typename V> 
+            cache::CacheImpl* GetCache(const char* name, GridError* err)
+            {
+                ignite::common::java::JniErrorInfo jniErr;
+
+                jobject cacheJavaRef = env.Get()->Context()->ProcessorCache(javaRef, name, &jniErr);
+
+                if (!cacheJavaRef)
+                {
+                    GridError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    return NULL;
+                }
+
+                char* name0 = utils::CopyChars(name);
+
+                return new cache::CacheImpl(name0, env, cacheJavaRef);
+            }
+
+            /**
+             * Get or create cache.
+             *
+             * @param name Cache name.
+             * @param err Error.
+             */
+            template<typename K, typename V>
+            cache::CacheImpl* GetOrCreateCache(const char* name, GridError* err)
+            {
+                ignite::common::java::JniErrorInfo jniErr;
+
+                jobject cacheJavaRef = env.Get()->Context()->ProcessorGetOrCreateCache(javaRef, name, &jniErr);
+
+                if (!cacheJavaRef)
+                {
+                    GridError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    return NULL;
+                }
+
+                char* name0 = utils::CopyChars(name);
+
+                return new cache::CacheImpl(name0, env, cacheJavaRef);
+            }
+
+            /**
+             * Create cache.
+             *
+             * @param name Cache name.
+             * @param err Error.
+             */
+            template<typename K, typename V>
+            cache::CacheImpl* CreateCache(const char* name, GridError* err)
+            {
+                ignite::common::java::JniErrorInfo jniErr;
+
+                jobject cacheJavaRef = env.Get()->Context()->ProcessorCreateCache(javaRef, name, &jniErr);
+
+                if (!cacheJavaRef)
+                {
+                    GridError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    return NULL;
+                }
+
+                char* name0 = utils::CopyChars(name);
+
+                return new cache::CacheImpl(name0, env, cacheJavaRef);
+            }
+        private:
+            /** Environment. */
+            ignite::common::concurrent::SharedPointer<GridEnvironment> env;
+            
+            /** Native Java counterpart. */
+            jobject javaRef;   
+            
+            IGNITE_NO_COPY_ASSIGNMENT(GridImpl)
+        };
+    }
+    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/impl/handle_registry.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/impl/handle_registry.h b/modules/platform/src/main/cpp/core/include/gridgain/impl/handle_registry.h
new file mode 100644
index 0000000..b8c45c2
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/impl/handle_registry.h
@@ -0,0 +1,194 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_HANDLE_REGISTRY
+#define _GRIDGAIN_HANDLE_REGISTRY
+
+#include <map>
+#include <stdint.h>
+
+#include <ignite/common/concurrent.h>
+
+namespace gridgain
+{
+    namespace impl
+    {
+        /**
+         * Something what can be registered inside handle registry.
+         */
+        class IGNITE_IMPORT_EXPORT HandleRegistryEntry
+        {
+        public:
+            /**
+             * Destructor.
+             */
+            virtual ~HandleRegistryEntry();
+        };
+
+        /**
+         * Handle registry segment containing thread-specific data for slow-path access.
+         */
+        class IGNITE_IMPORT_EXPORT HandleRegistrySegment
+        {
+        public:
+            /**
+             * Constructor.
+             */
+            HandleRegistrySegment();
+
+            /**
+             * Destructor.
+             */
+            ~HandleRegistrySegment();
+
+            /**
+             * Get entry from segment.
+             *
+             * @param hnd Handle.
+             * @return Associated entry or NULL if it doesn't exists.
+             */
+            ignite::common::concurrent::SharedPointer<HandleRegistryEntry> Get(int64_t hnd);
+
+            /**
+             * Put entry into segment.
+             *
+             * @param hnd Handle.
+             * @param entry Associated entry (cannot be NULL).
+             */
+            void Put(int64_t hnd, const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& entry);
+
+            /**
+             * Remove entry from the segment.
+             *
+             * @param hnd Handle.
+             */
+            void Remove(int64_t hnd);            
+
+            /**
+             * Clear all entries from the segment.
+             */
+            void Clear();
+        private:
+            /** Map with data. */
+            std::map<int64_t, ignite::common::concurrent::SharedPointer<HandleRegistryEntry>>* map;
+
+            /** Mutex. */
+            ignite::common::concurrent::CriticalSection* mux;
+
+            IGNITE_NO_COPY_ASSIGNMENT(HandleRegistrySegment);
+        };
+
+        /**
+         * Handle registry.
+         */
+        class IGNITE_IMPORT_EXPORT HandleRegistry
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param fastCap Fast-path capacity.
+             * @param segmentCnt Slow-path segments count.
+             */
+            HandleRegistry(int32_t fastCap, int32_t slowSegmentCnt);
+
+            /**
+             * Destructor.
+             */
+            ~HandleRegistry();
+
+            /**
+             * Allocate handle.
+             *
+             * @param target Target.
+             * @return Handle.
+             */
+            int64_t Allocate(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+            /**
+             * Allocate handle in critical mode.
+             *
+             * @param target Target.
+             * @return Handle.
+             */
+            int64_t AllocateCritical(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+            /**
+             * Allocate handle in safe mode.
+             *
+             * @param target Target.
+             * @return Handle.
+             */
+            int64_t AllocateSafe(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+            /**
+             * Allocate handle in critical and safe modes.
+             *
+             * @param target Target.
+             * @return Handle.
+             */
+            int64_t AllocateCriticalSafe(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+            /**
+             * Release handle.
+             *
+             * @param hnd Handle.
+             */
+            void Release(int64_t hnd);
+
+            /**
+             * Get target.
+             *
+             * @param hnd Handle.
+             * @param Target.
+             */
+            ignite::common::concurrent::SharedPointer<HandleRegistryEntry> Get(int64_t hnd);
+
+            /**
+             * Close the registry.
+             */
+            void Close();
+        private:
+            /** Fast-path container capacity. */
+            int32_t fastCap;                     
+
+            /** Fast-path counter. */
+            int32_t fastCtr;               
+
+            /** Fast-path container. */
+            ignite::common::concurrent::SharedPointer<HandleRegistryEntry>* fast;
+
+            /** Amount of slow-path segments. */
+            int32_t slowSegmentCnt;            
+
+            /** Slow-path counter. */
+            int64_t slowCtr;                                                         
+            
+            /** Slow-path segments. */
+            HandleRegistrySegment** slow;                                            
+
+            /** Close flag. */
+            int32_t closed;                                                           
+
+            IGNITE_NO_COPY_ASSIGNMENT(HandleRegistry);
+
+            /**
+             * Internal allocation routine.
+             *
+             * @param target Target.
+             * @param Critical mode flag.
+             * @param Safe mode flag.
+             */
+            int64_t Allocate0(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target,
+                bool critical, bool safe);
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop.h b/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop.h
new file mode 100644
index 0000000..8c4fc88
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop.h
@@ -0,0 +1,17 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_IMPL_INTEROP
+#define _GRIDGAIN_IMPL_INTEROP
+
+#include "gridgain/impl/interop/interop_memory.h"
+#include "gridgain/impl/interop/interop_output_stream.h"
+#include "gridgain/impl/interop/interop_input_stream.h"
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_input_stream.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_input_stream.h b/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_input_stream.h
new file mode 100644
index 0000000..c560890
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_input_stream.h
@@ -0,0 +1,226 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_IMPL_INTEROP_INPUT_STREAM
+#define _GRIDGAIN_IMPL_INTEROP_INPUT_STREAM
+
+#include "gridgain/impl/interop/interop_memory.h"
+
+namespace gridgain
+{    
+    namespace impl
+    {
+        namespace interop
+        {
+            /**
+             * Interop input stream implementation.
+             */
+            class IGNITE_IMPORT_EXPORT InteropInputStream {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param mem Memory.
+                 */
+                InteropInputStream(InteropMemory* mem);
+
+                /**
+                 * Read signed 8-byte int.
+                 *
+                 * @return Value.
+                 */
+                int8_t ReadInt8();
+                    
+                /**
+                 * Read signed 8-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.                 
+                 */
+                void ReadInt8Array(int8_t* const res, const int32_t len);
+
+                /**
+                 * Read bool.
+                 *
+                 * @return Value.
+                 */
+                bool ReadBool();
+
+                /**
+                 * Read bool array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadBoolArray(bool* const res, const int32_t len);
+
+                /**
+                 * Read signed 16-byte int.
+                 *
+                 * @return Value.
+                 */
+                int16_t ReadInt16();
+
+                /**
+                 * Read signed 16-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadInt16Array(int16_t* const res, const int32_t len);
+
+                /**
+                 * Read unsigned 16-byte int.
+                 *
+                 * @return Value.
+                 */
+                uint16_t ReadUInt16();
+
+                /**
+                 * Read unsigned 16-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadUInt16Array(uint16_t* const res, const int32_t len);
+
+                /**
+                 * Read signed 32-byte int.
+                 *
+                 * @return Value.
+                 */
+                int32_t ReadInt32();
+
+                /**
+                 * Read signed 32-byte int at the given position.
+                 *
+                 * @param pos Position.
+                 * @return Value.
+                 */
+                int32_t ReadInt32(int32_t pos);
+                    
+                /**
+                 * Read signed 32-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadInt32Array(int32_t* const res, const int32_t len);
+
+                /**
+                 * Read signed 64-byte int.
+                 *
+                 * @return Value.
+                 */
+                int64_t ReadInt64();
+
+                /**
+                 * Read signed 64-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadInt64Array(int64_t* const res, const int32_t len);
+
+                /**
+                 * Read float.
+                 *
+                 * @return Value.
+                 */
+                float ReadFloat();
+
+                /**
+                 * Read float array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadFloatArray(float* const res, const int32_t len);
+
+                /**
+                 * Read double.
+                 *
+                 * @return Value.
+                 */
+                double ReadDouble();
+
+                /**
+                 * Read double array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadDoubleArray(double* const res, const int32_t len);
+
+                /**
+                 * Get remaining bytes.
+                 *
+                 * @return Remaining bytes.
+                 */
+                int32_t Remaining();
+
+                /**
+                 * Get position.
+                 *
+                 * @return Position.
+                 */
+                int32_t Position();
+
+                /**
+                 * Set position.
+                 *
+                 * @param Position.
+                 */
+                void Position(int32_t pos);
+
+                /**
+                 * Synchronize data from underlying memory.
+                 */
+                void Synchronize();
+            private:
+                /** Memory. */
+                InteropMemory* mem; 
+                
+                /** Pointer to data. */
+                int8_t* data;       
+                
+                /** Length. */
+                int len;            
+                
+                /** Current position. */
+                int pos;            
+                    
+                /**
+                 * Ensure there is enough data in the stream.
+                 *
+                 * @param cnt Amount of byte expected to be available.
+                 */
+                void EnsureEnoughData(int32_t cnt);
+
+                /**
+                 * Copy data from the stream shifting it along the way.
+                 *
+                 * @param ptr Pointer to data.
+                 * @param off Offset.
+                 * @param cnt Amount of data to copy.
+                 */
+                void CopyAndShift(int8_t* dest, int32_t off, int32_t cnt);
+
+                /**
+                 * Shift stream to the right.
+                 *
+                 * @param cnt Amount of bytes to shift the stream to.
+                 */
+                void Shift(int32_t cnt);
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_memory.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_memory.h b/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_memory.h
new file mode 100644
index 0000000..f7ad53b
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_memory.h
@@ -0,0 +1,272 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_IMPL_INTEROP_MEMORY
+#define _GRIDGAIN_IMPL_INTEROP_MEMORY
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+namespace gridgain 
+{
+    namespace impl 
+    {
+        namespace interop 
+        {
+            /** Memory header length. */
+            const int GG_MEM_HDR_LEN = 20;
+
+            /** Memory header offset: capacity. */
+            const int GG_MEM_HDR_OFF_CAP = 8;
+
+            /** Memory header offset: length. */
+            const int GG_MEM_HDR_OFF_LEN = 12;
+
+            /** Memory header offset: flags. */
+            const int GG_MEM_HDR_OFF_FLAGS = 16;
+
+            /** Flag: external. */
+            const int GG_MEM_FLAG_EXT = 0x1;
+
+            /** Flag: pooled. */
+            const int GG_MEM_FLAG_POOLED = 0x2;
+
+            /** Flag: acquired. */
+            const int GG_MEM_FLAG_ACQUIRED = 0x4;
+                
+            /**
+             * Interop memory.
+             */
+            class IGNITE_IMPORT_EXPORT InteropMemory
+            {
+            public:
+                /**
+                 * Get raw data pointer.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Raw data pointer.
+                 */
+                static int8_t* Data(int8_t* memPtr);
+
+                /**
+                 * Set raw data pointer.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @param ptr Raw data pointer.
+                 */
+                static void Data(int8_t* memPtr, void* ptr);
+
+                /**
+                 * Get capacity.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Capacity.
+                 */
+                static int32_t Capacity(int8_t* memPtr);
+
+                /**
+                 * Set capacity.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @param val Value.
+                 */
+                static void Capacity(int8_t* memPtr, int32_t val);
+
+                /**
+                 * Get length.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Length.
+                 */
+                static int32_t Length(int8_t* memPtr);
+
+                /**
+                 * Set length.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @param val Value.
+                 */
+                static void Length(int8_t* memPtr, int32_t val);
+
+                /**
+                 * Get flags.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Flags.
+                 */
+                static int32_t Flags(int8_t* memPtr);
+
+                /**
+                 * Set flags.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @param val Value.
+                 */
+                static void Flags(int8_t* memPtr, int32_t val);
+
+                /**
+                 * Get "external" flag state.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Flag state.
+                 */
+                static bool IsExternal(int8_t* memPtr);
+
+                /**
+                 * Get "external" flag state.
+                 *
+                 * @param flags Flags.
+                 * @return Flag state.
+                 */
+                static bool IsExternal(int32_t flags);
+
+                /**
+                 * Get "pooled" flag state.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Flag state.
+                 */
+                static bool IsPooled(int8_t* memPtr);
+
+                /**
+                 * Get "pooled" flag state.
+                 *
+                 * @param flags Flags.
+                 * @return Flag state.
+                 */
+                static bool IsPooled(int32_t flags);
+
+                /**
+                 * Get "acquired" flag state.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Flag state.
+                 */
+                static bool IsAcquired(int8_t* memPtr);
+
+                /**
+                 * Get "acquired" flag state.
+                 *
+                 * @param flags Flags.
+                 * @return Flag state.
+                 */
+                static bool IsAcquired(int32_t flags);
+
+                /**
+                 * Destructor.
+                 */
+                virtual ~InteropMemory() { }
+                    
+                /**
+                 * Get cross-platform memory pointer.
+                 *
+                 * @return Memory pointer.
+                 */
+                int8_t* Pointer();
+
+                /**
+                 * Get cross-platform pointer in long form.
+                 */
+                int64_t PointerLong();
+
+                /**
+                 * Get raw data pointer.
+                 *
+                 * @return Data pointer.
+                 */
+                int8_t* Data();
+
+                /**
+                 * Get capacity.
+                 *
+                 * @return Capacity.
+                 */
+                int32_t Capacity();
+
+                /**
+                 * Get length.
+                 *
+                 * @return Length.
+                 */
+                int32_t Length();
+
+                /**
+                 * Set length.
+                 *
+                 * @param val Length.
+                 */
+                void Length(int32_t val);
+
+                /**
+                 * Reallocate memory.
+                 *
+                 * @param cap Desired capactiy.
+                 */
+                virtual void Reallocate(int32_t cap) = 0;
+            protected:
+                /** Memory pointer. */
+                int8_t* memPtr; 
+            };
+
+            /**
+             * Interop unpooled memory.
+             */
+            class IGNITE_IMPORT_EXPORT InteropUnpooledMemory : public InteropMemory
+            {
+            public:
+                /**
+                 * Constructor create new unpooled memory object from scratch.
+                 *
+                 * @param cap Capacity.
+                 */
+                explicit InteropUnpooledMemory(int32_t cap);
+
+                /**
+                 * Constructor creating unpooled memory object from existing memory pointer.
+                 *
+                 * @param memPtr Memory pointer.
+                 */
+                explicit InteropUnpooledMemory(int8_t* memPtr);
+
+                /**
+                 * Destructor.
+                 */
+                ~InteropUnpooledMemory();
+
+                virtual void Reallocate(int32_t cap);
+            private:
+                /** Whether this instance is owner of memory chunk. */
+                bool owning; 
+
+                IGNITE_NO_COPY_ASSIGNMENT(InteropUnpooledMemory)
+            };
+
+            /**
+             * Interop external memory.
+             */
+            class IGNITE_IMPORT_EXPORT InteropExternalMemory : public InteropMemory
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param memPtr External memory pointer.
+                 */
+                explicit InteropExternalMemory(int8_t* memPtr);
+
+                virtual void Reallocate(int32_t cap);
+            private:
+                IGNITE_NO_COPY_ASSIGNMENT(InteropExternalMemory)
+            };
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1e18fa32/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_output_stream.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_output_stream.h b/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_output_stream.h
new file mode 100644
index 0000000..9cd6738
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/gridgain/impl/interop/interop_output_stream.h
@@ -0,0 +1,226 @@
+/*
+ *  Copyright (C) GridGain Systems. All Rights Reserved.
+ *  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+#ifndef _GRIDGAIN_IMPL_INTEROP_OUTPUT_STREAM
+#define _GRIDGAIN_IMPL_INTEROP_OUTPUT_STREAM
+
+#include "gridgain/impl/interop/interop_memory.h"
+
+namespace gridgain
+{    
+    namespace impl
+    {
+        namespace interop
+        {
+            /**
+             * Interop output stream.
+             */
+            class IGNITE_IMPORT_EXPORT InteropOutputStream {
+            public:
+                /**
+                 * Create new output stream with the given capacity.
+                 *
+                 * @param mem Memory.
+                 */
+                InteropOutputStream(InteropMemory* mem);
+
+                /**
+                 * Write signed 8-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt8(const int8_t val);
+
+                /**
+                 * Write signed 8-byte integer at the given position.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt8(const int8_t val, const int32_t pos);
+
+                /**
+                 * Write signed 8-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteInt8Array(const int8_t* val, const int32_t len);
+
+                /**
+                 * Write bool.
+                 *
+                 * @param val Value.
+                 */
+                void WriteBool(const bool val);
+
+                /**
+                 * Write bool array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteBoolArray(const bool* val, const int32_t len);
+
+                /**
+                 * Write signed 16-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt16(const int16_t val);
+
+                /**
+                 * Write signed 16-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteInt16Array(const int16_t* val, const int32_t len);
+
+                /**
+                 * Write unsigned 16-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteUInt16(const uint16_t val);
+
+                /**
+                 * Write unsigned 16-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteUInt16Array(const uint16_t* val, const int32_t len);
+
+                /**
+                 * Write signed 32-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt32(const int32_t val);
+
+                /**
+                 * Write signed 32-byte integer at the given position.
+                 *
+                 * @param pos Position.
+                 * @param val Value.
+                 */
+                void WriteInt32(const int32_t pos, const int32_t val);
+
+                /**
+                 * Write signed 32-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteInt32Array(const int32_t* val, const int32_t len);
+
+                /**
+                 * Write signed 64-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt64(const int64_t val);
+
+                /**
+                 * Write signed 64-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteInt64Array(const int64_t* val, const int32_t len);
+
+                /**
+                 * Write float.
+                 *
+                 * @param val Value.
+                 */
+                void WriteFloat(const float val);
+
+                /**
+                 * Write float array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteFloatArray(const float* val, const int32_t len);
+
+                /**
+                 * Write double.
+                 *
+                 * @param val Value.
+                 */
+                void WriteDouble(const double val);
+
+                /**
+                 * Write double array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteDoubleArray(const double* val, const int32_t len);
+
+                /**
+                 * Get current stream position.
+                 */
+                int32_t Position();
+
+                /**
+                 * Set current stream position (absolute).
+                 *
+                 * @param val Position (absolute).
+                 */
+                void Position(const int32_t val);
+
+                /**
+                 * Synchronize data with underlying memory.
+                 */
+                void Synchronize();
+            private:
+                /** Memory. */
+                InteropMemory* mem; 
+
+                /** Pointer to data. */
+                int8_t* data;       
+
+                /** Capacity. */
+                int cap;            
+
+                /** Current position. */
+                int pos;            
+
+                IGNITE_NO_COPY_ASSIGNMENT(InteropOutputStream)
+
+                /**
+                 * Ensure that stream enough capacity optionally extending it.
+                 *
+                 * @param reqCap Requsted capacity.
+                 */
+                void EnsureCapacity(int32_t reqCap);
+
+                /**
+                 * Shift stream to the right.
+                 *
+                 * @param cnt Amount of bytes to shift the stream to.
+                 */
+                void Shift(int32_t cnt);
+
+                /**
+                 * Copy data to the stream shifting it along the way.
+                 *
+                 * @param ptr Pointer to data.
+                 * @param off Offset.
+                 * @param len Length.
+                 */
+                void CopyAndShift(const int8_t* src, int32_t off, int32_t len);
+            };
+        }
+    }
+}
+
+#endif
\ No newline at end of file