Skip to content
Snippets Groups Projects
Commit 947bccc6 authored by Michi Mutsuzaki's avatar Michi Mutsuzaki
Browse files

gh-27 MongoDbClient was not working with non localhost URLs (arunxarun)

parent 77ce3a8e
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@
* gh-31 Support to stop benchmark after a maximum specified elapsed time. (sudiptodas)
* gh-35 Cassandra0.8 support (joaquincasares)
* gh-30 IllegalArgumentException with MongoDB (m1ch1)
* gh-27 MongoDbClient was not working with non localhost URLs (arunxarun)
0.1.3
* Voldemort binding (rsumbaly)
......
......@@ -80,11 +80,11 @@ public class MongoDbClient extends DB {
url = url.substring(10);
}
ArrayList<ServerAddress> addr = new ArrayList<ServerAddress>();
for (String s: url.split(",")) {
addr.add(new ServerAddress(s));
}
mongo = new Mongo(addr);
// need to append db to url.
url += "/"+database;
System.out.println("new database url = "+url);
mongo = new Mongo(new DBAddress(url));
System.out.println("mongo connection created with "+url);
} catch (Exception e1) {
logger.error(
"Could not initialize MongoDB connection pool for Loader: "
......@@ -159,8 +159,9 @@ public class MongoDbClient extends DB {
// determine if record was inserted, does not seem to return
// n=<records affected> for insert
DBObject errors = db.getLastError();
System.out.println(errors.toString());
return (errors.get("ok") != null && errors.get("err") == null) ? 0 : 1;
return ((Double) errors.get("ok") == 1.0) && errors.get("err") == null ? 0 : 1;
} catch (Exception e) {
logger.error(e + "", e);
return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment