mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-19 04:45:07 -04:00
Remove JNA from server dependencies (#110809)
All native methods are now bound through NativeAccess. This commit removes the jna dependency from server. relates #104876
This commit is contained in:
parent
f79930462c
commit
224726a1d9
9 changed files with 3 additions and 74 deletions
|
@ -15,8 +15,7 @@ base {
|
|||
dependencies {
|
||||
compileOnly project(':libs:elasticsearch-core')
|
||||
compileOnly project(':libs:elasticsearch-native')
|
||||
// TODO: this will become an implementation dep onces jna is removed from server
|
||||
compileOnly "net.java.dev.jna:jna:${versions.jna}"
|
||||
implementation "net.java.dev.jna:jna:${versions.jna}"
|
||||
|
||||
testImplementation(project(":test:framework")) {
|
||||
exclude group: 'org.elasticsearch', module: 'elasticsearch-native'
|
||||
|
|
|
@ -68,7 +68,6 @@ dependencies {
|
|||
|
||||
// access to native functions
|
||||
implementation project(':libs:elasticsearch-native')
|
||||
api "net.java.dev.jna:jna:${versions.jna}"
|
||||
|
||||
api "co.elastic.logging:log4j2-ecs-layout:${versions.ecsLogging}"
|
||||
api "co.elastic.logging:ecs-logging-core:${versions.ecsLogging}"
|
||||
|
|
|
@ -34,7 +34,6 @@ module org.elasticsearch.server {
|
|||
requires org.elasticsearch.tdigest;
|
||||
requires org.elasticsearch.simdvec;
|
||||
|
||||
requires com.sun.jna;
|
||||
requires hppc;
|
||||
requires HdrHistogram;
|
||||
requires jopt.simple;
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.bootstrap;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.lucene.util.Constants;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* java mapping to some libc functions
|
||||
*/
|
||||
final class JNACLibrary {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(JNACLibrary.class);
|
||||
|
||||
public static final int MCL_CURRENT = 1;
|
||||
public static final int ENOMEM = 12;
|
||||
public static final int RLIMIT_MEMLOCK = Constants.MAC_OS_X ? 6 : 8;
|
||||
public static final int RLIMIT_AS = Constants.MAC_OS_X ? 5 : 9;
|
||||
public static final int RLIMIT_FSIZE = Constants.MAC_OS_X ? 1 : 1;
|
||||
public static final long RLIM_INFINITY = Constants.MAC_OS_X ? 9223372036854775807L : -1L;
|
||||
|
||||
static {
|
||||
try {
|
||||
Native.register("c");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
logger.warn("unable to link C library. native methods (mlockall) will be disabled.", e);
|
||||
}
|
||||
}
|
||||
|
||||
static native int mlockall(int flags);
|
||||
|
||||
/** corresponds to struct rlimit */
|
||||
public static final class Rlimit extends Structure implements Structure.ByReference {
|
||||
public NativeLong rlim_cur = new NativeLong(0);
|
||||
public NativeLong rlim_max = new NativeLong(0);
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("rlim_cur", "rlim_max");
|
||||
}
|
||||
}
|
||||
|
||||
static native int getrlimit(int resource, Rlimit rlimit);
|
||||
|
||||
static native int setrlimit(int resource, Rlimit rlimit);
|
||||
|
||||
static native String strerror(int errno);
|
||||
|
||||
private JNACLibrary() {}
|
||||
}
|
|
@ -67,11 +67,6 @@ grant codeBase "${codebase.elasticsearch-cli}" {
|
|||
permission java.util.PropertyPermission "*", "read,write";
|
||||
};
|
||||
|
||||
grant codeBase "${codebase.jna}" {
|
||||
// for registering native methods
|
||||
permission java.lang.RuntimePermission "accessDeclaredMembers";
|
||||
};
|
||||
|
||||
grant codeBase "${codebase.log4j-api}" {
|
||||
permission java.lang.RuntimePermission "getClassLoader";
|
||||
};
|
||||
|
|
|
@ -3,4 +3,5 @@ apply plugin: 'elasticsearch.standalone-test'
|
|||
dependencies {
|
||||
testImplementation project(":x-pack:plugin:core")
|
||||
testImplementation project(path: xpackModule('ml'))
|
||||
testImplementation "net.java.dev.jna:jna:${versions.jna}"
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ dependencies {
|
|||
|
||||
api project(':x-pack:plugin:sql:sql-client')
|
||||
api project(":libs:elasticsearch-cli")
|
||||
runtimeOnly "net.java.dev.jna:jna:${versions.jna}"
|
||||
implementation "net.java.dev.jna:jna:${versions.jna}"
|
||||
testImplementation project(":test:framework")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue