*/
private Mongo onSetMongoServerProperties(String contactNode, String defaultPort, String poolSize,
List<ServerAddress> addrs) throws UnknownHostException
{
Mongo mongo = null;
MongoOptions mo = null;
MongoDBSchemaMetadata metadata = MongoDBPropertyReader.msmd;
ClientProperties cp = metadata != null ? metadata.getClientProperties() : null;
if (cp != null)
{
DataStore dataStore = metadata != null ? metadata.getDataStore() : null;
List<Server> servers = dataStore != null && dataStore.getConnection() != null ? dataStore.getConnection()
.getServers() : null;
if (servers != null && !servers.isEmpty())
{
for (Server server : servers)
{
addrs.add(new ServerAddress(server.getHost().trim(), Integer.parseInt(server.getPort().trim())));
}
mongo = new Mongo(addrs);
}
else
{
logger.info("Connecting to mongodb at " + contactNode + " on port " + defaultPort);
mongo = new Mongo(contactNode, Integer.parseInt(defaultPort));
}
mo = mongo.getMongoOptions();
Properties p = dataStore != null && dataStore.getConnection() != null ? dataStore.getConnection()
.getProperties() : null;
PopulateMongoOptions.populateMongoOptions(mo, p);
}
else
{
logger.info("Connecting to mongodb at " + contactNode + " on port " + defaultPort);
mongo = new Mongo(contactNode, Integer.parseInt(defaultPort));
mo = mongo.getMongoOptions();
}
// setting server property.
if (mo.getConnectionsPerHost() <= 0 && !StringUtils.isEmpty(poolSize))
{
mo.connectionsPerHost = Integer.parseInt(poolSize);
}
return mongo;
}