HPE Ezmeral Software platform
1833294 Members
3247 Online
110051 Solutions
New Discussion

Re: maprDB query works at command line but not in docker container

 
SOLVED
Go to solution
Tim11
Advisor

maprDB query works at command line but not in docker container

I have this simple query

 

package mapr_java_client;

import com.mapr.db.MapRDB;
import com.mapr.db.Table;
import com.mapr.db.Admin;
import org.ojai.Document;
import org.ojai.DocumentStream;

public class App {

	public static void main(String[] args) {

		Table dMediaTable = MapRDB.getTable("/user/tim/transactions");

		DocumentStream stream = dMediaTable.find();

		for (final Document userDocument : stream) {
			System.out.println(userDocument.asJsonString());
		}
	}

}

 

and when I execute it at the mac command line

 

java -jar mapr_java_client.jar

 

I get an annoying warning but then it outputs the table content with no problem.  Although I don't want to go down the rabbit hole, for completeness  the annoying warning is this.  But please scroll down for what happens when I do the same inside a docker container

 

WARNING: Exception thrown during refresh
com.google.common.cache.CacheLoader$InvalidCacheLoadException: CacheLoader returned null for key 0.
	at com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2350)
	at com.google.common.cache.LocalCache$Segment$1.run(LocalCache.java:2331)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:457)
	at com.google.common.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
	at com.google.common.util.concurrent.ExecutionList.add(ExecutionList.java:101)
	at com.google.common.util.concurrent.AbstractFuture.addListener(AbstractFuture.java:170)
	at com.google.common.cache.LocalCache$Segment.loadAsync(LocalCache.java:2326)
	at com.google.common.cache.LocalCache$Segment.refresh(LocalCache.java:2389)
	at com.google.common.cache.LocalCache.refresh(LocalCache.java:4090)
	at com.google.common.cache.LocalCache$LocalLoadingCache.refresh(LocalCache.java:4843)
	at com.mapr.fs.MapRClientImpl.refreshZkConnectString(MapRClientImpl.java:1445)
	at com.mapr.fs.MapRClientImpl.<init>(MapRClientImpl.java:149)
	at com.mapr.fs.MapRFileSystem.lookupClient(MapRFileSystem.java:690)
	at com.mapr.fs.MapRFileSystem.lookupClient(MapRFileSystem.java:749)
	at com.mapr.fs.MapRFileSystem.openTable(MapRFileSystem.java:3720)
	at com.mapr.fs.MapRHTable.init(MapRHTable.java:111)
	at com.mapr.db.impl.MapRDBTableImpl.<init>(MapRDBTableImpl.java:85)
	at com.mapr.db.impl.MapRDBImpl.getTable(MapRDBImpl.java:129)
	at com.mapr.db.impl.MapRDBImpl.getTable(MapRDBImpl.java:115)
	at com.mapr.db.MapRDB.getTable(MapRDB.java:98)
	at mapr_java_client.App.main(App.java:29)

 

But when I put the jar in a centos7 docker container, I get this

 

2023-08-22 23:37:15,8008 ERROR Client fc/client.cc:11409 Thread: 19 rpc err Connection timed out(110) 28.21 to 34.218.238.108:5692, fid 2049.16.2, upd 0

 

Now you should know that in both environments, mac and inside docker container the file, /opt/mapr/conf/mapr-clusters.conf contains this 

 

mycluster secure=false ec2-34-218-238-108.us-west-2.compute.amazonaws.com:7222 ec2-34-219-45-86.us-west-2.compute.amazonaws.com:7222 ec2-34-216-115-96.us-west-2.compute.amazonaws.com:7222

 

And the real puzzler is this. When I run a net cat command on two ports, they say the ports are open

 

[root@44845a00cdac /]# nc -zv 34.218.238.108 7222
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 34.218.238.108:7222.
Ncat: 0 bytes sent, 0 bytes received in 0.06 seconds.
[root@44845a00cdac /]# nc -zv 34.218.238.108 5692
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 34.218.238.108:5692.
Ncat: 0 bytes sent, 0 bytes received in 0.07 seconds.

 

 

So there you have it. Docker container can see the endpoint and open port, yet it simple query doesn't work. My cluster is setup right since the java -jar command works on my mac command line.

Any ideas would be welcome

 

3 REPLIES 3
Yong-Liu
HPE Pro

Re: maprDB query works at command line but not in docker container

I guess, you installed mapr-client on your Mac, right?

if possible, please share your docker file, we can reproduce that issue. 

I'm an HPE employee.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Tim11
Advisor

Re: maprDB query works at command line but not in docker container

@Yong-Liu 

Yong-Liu,

No, I did not install mapr-client on the mac. All cluster interactions take place through the maprDB call. Here's my Dockerfile. I build the previous java with gradle hence the build/libs path.  Thank you for your help.

 

FROM alizarion/centos7java8

USER root

COPY build/libs/mapr_java_client.jar /mapr_java_client.jar

USER root
RUN mkdir -p /opt/mapr/conf
RUN chmod 0775 /opt/mapr/conf
COPY conf/mapr-clusters.conf /opt/mapr/conf

 

 

Yong-Liu
HPE Pro
Solution

Re: maprDB query works at command line but not in docker container

I'm trying to mimic your issue, @Tim11 , I used below dependencies in the pom.xml, and then, build with mvn clean package, to build a fat jar(with dependencies), I didn't saw the error you mentioned in the threads, I 'll put that to docker latter today, hope I can reproduce your issue:

my steps as below:

1. build fat jar, 

2. I uses windows laptop, so, I generated a service ticket for mapruser, then, add an env var :MAPR_TICKETFILE_LOCATION,

3. run like below:

c:\mike_maprdb\maprdb\target>java -cp maprdb-example-jar-with-dependencies.jar org.example.App
env:===C:\mike_maprdb\maprdb\mapr_service_ticket
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.mapr.fs.ShimLoader (file:/C:/mike_maprdb/maprdb/target/maprdb-example-jar-with-dependencies.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.mapr.fs.ShimLoader
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
{"_id":"mike000222333","fans":0,"name":"mike","support":"gold","type":"user","yelping_since":"2016-09-22"}

 

 

<dependency>
<groupId>com.mapr.db</groupId>
<artifactId>maprdb</artifactId>
<version>7.1.0.6-mapr</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
I'm an HPE employee.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo