You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/09/01 14:08:20 UTC
[71/82] [abbrv] ignite git commit: IGNITE-1337: Moved "common" CPP
project to Ignite.
IGNITE-1337: Moved "common" CPP project to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7ca8cbc7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7ca8cbc7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7ca8cbc7
Branch: refs/heads/ignite-1093-2
Commit: 7ca8cbc774b0c23aca537b078898707a2ede3cbd
Parents: 10e51d1
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Sep 1 10:39:17 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Sep 1 10:39:17 2015 +0300
----------------------------------------------------------------------
.../platform/src/main/cpp/common/Makefile.am | 45 +
.../platform/src/main/cpp/common/configure.ac | 62 +
.../src/main/cpp/common/ignite-common.pc.in | 9 +
.../src/main/cpp/common/include/Makefile.am | 22 +
.../common/include/ignite/common/concurrent.h | 210 ++
.../cpp/common/include/ignite/common/exports.h | 145 ++
.../cpp/common/include/ignite/common/java.h | 652 ++++++
.../cpp/common/os/linux/include/Makefile.am | 21 +
.../os/linux/include/ignite/common/common.h | 81 +
.../linux/include/ignite/common/concurrent_os.h | 394 ++++
.../src/main/cpp/common/os/linux/src/common.cpp | 59 +
.../cpp/common/os/linux/src/concurrent_os.cpp | 175 ++
.../os/win/include/ignite/common/common.h | 56 +
.../win/include/ignite/common/concurrent_os.h | 406 ++++
.../src/main/cpp/common/os/win/src/common.cpp | 65 +
.../cpp/common/os/win/src/concurrent_os.cpp | 151 ++
.../src/main/cpp/common/project/README.TXT | 1 +
.../src/main/cpp/common/project/vs/README.TXT | 1 +
.../main/cpp/common/project/vs/common.vcxproj | 202 ++
.../common/project/vs/common.vcxproj.filters | 54 +
.../src/main/cpp/common/project/vs/module.def | 99 +
.../src/main/cpp/common/project/vs/targetver.h | 25 +
.../src/main/cpp/common/src/concurrent.cpp | 94 +
.../src/main/cpp/common/src/exports.cpp | 413 ++++
.../platform/src/main/cpp/common/src/java.cpp | 2204 ++++++++++++++++++
parent/pom.xml | 5 +
26 files changed, 5651 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/Makefile.am b/modules/platform/src/main/cpp/common/Makefile.am
new file mode 100644
index 0000000..f5ca5dd
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/Makefile.am
@@ -0,0 +1,45 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+SUBDIRS = . include os/linux/include
+DIST_SUBDIRS = . include os/linux/include
+
+AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/os/linux/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -DIGNITE_IMPL
+AM_CXXFLAGS = -Wall -std=c++0x
+LIB_LDFLAGS = -no-undefined -version-info 1
+
+COMMON_SRC = os/linux/src/concurrent_os.cpp \
+ src/concurrent.cpp \
+ src/java.cpp \
+ src/exports.cpp \
+ os/linux/src/common.cpp
+
+lib_LTLIBRARIES = libignite-common.la
+libignite_common_la_SOURCES = $(COMMON_SRC)
+libignite_common_la_LIBADD = -L$(JAVA_HOME)/jre/lib/amd64/server
+libignite_common_la_LDFLAGS = $(LIB_LDFLAGS) -L/usr/local/lib -ljvm -version-info 0:0:0 -release $(PACKAGE_VERSION)
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = ignite-common.pc
+
+clean-local:
+ $(RM) *.gcno *.gcda
+
+clean-docs:
+ $(RM) $(DX_CLEANFILES)
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/configure.ac b/modules/platform/src/main/cpp/common/configure.ac
new file mode 100644
index 0000000..7706737
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/configure.ac
@@ -0,0 +1,62 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([Ignite JNI bridge for C++], [7.4.1], [dev@ignite.apache.org], [ignite-common], [ignite.apache.org])
+AC_CONFIG_SRCDIR(src)
+
+AC_CANONICAL_SYSTEM
+AC_CONFIG_MACRO_DIR([m4])
+AC_LANG([C++])
+
+# Initialize automake
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
+AC_CONFIG_HEADER(config.h)
+
+AM_PROG_AR
+
+# Checks for programs.
+GXX="-g -O2"
+
+AC_PROG_CXX
+
+# Initialize Libtool
+LT_INIT
+
+# Checks for libraries.
+AC_CHECK_LIB([pthread], [pthread_mutex_lock])
+
+# Checks for header files.
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_ERROR_AT_LINE
+
+AC_CONFIG_FILES(Makefile include/Makefile os/linux/include/Makefile ignite-common.pc)
+
+AC_OUTPUT
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/ignite-common.pc.in
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/ignite-common.pc.in b/modules/platform/src/main/cpp/common/ignite-common.pc.in
new file mode 100644
index 0000000..3cd3cec
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/ignite-common.pc.in
@@ -0,0 +1,9 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ignite-common
+Description: Ignite JNI bridge for C++.
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lignite-common
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/include/Makefile.am b/modules/platform/src/main/cpp/common/include/Makefile.am
new file mode 100644
index 0000000..5db1d4a
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/include/Makefile.am
@@ -0,0 +1,22 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+nobase_include_HEADERS = ignite/common/concurrent.h \
+ ignite/common/java.h \
+ ignite/common/exports.h
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/include/ignite/common/concurrent.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/include/ignite/common/concurrent.h b/modules/platform/src/main/cpp/common/include/ignite/common/concurrent.h
new file mode 100644
index 0000000..1c9ab22
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/include/ignite/common/concurrent.h
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_COMMON_CONCURRENT
+#define _IGNITE_COMMON_CONCURRENT
+
+#include "ignite/common/concurrent_os.h"
+
+namespace ignite
+{
+ namespace common
+ {
+ namespace concurrent
+ {
+ /**
+ * Default deleter implementation.
+ *
+ * @param obj Object to be deleted.
+ */
+ template<typename T>
+ IGNITE_IMPORT_EXPORT void SharedPointerDefaultDeleter(T* obj)
+ {
+ delete obj;
+ }
+
+ /**
+ * Holder of shared pointer data.
+ */
+ class IGNITE_IMPORT_EXPORT SharedPointerImpl
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param ptr Raw pointer.
+ */
+ SharedPointerImpl(void* ptr);
+
+ /**
+ * Get raw pointer.
+ *
+ * @return Raw pointer.
+ */
+ void* Pointer();
+
+ /**
+ * Increment usage counter.
+ */
+ void Increment();
+
+ /**
+ * Decrement usage counter.
+ *
+ * @return True if counter reached zero.
+ */
+ bool Decrement();
+ private:
+ /** Raw pointer. */
+ void* ptr;
+
+ /** Reference count. */
+ int32_t refCnt;
+
+ IGNITE_NO_COPY_ASSIGNMENT(SharedPointerImpl)
+ };
+
+ /**
+ * Shared pointer.
+ */
+ template<typename T>
+ class IGNITE_IMPORT_EXPORT SharedPointer
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ SharedPointer() : impl(NULL), deleter(NULL)
+ {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param ptr Raw pointer.
+ */
+ explicit SharedPointer(T* ptr)
+ {
+ if (ptr)
+ {
+ impl = new SharedPointerImpl(ptr);
+ deleter = SharedPointerDefaultDeleter;
+ }
+ else
+ {
+ impl = NULL;
+ deleter = NULL;
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param ptr Raw pointer.
+ * @param deleter Delete function.
+ */
+ SharedPointer(T* ptr, void(*deleter)(T*))
+ {
+ if (ptr)
+ {
+ this->impl = new SharedPointerImpl(ptr);
+ this->deleter = deleter;
+ }
+ else
+ {
+ this->impl = NULL;
+ this->deleter = NULL;
+ }
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param other Instance to copy.
+ */
+ SharedPointer(const SharedPointer& other)
+ {
+ impl = other.impl;
+ deleter = other.deleter;
+
+ if (impl)
+ impl->Increment();
+ }
+
+ /**
+ * Assignment operator.
+ *
+ * @param other Other instance.
+ */
+ SharedPointer& operator=(const SharedPointer& other)
+ {
+ if (this != &other)
+ {
+ // 1. Create new instance.
+ SharedPointer tmp(other);
+
+ // 2. Swap with temp.
+ SharedPointerImpl* impl0 = impl;
+ void(*deleter0)(T*) = deleter;
+
+ impl = tmp.impl;
+ deleter = tmp.deleter;
+
+ tmp.impl = impl0;
+ tmp.deleter = deleter0;
+ }
+
+ return *this;
+ }
+
+ /**
+ * Destructor.
+ */
+ ~SharedPointer()
+ {
+ if (impl && impl->Decrement())
+ {
+ T* ptr = Get();
+
+ delete impl;
+
+ deleter(ptr);
+ }
+ }
+
+ /**
+ * Get raw pointer.
+ *
+ * @return Raw pointer.
+ */
+ T* Get()
+ {
+ return impl ? static_cast<T*>(impl->Pointer()) : NULL;
+ }
+ private:
+ /** Implementation. */
+ SharedPointerImpl* impl;
+
+ /** Delete function. */
+ void(*deleter)(T*);
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/include/ignite/common/exports.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/include/ignite/common/exports.h b/modules/platform/src/main/cpp/common/include/ignite/common/exports.h
new file mode 100644
index 0000000..48e86f0
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/include/ignite/common/exports.h
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_COMMON_EXPORTS
+#define _IGNITE_COMMON_EXPORTS
+
+#include "ignite/common/java.h"
+
+namespace gcj = ignite::common::java;
+
+extern "C" {
+ int IGNITE_CALL IgniteReallocate(long long memPtr, int cap);
+
+ void* IGNITE_CALL IgniteIgnitionStart(gcj::JniContext* ctx, char* cfgPath, char* gridName, int factoryId, long long dataPtr);
+ void* IGNITE_CALL IgniteIgnitionInstance(gcj::JniContext* ctx, char* gridName);
+ long long IGNITE_CALL IgniteIgnitionEnvironmentPointer(gcj::JniContext* ctx, char* gridName);
+ bool IGNITE_CALL IgniteIgnitionStop(gcj::JniContext* ctx, char* gridName, bool cancel);
+ void IGNITE_CALL IgniteIgnitionStopAll(gcj::JniContext* ctx, bool cancel);
+
+ void IGNITE_CALL IgniteProcessorReleaseStart(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteProcessorProjection(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteProcessorCache(gcj::JniContext* ctx, void* obj, char* name);
+ void* IGNITE_CALL IgniteProcessorCreateCache(gcj::JniContext* ctx, void* obj, char* name);
+ void* IGNITE_CALL IgniteProcessorGetOrCreateCache(gcj::JniContext* ctx, void* obj, char* name);
+ void* IGNITE_CALL IgniteProcessorAffinity(gcj::JniContext* ctx, void* obj, char* name);
+ void* IGNITE_CALL IgniteProcessorDataStreamer(gcj::JniContext* ctx, void* obj, char* name, bool keepPortable);
+ void* IGNITE_CALL IgniteProcessorTransactions(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteProcessorCompute(gcj::JniContext* ctx, void* obj, void* prj);
+ void* IGNITE_CALL IgniteProcessorMessage(gcj::JniContext* ctx, void* obj, void* prj);
+ void* IGNITE_CALL IgniteProcessorEvents(gcj::JniContext* ctx, void* obj, void* prj);
+ void* IGNITE_CALL IgniteProcessorServices(gcj::JniContext* ctx, void* obj, void* prj);
+ void* IGNITE_CALL IgniteProcessorExtensions(gcj::JniContext* ctx, void* obj);
+
+ long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
+ void IGNITE_CALL IgniteTargetInStreamOutStream(gcj::JniContext* ctx, void* obj, int opType, long long inMemPtr, long long outMemPtr);
+ void* IGNITE_CALL IgniteTargetInStreamOutObject(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
+ void IGNITE_CALL IgniteTargetInObjectStreamOutStream(gcj::JniContext* ctx, void* obj, int opType, void* arg, long long inMemPtr, long long outMemPtr);
+ long long IGNITE_CALL IgniteTargetOutLong(gcj::JniContext* ctx, void* obj, int opType);
+ void IGNITE_CALL IgniteTargetOutStream(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
+ void* IGNITE_CALL IgniteTargetOutObject(gcj::JniContext* ctx, void* obj, int opType);
+ void IGNITE_CALL IgniteTargetListenFuture(gcj::JniContext* ctx, void* obj, long long futId, int typ);
+ void IGNITE_CALL IgniteTargetListenFutureForOperation(gcj::JniContext* ctx, void* obj, long long futId, int typ, int opId);
+
+ int IGNITE_CALL IgniteAffinityPartitions(gcj::JniContext* ctx, void* obj);
+
+ void* IGNITE_CALL IgniteCacheWithSkipStore(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteCacheWithNoRetries(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteCacheWithExpiryPolicy(gcj::JniContext* ctx, void* obj, long long create, long long update, long long access);
+ void* IGNITE_CALL IgniteCacheWithAsync(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteCacheWithKeepPortable(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteCacheClear(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteCacheRemoveAll(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteCacheOutOpQueryCursor(gcj::JniContext* ctx, void* obj, int type, long long memPtr);
+ void* IGNITE_CALL IgniteCacheOutOpContinuousQuery(gcj::JniContext* ctx, void* obj, int type, long long memPtr);
+ void* IGNITE_CALL IgniteCacheIterator(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteCacheLocalIterator(gcj::JniContext* ctx, void* obj, int peekModes);
+ void IGNITE_CALL IgniteCacheEnterLock(gcj::JniContext* ctx, void* obj, long long id);
+ void IGNITE_CALL IgniteCacheExitLock(gcj::JniContext* ctx, void* obj, long long id);
+ bool IGNITE_CALL IgniteCacheTryEnterLock(gcj::JniContext* ctx, void* obj, long long id, long long timeout);
+ void IGNITE_CALL IgniteCacheCloseLock(gcj::JniContext* ctx, void* obj, long long id);
+ void IGNITE_CALL IgniteCacheRebalance(gcj::JniContext* ctx, void* obj, long long futId);
+ int IGNITE_CALL IgniteCacheSize(gcj::JniContext* ctx, void* obj, int peekModes, bool loc);
+
+ void IGNITE_CALL IgniteCacheStoreCallbackInvoke(gcj::JniContext* ctx, void* obj, long long memPtr);
+
+ void IGNITE_CALL IgniteComputeWithNoFailover(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteComputeWithTimeout(gcj::JniContext* ctx, void* obj, long long timeout);
+ void IGNITE_CALL IgniteComputeExecuteNative(gcj::JniContext* ctx, void* obj, long long taskPtr, long long topVer);
+
+ void IGNITE_CALL IgniteContinuousQueryClose(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteContinuousQueryGetInitialQueryCursor(gcj::JniContext* ctx, void* obj);
+
+ void IGNITE_CALL IgniteDataStreamerListenTopology(gcj::JniContext* ctx, void* obj, long long ptr);
+ bool IGNITE_CALL IgniteDataStreamerAllowOverwriteGet(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteDataStreamerAllowOverwriteSet(gcj::JniContext* ctx, void* obj, bool val);
+ bool IGNITE_CALL IgniteDataStreamerSkipStoreGet(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteDataStreamerSkipStoreSet(gcj::JniContext* ctx, void* obj, bool val);
+ int IGNITE_CALL IgniteDataStreamerPerNodeBufferSizeGet(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteDataStreamerPerNodeBufferSizeSet(gcj::JniContext* ctx, void* obj, int val);
+ int IGNITE_CALL IgniteDataStreamerPerNodeParallelOperationsGet(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteDataStreamerPerNodeParallelOperationsSet(gcj::JniContext* ctx, void* obj, int val);
+
+ void* IGNITE_CALL IgniteMessagingWithAsync(gcj::JniContext* ctx, void* obj);
+
+ void* IGNITE_CALL IgniteProjectionForOthers(gcj::JniContext* ctx, void* obj, void* prj);
+ void* IGNITE_CALL IgniteProjectionForRemotes(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteProjectionForDaemons(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteProjectionForRandom(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteProjectionForOldest(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteProjectionForYoungest(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteProjectionResetMetrics(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteProjectionOutOpRet(gcj::JniContext* ctx, void* obj, int type, long long memPtr);
+
+ void IGNITE_CALL IgniteQueryCursorIterator(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteQueryCursorClose(gcj::JniContext* ctx, void* obj);
+
+ long long IGNITE_CALL IgniteTransactionsStart(gcj::JniContext* ctx, void* obj, int concurrency, int isolation, long long timeout, int txSize);
+ int IGNITE_CALL IgniteTransactionsCommit(gcj::JniContext* ctx, void* obj, long long id);
+ void IGNITE_CALL IgniteTransactionsCommitAsync(gcj::JniContext* ctx, void* obj, long long id, long long futId);
+ int IGNITE_CALL IgniteTransactionsRollback(gcj::JniContext* ctx, void* obj, long long id);
+ void IGNITE_CALL IgniteTransactionsRollbackAsync(gcj::JniContext* ctx, void* obj, long long id, long long futId);
+ int IGNITE_CALL IgniteTransactionsClose(gcj::JniContext* ctx, void* obj, long long id);
+ int IGNITE_CALL IgniteTransactionsState(gcj::JniContext* ctx, void* obj, long long id);
+ bool IGNITE_CALL IgniteTransactionsSetRollbackOnly(gcj::JniContext* ctx, void* obj, long long id);
+ void IGNITE_CALL IgniteTransactionsResetMetrics(gcj::JniContext* ctx, void* obj);
+
+ void* IGNITE_CALL IgniteAcquire(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteRelease(void* obj);
+
+ void IGNITE_CALL IgniteThrowToJava(gcj::JniContext* ctx, char* errMsg);
+
+ int IGNITE_CALL IgniteHandlersSize();
+
+ void* IGNITE_CALL IgniteCreateContext(char** opts, int optsLen, gcj::JniHandlers* cbs);
+ void IGNITE_CALL IgniteDeleteContext(gcj::JniContext* ctx);
+
+ void IGNITE_CALL IgniteDestroyJvm(gcj::JniContext* ctx);
+
+ void* IGNITE_CALL IgniteEventsWithAsync(gcj::JniContext* ctx, void* obj);
+ bool IGNITE_CALL IgniteEventsStopLocalListen(gcj::JniContext* ctx, void* obj, long long hnd);
+ void IGNITE_CALL IgniteEventsLocalListen(gcj::JniContext* ctx, void* obj, long long hnd, int type);
+ bool IGNITE_CALL IgniteEventsIsEnabled(gcj::JniContext* ctx, void* obj, int type);
+
+ void* IGNITE_CALL IgniteServicesWithAsync(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteServicesWithServerKeepPortable(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteServicesCancel(gcj::JniContext* ctx, void* obj, char* name);
+ void IGNITE_CALL IgniteServicesCancelAll(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteServicesGetServiceProxy(gcj::JniContext* ctx, void* obj, char* name, bool sticky);
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/include/ignite/common/java.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/include/ignite/common/java.h b/modules/platform/src/main/cpp/common/include/ignite/common/java.h
new file mode 100644
index 0000000..426ac68
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/include/ignite/common/java.h
@@ -0,0 +1,652 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_COMMON_JVM
+#define _IGNITE_COMMON_JVM
+
+#include <jni.h>
+
+#include "ignite/common/common.h"
+
+namespace ignite
+{
+ namespace common
+ {
+ namespace java
+ {
+ /* Error constants. */
+ const int IGNITE_JNI_ERR_SUCCESS = 0;
+ const int IGNITE_JNI_ERR_GENERIC = 1;
+ const int IGNITE_JNI_ERR_JVM_INIT = 2;
+ const int IGNITE_JNI_ERR_JVM_ATTACH = 3;
+
+ /* Handlers for callbacks from Java. */
+ typedef long long(JNICALL *CacheStoreCreateHandler)(void* target, long long memPtr);
+ typedef int(JNICALL *CacheStoreInvokeHandler)(void* target, long long objPtr, long long memPtr, void* cb);
+ typedef void(JNICALL *CacheStoreDestroyHandler)(void* target, long long objPtr);
+ typedef long long(JNICALL *CacheStoreSessionCreateHandler)(void* target, long long storePtr);
+
+ typedef long long(JNICALL *CacheEntryFilterCreateHandler)(void* target, long long memPtr);
+ typedef int(JNICALL *CacheEntryFilterApplyHandler)(void* target, long long ptr, long long memPtr);
+ typedef void(JNICALL *CacheEntryFilterDestroyHandler)(void* target, long long ptr);
+
+ typedef void(JNICALL *CacheInvokeHandler)(void* target, long long inMemPtr, long long outMemPtr);
+
+ typedef void(JNICALL *ComputeTaskMapHandler)(void* target, long long taskPtr, long long inMemPtr, long long outMemPtr);
+ typedef int(JNICALL *ComputeTaskJobResultHandler)(void* target, long long taskPtr, long long jobPtr, long long memPtr);
+ typedef void(JNICALL *ComputeTaskReduceHandler)(void* target, long long taskPtr);
+ typedef void(JNICALL *ComputeTaskCompleteHandler)(void* target, long long taskPtr, long long memPtr);
+ typedef int(JNICALL *ComputeJobSerializeHandler)(void* target, long long jobPtr, long long memPtr);
+ typedef long long(JNICALL *ComputeJobCreateHandler)(void* target, long long memPtr);
+ typedef void(JNICALL *ComputeJobExecuteHandler)(void* target, long long jobPtr, int cancel, long long memPtr);
+ typedef void(JNICALL *ComputeJobCancelHandler)(void* target, long long jobPtr);
+ typedef void(JNICALL *ComputeJobDestroyHandler)(void* target, long long jobPtr);
+
+ typedef void(JNICALL *ContinuousQueryListenerApplyHandler)(void* target, long long lsnrPtr, long long memPtr);
+ typedef long long(JNICALL *ContinuousQueryFilterCreateHandler)(void* target, long long memPtr);
+ typedef int(JNICALL *ContinuousQueryFilterApplyHandler)(void* target, long long filterPtr, long long memPtr);
+ typedef void(JNICALL *ContinuousQueryFilterReleaseHandler)(void* target, long long filterPtr);
+
+ typedef void(JNICALL *DataStreamerTopologyUpdateHandler)(void* target, long long ldrPtr, long long topVer, int topSize);
+ typedef void(JNICALL *DataStreamerStreamReceiverInvokeHandler)(void* target, long long ptr, void* cache, long long memPtr, unsigned char keepPortable);
+
+ typedef void(JNICALL *FutureByteResultHandler)(void* target, long long futAddr, int res);
+ typedef void(JNICALL *FutureBoolResultHandler)(void* target, long long futAddr, int res);
+ typedef void(JNICALL *FutureShortResultHandler)(void* target, long long futAddr, int res);
+ typedef void(JNICALL *FutureCharResultHandler)(void* target, long long futAddr, int res);
+ typedef void(JNICALL *FutureIntResultHandler)(void* target, long long futAddr, int res);
+ typedef void(JNICALL *FutureFloatResultHandler)(void* target, long long futAddr, float res);
+ typedef void(JNICALL *FutureLongResultHandler)(void* target, long long futAddr, long long res);
+ typedef void(JNICALL *FutureDoubleResultHandler)(void* target, long long futAddr, double res);
+ typedef void(JNICALL *FutureObjectResultHandler)(void* target, long long futAddr, long long memPtr);
+ typedef void(JNICALL *FutureNullResultHandler)(void* target, long long futAddr);
+ typedef void(JNICALL *FutureErrorHandler)(void* target, long long futAddr, long long memPtr);
+
+ typedef void(JNICALL *LifecycleEventHandler)(void* target, long long ptr, int evt);
+
+ typedef void(JNICALL *MemoryReallocateHandler)(void* target, long long memPtr, int cap);
+
+ typedef long long(JNICALL *MessagingFilterCreateHandler)(void* target, long long memPtr);
+ typedef int(JNICALL *MessagingFilterApplyHandler)(void* target, long long ptr, long long memPtr);
+ typedef void(JNICALL *MessagingFilterDestroyHandler)(void* target, long long ptr);
+
+ typedef long long(JNICALL *EventFilterCreateHandler)(void* target, long long memPtr);
+ typedef int(JNICALL *EventFilterApplyHandler)(void* target, long long ptr, long long memPtr);
+ typedef void(JNICALL *EventFilterDestroyHandler)(void* target, long long ptr);
+
+ typedef long long(JNICALL *ServiceInitHandler)(void* target, long long memPtr);
+ typedef void(JNICALL *ServiceExecuteHandler)(void* target, long long svcPtr, long long memPtr);
+ typedef void(JNICALL *ServiceCancelHandler)(void* target, long long svcPtr, long long memPtr);
+ typedef void(JNICALL *ServiceInvokeMethodHandler)(void* target, long long svcPtr, long long inMemPtr, long long outMemPtr);
+ typedef int(JNICALL *ClusterNodeFilterApplyHandler)(void* target, long long memPtr);
+
+ typedef long long(JNICALL *NodeInfoHandler)(void* target, long long memPtr);
+
+ typedef void(JNICALL *OnStartHandler)(void* target, long long memPtr);
+ typedef void(JNICALL *OnStopHandler)(void* target);
+ typedef void(JNICALL *ErrorHandler)(void* target, int errCode, const char* errClsChars, int errClsCharsLen, const char* errMsgChars, int errMsgCharsLen, void* errData, int errDataLen);
+
+ typedef long long(JNICALL *ExtensionCallbackInLongOutLongHandler)(void* target, int typ, long long arg1);
+ typedef long long(JNICALL *ExtensionCallbackInLongLongOutLongHandler)(void* target, int typ, long long arg1, long long arg2);
+
+ /**
+ * JNI handlers holder.
+ */
+ struct JniHandlers {
+ void* target;
+
+ CacheStoreCreateHandler cacheStoreCreate;
+ CacheStoreInvokeHandler cacheStoreInvoke;
+ CacheStoreDestroyHandler cacheStoreDestroy;
+ CacheStoreSessionCreateHandler cacheStoreSessionCreate;
+
+ CacheEntryFilterCreateHandler cacheEntryFilterCreate;
+ CacheEntryFilterApplyHandler cacheEntryFilterApply;
+ CacheEntryFilterDestroyHandler cacheEntryFilterDestroy;
+
+ CacheInvokeHandler cacheInvoke;
+
+ ComputeTaskMapHandler computeTaskMap;
+ ComputeTaskJobResultHandler computeTaskJobRes;
+ ComputeTaskReduceHandler computeTaskReduce;
+ ComputeTaskCompleteHandler computeTaskComplete;
+ ComputeJobSerializeHandler computeJobSerialize;
+ ComputeJobCreateHandler computeJobCreate;
+ ComputeJobExecuteHandler computeJobExec;
+ ComputeJobCancelHandler computeJobCancel;
+ ComputeJobDestroyHandler computeJobDestroy;
+
+ ContinuousQueryListenerApplyHandler contQryLsnrApply;
+ ContinuousQueryFilterCreateHandler contQryFilterCreate;
+ ContinuousQueryFilterApplyHandler contQryFilterApply;
+ ContinuousQueryFilterReleaseHandler contQryFilterRelease;
+
+ DataStreamerTopologyUpdateHandler dataStreamerTopologyUpdate;
+ DataStreamerStreamReceiverInvokeHandler streamReceiverInvoke;
+
+ FutureByteResultHandler futByteRes;
+ FutureBoolResultHandler futBoolRes;
+ FutureShortResultHandler futShortRes;
+ FutureCharResultHandler futCharRes;
+ FutureIntResultHandler futIntRes;
+ FutureFloatResultHandler futFloatRes;
+ FutureLongResultHandler futLongRes;
+ FutureDoubleResultHandler futDoubleRes;
+ FutureObjectResultHandler futObjRes;
+ FutureNullResultHandler futNullRes;
+ FutureErrorHandler futErr;
+
+ LifecycleEventHandler lifecycleEvt;
+
+ MemoryReallocateHandler memRealloc;
+
+ MessagingFilterCreateHandler messagingFilterCreate;
+ MessagingFilterApplyHandler messagingFilterApply;
+ MessagingFilterDestroyHandler messagingFilterDestroy;
+
+ EventFilterCreateHandler eventFilterCreate;
+ EventFilterApplyHandler eventFilterApply;
+ EventFilterDestroyHandler eventFilterDestroy;
+
+ ServiceInitHandler serviceInit;
+ ServiceExecuteHandler serviceExecute;
+ ServiceCancelHandler serviceCancel;
+ ServiceInvokeMethodHandler serviceInvokeMethod;
+
+ ClusterNodeFilterApplyHandler clusterNodeFilterApply;
+
+ NodeInfoHandler nodeInfo;
+
+ OnStartHandler onStart;
+ OnStopHandler onStop;
+ ErrorHandler error;
+
+ ExtensionCallbackInLongOutLongHandler extensionCallbackInLongOutLong;
+ ExtensionCallbackInLongLongOutLongHandler extensionCallbackInLongLongOutLong;
+ };
+
+ /**
+ * JNI Java members.
+ */
+ struct JniJavaMembers {
+ jclass c_Class;
+ jmethodID m_Class_getName;
+
+ jclass c_Throwable;
+ jmethodID m_Throwable_getMessage;
+ jmethodID m_Throwable_printStackTrace;
+
+ /**
+ * Constructor.
+ */
+ void Initialize(JNIEnv* env);
+
+ /**
+ * Destroy members releasing all allocated classes.
+ */
+ void Destroy(JNIEnv* env);
+
+ /**
+ * Write error information.
+ */
+ bool WriteErrorInfo(JNIEnv* env, char** errClsName, int* errClsNameLen, char** errMsg, int* errMsgLen);
+ };
+
+ /**
+ * JNI members.
+ */
+ struct JniMembers {
+ jclass c_PlatformAbstractQryCursor;
+ jmethodID m_PlatformAbstractQryCursor_iter;
+ jmethodID m_PlatformAbstractQryCursor_iterHasNext;
+ jmethodID m_PlatformAbstractQryCursor_close;
+
+ jclass c_PlatformAffinity;
+ jmethodID m_PlatformAffinity_partitions;
+
+ jclass c_PlatformCache;
+ jmethodID m_PlatformCache_withSkipStore;
+ jmethodID m_PlatformCache_withNoRetries;
+ jmethodID m_PlatformCache_withExpiryPolicy;
+ jmethodID m_PlatformCache_withAsync;
+ jmethodID m_PlatformCache_withKeepPortable;
+ jmethodID m_PlatformCache_clear;
+ jmethodID m_PlatformCache_removeAll;
+ jmethodID m_PlatformCache_iterator;
+ jmethodID m_PlatformCache_localIterator;
+ jmethodID m_PlatformCache_enterLock;
+ jmethodID m_PlatformCache_exitLock;
+ jmethodID m_PlatformCache_tryEnterLock;
+ jmethodID m_PlatformCache_closeLock;
+ jmethodID m_PlatformCache_rebalance;
+ jmethodID m_PlatformCache_size;
+
+ jclass c_PlatformCacheStoreCallback;
+ jmethodID m_PlatformCacheStoreCallback_invoke;
+
+ jclass c_IgniteException;
+
+ jclass c_PlatformClusterGroup;
+ jmethodID m_PlatformClusterGroup_forOthers;
+ jmethodID m_PlatformClusterGroup_forRemotes;
+ jmethodID m_PlatformClusterGroup_forDaemons;
+ jmethodID m_PlatformClusterGroup_forRandom;
+ jmethodID m_PlatformClusterGroup_forOldest;
+ jmethodID m_PlatformClusterGroup_forYoungest;
+ jmethodID m_PlatformClusterGroup_resetMetrics;
+
+ jclass c_PlatformCompute;
+ jmethodID m_PlatformCompute_withNoFailover;
+ jmethodID m_PlatformCompute_withTimeout;
+ jmethodID m_PlatformCompute_executeNative;
+
+ jclass c_PlatformContinuousQuery;
+ jmethodID m_PlatformContinuousQuery_close;
+ jmethodID m_PlatformContinuousQuery_getInitialQueryCursor;
+
+ jclass c_PlatformDataStreamer;
+ jmethodID m_PlatformDataStreamer_listenTopology;
+ jmethodID m_PlatformDataStreamer_getAllowOverwrite;
+ jmethodID m_PlatformDataStreamer_setAllowOverwrite;
+ jmethodID m_PlatformDataStreamer_getSkipStore;
+ jmethodID m_PlatformDataStreamer_setSkipStore;
+ jmethodID m_PlatformDataStreamer_getPerNodeBufSize;
+ jmethodID m_PlatformDataStreamer_setPerNodeBufSize;
+ jmethodID m_PlatformDataStreamer_getPerNodeParallelOps;
+ jmethodID m_PlatformDataStreamer_setPerNodeParallelOps;
+
+ jclass c_PlatformEvents;
+ jmethodID m_PlatformEvents_withAsync;
+ jmethodID m_PlatformEvents_stopLocalListen;
+ jmethodID m_PlatformEvents_localListen;
+ jmethodID m_PlatformEvents_isEnabled;
+
+ jclass c_PlatformServices;
+ jmethodID m_PlatformServices_withAsync;
+ jmethodID m_PlatformServices_withServerKeepPortable;
+ jmethodID m_PlatformServices_cancel;
+ jmethodID m_PlatformServices_cancelAll;
+ jmethodID m_PlatformServices_serviceProxy;
+
+ jclass c_PlatformIgnition;
+ jmethodID m_PlatformIgnition_start;
+ jmethodID m_PlatformIgnition_instance;
+ jmethodID m_PlatformIgnition_environmentPointer;
+ jmethodID m_PlatformIgnition_stop;
+ jmethodID m_PlatformIgnition_stopAll;
+
+ jclass c_PlatformMessaging;
+ jmethodID m_PlatformMessaging_withAsync;
+
+ jclass c_PlatformProcessor;
+ jmethodID m_PlatformProcessor_releaseStart;
+ jmethodID m_PlatformProcessor_cache;
+ jmethodID m_PlatformProcessor_createCache;
+ jmethodID m_PlatformProcessor_getOrCreateCache;
+ jmethodID m_PlatformProcessor_affinity;
+ jmethodID m_PlatformProcessor_dataStreamer;
+ jmethodID m_PlatformProcessor_transactions;
+ jmethodID m_PlatformProcessor_projection;
+ jmethodID m_PlatformProcessor_compute;
+ jmethodID m_PlatformProcessor_message;
+ jmethodID m_PlatformProcessor_events;
+ jmethodID m_PlatformProcessor_services;
+ jmethodID m_PlatformProcessor_extensions;
+
+ jclass c_PlatformTarget;
+ jmethodID m_PlatformTarget_inStreamOutLong;
+ jmethodID m_PlatformTarget_inStreamOutObject;
+ jmethodID m_PlatformTarget_outLong;
+ jmethodID m_PlatformTarget_outStream;
+ jmethodID m_PlatformTarget_outObject;
+ jmethodID m_PlatformTarget_inStreamOutStream;
+ jmethodID m_PlatformTarget_inObjectStreamOutStream;
+ jmethodID m_PlatformTarget_listenFuture;
+ jmethodID m_PlatformTarget_listenFutureForOperation;
+
+ jclass c_PlatformTransactions;
+ jmethodID m_PlatformTransactions_txStart;
+ jmethodID m_PlatformTransactions_txCommit;
+ jmethodID m_PlatformTransactions_txCommitAsync;
+ jmethodID m_PlatformTransactions_txRollback;
+ jmethodID m_PlatformTransactions_txRollbackAsync;
+ jmethodID m_PlatformTransactions_txState;
+ jmethodID m_PlatformTransactions_txSetRollbackOnly;
+ jmethodID m_PlatformTransactions_txClose;
+ jmethodID m_PlatformTransactions_resetMetrics;
+
+ jclass c_PlatformUtils;
+ jmethodID m_PlatformUtils_reallocate;
+ jmethodID m_PlatformUtils_errData;
+
+ /**
+ * Constructor.
+ */
+ void Initialize(JNIEnv* env);
+
+ /**
+ * Destroy members releasing all allocated classes.
+ */
+ void Destroy(JNIEnv* env);
+ };
+
+ /**
+ * JNI JVM wrapper.
+ */
+ class IGNITE_IMPORT_EXPORT JniJvm {
+ public:
+ /**
+ * Default constructor for uninitialized JVM.
+ */
+ JniJvm();
+
+ /**
+ * Constructor.
+ *
+ * @param jvm JVM.
+ * @param javaMembers Java members.
+ * @param members Members.
+ */
+ JniJvm(JavaVM* jvm, JniJavaMembers javaMembers, JniMembers members);
+
+ /**
+ * Get JVM.
+ *
+ * @param JVM.
+ */
+ JavaVM* GetJvm();
+
+ /**
+ * Get Java members.
+ *
+ * @param Java members.
+ */
+ JniJavaMembers& GetJavaMembers();
+
+ /**
+ * Get members.
+ *
+ * @param Members.
+ */
+ JniMembers& GetMembers();
+ private:
+ /** JVM. */
+ JavaVM* jvm;
+
+ /** Java members. */
+ JniJavaMembers javaMembers;
+
+ /** Members. */
+ JniMembers members;
+ };
+
+ /**
+ * JNI error information.
+ */
+ struct IGNITE_IMPORT_EXPORT JniErrorInfo
+ {
+ int code;
+ char* errCls;
+ char* errMsg;
+
+ /**
+ * Default constructor. Creates empty error info.
+ */
+ JniErrorInfo();
+
+ /**
+ * Constructor.
+ *
+ * @param code Code.
+ * @param errCls Error class.
+ * @param errMsg Error message.
+ */
+ JniErrorInfo(int code, const char* errCls, const char* errMsg);
+
+ /**
+ * Copy constructor.
+ *
+ * @param other Other instance.
+ */
+ JniErrorInfo(const JniErrorInfo& other);
+
+ /**
+ * Assignment operator overload.
+ *
+ * @param other Other instance.
+ * @return This instance.
+ */
+ JniErrorInfo& operator=(const JniErrorInfo& other);
+
+ /**
+ * Destructor.
+ */
+ ~JniErrorInfo();
+ };
+
+ /**
+ * Unmanaged context.
+ */
+ class IGNITE_IMPORT_EXPORT JniContext {
+ public:
+ static JniContext* Create(char** opts, int optsLen, JniHandlers hnds);
+ static JniContext* Create(char** opts, int optsLen, JniHandlers hnds, JniErrorInfo* errInfo);
+ static int Reallocate(long long memPtr, int cap);
+ static void Detach();
+ static void Release(jobject obj);
+
+ jobject IgnitionStart(char* cfgPath, char* gridName, int factoryId, long long dataPtr);
+ jobject IgnitionStart(char* cfgPath, char* gridName, int factoryId, long long dataPtr, JniErrorInfo* errInfo);
+ jobject IgnitionInstance(char* gridName);
+ jobject IgnitionInstance(char* gridName, JniErrorInfo* errInfo);
+ long long IgnitionEnvironmentPointer(char* gridName);
+ long long IgnitionEnvironmentPointer(char* gridName, JniErrorInfo* errInfo);
+ bool IgnitionStop(char* gridName, bool cancel);
+ bool IgnitionStop(char* gridName, bool cancel, JniErrorInfo* errInfo);
+ void IgnitionStopAll(bool cancel);
+ void IgnitionStopAll(bool cancel, JniErrorInfo* errInfo);
+
+ void ProcessorReleaseStart(jobject obj);
+ jobject ProcessorProjection(jobject obj);
+ jobject ProcessorCache(jobject obj, const char* name);
+ jobject ProcessorCache(jobject obj, const char* name, JniErrorInfo* errInfo);
+ jobject ProcessorCreateCache(jobject obj, const char* name);
+ jobject ProcessorCreateCache(jobject obj, const char* name, JniErrorInfo* errInfo);
+ jobject ProcessorGetOrCreateCache(jobject obj, const char* name);
+ jobject ProcessorGetOrCreateCache(jobject obj, const char* name, JniErrorInfo* errInfo);
+ jobject ProcessorAffinity(jobject obj, const char* name);
+ jobject ProcessorDataStreamer(jobject obj, const char* name, bool keepPortable);
+ jobject ProcessorTransactions(jobject obj);
+ jobject ProcessorCompute(jobject obj, jobject prj);
+ jobject ProcessorMessage(jobject obj, jobject prj);
+ jobject ProcessorEvents(jobject obj, jobject prj);
+ jobject ProcessorServices(jobject obj, jobject prj);
+ jobject ProcessorExtensions(jobject obj);
+
+ long long TargetInStreamOutLong(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
+ void TargetInStreamOutStream(jobject obj, int opType, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);
+ jobject TargetInStreamOutObject(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
+ void TargetInObjectStreamOutStream(jobject obj, int opType, void* arg, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);
+ long long TargetOutLong(jobject obj, int opType, JniErrorInfo* errInfo = NULL);
+ void TargetOutStream(jobject obj, int opType, long long memPtr, JniErrorInfo* errInfo = NULL);
+ jobject TargetOutObject(jobject obj, int opType, JniErrorInfo* errInfo = NULL);
+ void TargetListenFuture(jobject obj, long long futId, int typ);
+ void TargetListenFutureForOperation(jobject obj, long long futId, int typ, int opId);
+
+ int AffinityPartitions(jobject obj);
+
+ jobject CacheWithSkipStore(jobject obj);
+ jobject CacheWithNoRetries(jobject obj);
+ jobject CacheWithExpiryPolicy(jobject obj, long long create, long long update, long long access);
+ jobject CacheWithAsync(jobject obj);
+ jobject CacheWithKeepPortable(jobject obj);
+ void CacheClear(jobject obj, JniErrorInfo* errInfo = NULL);
+ void CacheRemoveAll(jobject obj, JniErrorInfo* errInfo = NULL);
+ jobject CacheOutOpQueryCursor(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
+ jobject CacheOutOpContinuousQuery(jobject obj, int type, long long memPtr);
+ jobject CacheIterator(jobject obj);
+ jobject CacheLocalIterator(jobject obj, int peekModes);
+ void CacheEnterLock(jobject obj, long long id);
+ void CacheExitLock(jobject obj, long long id);
+ bool CacheTryEnterLock(jobject obj, long long id, long long timeout);
+ void CacheCloseLock(jobject obj, long long id);
+ void CacheRebalance(jobject obj, long long futId);
+ int CacheSize(jobject obj, int peekModes, bool loc, JniErrorInfo* errInfo = NULL);
+
+ void CacheStoreCallbackInvoke(jobject obj, long long memPtr);
+
+ void ComputeWithNoFailover(jobject obj);
+ void ComputeWithTimeout(jobject obj, long long timeout);
+ void ComputeExecuteNative(jobject obj, long long taskPtr, long long topVer);
+
+ void ContinuousQueryClose(jobject obj);
+ void* ContinuousQueryGetInitialQueryCursor(jobject obj);
+
+ void DataStreamerListenTopology(jobject obj, long long ptr);
+ bool DataStreamerAllowOverwriteGet(jobject obj);
+ void DataStreamerAllowOverwriteSet(jobject obj, bool val);
+ bool DataStreamerSkipStoreGet(jobject obj);
+ void DataStreamerSkipStoreSet(jobject obj, bool val);
+ int DataStreamerPerNodeBufferSizeGet(jobject obj);
+ void DataStreamerPerNodeBufferSizeSet(jobject obj, int val);
+ int DataStreamerPerNodeParallelOperationsGet(jobject obj);
+ void DataStreamerPerNodeParallelOperationsSet(jobject obj, int val);
+
+ jobject MessagingWithAsync(jobject obj);
+
+ jobject ProjectionForOthers(jobject obj, jobject prj);
+ jobject ProjectionForRemotes(jobject obj);
+ jobject ProjectionForDaemons(jobject obj);
+ jobject ProjectionForRandom(jobject obj);
+ jobject ProjectionForOldest(jobject obj);
+ jobject ProjectionForYoungest(jobject obj);
+ void ProjectionResetMetrics(jobject obj);
+ jobject ProjectionOutOpRet(jobject obj, int type, long long memPtr);
+
+ void QueryCursorIterator(jobject obj, JniErrorInfo* errInfo = NULL);
+ bool QueryCursorIteratorHasNext(jobject obj, JniErrorInfo* errInfo = NULL);
+ void QueryCursorClose(jobject obj, JniErrorInfo* errInfo = NULL);
+
+ long long TransactionsStart(jobject obj, int concurrency, int isolation, long long timeout, int txSize);
+ int TransactionsCommit(jobject obj, long long id);
+ void TransactionsCommitAsync(jobject obj, long long id, long long futId);
+ int TransactionsRollback(jobject obj, long long id);
+ void TransactionsRollbackAsync(jobject obj, long long id, long long futId);
+ int TransactionsClose(jobject obj, long long id);
+ int TransactionsState(jobject obj, long long id);
+ bool TransactionsSetRollbackOnly(jobject obj, long long id);
+ void TransactionsResetMetrics(jobject obj);
+
+ jobject EventsWithAsync(jobject obj);
+ bool EventsStopLocalListen(jobject obj, long long hnd);
+ void EventsLocalListen(jobject obj, long long hnd, int type);
+ bool EventsIsEnabled(jobject obj, int type);
+
+ jobject ServicesWithAsync(jobject obj);
+ jobject ServicesWithServerKeepPortable(jobject obj);
+ void ServicesCancel(jobject obj, char* name);
+ void ServicesCancelAll(jobject obj);
+ void* ServicesGetServiceProxy(jobject obj, char* name, bool sticky);
+
+ jobject Acquire(jobject obj);
+
+ void DestroyJvm();
+ void ThrowToJava(char* errMsg);
+ private:
+ JniJvm* jvm;
+ JniHandlers hnds;
+
+ JniContext(JniJvm* jvm, JniHandlers hnds);
+
+ JNIEnv* Attach();
+ void ExceptionCheck(JNIEnv* env);
+ void ExceptionCheck(JNIEnv* env, JniErrorInfo* errInfo);
+ jobject LocalToGlobal(JNIEnv* env, jobject obj);
+ jobject ProcessorCache0(jobject proc, const char* name, jmethodID mthd, JniErrorInfo* errInfo);
+ };
+
+ JNIEXPORT jlong JNICALL JniCacheStoreCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+ JNIEXPORT jint JNICALL JniCacheStoreInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr, jlong memPtr, jobject cb);
+ JNIEXPORT void JNICALL JniCacheStoreDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr);
+ JNIEXPORT jlong JNICALL JniCacheStoreSessionCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong storePtr);
+
+ JNIEXPORT jlong JNICALL JniCacheEntryFilterCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+ JNIEXPORT jint JNICALL JniCacheEntryFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr, jlong memPtr);
+ JNIEXPORT void JNICALL JniCacheEntryFilterDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr);
+
+ JNIEXPORT void JNICALL JniCacheInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong inMemPtr, jlong outMemPtr);
+
+ JNIEXPORT void JNICALL JniComputeTaskMap(JNIEnv *env, jclass cls, jlong envPtr, jlong taskPtr, jlong inMemPtr, jlong outMemPtr);
+ JNIEXPORT jint JNICALL JniComputeTaskJobResult(JNIEnv *env, jclass cls, jlong envPtr, jlong taskPtr, jlong jobPtr, jlong memPtr);
+ JNIEXPORT void JNICALL JniComputeTaskReduce(JNIEnv *env, jclass cls, jlong envPtr, jlong taskPtr);
+ JNIEXPORT void JNICALL JniComputeTaskComplete(JNIEnv *env, jclass cls, jlong envPtr, jlong taskPtr, jlong memPtr);
+ JNIEXPORT jint JNICALL JniComputeJobSerialize(JNIEnv *env, jclass cls, jlong envPtr, jlong jobPtr, jlong memPtr);
+ JNIEXPORT jlong JNICALL JniComputeJobCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+ JNIEXPORT void JNICALL JniComputeJobExecute(JNIEnv *env, jclass cls, jlong envPtr, jlong jobPtr, jint cancel, jlong memPtr);
+ JNIEXPORT void JNICALL JniComputeJobCancel(JNIEnv *env, jclass cls, jlong envPtr, jlong jobPtr);
+ JNIEXPORT void JNICALL JniComputeJobDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong jobPtr);
+
+ JNIEXPORT void JNICALL JniContinuousQueryListenerApply(JNIEnv *env, jclass cls, jlong envPtr, jlong cbPtr, jlong memPtr);
+ JNIEXPORT jlong JNICALL JniContinuousQueryFilterCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+ JNIEXPORT jint JNICALL JniContinuousQueryFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong filterPtr, jlong memPtr);
+ JNIEXPORT void JNICALL JniContinuousQueryFilterRelease(JNIEnv *env, jclass cls, jlong envPtr, jlong filterPtr);
+
+ JNIEXPORT void JNICALL JniDataStreamerTopologyUpdate(JNIEnv *env, jclass cls, jlong envPtr, jlong ldrPtr, jlong topVer, jint topSize);
+ JNIEXPORT void JNICALL JniDataStreamerStreamReceiverInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jobject cache, jlong memPtr, jboolean keepPortable);
+
+ JNIEXPORT void JNICALL JniFutureByteResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
+ JNIEXPORT void JNICALL JniFutureBoolResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
+ JNIEXPORT void JNICALL JniFutureShortResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
+ JNIEXPORT void JNICALL JniFutureCharResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
+ JNIEXPORT void JNICALL JniFutureIntResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
+ JNIEXPORT void JNICALL JniFutureFloatResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jfloat res);
+ JNIEXPORT void JNICALL JniFutureLongResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jlong res);
+ JNIEXPORT void JNICALL JniFutureDoubleResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jdouble res);
+ JNIEXPORT void JNICALL JniFutureObjectResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jlong memPtr);
+ JNIEXPORT void JNICALL JniFutureNullResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr);
+ JNIEXPORT void JNICALL JniFutureError(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jlong memPtr);
+
+ JNIEXPORT void JNICALL JniLifecycleEvent(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jint evt);
+
+ JNIEXPORT void JNICALL JniMemoryReallocate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr, jint cap);
+
+ JNIEXPORT jlong JNICALL JniMessagingFilterCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+ JNIEXPORT jint JNICALL JniMessagingFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr);
+ JNIEXPORT void JNICALL JniMessagingFilterDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr);
+
+ JNIEXPORT jlong JNICALL JniEventFilterCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+ JNIEXPORT jint JNICALL JniEventFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr);
+ JNIEXPORT void JNICALL JniEventFilterDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr);
+
+ JNIEXPORT jlong JNICALL JniServiceInit(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+ JNIEXPORT void JNICALL JniServiceExecute(JNIEnv *env, jclass cls, jlong envPtr, jlong svcPtr, jlong memPtr);
+ JNIEXPORT void JNICALL JniServiceCancel(JNIEnv *env, jclass cls, jlong envPtr, jlong svcPtr, jlong memPtr);
+ JNIEXPORT void JNICALL JniServiceInvokeMethod(JNIEnv *env, jclass cls, jlong envPtr, jlong svcPtr, jlong inMemPtr, jlong outMemPtr);
+ JNIEXPORT jint JNICALL JniClusterNodeFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+
+ JNIEXPORT jlong JNICALL JniNodeInfo(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+
+ JNIEXPORT void JNICALL JniOnStart(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
+ JNIEXPORT void JNICALL JniOnStop(JNIEnv *env, jclass cls, jlong envPtr);
+
+ JNIEXPORT jlong JNICALL JniExtensionCallbackInLongOutLong(JNIEnv *env, jclass cls, jlong envPtr, jint typ, jlong arg1);
+ JNIEXPORT jlong JNICALL JniExtensionCallbackInLongLongOutLong(JNIEnv *env, jclass cls, jlong envPtr, jint typ, jlong arg1, jlong arg2);
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/os/linux/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/os/linux/include/Makefile.am b/modules/platform/src/main/cpp/common/os/linux/include/Makefile.am
new file mode 100644
index 0000000..68e45e6
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/os/linux/include/Makefile.am
@@ -0,0 +1,21 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+nobase_include_HEADERS = ignite/common/common.h \
+ ignite/common/concurrent_os.h
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/os/linux/include/ignite/common/common.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/os/linux/include/ignite/common/common.h b/modules/platform/src/main/cpp/common/os/linux/include/ignite/common/common.h
new file mode 100644
index 0000000..6577ad8
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/os/linux/include/ignite/common/common.h
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_COMMON_OS
+#define _IGNITE_COMMON_OS
+
+#ifndef __has_attribute
+ #define __has_attribute(x) 0
+#endif
+
+#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
+ #define IGNITE_EXPORT __attribute__((visibility("default")))
+ #define IGNITE_IMPORT __attribute__((visibility("default")))
+#else
+ #define IGNITE_EXPORT
+ #define IGNITE_IMPORT
+#endif
+
+#define IGNITE_CALL
+
+#ifdef IGNITE_IMPL
+ #define IGNITE_IMPORT_EXPORT IGNITE_EXPORT
+#else
+ #define IGNITE_IMPORT_EXPORT IGNITE_IMPORT
+#endif
+
+/**
+ * Common construction to disable copy constructor and assignment for class.
+ */
+#define IGNITE_NO_COPY_ASSIGNMENT(cls) \
+ cls(const cls& src); \
+ cls& operator= (const cls& other);
+
+namespace ignite
+{
+ namespace common
+ {
+ /**
+ * Helper class to manage attached threads.
+ */
+ class AttachHelper
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ ~AttachHelper();
+
+ /**
+ * Callback invoked on successful thread attach ot JVM.
+ */
+ static void OnThreadAttach();
+ private:
+ /**
+ * Helper method to allocate attach key.
+ */
+ static void AllocateAttachKey();
+
+ /**
+ * Attach key destructor.
+ */
+ static void DestroyAttachKey(void* key);
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/os/linux/include/ignite/common/concurrent_os.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/os/linux/include/ignite/common/concurrent_os.h b/modules/platform/src/main/cpp/common/os/linux/include/ignite/common/concurrent_os.h
new file mode 100644
index 0000000..63798b1
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/os/linux/include/ignite/common/concurrent_os.h
@@ -0,0 +1,394 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_COMMON_CONCURRENT_OS
+#define _IGNITE_COMMON_CONCURRENT_OS
+
+#include <map>
+#include <stdint.h>
+#include <pthread.h>
+
+#include "ignite/common/common.h"
+
+namespace ignite
+{
+ namespace common
+ {
+ namespace concurrent
+ {
+ /**
+ * Static class to manage memory visibility semantics.
+ */
+ class IGNITE_IMPORT_EXPORT Memory {
+ public:
+ /**
+ * Full fence.
+ */
+ static void Fence();
+ };
+
+ /**
+ * Critical section.
+ */
+ class IGNITE_IMPORT_EXPORT CriticalSection {
+ public:
+ /**
+ * Constructor.
+ */
+ CriticalSection();
+
+ /**
+ * Destructor.
+ */
+ ~CriticalSection();
+
+ /**
+ * Enter critical section.
+ */
+ void Enter();
+
+ /**
+ * Leave critical section.
+ */
+ void Leave();
+ private:
+ pthread_mutex_t mux;
+
+ IGNITE_NO_COPY_ASSIGNMENT(CriticalSection)
+ };
+
+ /**
+ * Special latch with count = 1.
+ */
+ class IGNITE_IMPORT_EXPORT SingleLatch
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ SingleLatch();
+
+ /**
+ * Destructor.
+ */
+ ~SingleLatch();
+
+ /**
+ * Perform the countdown.
+ */
+ void CountDown();
+
+ /**
+ * Await the countdown.
+ */
+ void Await();
+ private:
+ /** Mutex. */
+ pthread_mutex_t mux;
+
+ /** Condition. */
+ pthread_cond_t cond;
+
+ /** Ready flag. */
+ bool ready;
+
+ IGNITE_NO_COPY_ASSIGNMENT(SingleLatch)
+ };
+
+ /**
+ * Primitives for atomic access.
+ */
+ class IGNITE_IMPORT_EXPORT Atomics
+ {
+ public:
+ /**
+ * Update the 32-bit integer value if it is equal to expected value.
+ *
+ * @param ptr Pointer.
+ * @param expVal Expected value.
+ * @param newVal New value.
+ * @return True if update occurred as a result of this call, false otherwise.
+ */
+ static bool CompareAndSet32(int32_t* ptr, int32_t expVal, int32_t newVal);
+
+ /**
+ * Update the 32-bit integer value if it is equal to expected value.
+ *
+ * @param ptr Pointer.
+ * @param expVal Expected value.
+ * @param newVal New value.
+ * @return Value which were observed during CAS attempt.
+ */
+ static int32_t CompareAndSet32Val(int32_t* ptr, int32_t expVal, int32_t newVal);
+
+ /**
+ * Increment 32-bit integer and return new value.
+ *
+ * @param ptr Pointer.
+ * @return Value after increment.
+ */
+ static int32_t IncrementAndGet32(int32_t* ptr);
+
+ /**
+ * Decrement 32-bit integer and return new value.
+ *
+ * @param ptr Pointer.
+ * @return Value after decrement.
+ */
+ static int32_t DecrementAndGet32(int32_t* ptr);
+
+ /**
+ * Update the 64-bit integer value if it is equal to expected value.
+ *
+ * @param ptr Pointer.
+ * @param expVal Expected value.
+ * @param newVal New value.
+ * @return True if update occurred as a result of this call, false otherwise.
+ */
+ static bool CompareAndSet64(int64_t* ptr, int64_t expVal, int64_t newVal);
+
+ /**
+ * Update the 64-bit integer value if it is equal to expected value.
+ *
+ * @param ptr Pointer.
+ * @param expVal Expected value.
+ * @param newVal New value.
+ * @return Value which were observed during CAS attempt.
+ */
+ static int64_t CompareAndSet64Val(int64_t* ptr, int64_t expVal, int64_t newVal);
+
+ /**
+ * Increment 64-bit integer and return new value.
+ *
+ * @param ptr Pointer.
+ * @return Value after increment.
+ */
+ static int64_t IncrementAndGet64(int64_t* ptr);
+
+ /**
+ * Decrement 64-bit integer and return new value.
+ *
+ * @param ptr Pointer.
+ * @return Value after decrement.
+ */
+ static int64_t DecrementAndGet64(int64_t* ptr);
+ };
+
+ /**
+ * Thread-local entry.
+ */
+ class IGNITE_IMPORT_EXPORT ThreadLocalEntry
+ {
+ public:
+ /**
+ * Virtual destructor to allow for correct typed entries cleanup.
+ */
+ virtual ~ThreadLocalEntry()
+ {
+ // No-op.
+ }
+ };
+
+ /**
+ * Typed thread-local entry.
+ */
+ template<typename T>
+ class IGNITE_IMPORT_EXPORT ThreadLocalTypedEntry : public ThreadLocalEntry
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param val Value.
+ */
+ ThreadLocalTypedEntry(T val) : val(val)
+ {
+ // No-op.
+ }
+
+ ~ThreadLocalTypedEntry()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get value.
+ *
+ * @return Value.
+ */
+ T Get()
+ {
+ return val;
+ }
+ private:
+ /** Value. */
+ T val;
+ };
+
+ /**
+ * Thread-local abstraction.
+ */
+ class IGNITE_IMPORT_EXPORT ThreadLocal
+ {
+ public:
+ /**
+ * Get next available index to be used in thread-local storage.
+ *
+ * @return Index.
+ */
+ static int32_t NextIndex();
+
+ /**
+ * Get value by index.
+ *
+ * @param idx Index.
+ * @return Value associated with the index or NULL.
+ */
+ template<typename T>
+ static T Get(int32_t idx)
+ {
+ void* linuxVal = Get0();
+
+ if (linuxVal)
+ {
+ std::map<int32_t, ThreadLocalEntry*>* map =
+ static_cast<std::map<int32_t, ThreadLocalEntry*>*>(linuxVal);
+
+ ThreadLocalTypedEntry<T>* entry = static_cast<ThreadLocalTypedEntry<T>*>((*map)[idx]);
+
+ if (entry)
+ return entry->Get();
+ }
+
+ return T();
+ }
+
+ /**
+ * Set value at the given index.
+ *
+ * @param idx Index.
+ * @param val Value to be associated with the index.
+ */
+ template<typename T>
+ static void Set(int32_t idx, const T& val)
+ {
+ void* linuxVal = Get0();
+
+ if (linuxVal)
+ {
+ std::map<int32_t, ThreadLocalEntry*>* map =
+ static_cast<std::map<int32_t, ThreadLocalEntry*>*>(linuxVal);
+
+ ThreadLocalEntry* appVal = (*map)[idx];
+
+ if (appVal)
+ delete appVal;
+
+ (*map)[idx] = new ThreadLocalTypedEntry<T>(val);
+ }
+ else
+ {
+ std::map<int32_t, ThreadLocalEntry*>* map = new std::map<int32_t, ThreadLocalEntry*>();
+
+ Set0(map);
+
+ (*map)[idx] = new ThreadLocalTypedEntry<T>(val);
+ }
+ }
+
+ /**
+ * Remove value at the given index.
+ *
+ * @param idx Index.
+ */
+ static void Remove(int32_t idx);
+
+ /**
+ * Internal thread-local map clear routine.
+ *
+ * @param mapPtr Pointer to map.
+ */
+ static void Clear0(void* mapPtr);
+
+ private:
+ /**
+ * Internal get routine.
+ *
+ * @param Associated value.
+ */
+ static void* Get0();
+
+ /**
+ * Internal set routine.
+ *
+ * @param ptr Pointer.
+ */
+ static void Set0(void* ptr);
+ };
+
+ /**
+ * Thread-local instance. Simplifies API avoiding direct index allocations.
+ */
+ template<typename T>
+ class IGNITE_IMPORT_EXPORT ThreadLocalInstance
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ ThreadLocalInstance() : idx(ThreadLocal::NextIndex())
+ {
+ // No-op.
+ }
+
+ /**
+ * Get value.
+ *
+ * @return Value.
+ */
+ T Get()
+ {
+ return ThreadLocal::Get<T>(idx);
+ }
+
+ /**
+ * Set instance.
+ *
+ * @param val Value.
+ */
+ void Set(const T& val)
+ {
+ ThreadLocal::Set<T>(idx, val);
+ }
+
+ /**
+ * Remove instance.
+ */
+ void Remove()
+ {
+ ThreadLocal::Remove(idx);
+ }
+
+ private:
+ /** Index. */
+ int32_t idx;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/os/linux/src/common.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/os/linux/src/common.cpp b/modules/platform/src/main/cpp/common/os/linux/src/common.cpp
new file mode 100644
index 0000000..c0cccdc
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/os/linux/src/common.cpp
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <pthread.h>
+
+#include "ignite/common/common.h"
+#include "ignite/common/java.h"
+
+using namespace ignite::common::java;
+
+namespace ignite
+{
+ namespace common
+ {
+ /** Key indicating that the thread is attached. */
+ static pthread_key_t attachKey;
+
+ /** Helper to ensure that attach key is allocated only once. */
+ static pthread_once_t attachKeyInit = PTHREAD_ONCE_INIT;
+
+ AttachHelper::~AttachHelper()
+ {
+ JniContext::Detach();
+ }
+
+ void AttachHelper::OnThreadAttach()
+ {
+ pthread_once(&attachKeyInit, AllocateAttachKey);
+
+ void* val = pthread_getspecific(attachKey);
+
+ if (!val)
+ pthread_setspecific(attachKey, new AttachHelper());
+ }
+
+ void AttachHelper::AllocateAttachKey()
+ {
+ pthread_key_create(&attachKey, DestroyAttachKey);
+ }
+
+ void AttachHelper::DestroyAttachKey(void* key)
+ {
+ delete reinterpret_cast<AttachHelper*>(key);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ca8cbc7/modules/platform/src/main/cpp/common/os/linux/src/concurrent_os.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/os/linux/src/concurrent_os.cpp b/modules/platform/src/main/cpp/common/os/linux/src/concurrent_os.cpp
new file mode 100644
index 0000000..44f0b22
--- /dev/null
+++ b/modules/platform/src/main/cpp/common/os/linux/src/concurrent_os.cpp
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ignite/common/concurrent_os.h"
+
+namespace ignite
+{
+ namespace common
+ {
+ namespace concurrent
+ {
+ /** Key indicating that the thread is attached. */
+ static pthread_key_t tlsKey;
+
+ /** Helper to ensure that attach key is allocated only once. */
+ static pthread_once_t tlsKeyInit = PTHREAD_ONCE_INIT;
+
+ /**
+ * Routine to destroy TLS key.
+ *
+ * @param key Key.
+ */
+ void DestroyTlsKey(void* key) {
+ ThreadLocal::Clear0(key);
+ }
+
+ /**
+ * Routine to allocate TLS key.
+ */
+ void AllocateTlsKey() {
+ pthread_key_create(&tlsKey, DestroyTlsKey);
+ }
+
+ void Memory::Fence() {
+ __asm__ volatile ("" ::: "memory");
+ }
+
+ CriticalSection::CriticalSection() {
+ pthread_mutex_init(&mux, NULL);
+
+ Memory::Fence();
+ }
+
+ CriticalSection::~CriticalSection() {
+ Memory::Fence();
+
+ pthread_mutex_destroy(&mux);
+ }
+
+ void CriticalSection::Enter() {
+ Memory::Fence();
+
+ pthread_mutex_lock(&mux);
+ }
+
+ void CriticalSection::Leave() {
+ Memory::Fence();
+
+ pthread_mutex_unlock(&mux);
+ }
+
+ SingleLatch::SingleLatch()
+ {
+ pthread_mutex_init(&mux, NULL);
+ pthread_cond_init(&cond, NULL);
+ ready = false;
+
+ Memory::Fence();
+ }
+
+ SingleLatch::~SingleLatch()
+ {
+ Memory::Fence();
+
+ pthread_cond_destroy(&cond);
+ pthread_mutex_destroy(&mux);
+ }
+
+ void SingleLatch::CountDown()
+ {
+ pthread_mutex_lock(&mux);
+
+ if (!ready) {
+ ready = true;
+
+ pthread_cond_broadcast(&cond);
+ }
+
+ pthread_mutex_unlock(&mux);
+
+ Memory::Fence();
+ }
+
+ void SingleLatch::Await()
+ {
+ pthread_mutex_lock(&mux);
+
+ while (!ready)
+ pthread_cond_wait(&cond, &mux);
+
+ pthread_mutex_unlock(&mux);
+
+ Memory::Fence();
+ }
+
+ bool Atomics::CompareAndSet32(int32_t* ptr, int32_t expVal, int32_t newVal)
+ {
+ return __sync_bool_compare_and_swap(ptr, expVal, newVal);
+ }
+
+ int32_t Atomics::CompareAndSet32Val(int32_t* ptr, int32_t expVal, int32_t newVal)
+ {
+ return __sync_val_compare_and_swap(ptr, expVal, newVal);
+ }
+
+ int32_t Atomics::IncrementAndGet32(int32_t* ptr)
+ {
+ return __sync_fetch_and_add(ptr, 1) + 1;
+ }
+
+ int32_t Atomics::DecrementAndGet32(int32_t* ptr)
+ {
+ return __sync_fetch_and_sub(ptr, 1) - 1;
+ }
+
+ bool Atomics::CompareAndSet64(int64_t* ptr, int64_t expVal, int64_t newVal)
+ {
+ return __sync_bool_compare_and_swap(ptr, expVal, newVal);
+ }
+
+ int64_t Atomics::CompareAndSet64Val(int64_t* ptr, int64_t expVal, int64_t newVal)
+ {
+ return __sync_val_compare_and_swap(ptr, expVal, newVal);
+ }
+
+ int64_t Atomics::IncrementAndGet64(int64_t* ptr)
+ {
+ return __sync_fetch_and_add(ptr, 1) + 1;
+ }
+
+ int64_t Atomics::DecrementAndGet64(int64_t* ptr)
+ {
+ return __sync_fetch_and_sub(ptr, 1) - 1;
+ }
+
+ void* ThreadLocal::Get0()
+ {
+ pthread_once(&tlsKeyInit, AllocateTlsKey);
+
+ return pthread_getspecific(tlsKey);
+ }
+
+ void ThreadLocal::Set0(void* ptr)
+ {
+ pthread_once(&tlsKeyInit, AllocateTlsKey);
+
+ pthread_setspecific(tlsKey, ptr);
+ }
+ }
+ }
+}
\ No newline at end of file