// force:True is misbehaving it seems
.add("force", false)
.add("maxChunkSize", splitSize)
.get();
CommandResult data;
boolean ok = true;
if (authDB == null) {
try {
data = inputCollection.getDB().getSisterDB("admin").command(cmd);
} catch (MongoException e) { // 2.0 servers throw exceptions rather than info in a CommandResult
data = null;
LOG.info(e.getMessage(), e);
if (e.getMessage().contains("unrecognized command: splitVector")) {
ok = false;
} else {
throw e;
}
}
} else {
data = authDB.command(cmd);
}
if (data != null) {
if (data.containsField("$err")) {
throw new SplitFailedException("Error calculating splits: " + data);
} else if (!data.get("ok").equals(1.0)) {
ok = false;
}
}
if (!ok) {
CommandResult stats = inputCollection.getStats();
if (stats.containsField("primary")) {
DBCursor shards = inputCollection.getDB().getSisterDB("config")
.getCollection("shards")
.find(new BasicDBObject("_id", stats.getString("primary")));
try {
if (shards.hasNext()) {
DBObject shard = shards.next();
String host = ((String) shard.get("host")).replace(shard.get("_id") + "/", "");
MongoClientURI shardHost = new MongoClientURIBuilder(inputURI)