http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/include/ignite/common/exports.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/common/exports.h b/modules/platforms/cpp/common/include/ignite/common/exports.h deleted file mode 100644 index 5798c83..0000000 --- a/modules/platforms/cpp/common/include/ignite/common/exports.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * 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* name, int factoryId, long long dataPtr); - void* IGNITE_CALL IgniteIgnitionInstance(gcj::JniContext* ctx, char* name); - long long IGNITE_CALL IgniteIgnitionEnvironmentPointer(gcj::JniContext* ctx, char* name); - bool IGNITE_CALL IgniteIgnitionStop(gcj::JniContext* ctx, char* name, 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 IgniteProcessorCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long long memPtr); - void* IGNITE_CALL IgniteProcessorGetOrCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long long memPtr); - void* IGNITE_CALL IgniteProcessorCreateNearCache(gcj::JniContext* ctx, void* obj, char* name, long long memPtr); - void* IGNITE_CALL IgniteProcessorGetOrCreateNearCache(gcj::JniContext* ctx, void* obj, char* name, long long memPtr); - void IGNITE_CALL IgniteProcessorDestroyCache(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); - void* IGNITE_CALL IgniteProcessorAtomicLong(gcj::JniContext* ctx, void* obj, char* name, long long initVal, bool create); - void* IGNITE_CALL IgniteProcessorAtomicSequence(gcj::JniContext* ctx, void* obj, char* name, long long initVal, bool create); - void* IGNITE_CALL IgniteProcessorAtomicReference(gcj::JniContext* ctx, void* obj, char* name, long long memPtr, bool create); - void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long long memPtr); - void IGNITE_CALL IgniteProcessorGetCacheNames(gcj::JniContext* ctx, void* obj, long long memPtr); - - 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); - void* IGNITE_CALL IgniteTargetListenFutureAndGet(gcj::JniContext* ctx, void* obj, long long futId, int typ); - void* IGNITE_CALL IgniteTargetListenFutureForOperationAndGet(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); - - long long IGNITE_CALL IgniteAtomicLongGet(gcj::JniContext* ctx, void* obj); - long long IGNITE_CALL IgniteAtomicLongIncrementAndGet(gcj::JniContext* ctx, void* obj); - long long IGNITE_CALL IgniteAtomicLongGetAndIncrement(gcj::JniContext* ctx, void* obj); - long long IGNITE_CALL IgniteAtomicLongAddAndGet(gcj::JniContext* ctx, void* obj, long long value); - long long IGNITE_CALL IgniteAtomicLongGetAndAdd(gcj::JniContext* ctx, void* obj, long long value); - long long IGNITE_CALL IgniteAtomicLongDecrementAndGet(gcj::JniContext* ctx, void* obj); - long long IGNITE_CALL IgniteAtomicLongGetAndDecrement(gcj::JniContext* ctx, void* obj); - long long IGNITE_CALL IgniteAtomicLongGetAndSet(gcj::JniContext* ctx, void* obj, long long value); - long long IGNITE_CALL IgniteAtomicLongCompareAndSetAndGet(gcj::JniContext* ctx, void* obj, long long expVal, long long newVal); - bool IGNITE_CALL IgniteAtomicLongIsClosed(gcj::JniContext* ctx, void* obj); - void IGNITE_CALL IgniteAtomicLongClose(gcj::JniContext* ctx, void* obj); - - long long IGNITE_CALL IgniteAtomicSequenceGet(gcj::JniContext* ctx, void* obj); - long long IGNITE_CALL IgniteAtomicSequenceIncrementAndGet(gcj::JniContext* ctx, void* obj); - long long IGNITE_CALL IgniteAtomicSequenceGetAndIncrement(gcj::JniContext* ctx, void* obj); - long long IGNITE_CALL IgniteAtomicSequenceAddAndGet(gcj::JniContext* ctx, void* obj, long long l); - long long IGNITE_CALL IgniteAtomicSequenceGetAndAdd(gcj::JniContext* ctx, void* obj, long long l); - int IGNITE_CALL IgniteAtomicSequenceGetBatchSize(gcj::JniContext* ctx, void* obj); - void IGNITE_CALL IgniteAtomicSequenceSetBatchSize(gcj::JniContext* ctx, void* obj, int size); - bool IGNITE_CALL IgniteAtomicSequenceIsClosed(gcj::JniContext* ctx, void* obj); - void IGNITE_CALL IgniteAtomicSequenceClose(gcj::JniContext* ctx, void* obj); - - bool IGNITE_CALL IgniteAtomicReferenceIsClosed(gcj::JniContext* ctx, void* obj); - void IGNITE_CALL IgniteAtomicReferenceClose(gcj::JniContext* ctx, void* obj); - - bool IGNITE_CALL IgniteListenableCancel(gcj::JniContext* ctx, void* obj); - bool IGNITE_CALL IgniteListenableIsCancelled(gcj::JniContext* ctx, void* obj); -} - -#endif \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/include/ignite/common/java.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/common/java.h b/modules/platforms/cpp/common/include/ignite/common/java.h deleted file mode 100644 index 7deb5ef..0000000 --- a/modules/platforms/cpp/common/include/ignite/common/java.h +++ /dev/null @@ -1,750 +0,0 @@ -/* - * 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, void* proc, 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); - - typedef void(JNICALL *OnClientDisconnectedHandler)(void* target); - typedef void(JNICALL *OnClientReconnectedHandler)(void* target, unsigned char clusterRestarted); - - /** - * 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; - - OnClientDisconnectedHandler onClientDisconnected; - OnClientReconnectedHandler onClientReconnected; - }; - - /** - * 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_createCacheFromConfig; - jmethodID m_PlatformProcessor_getOrCreateCacheFromConfig; - jmethodID m_PlatformProcessor_createNearCache; - jmethodID m_PlatformProcessor_getOrCreateNearCache; - jmethodID m_PlatformProcessor_destroyCache; - 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; - jmethodID m_PlatformProcessor_atomicLong; - jmethodID m_PlatformProcessor_getIgniteConfiguration; - jmethodID m_PlatformProcessor_getCacheNames; - jmethodID m_PlatformProcessor_atomicSequence; - jmethodID m_PlatformProcessor_atomicReference; - - 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; - jmethodID m_PlatformTarget_listenFutureAndGet; - jmethodID m_PlatformTarget_listenFutureForOperationAndGet; - - 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; - - jclass c_PlatformAtomicLong; - jmethodID m_PlatformAtomicLong_get; - jmethodID m_PlatformAtomicLong_incrementAndGet; - jmethodID m_PlatformAtomicLong_getAndIncrement; - jmethodID m_PlatformAtomicLong_addAndGet; - jmethodID m_PlatformAtomicLong_getAndAdd; - jmethodID m_PlatformAtomicLong_decrementAndGet; - jmethodID m_PlatformAtomicLong_getAndDecrement; - jmethodID m_PlatformAtomicLong_getAndSet; - jmethodID m_PlatformAtomicLong_compareAndSetAndGet; - jmethodID m_PlatformAtomicLong_isClosed; - jmethodID m_PlatformAtomicLong_close; - - jclass c_PlatformAtomicSequence; - jmethodID m_PlatformAtomicSequence_get; - jmethodID m_PlatformAtomicSequence_incrementAndGet; - jmethodID m_PlatformAtomicSequence_getAndIncrement; - jmethodID m_PlatformAtomicSequence_addAndGet; - jmethodID m_PlatformAtomicSequence_getAndAdd; - jmethodID m_PlatformAtomicSequence_getBatchSize; - jmethodID m_PlatformAtomicSequence_setBatchSize; - jmethodID m_PlatformAtomicSequence_isClosed; - jmethodID m_PlatformAtomicSequence_close; - - jclass c_PlatformAtomicReference; - jmethodID m_PlatformAtomicReference_isClosed; - jmethodID m_PlatformAtomicReference_close; - - jclass c_PlatformListenable; - jmethodID m_PlatformListenable_cancel; - jmethodID m_PlatformListenable_isCancelled; - - /** - * 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* name, int factoryId, long long dataPtr); - jobject IgnitionStart(char* cfgPath, char* name, int factoryId, long long dataPtr, JniErrorInfo* errInfo); - jobject IgnitionInstance(char* name); - jobject IgnitionInstance(char* name, JniErrorInfo* errInfo); - long long IgnitionEnvironmentPointer(char* name); - long long IgnitionEnvironmentPointer(char* name, JniErrorInfo* errInfo); - bool IgnitionStop(char* name, bool cancel); - bool IgnitionStop(char* name, 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 ProcessorCreateCacheFromConfig(jobject obj, long long memPtr); - jobject ProcessorCreateCacheFromConfig(jobject obj, long long memPtr, JniErrorInfo* errInfo); - jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long long memPtr); - jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long long memPtr, JniErrorInfo* errInfo); - jobject ProcessorCreateNearCache(jobject obj, const char* name, long long memPtr); - jobject ProcessorGetOrCreateNearCache(jobject obj, const char* name, long long memPtr); - void ProcessorDestroyCache(jobject obj, const char* name); - void ProcessorDestroyCache(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); - jobject ProcessorAtomicLong(jobject obj, char* name, long long initVal, bool create); - jobject ProcessorAtomicSequence(jobject obj, char* name, long long initVal, bool create); - jobject ProcessorAtomicReference(jobject obj, char* name, long long memPtr, bool create); - void ProcessorGetIgniteConfiguration(jobject obj, long long memPtr); - void ProcessorGetCacheNames(jobject obj, long long memPtr); - - 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); - void* TargetListenFutureAndGet(jobject obj, long long futId, int typ); - void* TargetListenFutureForOperationAndGet(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); - jobject 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); - - long long AtomicLongGet(jobject obj); - long long AtomicLongIncrementAndGet(jobject obj); - long long AtomicLongGetAndIncrement(jobject obj); - long long AtomicLongAddAndGet(jobject obj, long long value); - long long AtomicLongGetAndAdd(jobject obj, long long value); - long long AtomicLongDecrementAndGet(jobject obj); - long long AtomicLongGetAndDecrement(jobject obj); - long long AtomicLongGetAndSet(jobject obj, long long value); - long long AtomicLongCompareAndSetAndGet(jobject obj, long long expVal, long long newVal); - bool AtomicLongIsClosed(jobject obj); - void AtomicLongClose(jobject obj); - - long long AtomicSequenceGet(jobject obj); - long long AtomicSequenceIncrementAndGet(jobject obj); - long long AtomicSequenceGetAndIncrement(jobject obj); - long long AtomicSequenceAddAndGet(jobject obj, long long l); - long long AtomicSequenceGetAndAdd(jobject obj, long long l); - int AtomicSequenceGetBatchSize(jobject obj); - void AtomicSequenceSetBatchSize(jobject obj, int size); - bool AtomicSequenceIsClosed(jobject obj); - void AtomicSequenceClose(jobject obj); - - bool AtomicReferenceIsClosed(jobject obj); - void AtomicReferenceClose(jobject obj); - - bool ListenableCancel(jobject obj); - bool ListenableIsCancelled(jobject obj); - - 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); - jobject ProcessorCacheFromConfig0(jobject proc, long long memPtr, jmethodID mthd, JniErrorInfo* errInfo); - jobject ProcessorGetOrCreateNearCache0(jobject obj, const char* name, long long memPtr, jmethodID methodID); - }; - - 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, jobject proc, 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); - - JNIEXPORT void JNICALL JniOnClientDisconnected(JNIEnv *env, jclass cls, jlong envPtr); - JNIEXPORT void JNICALL JniOnClientReconnected(JNIEnv *env, jclass cls, jlong envPtr, jboolean clusterRestarted); - } - } -} - -#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/include/ignite/common/utils.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h index 44db6e8..ff6905d 100644 --- a/modules/platforms/cpp/common/include/ignite/common/utils.h +++ b/modules/platforms/cpp/common/include/ignite/common/utils.h @@ -17,64 +17,196 @@ #ifndef _IGNITE_COMMON_UTILS #define _IGNITE_COMMON_UTILS +#include <stdint.h> + +#include <cstring> #include <string> #include <sstream> #include <algorithm> +#include <ignite/common/common.h> + +#ifdef IGNITE_FRIEND +# define IGNITE_FRIEND_EXPORT IGNITE_EXPORT +#else +# define IGNITE_FRIEND_EXPORT +#endif + namespace ignite { namespace common { - namespace util + /** + * Replace all alphabetic symbols of the string with their lowercase + * versions. + * @param str String to be transformed. + */ + inline void IntoLower(std::string& str) { - /** - * Transform string into lowercase. - * - * @param str String to be transformed. - */ - inline void IntoLower(std::string& str) - { - std::transform(str.begin(), str.end(), str.begin(), ::tolower); - } + std::transform(str.begin(), str.end(), str.begin(), ::tolower); + } - /** - * Get lowercase version of the string. - * - * @param str Input string. - * @return Lowercased version of the string. - */ - inline std::string ToLower(const std::string& str) - { - std::string res(str); - IntoLower(res); - return res; - } + /** + * Get lowercase version of the string. + * + * @param str Input string. + * @return Lowercased version of the string. + */ + inline std::string ToLower(const std::string& str) + { + std::string res(str); + IntoLower(res); + return res; + } + + /** + * Get string representation of long in decimal form. + * + * @param val Long value to be converted to string. + * @return String contataining decimal representation of the value. + */ + inline std::string LongToString(long val) + { + std::stringstream tmp; + tmp << val; + return tmp.str(); + } + + /** + * Parse string to try and get int value. + * + * @param str String to be parsed. + * @return String contataining decimal representation of the value. + */ + inline int ParseInt(const std::string& str) + { + return atoi(str.c_str()); + } + + /** + * Convert struct tm to time_t (UTC). + * + * @param time Standard C type struct tm value. + * @return Standard C type time_t value. + */ + IGNITE_IMPORT_EXPORT time_t IgniteTimeGm(const tm& time); + + /** + * Convert struct tm to time_t (Local time). + * + * @param time Standard C type struct tm value. + * @return Standard C type time_t value. + */ + IGNITE_IMPORT_EXPORT time_t IgniteTimeLocal(const tm& time); + + /** + * Convert time_t to struct tm (UTC). + * + * @param in Standard C type time_t value. + * @param out Standard C type struct tm value. + * @return True on success. + */ + IGNITE_IMPORT_EXPORT bool IgniteGmTime(time_t in, tm& out); + + /** + * Convert time_t to struct tm (Local time). + * + * @param in Standard C type time_t value. + * @param out Standard C type struct tm value. + * @return True on success. + */ + IGNITE_IMPORT_EXPORT bool IgniteLocalTime(time_t in, tm& out); + + /** + * Get number of leading zeroes in octet. + * + * @param octet Octet. + * @return Number of leading zero-bits. + */ + IGNITE_IMPORT_EXPORT int LeadingZeroesForOctet(int8_t octet); + + /** + * Get number of significant bits in octet. + * + * @param octet Octet. + * @return Number of significant bits. + */ + inline int BitLengthForOctet(int8_t octet) + { + return 8 - LeadingZeroesForOctet(octet); + } + + /** + * Check if the number is power of two. + * + * @param num Integer number. + * @return True if the number is power of two. + */ + inline bool PowerOfTwo(int num) + { + return (num & (num - 1)) == 0; + } + + /** + * Copy characters. + * + * @param val Value. + * @return Result. + */ + IGNITE_IMPORT_EXPORT char* CopyChars(const char* val); + + /** + * Release characters. + * + * @param val Value. + */ + IGNITE_IMPORT_EXPORT void ReleaseChars(char* val); + + /** + * Read system environment variable taking thread-safety in count. + * + * @param name Environment variable name. + * @param found Whether environment variable with such name was found. + * @return Environment variable value. + */ + IGNITE_IMPORT_EXPORT std::string GetEnv(const std::string& name, bool& found); + + /** + * Ensure that file on the given path exists in the system. + * + * @param path Path. + * @return True if file exists, false otherwise. + */ + IGNITE_IMPORT_EXPORT bool FileExists(const std::string& path); + + /** + * Safe array which automatically reclaims occupied memory when out of scope. + */ + template<typename T> + struct IGNITE_IMPORT_EXPORT SafeArray + { + /** Target array. */ + T* target; /** - * Get string representation of long in decimal form. - * - * @param val Long value to be converted to string. - * @return String contataining decimal representation of the value. + * Constructor. */ - inline std::string LongToString(long val) + SafeArray(int cap) { - std::stringstream tmp; - tmp << val; - return tmp.str(); + target = new T[cap]; } /** - * Parse string to try and get int value. - * - * @param str String to be parsed. - * @return String contataining decimal representation of the value. + * Destructor. */ - inline int ParseInt(const std::string& str) + ~SafeArray() { - return atoi(str.c_str()); + delete[] target; } - } + + IGNITE_NO_COPY_ASSIGNMENT(SafeArray); + }; } } -#endif \ No newline at end of file +#endif //_IGNITE_COMMON_UTILS \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/include/ignite/date.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/date.h b/modules/platforms/cpp/common/include/ignite/date.h new file mode 100644 index 0000000..31fe5d0 --- /dev/null +++ b/modules/platforms/cpp/common/include/ignite/date.h @@ -0,0 +1,138 @@ +/* + * 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. + */ + +/** + * @file + * Declares ignite::Date class. + */ + +#ifndef _IGNITE_DATE +#define _IGNITE_DATE + +#include <stdint.h> + +#include <ignite/common/common.h> + +namespace ignite +{ + /** + * Date type. + */ + class IGNITE_IMPORT_EXPORT Date + { + public: + /** + * Default constructor. + */ + Date(); + + /** + * Copy constructor. + * + * @param another Another instance. + */ + Date(const Date& another); + + /** + * Constructor. + * + * @param ms Number of milliseconds since 00:00 hours, Jan 1, 1970 UTC. + */ + Date(int64_t ms); + + /** + * Copy operator. + * + * @param another Another instance. + * @return This. + */ + Date& operator=(const Date& another); + + /** + * Returns number of milliseconds since 00:00 hours, Jan 1, 1970 UTC. + * + * @return Number of milliseconds since 00:00 hours, Jan 1, 1970 UTC. + */ + int64_t GetMilliseconds() const; + + /** + * Returns number of seconds since 00:00 hours, Jan 1, 1970 UTC. + * + * @return Number of seconds since 00:00 hours, Jan 1, 1970 UTC. + */ + int64_t GetSeconds() const; + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if equal. + */ + friend bool IGNITE_IMPORT_EXPORT operator==(const Date& val1, const Date& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if not equal. + */ + friend bool IGNITE_IMPORT_EXPORT operator!=(const Date& val1, const Date& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if less. + */ + friend bool IGNITE_IMPORT_EXPORT operator<(const Date& val1, const Date& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if less or equal. + */ + friend bool IGNITE_IMPORT_EXPORT operator<=(const Date& val1, const Date& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if gretter. + */ + friend bool IGNITE_IMPORT_EXPORT operator>(const Date& val1, const Date& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if gretter or equal. + */ + friend bool IGNITE_IMPORT_EXPORT operator>=(const Date& val1, const Date& val2); + private: + /** Number of milliseconds since 00:00 hours, Jan 1, 1970 UTC. */ + int64_t milliseconds; + }; +} + +#endif //_IGNITE_DATE http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/include/ignite/guid.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/guid.h b/modules/platforms/cpp/common/include/ignite/guid.h new file mode 100644 index 0000000..9a045e6 --- /dev/null +++ b/modules/platforms/cpp/common/include/ignite/guid.h @@ -0,0 +1,172 @@ +/* + * 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. + */ + +/** + * @file + * Declares ignite::Guid class. + */ + +#ifndef _IGNITE_GUID +#define _IGNITE_GUID + +#include <stdint.h> +#include <iomanip> + +#include <ignite/common/common.h> + +namespace ignite +{ + /** + * 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== (const Guid& val1, const Guid& val2); + private: + /** Most significant bits. */ + int64_t most; + + /** Least significant bits. */ + int64_t least; + }; + + /** + * Output operator. + * + * @param os Output stream. + * @param guid Guid to output. + * @return Reference to the first param. + */ + template<typename C> + std::basic_ostream<C>& operator<<(std::basic_ostream<C>& os, const Guid& guid) + { + uint32_t part1 = static_cast<uint32_t>(guid.GetMostSignificantBits() >> 32); + uint16_t part2 = static_cast<uint16_t>(guid.GetMostSignificantBits() >> 16); + uint16_t part3 = static_cast<uint16_t>(guid.GetMostSignificantBits()); + uint16_t part4 = static_cast<uint16_t>(guid.GetLeastSignificantBits() >> 48); + uint64_t part5 = guid.GetLeastSignificantBits() & 0x0000FFFFFFFFFFFFULL; + + os << std::setfill<C>('0') << std::setw(8) << std::hex << part1 << '-' + << std::setfill<C>('0') << std::setw(4) << std::hex << part2 << '-' + << std::setfill<C>('0') << std::setw(4) << std::hex << part3 << '-' + << std::setfill<C>('0') << std::setw(4) << std::hex << part4 << '-' + << std::setfill<C>('0') << std::setw(12) << std::hex << part5; + + return os; + } + + /** + * Input operator. + * + * @param is Input stream. + * @param guid Guid to input. + * @return Reference to the first param. + */ + template<typename C> + std::basic_istream<C>& operator>>(std::basic_istream<C>& is, Guid& guid) + { + uint64_t parts[5]; + + C delim; + + for (int i = 0; i < 4; ++i) + { + is >> std::hex >> parts[i] >> delim; + + if (delim != static_cast<C>('-')) + return is; + } + + is >> std::hex >> parts[4]; + + guid = Guid((parts[0] << 32) | (parts[1] << 16) | parts[2], (parts[3] << 48) | parts[4]); + + return is; + } +} + +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/include/ignite/ignite_error.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/ignite_error.h b/modules/platforms/cpp/common/include/ignite/ignite_error.h new file mode 100644 index 0000000..edba67a --- /dev/null +++ b/modules/platforms/cpp/common/include/ignite/ignite_error.h @@ -0,0 +1,284 @@ +/* + * 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. + */ + +/** + * @file + * Declares ignite::IgniteError class. + */ + +#ifndef _IGNITE_IGNITE_ERROR +#define _IGNITE_IGNITE_ERROR + +#include <stdint.h> + +#include <exception> +#include <sstream> + +#include <ignite/common/common.h> + +#define IGNITE_ERROR_1(code, part1) { \ + std::stringstream stream; \ + stream << (part1); \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_2(code, part1, part2) { \ + std::stringstream stream; \ + stream << (part1) << (part2); \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_3(code, part1, part2, part3) { \ + std::stringstream stream; \ + stream << (part1) << (part2) << (part3); \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_FORMATTED_1(code, msg, key1, val1) { \ + std::stringstream stream; \ + stream << msg << " [" << key1 << "=" << (val1) << "]"; \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_FORMATTED_2(code, msg, key1, val1, key2, val2) { \ + std::stringstream stream; \ + stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << "]"; \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_FORMATTED_3(code, msg, key1, val1, key2, val2, key3, val3) { \ + std::stringstream stream; \ + stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << "]"; \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_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 ignite::IgniteError(code, stream.str().c_str()); \ +} + +namespace ignite +{ + 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; + } + + /** + * Ignite error information. + */ + class IGNITE_IMPORT_EXPORT IgniteError : public std::exception + { + public: + /** Success. */ + static const int IGNITE_SUCCESS = 0; + + /** Failed to initialize JVM. */ + static const int IGNITE_ERR_JVM_INIT = 1; + + /** Failed to attach to JVM. */ + static const int IGNITE_ERR_JVM_ATTACH = 2; + + /** JVM library is not found. */ + static const int IGNITE_ERR_JVM_LIB_NOT_FOUND = 3; + + /** Failed to load JVM library. */ + static const int IGNITE_ERR_JVM_LIB_LOAD_FAILED = 4; + + /** JVM classpath is not provided. */ + static const int IGNITE_ERR_JVM_NO_CLASSPATH = 5; + + /** JVM error: no class definition found. */ + static const int IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND = 6; + + /** JVM error: no such method. */ + static const int IGNITE_ERR_JVM_NO_SUCH_METHOD = 7; + + /** Memory operation error. */ + static const int IGNITE_ERR_MEMORY = 1001; + + /** Binary error. */ + static const int IGNITE_ERR_BINARY = 1002; + + /** Generic Ignite error. */ + static const int IGNITE_ERR_GENERIC = 2000; + + /** Illegal argument passed. */ + static const int IGNITE_ERR_ILLEGAL_ARGUMENT = 2001; + + /** Illegal state. */ + static const int IGNITE_ERR_ILLEGAL_STATE = 2002; + + /** Unsupported operation. */ + static const int IGNITE_ERR_UNSUPPORTED_OPERATION = 2003; + + /** Thread has been interrup. */ + static const int IGNITE_ERR_INTERRUPTED = 2004; + + /** Cluster group is empty. */ + static const int IGNITE_ERR_CLUSTER_GROUP_EMPTY = 2005; + + /** Cluster topology problem. */ + static const int IGNITE_ERR_CLUSTER_TOPOLOGY = 2006; + + /** Compute execution rejected. */ + static const int IGNITE_ERR_COMPUTE_EXECUTION_REJECTED = 2007; + + /** Compute job failover. */ + static const int IGNITE_ERR_COMPUTE_JOB_FAILOVER = 2008; + + /** Compute task cancelled. */ + static const int IGNITE_ERR_COMPUTE_TASK_CANCELLED = 2009; + + /** Compute task timeout. */ + static const int IGNITE_ERR_COMPUTE_TASK_TIMEOUT = 2010; + + /** Compute user undeclared exception. */ + static const int IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011; + + /** Generic cache error. */ + static const int IGNITE_ERR_CACHE = 2012; + + /** Generic cache loader error. */ + static const int IGNITE_ERR_CACHE_LOADER = 2013; + + /** Generic cache writer error. */ + static const int IGNITE_ERR_CACHE_WRITER = 2014; + + /** Generic cache entry processor error. */ + static const int IGNITE_ERR_ENTRY_PROCESSOR = 2015; + + /** Cache atomic update timeout. */ + static const int IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016; + + /** Cache partial update. */ + static const int IGNITE_ERR_CACHE_PARTIAL_UPDATE = 2017; + + /** Transaction optimisitc exception. */ + static const int IGNITE_ERR_TX_OPTIMISTIC = 2018; + + /** Transaction timeout. */ + static const int IGNITE_ERR_TX_TIMEOUT = 2019; + + /** Transaction rollback. */ + static const int IGNITE_ERR_TX_ROLLBACK = 2020; + + /** Transaction heuristic exception. */ + static const int IGNITE_ERR_TX_HEURISTIC = 2021; + + /** Authentication error. */ + static const int IGNITE_ERR_AUTHENTICATION = 2022; + + /** Security error. */ + static const int IGNITE_ERR_SECURITY = 2023; + + /** Unknown error. */ + static const int IGNITE_ERR_UNKNOWN = -1; + + /** + * Throw an error if code is not IGNITE_SUCCESS. + * + * @param err Error. + */ + static void ThrowIfNeeded(IgniteError& err); + + /** + * Create empty error. + */ + IgniteError(); + + /** + * Create error with specific code. + * + * @param code Error code. + */ + IgniteError(const int32_t code); + + /** + * Create error with specific code and message. + * + * @param code Error code. + * @param msg Message. + */ + IgniteError(const int32_t code, const char* msg); + + /** + * Copy constructor. + * + * @param other Other instance. + */ + IgniteError(const IgniteError& other); + + /** + * Assignment operator. + * + * @param other Other instance. + * @return Assignment result. + */ + IgniteError& operator=(const IgniteError& other); + + /** + * Destructor. + */ + ~IgniteError(); + + /** + * Get error code. + * + * @return Error code. + */ + int32_t GetCode() const; + + /** + * Get error message. + * + * @return Error message. + */ + const char* GetText() const IGNITE_NO_THROW; + + /** + * Implementation of the standard std::exception::what() method. + * Synonym for GetText() method. + * + * @return Error message string. + */ + virtual const char* what() const IGNITE_NO_THROW; + + /** + * 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, IgniteError* err); + private: + /** Error code. */ + int32_t code; + + /** Error message. */ + char* msg; + }; +} + +#endif //_IGNITE_IGNITE_ERROR \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/include/ignite/timestamp.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/timestamp.h b/modules/platforms/cpp/common/include/ignite/timestamp.h new file mode 100644 index 0000000..4528e53 --- /dev/null +++ b/modules/platforms/cpp/common/include/ignite/timestamp.h @@ -0,0 +1,166 @@ +/* + * 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. + */ + +/** + * @file + * Declares ignite::Timestamp class. + */ + +#ifndef _IGNITE_TIMESTAMP +#define _IGNITE_TIMESTAMP + +#include <stdint.h> + +#include <ignite/common/common.h> + +#include <ignite/date.h> + +namespace ignite +{ + /** + * Timestamp type. + */ + class IGNITE_IMPORT_EXPORT Timestamp + { + public: + /** + * Default constructor. + */ + Timestamp(); + + /** + * Copy constructor. + * + * @param another Another instance. + */ + Timestamp(const Timestamp& another); + + /** + * Constructor. + * + * @param ms Number of milliseconds since 00:00 hours, Jan 1, 1970 UTC. + */ + Timestamp(int64_t ms); + + /** + * Constructor. + * + * @param seconds Number of seconds since 00:00 hours, Jan 1, 1970 UTC. + * @param fractionNs Fractional second component in nanoseconds. + * Must be in range [0..999999999]. + */ + Timestamp(int64_t seconds, int32_t fractionNs); + + /** + * Copy operator. + * + * @param another Another instance. + * @return This. + */ + Timestamp& operator=(const Timestamp& another); + + /** + * Returns number of milliseconds since 00:00 hours, Jan 1, 1970 UTC. + * + * @return Number of milliseconds since 00:00 hours, Jan 1, 1970 UTC. + */ + int64_t GetMilliseconds() const; + + /** + * Returns number of seconds since 00:00 hours, Jan 1, 1970 UTC. + * + * @return Number of seconds since 00:00 hours, Jan 1, 1970 UTC. + */ + int64_t GetSeconds() const; + + /** + * Returns number of nanoseconds - fractional seconds component. + * + * @return Fractional second component expressed in nanoseconds. + */ + int32_t GetSecondFraction() const; + + /** + * Returns corresponding date. + * + * @return Corresponding date. + */ + Date GetDate() const; + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if equal. + */ + friend bool IGNITE_IMPORT_EXPORT operator==(const Timestamp& val1, const Timestamp& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if not equal. + */ + friend bool IGNITE_IMPORT_EXPORT operator!=(const Timestamp& val1, const Timestamp& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if less. + */ + friend bool IGNITE_IMPORT_EXPORT operator<(const Timestamp& val1, const Timestamp& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if less or equal. + */ + friend bool IGNITE_IMPORT_EXPORT operator<=(const Timestamp& val1, const Timestamp& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if gretter. + */ + friend bool IGNITE_IMPORT_EXPORT operator>(const Timestamp& val1, const Timestamp& val2); + + /** + * Comparison operator override. + * + * @param val1 First value. + * @param val2 Second value. + * @return True if gretter or equal. + */ + friend bool IGNITE_IMPORT_EXPORT operator>=(const Timestamp& val1, const Timestamp& val2); + private: + /** Number of seconds since 00:00 hours, Jan 1, 1970 UTC. */ + int64_t seconds; + + /** Fractional second component in nanoseconds. */ + int32_t fractionNs; + }; +} + +#endif //_IGNITE_TIMESTAMP
