-
Notifications
You must be signed in to change notification settings - Fork 102
Provide a pure Java Elasticsearch spatial plugin #2388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
df1ce2f
6ac229f
e02d8dd
952ae58
c70bb0f
a4bddcf
3ec2184
5c043df
27c9cbd
6cefc39
ce048ea
2ae1cbd
7b7fe81
94df37b
ff70261
834afa8
3ae7730
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ARG BASE_IMAGE_REPO= | ||
|
|
||
| FROM ${BASE_IMAGE_REPO}docker.elastic.co/elasticsearch/elasticsearch:8.18.7 | ||
|
|
||
| USER root | ||
| RUN apt update && apt upgrade -y && apt clean | ||
|
|
||
| COPY target/cmr-es-spatial-plugin-0.1.0-SNAPSHOT.zip /tmp | ||
| RUN mkdir -p /var/lib/elasticsearch/tmp &&\ | ||
| chown elasticsearch:elasticsearch /var/lib/elasticsearch/tmp &&\ | ||
| chown elasticsearch:elasticsearch /usr/share/elasticsearch &&\ | ||
| bin/elasticsearch-plugin install discovery-ec2 --batch &&\ | ||
| bin/elasticsearch-plugin install file:///tmp/cmr-es-spatial-plugin-0.1.0-SNAPSHOT.zip --batch &&\ | ||
| chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/plugins &&\ | ||
| echo "root soft memlock unlimited" >> /etc/security/limits.conf &&\ | ||
| echo "root hard memlock unlimited" >> /etc/security/limits.conf | ||
|
|
||
| WORKDIR / | ||
|
|
||
| USER 1000 | ||
| ENV HOME=/usr/share/elasticsearch | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,9 @@ | |
| last | ||
| (clojure.string/replace "\"" "")))) | ||
|
|
||
| (def plugin-jar-name | ||
| (str "target/cmr-es-spatial-plugin-" version ".jar")) | ||
|
|
||
| (def uberjar-name | ||
| (str "target/cmr-es-spatial-plugin-" version "-standalone.jar")) | ||
|
|
||
|
|
@@ -23,76 +26,65 @@ | |
| (def es-deps-target-path | ||
| "es-deps") | ||
|
|
||
| (def elastic-version "7.17.25") | ||
| (defn get-list-of-dep-jars [] | ||
| (let [all-jars (into [] (map #(.getName %) (.listFiles (clojure.java.io/file "target/lib")))) | ||
| ;; Minimal set: only what spatial-lib Java code actually needs | ||
| allowed-prefixes ["clojure" ; Runtime (spatial-lib has compiled Clojure) | ||
| "cmr-spatial-lib" ; Main library | ||
| "jafama" ; Math library used by spatial calculations | ||
| "primitive-math" ; Math optimizations | ||
| "vectorz"]] ; Vector math library | ||
| (map #(str "target/lib/" %) (filter (fn [jar-name] (some (fn [prefix] (str/starts-with? jar-name prefix)) allowed-prefixes)) all-jars)))) | ||
|
Comment on lines
+29
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, locate and read the full project.clj file
find . -name "project.clj" -path "*/es-spatial-plugin/*" | head -1 | xargs cat -nRepository: nasa/Common-Metadata-Repository Length of output: 9514 🏁 Script executed: # Also check for any require or ns declarations at the top of the file
head -50 es-spatial-plugin/project.cljRepository: nasa/Common-Metadata-Repository Length of output: 2425 🏁 Script executed: # Search for any aliasing of clojure.string or str namespace in the file
rg -n "(require|ns|:as str)" es-spatial-plugin/project.cljRepository: nasa/Common-Metadata-Repository Length of output: 1134
Line 37 uses Replace line 37: Fix- (map #(str "target/lib/" %) (filter (fn [jar-name] (some (fn [prefix] (str/starts-with? jar-name prefix)) allowed-prefixes)) all-jars))))
+ (map #(str "target/lib/" %) (filter (fn [jar-name] (some (fn [prefix] (clojure.string/starts-with? jar-name prefix)) allowed-prefixes)) all-jars))))🤖 Prompt for AI Agents |
||
|
|
||
| (defproject nasa-cmr/cmr-es-spatial-plugin "0.1.0-SNAPSHOT" | ||
| :description "A Elastic Search plugin that enables spatial search entirely within elastic." | ||
| :url "https://github.com/nasa/Common-Metadata-Repository/tree/master/es-spatial-plugin" | ||
| :java-source-paths ["src/java"] | ||
| :javac-options ["-target" "11" "-source" "11"] | ||
| :jvm-opts ^:replace ["-server" | ||
| "-Dclojure.compiler.direct-linking=true"] | ||
| :plugins [[lein-shell "0.5.0"]] | ||
| :profiles {:security {:plugins [[com.livingsocial/lein-dependency-check "1.4.1"]] | ||
| :dependency-check {:output-format [:all] | ||
| :suppression-file "resources/security/suppression.xml"}} | ||
| :provided {:dependencies [[nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT" | ||
| :exclusions [[com.fasterxml.jackson.core/jackson-core] | ||
| [com.fasterxml.jackson.dataformat/jackson-dataformat-cbor] | ||
| [com.fasterxml.jackson.dataformat/jackson-dataformat-smile] | ||
| [com.fasterxml.jackson.dataformat/jackson-dataformat-yaml]]] | ||
| [nasa-cmr/cmr-spatial-lib "0.1.0-SNAPSHOT" | ||
| :exclusions [[com.fasterxml.jackson.core/jackson-core] | ||
| [com.fasterxml.jackson.dataformat/jackson-dataformat-cbor] | ||
| [com.fasterxml.jackson.dataformat/jackson-dataformat-smile] | ||
| [com.fasterxml.jackson.dataformat/jackson-dataformat-yaml]]] | ||
| [org.elasticsearch/elasticsearch ~elastic-version] | ||
| [org.clojure/tools.reader "1.3.2"] | ||
| [org.yaml/snakeyaml "1.31"]]} | ||
| :provided {:dependencies [[nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"] | ||
| [nasa-cmr/cmr-spatial-lib "0.1.0-SNAPSHOT"] | ||
| [org.elasticsearch/elasticsearch "8.18.7"]]} | ||
| :es-deps {:dependencies [[nasa-cmr/cmr-spatial-lib "0.1.0-SNAPSHOT" | ||
| ;; These exclusions will be provided by elasticsearch. | ||
| :exclusions [[com.dadrox/quiet-slf4j] | ||
| [com.fasterxml.jackson.core/jackson-core] | ||
| [com.fasterxml.jackson.dataformat/jackson-dataformat-cbor] | ||
| [com.fasterxml.jackson.dataformat/jackson-dataformat-smile] | ||
| [com.fasterxml.jackson.dataformat/jackson-dataformat-yaml] | ||
| [commons-io] | ||
| [commons-codec] | ||
| [commons-logging] | ||
| [joda-time] | ||
| [org.ow2.asm/asm] | ||
| [org.ow2.asm/asm-all] | ||
| ;; Both lz4 libraries are linked together. yawk | ||
| ;; is supposed to be a drop in replacement and | ||
| ;; uses the same package name as the original. | ||
| [net.jpountz.lz4/lz4] | ||
| [at.yawk.lz4/lz4-java] | ||
| [org.locationtech.jts/jts-core] | ||
| [org.locationtech.jts.JTSVersion] | ||
| [org.slf4j/slf4j-api]]] | ||
| [org.clojure/tools.reader "1.3.2"] | ||
| [org.clojure/tools.reader "1.5.0"] | ||
| [org.clojure/clojure "1.11.2"]] | ||
| :target-path ~es-deps-target-path | ||
| :uberjar-name ~es-deps-uberjar-name | ||
| :jar-name ~es-deps-jar-name | ||
| :aot []} | ||
| :es-plugin {:aot [cmr.elasticsearch.plugins.spatial.script.core | ||
| cmr.elasticsearch.plugins.spatial.factory.lfactory | ||
| cmr.elasticsearch.plugins.spatial.factory.core | ||
| cmr.elasticsearch.plugins.spatial.engine.core | ||
| cmr.elasticsearch.plugins.spatial.plugin]} | ||
| :jar-deps {:plugins [[org.clojars.jj/copy-deps "1.0.1"]] | ||
| :dependencies [[nasa-cmr/cmr-spatial-lib "0.1.0-SNAPSHOT"] | ||
| [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"]] | ||
| :aot []} | ||
| :dev {:dependencies [[criterium "0.4.4"] | ||
| [cheshire "5.12.0"] | ||
| [org.clojure/tools.reader "1.3.2"] | ||
| [cheshire "5.13.0"] | ||
| [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"] | ||
| [nasa-cmr/cmr-spatial-lib "0.1.0-SNAPSHOT"] | ||
| [org.elasticsearch/elasticsearch ~elastic-version] | ||
| [org.elasticsearch/elasticsearch "8.18.7"] | ||
| [org.clojars.gjahad/debug-repl "0.3.3"] | ||
| [org.clojure/tools.nrepl "0.2.13"] | ||
| [org.clojure/tools.namespace "0.2.11"] | ||
| [org.yaml/snakeyaml "1.31"]] | ||
| :aot [cmr.elasticsearch.plugins.spatial.script.core | ||
| cmr.elasticsearch.plugins.spatial.factory.lfactory | ||
| cmr.elasticsearch.plugins.spatial.factory.core | ||
| cmr.elasticsearch.plugins.spatial.engine.core | ||
| cmr.elasticsearch.plugins.spatial.plugin] | ||
| [nrepl/nrepl "1.3.0"] | ||
| [org.clojure/tools.namespace "1.2.0"]] | ||
| :global-vars {*warn-on-reflection* false | ||
| *assert* false}} | ||
| :static {} | ||
|
|
@@ -108,28 +100,27 @@ | |
| :kaocha {:dependencies [[lambdaisland/kaocha "1.0.732"] | ||
| [lambdaisland/kaocha-cloverage "1.0.75"] | ||
| [lambdaisland/kaocha-junit-xml "0.0.76"]]}} | ||
| :aliases {"install-es-deps" ["do" | ||
| "with-profile" "es-deps,provided" "clean," | ||
| "with-profile" "es-deps,provided" "uberjar," | ||
| ;; target-path is being ignored for uberjar. move uberjar to es-deps-target-path. | ||
| ["shell" "echo" "inst-es-deps"] | ||
| "shell" "mv" ~(str "target/" es-deps-uberjar-name) ~es-deps-target-path] | ||
| "install-es-plugin" ["do" | ||
| ["shell" "echo" "inst-es-plugin"] | ||
| "with-profile" "es-plugin,provided" "clean," | ||
| "with-profile" "es-plugin,provided" "uberjar,"] | ||
| "package-es-plugin" ["do" | ||
| :aliases {"install-es-plugin" ["do" | ||
| ["shell" "echo" "Building ES spatial plugin JAR"] | ||
| "with-profile" "provided" "clean," | ||
| "with-profile" "provided" "jar,"] | ||
| "gather-dependencies" ["do" | ||
| ["shell" "echo" "Collecting dependent JARs"] | ||
| "with-profile" "jar-deps" "copy-deps,"] | ||
| "prepare-es-plugin" ["do" | ||
| "install-es-plugin" | ||
| ["shell" "echo" "pack-es-deps"] | ||
| "shell" | ||
| "zip" | ||
| "-j" | ||
| ~plugin-zip-name | ||
| ~uberjar-name | ||
| "resources/plugin/plugin-descriptor.properties"] | ||
| "gather-dependencies"] | ||
| "package-es-plugin" ~(vec (concat ["do" | ||
| ["shell" "echo" "Packaging ES plugin into zip file"] | ||
| "shell" | ||
| "zip" | ||
| "-j" | ||
| plugin-zip-name | ||
| plugin-jar-name | ||
| "resources/plugin/plugin-descriptor.properties"] | ||
| (get-list-of-dep-jars))) | ||
|
Comment on lines
+113
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The This means 🤖 Prompt for AI Agents |
||
| "build-all" ["do" | ||
| ["shell" "echo" "build-all"] | ||
| "install-es-deps," | ||
| "install-es-plugin,"] | ||
|
|
||
| ;; Kaocha test aliases | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ classname=cmr.elasticsearch.plugins.SpatialSearchPlugin | |||||||||||||||||
| # use the system property java.specification.version | ||||||||||||||||||
| # version string must be a sequence of nonnegative decimal integers | ||||||||||||||||||
| # separated by "."'s and may have leading zeros | ||||||||||||||||||
| java.version=1.8 | ||||||||||||||||||
| java.version=11 | ||||||||||||||||||
| # | ||||||||||||||||||
| # 'elasticsearch.version': version of elasticsearch compiled against | ||||||||||||||||||
| elasticsearch.version=7.17.14 | ||||||||||||||||||
|
Comment on lines
+16
to
19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's check if the files mentioned in the review exist and examine their contents
find . -type f -path "*es-spatial-plugin/resources/plugin/plugin-descriptor.properties" 2>/dev/null | head -5Repository: nasa/Common-Metadata-Repository Length of output: 140 🏁 Script executed: # Search for version declarations in key plugin files
rg -n "java\.version|elasticsearch\.version" --type properties 2>/dev/null | head -20Repository: nasa/Common-Metadata-Repository Length of output: 57 🏁 Script executed: # Check the Dockerfile for Elasticsearch version
find . -type f -name "Dockerfile" -path "*es-spatial-plugin*" 2>/dev/null | xargs cat 2>/dev/nullRepository: nasa/Common-Metadata-Repository Length of output: 907 🏁 Script executed: # Check project.clj or build files for version declarations
find . -type f -path "*es-spatial-plugin*" \( -name "project.clj" -o -name "*.gradle" -o -name "pom.xml" \) 2>/dev/null | xargs ls -lh 2>/dev/nullRepository: nasa/Common-Metadata-Repository Length of output: 155 🏁 Script executed: cat -n ./es-spatial-plugin/resources/plugin/plugin-descriptor.propertiesRepository: nasa/Common-Metadata-Repository Length of output: 794 🏁 Script executed: cat -n ./es-spatial-plugin/project.cljRepository: nasa/Common-Metadata-Repository Length of output: 9514 Update plugin descriptor Elasticsearch version to match build target. Line 19 declares Update the descriptor to match: Fix-elasticsearch.version=7.17.14
+elasticsearch.version=8.18.7📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memlock limits are configured for the wrong user.
Limits are appended for
root, but Elasticsearch runs as UID 1000 here, so the intended memlock setting will not apply at runtime.🔧 Proposed fix
Also applies to: 20-20
🤖 Prompt for AI Agents