17 #ifndef _IGNITE_JNI_JAVA
18 #define _IGNITE_JNI_JAVA
24 #include <ignite/common/common.h>
33 typedef int64_t(JNICALL *CacheStoreCreateHandler)(
void* target, int64_t memPtr);
34 typedef int(JNICALL *CacheStoreInvokeHandler)(
void* target, int64_t objPtr, int64_t memPtr);
35 typedef void(JNICALL *CacheStoreDestroyHandler)(
void* target, int64_t objPtr);
36 typedef int64_t(JNICALL *CacheStoreSessionCreateHandler)(
void* target, int64_t storePtr);
38 typedef int64_t(JNICALL *CacheEntryFilterCreateHandler)(
void* target, int64_t memPtr);
39 typedef int(JNICALL *CacheEntryFilterApplyHandler)(
void* target, int64_t ptr, int64_t memPtr);
40 typedef void(JNICALL *CacheEntryFilterDestroyHandler)(
void* target, int64_t ptr);
42 typedef void(JNICALL *CacheInvokeHandler)(
void* target, int64_t inMemPtr, int64_t outMemPtr);
44 typedef void(JNICALL *ComputeTaskMapHandler)(
void* target, int64_t taskPtr, int64_t inMemPtr, int64_t outMemPtr);
45 typedef int(JNICALL *ComputeTaskJobResultHandler)(
void* target, int64_t taskPtr, int64_t jobPtr, int64_t memPtr);
46 typedef void(JNICALL *ComputeTaskReduceHandler)(
void* target, int64_t taskPtr);
47 typedef void(JNICALL *ComputeTaskCompleteHandler)(
void* target, int64_t taskPtr, int64_t memPtr);
48 typedef int(JNICALL *ComputeJobSerializeHandler)(
void* target, int64_t jobPtr, int64_t memPtr);
49 typedef int64_t(JNICALL *ComputeJobCreateHandler)(
void* target, int64_t memPtr);
50 typedef void(JNICALL *ComputeJobExecuteHandler)(
void* target, int64_t jobPtr,
int cancel, int64_t memPtr);
51 typedef void(JNICALL *ComputeJobCancelHandler)(
void* target, int64_t jobPtr);
52 typedef void(JNICALL *ComputeJobDestroyHandler)(
void* target, int64_t jobPtr);
54 typedef void(JNICALL *ContinuousQueryListenerApplyHandler)(
void* target, int64_t lsnrPtr, int64_t memPtr);
55 typedef int64_t(JNICALL *ContinuousQueryFilterCreateHandler)(
void* target, int64_t memPtr);
56 typedef int(JNICALL *ContinuousQueryFilterApplyHandler)(
void* target, int64_t filterPtr, int64_t memPtr);
57 typedef void(JNICALL *ContinuousQueryFilterReleaseHandler)(
void* target, int64_t filterPtr);
59 typedef void(JNICALL *DataStreamerTopologyUpdateHandler)(
void* target, int64_t ldrPtr, int64_t topVer,
int topSize);
60 typedef void(JNICALL *DataStreamerStreamReceiverInvokeHandler)(
void* target, int64_t ptr,
void* cache, int64_t memPtr,
unsigned char keepPortable);
62 typedef void(JNICALL *FutureByteResultHandler)(
void* target, int64_t futAddr,
int res);
63 typedef void(JNICALL *FutureBoolResultHandler)(
void* target, int64_t futAddr,
int res);
64 typedef void(JNICALL *FutureShortResultHandler)(
void* target, int64_t futAddr,
int res);
65 typedef void(JNICALL *FutureCharResultHandler)(
void* target, int64_t futAddr,
int res);
66 typedef void(JNICALL *FutureIntResultHandler)(
void* target, int64_t futAddr,
int res);
67 typedef void(JNICALL *FutureFloatResultHandler)(
void* target, int64_t futAddr,
float res);
68 typedef void(JNICALL *FutureLongResultHandler)(
void* target, int64_t futAddr, int64_t res);
69 typedef void(JNICALL *FutureDoubleResultHandler)(
void* target, int64_t futAddr,
double res);
70 typedef void(JNICALL *FutureObjectResultHandler)(
void* target, int64_t futAddr, int64_t memPtr);
71 typedef void(JNICALL *FutureNullResultHandler)(
void* target, int64_t futAddr);
72 typedef void(JNICALL *FutureErrorHandler)(
void* target, int64_t futAddr, int64_t memPtr);
74 typedef void(JNICALL *LifecycleEventHandler)(
void* target, int64_t ptr,
int evt);
76 typedef void(JNICALL *MemoryReallocateHandler)(
void* target, int64_t memPtr,
int cap);
78 typedef int64_t(JNICALL *MessagingFilterCreateHandler)(
void* target, int64_t memPtr);
79 typedef int(JNICALL *MessagingFilterApplyHandler)(
void* target, int64_t ptr, int64_t memPtr);
80 typedef void(JNICALL *MessagingFilterDestroyHandler)(
void* target, int64_t ptr);
82 typedef int64_t(JNICALL *EventFilterCreateHandler)(
void* target, int64_t memPtr);
83 typedef int(JNICALL *EventFilterApplyHandler)(
void* target, int64_t ptr, int64_t memPtr);
84 typedef void(JNICALL *EventFilterDestroyHandler)(
void* target, int64_t ptr);
86 typedef int64_t(JNICALL *ServiceInitHandler)(
void* target, int64_t memPtr);
87 typedef void(JNICALL *ServiceExecuteHandler)(
void* target, int64_t svcPtr, int64_t memPtr);
88 typedef void(JNICALL *ServiceCancelHandler)(
void* target, int64_t svcPtr, int64_t memPtr);
89 typedef void(JNICALL *ServiceInvokeMethodHandler)(
void* target, int64_t svcPtr, int64_t inMemPtr, int64_t outMemPtr);
90 typedef int(JNICALL *ClusterNodeFilterApplyHandler)(
void* target, int64_t memPtr);
92 typedef int64_t(JNICALL *NodeInfoHandler)(
void* target, int64_t memPtr);
94 typedef void(JNICALL *OnStartHandler)(
void* target,
void* proc, int64_t memPtr);
95 typedef void(JNICALL *OnStopHandler)(
void* target);
96 typedef void(JNICALL *ErrorHandler)(
void* target,
int errCode,
const char* errClsChars,
int errClsCharsLen,
const char* errMsgChars,
int errMsgCharsLen,
const char* stackTraceChars,
int stackTraceCharsLen,
void* errData,
int errDataLen);
98 typedef int64_t(JNICALL *ExtensionCallbackInLongOutLongHandler)(
void* target,
int typ, int64_t arg1);
99 typedef int64_t(JNICALL *ExtensionCallbackInLongLongOutLongHandler)(
void* target,
int typ, int64_t arg1, int64_t arg2);
101 typedef void(JNICALL *OnClientDisconnectedHandler)(
void* target);
102 typedef void(JNICALL *OnClientReconnectedHandler)(
void* target,
unsigned char clusterRestarted);
104 typedef int64_t(JNICALL *AffinityFunctionInitHandler)(
void* target, int64_t memPtr,
void* baseFunc);
105 typedef int(JNICALL *AffinityFunctionPartitionHandler)(
void* target, int64_t ptr, int64_t memPtr);
106 typedef void(JNICALL *AffinityFunctionAssignPartitionsHandler)(
void* target, int64_t ptr, int64_t inMemPtr, int64_t outMemPtr);
107 typedef void(JNICALL *AffinityFunctionRemoveNodeHandler)(
void* target, int64_t ptr, int64_t memPtr);
108 typedef void(JNICALL *AffinityFunctionDestroyHandler)(
void* target, int64_t ptr);
110 typedef void(JNICALL *ConsoleWriteHandler)(
const char* chars,
int charsLen,
unsigned char isErr);
112 typedef void(JNICALL *LoggerLogHandler)(
void* target,
int level,
const char* messageChars,
int messageCharsLen,
const char* categoryChars,
int categoryCharsLen,
const char* errorInfoChars,
int errorInfoCharsLen, int64_t memPtr);
113 typedef bool(JNICALL *LoggerIsLevelEnabledHandler)(
void* target,
int level);
115 typedef int64_t(JNICALL *InLongOutLongHandler)(
void* target,
int type, int64_t val);
116 typedef int64_t(JNICALL *InLongLongLongObjectOutLongHandler)(
void* target,
int type, int64_t val1, int64_t val2, int64_t val3,
void* arg);
123 bool IsJava9OrLater();
133 LoggerLogHandler loggerLog;
134 LoggerIsLevelEnabledHandler loggerIsLevelEnabled;
136 InLongOutLongHandler inLongOutLong;
137 InLongLongLongObjectOutLongHandler inLongLongLongObjectOutLong;
145 jmethodID m_Class_getName;
148 jmethodID m_Throwable_getMessage;
149 jmethodID m_Throwable_printStackTrace;
151 jclass c_PlatformUtils;
152 jmethodID m_PlatformUtils_getFullStackTrace;
167 bool WriteErrorInfo(JNIEnv* env,
char** errClsName,
int* errClsNameLen,
char** errMsg,
int* errMsgLen,
168 char** stackTrace,
int* stackTraceLen);
175 jclass c_IgniteException;
177 jclass c_PlatformIgnition;
178 jmethodID m_PlatformIgnition_start;
179 jmethodID m_PlatformIgnition_instance;
180 jmethodID m_PlatformIgnition_environmentPointer;
181 jmethodID m_PlatformIgnition_stop;
182 jmethodID m_PlatformIgnition_stopAll;
184 jclass c_PlatformTarget;
185 jmethodID m_PlatformTarget_inLongOutLong;
186 jmethodID m_PlatformTarget_inStreamOutLong;
187 jmethodID m_PlatformTarget_inStreamOutObject;
188 jmethodID m_PlatformTarget_outStream;
189 jmethodID m_PlatformTarget_outObject;
190 jmethodID m_PlatformTarget_inStreamAsync;
191 jmethodID m_PlatformTarget_inStreamOutObjectAsync;
192 jmethodID m_PlatformTarget_inStreamOutStream;
193 jmethodID m_PlatformTarget_inObjectStreamOutObjectStream;
195 jclass c_PlatformUtils;
196 jmethodID m_PlatformUtils_reallocate;
197 jmethodID m_PlatformUtils_errData;
281 JniErrorInfo(
int code,
const char* errCls,
const char* errMsg);
311 static int Reallocate(int64_t memPtr,
int cap);
312 static void Detach();
313 static void Release(jobject obj);
314 static void SetConsoleHandler(ConsoleWriteHandler consoleHandler);
315 static int RemoveConsoleHandler(ConsoleWriteHandler consoleHandler);
317 void IgnitionStart(
char* cfgPath,
char* name,
int factoryId, int64_t dataPtr);
318 void IgnitionStart(
char* cfgPath,
char* name,
int factoryId, int64_t dataPtr,
JniErrorInfo* errInfo);
319 int64_t IgnitionEnvironmentPointer(
char* name);
320 int64_t IgnitionEnvironmentPointer(
char* name,
JniErrorInfo* errInfo);
321 bool IgnitionStop(
char* name,
bool cancel);
322 bool IgnitionStop(
char* name,
bool cancel,
JniErrorInfo* errInfo);
323 void IgnitionStopAll(
bool cancel);
324 void IgnitionStopAll(
bool cancel,
JniErrorInfo* errInfo);
326 int64_t TargetInLongOutLong(jobject obj,
int type, int64_t memPtr,
JniErrorInfo* errInfo = NULL);
327 int64_t TargetInStreamOutLong(jobject obj,
int type, int64_t memPtr,
JniErrorInfo* errInfo = NULL);
328 void TargetInStreamOutStream(jobject obj,
int opType, int64_t inMemPtr, int64_t outMemPtr,
JniErrorInfo* errInfo = NULL);
329 jobject TargetInStreamOutObject(jobject obj,
int type, int64_t memPtr,
JniErrorInfo* errInfo = NULL);
330 jobject TargetInObjectStreamOutObjectStream(jobject obj,
int opType,
void* arg, int64_t inMemPtr, int64_t outMemPtr,
JniErrorInfo* errInfo = NULL);
331 void TargetOutStream(jobject obj,
int opType, int64_t memPtr,
JniErrorInfo* errInfo = NULL);
332 jobject TargetOutObject(jobject obj,
int opType,
JniErrorInfo* errInfo = NULL);
333 void TargetInStreamAsync(jobject obj,
int type, int64_t memPtr,
JniErrorInfo* errInfo = NULL);
334 jobject TargetInStreamOutObjectAsync(jobject obj,
int type, int64_t memPtr,
JniErrorInfo* errInfo = NULL);
336 jobject CacheOutOpQueryCursor(jobject obj,
int type, int64_t memPtr,
JniErrorInfo* errInfo = NULL);
337 jobject CacheOutOpContinuousQuery(jobject obj,
int type, int64_t memPtr,
JniErrorInfo* errInfo = NULL);
339 jobject Acquire(jobject obj);
342 void ThrowToJava(
char* errMsg);
350 void ExceptionCheck(JNIEnv* env);
351 void ExceptionCheck(JNIEnv* env,
JniErrorInfo* errInfo);
352 jobject LocalToGlobal(JNIEnv* env, jobject obj);
355 JNIEXPORT jlong JNICALL JniCacheStoreCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
356 JNIEXPORT jint JNICALL JniCacheStoreInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr, jlong memPtr);
357 JNIEXPORT
void JNICALL JniCacheStoreDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr);
358 JNIEXPORT jlong JNICALL JniCacheStoreSessionCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong storePtr);
360 JNIEXPORT jlong JNICALL JniCacheEntryFilterCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
361 JNIEXPORT jint JNICALL JniCacheEntryFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr, jlong memPtr);
362 JNIEXPORT
void JNICALL JniCacheEntryFilterDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr);
364 JNIEXPORT
void JNICALL JniCacheInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong inMemPtr, jlong outMemPtr);
366 JNIEXPORT
void JNICALL JniComputeTaskMap(JNIEnv *env, jclass cls, jlong envPtr, jlong taskPtr, jlong inMemPtr, jlong outMemPtr);
367 JNIEXPORT jint JNICALL JniComputeTaskJobResult(JNIEnv *env, jclass cls, jlong envPtr, jlong taskPtr, jlong jobPtr, jlong memPtr);
368 JNIEXPORT
void JNICALL JniComputeTaskReduce(JNIEnv *env, jclass cls, jlong envPtr, jlong taskPtr);
369 JNIEXPORT
void JNICALL JniComputeTaskComplete(JNIEnv *env, jclass cls, jlong envPtr, jlong taskPtr, jlong memPtr);
370 JNIEXPORT jint JNICALL JniComputeJobSerialize(JNIEnv *env, jclass cls, jlong envPtr, jlong jobPtr, jlong memPtr);
371 JNIEXPORT jlong JNICALL JniComputeJobCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
372 JNIEXPORT
void JNICALL JniComputeJobExecute(JNIEnv *env, jclass cls, jlong envPtr, jlong jobPtr, jint cancel, jlong memPtr);
373 JNIEXPORT
void JNICALL JniComputeJobCancel(JNIEnv *env, jclass cls, jlong envPtr, jlong jobPtr);
374 JNIEXPORT
void JNICALL JniComputeJobDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong jobPtr);
376 JNIEXPORT
void JNICALL JniContinuousQueryListenerApply(JNIEnv *env, jclass cls, jlong envPtr, jlong cbPtr, jlong memPtr);
377 JNIEXPORT jlong JNICALL JniContinuousQueryFilterCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
378 JNIEXPORT jint JNICALL JniContinuousQueryFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong filterPtr, jlong memPtr);
379 JNIEXPORT
void JNICALL JniContinuousQueryFilterRelease(JNIEnv *env, jclass cls, jlong envPtr, jlong filterPtr);
381 JNIEXPORT
void JNICALL JniDataStreamerTopologyUpdate(JNIEnv *env, jclass cls, jlong envPtr, jlong ldrPtr, jlong topVer, jint topSize);
382 JNIEXPORT
void JNICALL JniDataStreamerStreamReceiverInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jobject cache, jlong memPtr, jboolean keepPortable);
384 JNIEXPORT
void JNICALL JniFutureByteResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
385 JNIEXPORT
void JNICALL JniFutureBoolResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
386 JNIEXPORT
void JNICALL JniFutureShortResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
387 JNIEXPORT
void JNICALL JniFutureCharResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
388 JNIEXPORT
void JNICALL JniFutureIntResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jint res);
389 JNIEXPORT
void JNICALL JniFutureFloatResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jfloat res);
390 JNIEXPORT
void JNICALL JniFutureLongResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jlong res);
391 JNIEXPORT
void JNICALL JniFutureDoubleResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jdouble res);
392 JNIEXPORT
void JNICALL JniFutureObjectResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jlong memPtr);
393 JNIEXPORT
void JNICALL JniFutureNullResult(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr);
394 JNIEXPORT
void JNICALL JniFutureError(JNIEnv *env, jclass cls, jlong envPtr, jlong futPtr, jlong memPtr);
396 JNIEXPORT
void JNICALL JniLifecycleEvent(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jint evt);
398 JNIEXPORT
void JNICALL JniMemoryReallocate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr, jint cap);
400 JNIEXPORT jlong JNICALL JniMessagingFilterCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
401 JNIEXPORT jint JNICALL JniMessagingFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr);
402 JNIEXPORT
void JNICALL JniMessagingFilterDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr);
404 JNIEXPORT jlong JNICALL JniEventFilterCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
405 JNIEXPORT jint JNICALL JniEventFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr);
406 JNIEXPORT
void JNICALL JniEventFilterDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr);
408 JNIEXPORT jlong JNICALL JniServiceInit(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
409 JNIEXPORT
void JNICALL JniServiceExecute(JNIEnv *env, jclass cls, jlong envPtr, jlong svcPtr, jlong memPtr);
410 JNIEXPORT
void JNICALL JniServiceCancel(JNIEnv *env, jclass cls, jlong envPtr, jlong svcPtr, jlong memPtr);
411 JNIEXPORT
void JNICALL JniServiceInvokeMethod(JNIEnv *env, jclass cls, jlong envPtr, jlong svcPtr, jlong inMemPtr, jlong outMemPtr);
412 JNIEXPORT jint JNICALL JniClusterNodeFilterApply(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
414 JNIEXPORT jlong JNICALL JniNodeInfo(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
416 JNIEXPORT
void JNICALL JniOnStart(JNIEnv *env, jclass cls, jlong envPtr, jobject proc, jlong memPtr);
417 JNIEXPORT
void JNICALL JniOnStop(JNIEnv *env, jclass cls, jlong envPtr);
419 JNIEXPORT jlong JNICALL JniExtensionCallbackInLongOutLong(JNIEnv *env, jclass cls, jlong envPtr, jint typ, jlong arg1);
420 JNIEXPORT jlong JNICALL JniExtensionCallbackInLongLongOutLong(JNIEnv *env, jclass cls, jlong envPtr, jint typ, jlong arg1, jlong arg2);
422 JNIEXPORT
void JNICALL JniOnClientDisconnected(JNIEnv *env, jclass cls, jlong envPtr);
423 JNIEXPORT
void JNICALL JniOnClientReconnected(JNIEnv *env, jclass cls, jlong envPtr, jboolean clusterRestarted);
425 JNIEXPORT jlong JNICALL JniAffinityFunctionInit(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr, jobject baseFunc);
426 JNIEXPORT jint JNICALL JniAffinityFunctionPartition(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr);
427 JNIEXPORT
void JNICALL JniAffinityFunctionAssignPartitions(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong inMemPtr, jlong outMemPtr);
428 JNIEXPORT
void JNICALL JniAffinityFunctionRemoveNode(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr, jlong memPtr);
429 JNIEXPORT
void JNICALL JniAffinityFunctionDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong ptr);
431 JNIEXPORT
void JNICALL JniConsoleWrite(JNIEnv *env, jclass cls, jstring str, jboolean isErr);
433 JNIEXPORT
void JNICALL JniLoggerLog(JNIEnv *env, jclass cls, jlong envPtr, jint level, jstring message, jstring category, jstring errorInfo, jlong memPtr);
434 JNIEXPORT jboolean JNICALL JniLoggerIsLevelEnabled(JNIEnv *env, jclass cls, jlong envPtr, jint level);
436 JNIEXPORT jlong JNICALL JniInLongOutLong(JNIEnv *env, jclass cls, jlong envPtr, jint type, jlong val);
437 JNIEXPORT jlong JNICALL JniInLongLongLongObjectOutLong(JNIEnv *env, jclass cls, jlong envPtr, jint type, jlong val1, jlong val2, jlong val3, jobject arg);
442 #endif //_IGNITE_JNI_JAVA