Skip to content
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

[mongodb] Add support for connecting to mongodb domain sockets #1587

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vaibhav92
Copy link

These two commit lets YCSB connect to a mongodb instance thats exposed as a Unix domain socket like "mongodb://run/mongodb/mongodb-.sock" . Presently this functionality is broken due to some missing dependencies and the way get_classpath_from_maven() generates the classpath from maven's dependency:build-classpath plugin.

These two commits adds the needed runtime dependencies for mongodb plugin to be able to connect to a Unix domain socket and also updates get_classpath_from_maven() so that it can correctly identify these runtime dependencies and generates correct classpath to invoke the mongodb plugin.

…in sockets

Presently when trying to connect to a Mongodb instace exposed as a unix domain
socket (e.g mongodb://run/mongodb/mongodb-<pid>.sock) following exception is reported:

Exception in thread "Thread-3" java.lang.NoClassDefFoundError:
jnr/unixsocket/UnixSocketAddress at
	com.mongodb.internal.connection.ServerAddressHelper.createServerAddress(ServerAddressHelper.java:31)
<snip/>
Caused by: java.lang.ClassNotFoundException: jnr.unixsocket.UnixSocketAddress
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
<snip/>

This is caused by missing runtime dependencies of
jnr-unixsocket (https://github.com/jnr/jnr-unixsocket) ,
jnr-ffi (https://github.com/jnr/jnr-ffi) and
jnr-constants (https://github.com/jnr/jnr-constants). These dependencies lets
the mongodb plugin connect to an db-instance via unix domain socket. Hence this
change adds these dependencies to mongodb plugin's pom.xml as runtime scoped
dependencies.
…ile scoped

get_classpath_from_maven() generates the runtime classpath of a plugin by
calling maven's dependency:build-classpath plugin to list all the jar files
needed in compile scoped jar files. This might not always be correct since
plugins like mongodb may have some runtime dependencies which may cause thier
invocation to fail.

One such exception was seen when mongodb plugin was trying to connect to an
instance exposed a Unix domain socket which needs jnr-unixsocket dependency at
runtime rather than at compile time. Hence passing the '-DincludeScope=compile'
is not a correct choice in such a case. The exception thrown was similar to one
below:

INFO: Exception in monitor thread while connecting to server /run/mongodb/mongodb-27017.sock                                              com.mongodb.MongoException: java.lang.UnsatisfiedLinkError: could not load FFI provider jnr.ffi.provider.jffi.Provider
	at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:138)
	at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsatisfiedLinkError: could not load FFI provider jnr.ffi.provider.jffi.Provider
	at jnr.ffi.provider.InvalidRuntime.newLoadError(InvalidRuntime.java:102)

<snip/>
Caused by: java.lang.UnsatisfiedLinkError: could not get native definition for type `POINTER`, original error message follows: java.lang.UnsatisfiedLinkError: could not locate stub library in jar file.  Tried [jni/ppc64le-Linux/libjffi-1.2.so, /jni/ppc6
4le-Linux/libjffi-1.2.so]
	at com.kenai.jffi.internal.StubLoader.getStubLibraryStream(StubLoader.java:577)
	at com.kenai.jffi.internal.StubLoader.loadFromJar(StubLoader.java:432)
	at com.kenai.jffi.internal.StubLoader.load(StubLoader.java:326)
	at com.kenai.jffi.internal.StubLoader.<clinit>(StubLoader.java:614)
<snip/>

To fix this the patch updates get_classpath_from_maven() to remove the
'-DincludeScope=compile' arg from the maven command-line which should force
maven to dependency:build-classpath plugin to list all compile and runtime
scoped dependencies for the given plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants