How to register UDF in aerospike server running in my laptop inside docker?

Hi, I am exploring Aerospike for my company. I installed the trail version of enterprise edition and running in my laptop inside docker. I also downloaded JAVA examples from aerospike git repository. Github Repo

When i run “Querysum.java” example, i am getting below error. Caused by: java.lang.IllegalArgumentException: Resource: /Users/arun.sk/Downloads/aerospike-client-java-master/udf/sum_example.lua not found But I have this lua file in this exact path. I gave this path in “Querysum.java” file.

Should i put lua file in some path inside docker? if so, kindly let me know how to do it?

Hi @skarunraja, it sounds like wherever you are running Querysum.java from is unable to see the path to the file. I understand you are running the database in a Docker container, but where are you running Querysum.java?

If you are trying to run the database and the client in the container you would need to use a bind mount to mount the file into the container when you first launch.

If you publish the ports when running the container e.g. -p 3000-3002:3000-3002 as part of the docker run command you should be able to access the database at 127.0.0.1:3000 from your local machine.

The example code you are using will register the UDF with the server in the register function.

Checkout managing UDFs for more info. Hope that helps!

Hi, Thanks for answering. I am running Querysum.java outside of docker in my laptop (from VS code).

1.) Should I run the client inside the docker container? 2.) Is there a way to run client from outside container while server is inside container?

It is not necessary to run the client inside the container.

I just set this up on my machine, running the Aerospike Enterprise container and the example code on my local machine.

My steps to make this work:

  1. Launch docker container with all defaults

On my local machine

  1. git clone https://github.com/aerospike/aerospike-client-java.git
  2. cd aerospike-client-java/examples
  3. mvn package
  4. ./run_examples -h localhost -p 3000 -n test -s demoset QuerySum

The steps above ran without issue. My guess is that changing the UDF path in Querysum.java is causing the error. Try setting that back to the default, if you cloned like I did, or double check your path format.