List of usage examples for com.mongodb MongoURI getCredentials
@Nullable
public MongoCredential getCredentials()
From source file:org.icgc.dcc.release.job.imports.hadoop.MongoAdminInputFormat.java
License:Open Source License
/** * Method to workaround {@code mongo-hadoop}'s lack of authentication support for the {@code splitVector} command * which first requires the client to authenticate against the {@code admin} db. This may be related to the referenced * links below.//from w w w . j ava 2 s.c om * * @param collectionUri a Mongo collection URI to any collection on the target database * @see https://jira.mongodb.org/browse/HADOOP-43 * @see https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/aTh_o0u-_B0 */ private static void authenticateAdmin(String collectionUri) { MongoURI mongoUri = mongoUri(collectionUri); if (mongoUri.getCredentials() == null) { // No need for the workaround return; } // Need to use this method which caches an instance of Mongo that is later // used for 'splitVector'ing in MongoSplitter Mongo hadoopMongo = getHadoopMongo(mongoUri); // Ensure that the downstream 'splitVector' command will succeed by // first authenticating against the admin db using the shared 'db' connection // object. authenticateAdmin(mongoUri, hadoopMongo); }