Details
-
Task
-
Resolution: Done
-
Major - P3
-
None
-
2.10.1
-
None
-
JDK 1.6 with Ubuntu 12.04
Description
Hello I am using Mongo Java Driver 2.10.1 and I am trying to reconfigure a replica set configuration by using Mongo Java Driver.
Initially I have four Mongo servers started up with next configuration:
{
|
"_id" : "rs-test",
|
"version" : 1,
|
members : [
|
{_id : 0, host : "localhost:27017"},
|
{_id : 1, host : "localhost:27018"},
|
{_id : 2, host : "localhost:27019"},
|
{_id : 3, host : "localhost:27020"}
|
]
|
}
|
Then I have my test which tries to reconfig this replica set by sending next document:
{
|
"_id" : "rs-test",
|
"version" : 2,
|
members : [
|
{_id : 0, host : "localhost:27017"},
|
{_id : 1, host : "localhost:27018"},
|
{_id : 2, host : "localhost:27019"},
|
{_id : 3, host : "localhost:27020", arbiterOnly: true}
|
]
|
}
|
|
|
And Java code:
MongoClient mongoClient = new MongoClient("localhost", 27017);
|
|
BasicDBObject basicDBObject = new BasicDBObject();
|
basicDBObject.put("replSetReconfig",JSON.parse(DOCUMENT));
|
|
DB db = mongoClient.getDB("admin");
|
CommandResult command = db.command(basicDBObject);
|
|
System.out.println(command);
|
And then next exception is returned:
emptying DBPortPool to localhost/127.0.0.1:27017 b/c of error
|
java.io.EOFException
|
at org.bson.io.Bits.readFully(Bits.java:48)
|
at org.bson.io.Bits.readFully(Bits.java:33)
|
at org.bson.io.Bits.readFully(Bits.java:28)
|
at com.mongodb.Response.<init>(Response.java:40)
|
at com.mongodb.DBPort.go(DBPort.java:124)
|
at com.mongodb.DBPort.call(DBPort.java:74)
|
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:286)
|
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:257)
|
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:310)
|
at com.mongodb.DB.command(DB.java:274)
|
at com.mongodb.DB.command(DB.java:256)
|
at com.mongodb.DB.command(DB.java:313)
|
at com.mongodb.DB.command(DB.java:211)
|
at MyTest.test(MyTest.java:32)
|
at MyTest.main(MyTest.java:40)
|
Exception in thread "main" com.mongodb.MongoException$Network: can't call something : localhost/127.0.0.1:27017/admin
|
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:295)
|
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:257)
|
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:310)
|
at com.mongodb.DB.command(DB.java:274)
|
at com.mongodb.DB.command(DB.java:256)
|
at com.mongodb.DB.command(DB.java:313)
|
at com.mongodb.DB.command(DB.java:211)
|
at MyTest.test(MyTest.java:32)
|
at MyTest.main(MyTest.java:40)
|
Caused by: java.io.EOFException
|
at org.bson.io.Bits.readFully(Bits.java:48)
|
at org.bson.io.Bits.readFully(Bits.java:33)
|
at org.bson.io.Bits.readFully(Bits.java:28)
|
at com.mongodb.Response.<init>(Response.java:40)
|
at com.mongodb.DBPort.go(DBPort.java:124)
|
at com.mongodb.DBPort.call(DBPort.java:74)
|
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:286)
|
... 8 more
|
If I go to mongo shell and I type rs.conf() at first time an errno:2 is also shown but then tries to reconnect again and then it works as expected and shows that server with id 3 is hidden. So it seems like command is send successful. Is there any way to avoid that Mongo Driver throws an exception? Maybe me as a user of Mongo Java Driver should implement a recovery function? (basically catching the exception and not propagating it?).
Also I have tried by registering all servers in MongoClient but same exception is thrown.
Thank you very much in advance for your help.