-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
jni_spark_cluster.cc
74 lines (65 loc) · 1.63 KB
/
jni_spark_cluster.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "org_vowpalwabbit_spark_ClusterSpanningTree.h"
#include "util.h"
#include "vw/spanning_tree/spanning_tree.h"
JNIEXPORT jlong JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_create(
JNIEnv* env, jclass, jint port, jboolean quiet)
{
try
{
return (jlong) new VW::SpanningTree(port, quiet);
}
catch (...)
{
rethrow_cpp_exception_as_java_exception(env);
return 0;
}
}
JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_delete(JNIEnv* env, jobject clusterObj)
{
auto tree = (VW::SpanningTree*)get_native_pointer(env, clusterObj);
try
{
delete tree;
}
catch (...)
{
rethrow_cpp_exception_as_java_exception(env);
}
}
JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_start(JNIEnv* env, jobject clusterObj)
{
auto tree = (VW::SpanningTree*)get_native_pointer(env, clusterObj);
try
{
tree->Start();
}
catch (...)
{
rethrow_cpp_exception_as_java_exception(env);
}
}
JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_stop(JNIEnv* env, jobject clusterObj)
{
auto tree = (VW::SpanningTree*)get_native_pointer(env, clusterObj);
try
{
tree->Stop();
}
catch (...)
{
rethrow_cpp_exception_as_java_exception(env);
}
}
JNIEXPORT jint JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_getPort(JNIEnv* env, jobject clusterObj)
{
auto tree = (VW::SpanningTree*)get_native_pointer(env, clusterObj);
try
{
return tree->BoundPort();
}
catch (...)
{
rethrow_cpp_exception_as_java_exception(env);
return 0;
}
}