You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by dl...@apache.org on 2018/01/04 22:07:26 UTC

[04/17] incubator-rya git commit: RYA-414 Introduced the stateful mongo configuratino object so that it is the arbitor of MongoDB state within a Sail object.

RYA-414 Introduced the stateful mongo configuratino object so that it is the arbitor of MongoDB state within a Sail object.


Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/767349da
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/767349da
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/767349da

Branch: refs/heads/master
Commit: 767349dac9822cd13e92f9b117d1b5d2dad13e3d
Parents: 62de7c5
Author: kchilton2 <ke...@gmail.com>
Authored: Fri Dec 22 20:52:27 2017 -0500
Committer: kchilton2 <ke...@gmail.com>
Committed: Wed Dec 27 14:08:11 2017 -0500

----------------------------------------------------------------------
 .../AbstractMongoDBRdfConfigurationBuilder.java |  39 +-
 .../rya/mongodb/EmbeddedMongoFactory.java       |  25 +-
 .../rya/mongodb/MongoConnectorFactory.java      | 134 ----
 .../apache/rya/mongodb/MongoDBQueryEngine.java  |  48 +-
 .../rya/mongodb/MongoDBRdfConfiguration.java    | 275 ++++---
 .../org/apache/rya/mongodb/MongoDBRyaDAO.java   |  71 +-
 .../StatefulMongoDBRdfConfiguration.java        |  79 ++
 .../mongodb/dao/MongoDBNamespaceManager.java    |  20 +-
 .../dao/SimpleMongoDBNamespaceManager.java      |  12 +-
 .../rya/mongodb/EmbeddedMongoSingleton.java     |  55 +-
 .../rya/mongodb/MongoDBQueryEngineTest.java     | 152 ++--
 .../mongodb/MongoDBRdfConfigurationTest.java    |  49 +-
 .../rya/mongodb/MongoDBRyaBatchWriterIT.java    |  34 +-
 .../org/apache/rya/mongodb/MongoDBRyaDAOIT.java | 654 ++++++++--------
 .../apache/rya/mongodb/MongoDBRyaDAOTest.java   | 147 ++--
 .../apache/rya/mongodb/MongoRyaTestBase.java    |  73 --
 .../org/apache/rya/mongodb/MongoTestBase.java   |  36 +-
 .../src/test/resources/log4j.properties         |  27 +
 .../indexing/entity/EntityIndexOptimizer.java   |   5 +
 .../entity/update/mongo/MongoEntityIndexer.java |  31 +-
 .../indexing/mongodb/AbstractMongoIndexer.java  |  36 +-
 .../rya/indexing/mongodb/MongoDbSmartUri.java   |  19 +-
 .../matching/RyaQueryEngineFactory.java         |  29 +-
 .../apache/rya/sail/config/RyaSailFactory.java  | 167 ++++-
 .../rya/indexing/mongo/MongoEntityIndexIT.java  | 183 +++--
 .../mongo/MongoFreeTextIndexerTest.java         |  58 +-
 .../mongo/MongoIndexingConfigurationTest.java   |   8 +-
 .../mongo/MongoTemporalIndexerTest.java         | 751 ++++++++++---------
 .../metadata/MongoStatementMetadataIT.java      |  97 ++-
 ...tatementMetadataExternalSetProviderTest.java |  20 +-
 .../StatementMetadataOptimizerTest.java         |  16 +-
 .../src/main/java/InferenceExamples.java        |  11 +-
 .../src/main/java/MongoRyaDirectExample.java    |   2 -
 .../org/apache/rya/indexing/export/ITBase.java  |   2 +-
 34 files changed, 1769 insertions(+), 1596 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java
index f50bf9a..a2bd03f 100644
--- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java
@@ -59,11 +59,11 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
 
     /**
      * Sets Mongo user.
-     * 
+     *
      * @param user - user name used to connect to Mongo
      * @return specified builder for chaining method invocations
      */
-    public B setMongoUser(String user) {
+    public B setMongoUser(final String user) {
         this.user = user;
         return confBuilder();
     }
@@ -71,11 +71,11 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
     /**
      * Sets password for Mongo user specified by
      * {@link AbstractMongoDBRdfConfigurationBuilder#setMongoUser(String)}.
-     * 
+     *
      * @param password - password used to connect to Mongo
      * @return specified builder for chaining method invocations
      */
-    public B setMongoPassword(String password) {
+    public B setMongoPassword(final String password) {
         this.pass = password;
         return confBuilder();
     }
@@ -83,11 +83,11 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
     /**
      * Sets Mongo port. This parameter must be set to connect to an instance of
      * MongoDB and will default to "27017" if no value is specified.
-     * 
+     *
      * @param port - port used to connect Mongo
      * @return specified builder for chaining method invocations
      */
-    public B setMongoPort(String port) {
+    public B setMongoPort(final String port) {
         this.port = port;
         return confBuilder();
     }
@@ -95,11 +95,11 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
     /**
      * Sets Mongo host. This parameter must be set to connect to an instance of
      * MongoDB and will default to "localhost" if no value is specified.
-     * 
+     *
      * @param host - host used to connect to Mongo
      * @return specified builder for chaining method invocations
      */
-    public B setMongoHost(String host) {
+    public B setMongoHost(final String host) {
         this.host = host;
         return confBuilder();
     }
@@ -107,11 +107,11 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
     /**
      * Sets MongoDB name. This parameter must be set to connect to an instance
      * of MongoDB and will default to "rya_triples" is no value is specified.
-     * 
+     *
      * @param name - name of MongoDB to connect to
      * @return specified builder for chaining method invocations
      */
-    public B setMongoDBName(String name) {
+    public B setMongoDBName(final String name) {
         this.mongoDBName = name;
         return confBuilder();
     }
@@ -120,11 +120,11 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
      * Sets MongoDB Collection prefix. This parameter must be set to connect to
      * an instance of MongoDB and will default to "rya_" is no value is
      * specified.
-     * 
+     *
      * @param name - name of Collection to connect to
      * @return specified builder for chaining method invocations
      */
-    public B setMongoCollectionPrefix(String prefix) {
+    public B setMongoCollectionPrefix(final String prefix) {
         this.mongoCollectionPrefix = prefix;
         return confBuilder();
     }
@@ -132,11 +132,11 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
     /**
      * Set whether to use instance of embedded Mongo as backend for Rya
      * instance.
-     * 
+     *
      * @param useMock - indicates whether to use embedded Mongo as Rya backing
      * @return specified builder for chaining method invocations
      */
-    public B setUseMockMongo(boolean useMock) {
+    public B setUseMockMongo(final boolean useMock) {
         this.useMock = useMock;
         return confBuilder();
     }
@@ -144,21 +144,22 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
     /**
      * @return extension of {@link MongoDBRdfConfiguration} with specified parameters set
      */
+    @Override
     public C build() {
         return getConf(super.build());
     }
 
     /**
      * Assigns builder values to appropriate parameters within the {@link Configuration} object.
-     * 
+     *
      * @param conf - Configuration object
      * @return - Configuration object with parameters set
      */
-    private C getConf(C conf) {
+    private C getConf(final C conf) {
 
         conf.setUseMock(useMock);
         conf.set("sc.useMongo", "true");
-        
+
         if (user != null) {
             conf.setMongoUser(user);
         }
@@ -166,9 +167,9 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
             conf.setMongoPassword(pass);
         }
         conf.setMongoDBName(mongoDBName);
-        conf.setCollectionName(mongoCollectionPrefix);
+        conf.setRyaInstance(mongoCollectionPrefix);
         conf.setTablePrefix(mongoCollectionPrefix);
-        conf.setMongoInstance(host);
+        conf.setMongoHostname(host);
         conf.setMongoPort(port);
 
         return conf;

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java
index f023739..d695ffa 100644
--- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -46,7 +46,7 @@ public class EmbeddedMongoFactory {
     public static EmbeddedMongoFactory newFactory() throws IOException {
         return EmbeddedMongoFactory.with(Version.Main.PRODUCTION);
     }
-    
+
     public static EmbeddedMongoFactory with(final IFeatureAwareVersion version) throws IOException {
         return new EmbeddedMongoFactory(version);
     }
@@ -56,9 +56,9 @@ public class EmbeddedMongoFactory {
 
     /**
      * Create the testing utility using the specified version of MongoDB.
-     * 
+     *
      * @param version
-     *            version of MongoDB.
+     *            - version of MongoDB.
      */
     private EmbeddedMongoFactory(final IFeatureAwareVersion version) throws IOException {
         final MongodStarter runtime = MongodStarter.getInstance(new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger).build());
@@ -67,7 +67,7 @@ public class EmbeddedMongoFactory {
     }
 
     private IMongodConfig newMongodConfig(final IFeatureAwareVersion version) throws UnknownHostException, IOException {
-        Net net = new Net(findRandomOpenPortOnAllLocalInterfaces(), false);
+        final Net net = new Net(findRandomOpenPortOnAllLocalInterfaces(), false);
         return new MongodConfigBuilder().version(version).net(net).build();
     }
 
@@ -79,7 +79,7 @@ public class EmbeddedMongoFactory {
 
     /**
      * Creates a new Mongo connection.
-     * 
+     *
      * @throws MongoException
      * @throws UnknownHostException
      */
@@ -88,10 +88,19 @@ public class EmbeddedMongoFactory {
     }
 
     /**
+     * Gives access to the process configuration.
+     *
+     */
+    public IMongodConfig getMongoServerDetails() {
+        return mongodProcess.getConfig();
+    }
+
+
+    /**
      * Cleans up the resources created by the utility.
      */
     public void shutdown() {
         mongodProcess.stop();
         mongodExecutable.stop();
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoConnectorFactory.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoConnectorFactory.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoConnectorFactory.java
deleted file mode 100644
index 50c3a52..0000000
--- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoConnectorFactory.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.rya.mongodb;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.apache.commons.configuration.ConfigurationRuntimeException;
-import org.apache.commons.io.IOUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.http.annotation.ThreadSafe;
-
-import com.mongodb.MongoClient;
-import com.mongodb.MongoCredential;
-import com.mongodb.MongoException;
-import com.mongodb.ServerAddress;
-
-import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
-import edu.umd.cs.findbugs.annotations.NonNull;
-/**
- * Mongo convention generally allows for a single instance of a {@link MongoClient}
- * throughout the life cycle of an application.  This MongoConnectorFactory lazy
- * loads a Mongo Client and uses the same one whenever {@link MongoConnectorFactory#getMongoClient(Configuration)}
- * is invoked.
- */
-@ThreadSafe
-@DefaultAnnotation(NonNull.class)
-public class MongoConnectorFactory {
-    private static MongoClient mongoClient;
-
-    private final static String MSG_INTRO = "Failed to connect to MongoDB: ";
-
-    /**
-     * @param conf The {@link Configuration} defining how to construct the MongoClient.
-     * @return A {@link MongoClient}.  This client is lazy loaded and the same one
-     * is used throughout the lifecycle of the application.
-     * @throws IOException - if MongodForTestsFactory constructor has an io exception.
-     * @throws ConfigurationRuntimeException - Thrown if the configured server, port, user, or others are missing.
-     * @throws MongoException  if can't connect despite conf parameters are given
-     */
-    public static synchronized MongoClient getMongoClient(final Configuration conf)
-            throws ConfigurationRuntimeException, MongoException {
-        if (mongoClient == null) {
-            if(conf instanceof MongoDBRdfConfiguration && ((MongoDBRdfConfiguration) conf).getMongoClient() != null) {
-                mongoClient = ((MongoDBRdfConfiguration) conf).getMongoClient();
-            } else {
-                createMongoClientForServer(conf);
-            }
-        }
-        return mongoClient;
-    }
-
-    /**
-     * Silently closes the underlying Mongo client.
-     */
-    public static synchronized void closeMongoClient() {
-        IOUtils.closeQuietly(mongoClient);
-        mongoClient = null;
-    }
-
-    /**
-     * Create a MongoDB client object and assign it to this class's static mongoClient
-     * @param conf configuration containing connection parameters
-     * @throws ConfigurationRuntimeException - Thrown if the configured server, port, user, or others are missing.
-     * @throws MongoException  if can't connect despite conf parameters are given
-     */
-    private static void createMongoClientForServer(final Configuration conf)
-            throws ConfigurationRuntimeException, MongoException {
-        // Connect to a running Mongo server
-        final String host = requireNonNull(conf.get(MongoDBRdfConfiguration.MONGO_INSTANCE), MSG_INTRO+"host name is required");
-        final int port = requireNonNullInt(conf.get(MongoDBRdfConfiguration.MONGO_INSTANCE_PORT), MSG_INTRO+"Port number is required.");
-        final ServerAddress server = new ServerAddress(host, port);
-        // check for authentication credentials
-        if (conf.get(MongoDBRdfConfiguration.MONGO_USER) != null) {
-            final String username = conf.get(MongoDBRdfConfiguration.MONGO_USER);
-            final String dbName = requireNonNull(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME),
-                    MSG_INTRO + MongoDBRdfConfiguration.MONGO_DB_NAME + " is null but required configuration if "
-                            + MongoDBRdfConfiguration.MONGO_USER + " is configured.");
-            final char[] pswd = requireNonNull(conf.get(MongoDBRdfConfiguration.MONGO_USER_PASSWORD),
-                    MSG_INTRO + MongoDBRdfConfiguration.MONGO_USER_PASSWORD + " is null but required configuration if "
-                            + MongoDBRdfConfiguration.MONGO_USER + " is configured.").toCharArray();
-            final MongoCredential cred = MongoCredential.createCredential(username, dbName, pswd);
-            mongoClient = new MongoClient(server, Arrays.asList(cred));
-        } else {
-            // No user was configured:
-            mongoClient = new MongoClient(server);
-        }
-    }
-
-    /**
-     * Throw exception for un-configured required values.
-     *
-     * @param required  String to check
-     * @param message  throw configuration exception with this description
-     * @return unaltered required string
-     * @throws ConfigurationRuntimeException  if required is null
-     */
-    private static String requireNonNull(final String required, final String message) throws ConfigurationRuntimeException {
-        if (required == null) {
-            throw new ConfigurationRuntimeException(message);
-        }
-        return required;
-    }
-
-    /*
-     * Same as above, check that it is a integer and return the parsed integer.
-     */
-    private static int requireNonNullInt(final String required, final String message) throws ConfigurationRuntimeException {
-        if (required == null) {
-            throw new ConfigurationRuntimeException(message);
-        }
-        try {
-            return Integer.parseInt(required);
-        } catch (final NumberFormatException e) {
-            throw new ConfigurationRuntimeException(message);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBQueryEngine.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBQueryEngine.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBQueryEngine.java
index f1115b1..d107d43 100644
--- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBQueryEngine.java
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBQueryEngine.java
@@ -1,5 +1,4 @@
-package org.apache.rya.mongodb;
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -17,8 +16,7 @@ package org.apache.rya.mongodb;
  * specific language governing permissions and limitations
  * under the License.
  */
-
-import static com.google.common.base.Preconditions.checkNotNull;
+package org.apache.rya.mongodb;
 
 import java.io.IOException;
 import java.util.AbstractMap;
@@ -47,7 +45,6 @@ import org.openrdf.query.impl.MapBindingSet;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
-import com.mongodb.MongoClient;
 import com.mongodb.client.MongoCollection;
 import com.mongodb.client.MongoDatabase;
 
@@ -57,48 +54,41 @@ import info.aduna.iteration.CloseableIteration;
  * Date: 7/17/12
  * Time: 9:28 AM
  */
-public class MongoDBQueryEngine implements RyaQueryEngine<MongoDBRdfConfiguration> {
-
-    private MongoDBRdfConfiguration configuration;
-    private final MongoClient mongoClient;
-    private final MongoDBStorageStrategy<RyaStatement> strategy;
-
-    public MongoDBQueryEngine(final MongoDBRdfConfiguration conf, final MongoClient mongoClient) {
-        this.mongoClient = checkNotNull(mongoClient);
-        strategy = new SimpleMongoDBStorageStrategy();
-    }
+public class MongoDBQueryEngine implements RyaQueryEngine<StatefulMongoDBRdfConfiguration> {
 
+    private StatefulMongoDBRdfConfiguration configuration;
+    private final MongoDBStorageStrategy<RyaStatement> strategy = new SimpleMongoDBStorageStrategy();
 
     @Override
-    public void setConf(final MongoDBRdfConfiguration conf) {
+    public void setConf(final StatefulMongoDBRdfConfiguration conf) {
         configuration = conf;
     }
 
     @Override
-    public MongoDBRdfConfiguration getConf() {
+    public StatefulMongoDBRdfConfiguration getConf() {
         return configuration;
     }
 
     @Override
     public CloseableIteration<RyaStatement, RyaDAOException> query(
-            final RyaStatement stmt, MongoDBRdfConfiguration conf)
+            final RyaStatement stmt, final StatefulMongoDBRdfConfiguration conf)
             throws RyaDAOException {
         Preconditions.checkNotNull(stmt);
         Preconditions.checkNotNull(conf);
-        
-        Entry<RyaStatement, BindingSet> entry = new AbstractMap.SimpleEntry<>(stmt, new MapBindingSet());
-        Collection<Entry<RyaStatement, BindingSet>> collection = Collections.singleton(entry);
-        
+
+        final Entry<RyaStatement, BindingSet> entry = new AbstractMap.SimpleEntry<>(stmt, new MapBindingSet());
+        final Collection<Entry<RyaStatement, BindingSet>> collection = Collections.singleton(entry);
+
         return new RyaStatementCursorIterator(queryWithBindingSet(collection, conf));
     }
 
     @Override
     public CloseableIteration<? extends Entry<RyaStatement, BindingSet>, RyaDAOException> queryWithBindingSet(
             final Collection<Entry<RyaStatement, BindingSet>> stmts,
-            MongoDBRdfConfiguration conf) throws RyaDAOException {
+            final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException {
         Preconditions.checkNotNull(stmts);
         Preconditions.checkNotNull(conf);
-        
+
         final Multimap<RyaStatement, BindingSet> rangeMap = HashMultimap.create();
 
         //TODO: cannot span multiple tables here
@@ -121,7 +111,7 @@ public class MongoDBQueryEngine implements RyaQueryEngine<MongoDBRdfConfiguratio
     }
     @Override
     public CloseableIteration<RyaStatement, RyaDAOException> batchQuery(
-            final Collection<RyaStatement> stmts, MongoDBRdfConfiguration conf)
+            final Collection<RyaStatement> stmts, final StatefulMongoDBRdfConfiguration conf)
             throws RyaDAOException {
         final Map<RyaStatement, BindingSet> queries = new HashMap<>();
 
@@ -131,7 +121,7 @@ public class MongoDBQueryEngine implements RyaQueryEngine<MongoDBRdfConfiguratio
 
         return new RyaStatementCursorIterator(queryWithBindingSet(queries.entrySet(), conf));
     }
-    
+
     @Override
     public CloseableIterable<RyaStatement> query(final RyaQuery ryaQuery)
             throws RyaDAOException {
@@ -151,12 +141,12 @@ public class MongoDBQueryEngine implements RyaQueryEngine<MongoDBRdfConfiguratio
             queries.put(stmt, new MapBindingSet());
         }
 
-        Iterator<RyaStatement> iterator = new RyaStatementCursorIterator(queryWithBindingSet(queries.entrySet(), getConf()));
+        final Iterator<RyaStatement> iterator = new RyaStatementCursorIterator(queryWithBindingSet(queries.entrySet(), getConf()));
         return CloseableIterables.wrap((Iterable<RyaStatement>) () -> iterator);
     }
 
-    private MongoCollection<Document> getCollection(final MongoDBRdfConfiguration conf) {
-        final MongoDatabase db = mongoClient.getDatabase(conf.getMongoDBName());
+    private MongoCollection<Document> getCollection(final StatefulMongoDBRdfConfiguration conf) {
+        final MongoDatabase db = conf.getMongoClient().getDatabase(conf.getMongoDBName());
         return db.getCollection(conf.getTriplesCollectionName());
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java
index 418a155..4d06ea1 100644
--- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java
@@ -1,6 +1,4 @@
-package org.apache.rya.mongodb;
-
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -18,72 +16,75 @@ package org.apache.rya.mongodb;
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.rya.mongodb;
+
+import static java.util.Objects.requireNonNull;
 
-import java.util.List;
 import java.util.Properties;
 
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.mongodb.MongoClient;
+import edu.umd.cs.findbugs.annotations.Nullable;
 
+/**
+ * A {@link RdfCloudTripleStoreConfiguration} that configures how Rya connects to a MongoDB Rya triple store.
+ */
 public class MongoDBRdfConfiguration extends RdfCloudTripleStoreConfiguration {
-    public static final String MONGO_INSTANCE = "mongo.db.instance";
-    public static final String MONGO_INSTANCE_PORT = "mongo.db.port";
-    public static final String MONGO_GEO_MAXDISTANCE = "mongo.geo.maxdist";
+
+    // MongoDB Server connection values.
+    public static final String MONGO_HOSTNAME = "mongo.db.instance";
+    public static final String MONGO_PORT = "mongo.db.port";
+
+    // MongoDB Database values.
     public static final String MONGO_DB_NAME = "mongo.db.name";
-    public static final String MONGO_COLLECTION_PREFIX = "mongo.db.collectionprefix";
     public static final String MONGO_USER = "mongo.db.user";
     public static final String MONGO_USER_PASSWORD = "mongo.db.userpassword";
-    public static final String CONF_ADDITIONAL_INDEXERS = "ac.additional.indexers";
+
+    // Rya Instance values.
+    public static final String MONGO_COLLECTION_PREFIX = "mongo.db.collectionprefix";
+
+    // Rya Sail configuration values.
     public static final String USE_MOCK_MONGO = ".useMockInstance";
     public static final String CONF_FLUSH_EACH_UPDATE = "rya.mongodb.dao.flusheachupdate";
+    public static final String CONF_ADDITIONAL_INDEXERS = "ac.additional.indexers";
+    public static final String MONGO_GEO_MAXDISTANCE = "mongo.geo.maxdist";
 
-    private MongoClient mongoClient;
-
+    /**
+     * Constructs an empty instance of {@link MongoDBRdfConfiguration}.
+     */
     public MongoDBRdfConfiguration() {
         super();
     }
 
+    /**
+     * Constructs an instance of {@link MongoDBRdfConfiguration} pre-loaded with values.
+     *
+     * @param other - The values that will be cloned into the constructed object. (not null)
+     */
     public MongoDBRdfConfiguration(final Configuration other) {
-        super(other);
+        super( requireNonNull(other) );
     }
 
     /**
-     * Creates a MongoRdfConfiguration object from a Properties file. This
-     * method assumes that all values in the Properties file are Strings and
-     * that the Properties file uses the keys below.
+     * Reads a {@link Properties} object into a {@link MongoDBRdfConfiguration}.
+     * See {@link MongoDBRdfConfigurationBuilder#fromProperties(Properties)} for which keys
+     * are to be used within the properties object. This method will replace that object's keys
+     * with the configuration object's keys since they are not the same.
      *
-     * <br>
-     * <ul>
-     * <li>"mongo.auths" - String of Mongo authorizations.  Empty auths used by default.
-     * <li>"mongo.visibilities" - String of Mongo visibilities assigned to ingested triples.
-     * <li>"mongo.user" - Mongo user.  Empty by default.
-     * <li>"mongo.password" - Mongo password.  Empty by default.
-     * <li>"mongo.host" - Mongo host.  Default host is "localhost"
-     * <li>"mongo.port" - Mongo port.  Default port is "27017".
-     * <li>"mongo.db.name" - Name of MongoDB.  Default name is "rya_triples".
-     * <li>"mongo.collection.prefix" - Mongo collection prefix. Default is "rya_".
-     * <li>"mongo.rya.prefix" - Prefix for Mongo Rya instance.  Same as value of "mongo.collection.prefix".
-     * <li>"use.mock" - Use a Embedded Mongo instance as back-end for Rya instance. False by default.
-     * <li>"use.display.plan" - Display query plan during evaluation. Useful for debugging.  True by default.
-     * <li>"use.inference" - Use backward chaining inference during query.  False by default.
-     * </ul>
-     * <br>
-     *
-     * @param props
-     *            - Properties file containing Mongo specific configuration
-     *            parameters
-     * @return MongoRdfConfiguration with properties set
+     * @param props - The properties containing Mongo specific configuration parameters. (not null)
+     * @return A {@link } loaded with the values that were in {@code props}.
      */
     public static MongoDBRdfConfiguration fromProperties(final Properties props) {
+        requireNonNull(props);
         return MongoDBRdfConfigurationBuilder.fromProperties(props);
     }
 
-    public MongoDBRdfConfigurationBuilder getBuilder() {
+    /**
+     * @return A new instance of {@link MongoDBRdfConfigurationBuilder}.
+     */
+    public static MongoDBRdfConfigurationBuilder getBuilder() {
         return new MongoDBRdfConfigurationBuilder();
     }
 
@@ -92,184 +93,162 @@ public class MongoDBRdfConfiguration extends RdfCloudTripleStoreConfiguration {
         return new MongoDBRdfConfiguration(this);
     }
 
-    public Authorizations getAuthorizations() {
-        final String[] auths = getAuths();
-        if (auths == null || auths.length == 0) {
-            return MongoDbRdfConstants.ALL_AUTHORIZATIONS;
-        }
-        return new Authorizations(auths);
-    }
-
     /**
-     * @return {@code true} if each statement added to the batch writer should
-     * be flushed and written right away to the datastore. {@code false} if the
-     * statements should be queued and written to the datastore when the queue
-     * is full or after enough time has passed without a write.<p>
-     * Defaults to {@code true} if nothing is specified.
+     * Set whether the Rya client should spin up an embedded MongoDB instance and connect to that
+     * or if it should connect to a MongoDB Server that is running somewhere.
+     *
+     * @param useMock - {@true} to use an embedded Mongo DB instance; {@code false} to connect to a real server.
      */
-    public boolean flushEachUpdate(){
-        return getBoolean(CONF_FLUSH_EACH_UPDATE, true);
+    public void setUseMock(final boolean useMock) {
+        this.setBoolean(USE_MOCK_MONGO, useMock);
     }
 
     /**
-     * Sets the {@link #CONF_FLUSH_EACH_UPDATE} property of the configuration.
-     * @param flush {@code true} if each statement added to the batch writer
-     * should be flushed and written right away to the datastore. {@code false}
-     * if the statements should be queued and written to the datastore when the
-     * queue is full or after enough time has passed without a write.
+     * Indicates whether the Rya client should spin up an embedded MongoDB instance and connect to that
+     * or if it should connect to a MongoDB Server that is running somewhere.
+     *
+     * @return {@true} to use an embedded Mongo DB instance; {@code false} to connect to a real server.
      */
-    public void setFlush(final boolean flush){
-        setBoolean(CONF_FLUSH_EACH_UPDATE, flush);
+    public boolean getUseMock() {
+        return getBoolean(USE_MOCK_MONGO, false);
     }
 
     /**
-     * @return name of Mongo Collection containing Rya triples
+     * @return The hostname of the MongoDB Server to connect to. (default: localhost)
      */
-    public String getTriplesCollectionName() {
-        return this.get(MONGO_COLLECTION_PREFIX, "rya") + "_triples";
+    public String getMongoHostname() {
+        return get(MONGO_HOSTNAME, "localhost");
     }
 
     /**
-     * @return name of Mongo Collection
+     * @param hostname - The hostname of the MongoDB Server to connect to.
      */
-    public String getCollectionName() {
-        return this.get(MONGO_COLLECTION_PREFIX, "rya");
+    public void setMongoHostname(final String hostname) {
+        requireNonNull(hostname);
+        set(MONGO_HOSTNAME, hostname);
     }
 
     /**
-     * Sets Mongo Collection name
-     * @param name - name of Mongo Collection to connect to
+     * @return The port of the MongoDB Server to connect to. (default: 27017)
      */
-    public void setCollectionName(final String name) {
-        Preconditions.checkNotNull(name);
-        this.set(MONGO_COLLECTION_PREFIX, name);
+    public String getMongoPort() {
+        return get(MONGO_PORT, AbstractMongoDBRdfConfigurationBuilder.DEFAULT_MONGO_PORT);
     }
 
     /**
-     * @return name of Mongo Host
+     * @param port - The port of the MongoDB Server to connect to.
      */
-    public String getMongoInstance() {
-        return this.get(MONGO_INSTANCE, "localhost");
+    public void setMongoPort(final String port) {
+        requireNonNull(port);
+        set(MONGO_PORT, port);
     }
 
     /**
-     * Sets name of Mongo Host
-     * @param name - name of Mongo Host to connect to
+     * @return The name of the MongoDB Database to connect to. (default: rya)
      */
-    public void setMongoInstance(final String name) {
-        Preconditions.checkNotNull(name);
-        this.set(MONGO_INSTANCE, name);
+    public String getMongoDBName() {
+        return get(MONGO_DB_NAME, "rya");
     }
 
     /**
-     * @return port that Mongo is running on
+     * @param database - The name of the MongoDb Database to connect to.
      */
-    public String getMongoPort() {
-        return this.get(MONGO_INSTANCE_PORT, AbstractMongoDBRdfConfigurationBuilder.DEFAULT_MONGO_PORT);
+    public void setMongoDBName(final String database) {
+        requireNonNull(database);
+        set(MONGO_DB_NAME, database);
     }
 
     /**
-     * Sets port that Mongo will run on
-     * @param name - Mongo port to connect to
+     * @param user - The user used to connect to the MongoDB Database that hosts the Rya Instance. (not null)
      */
-    public void setMongoPort(final String name) {
-        Preconditions.checkNotNull(name);
-        this.set(MONGO_INSTANCE_PORT, name);
+    public void setMongoUser(final String user) {
+        requireNonNull(user);
+        set(MONGO_USER, user);
     }
 
     /**
-     * @return name of MongoDB
+     * @return The user used to connect to the MongoDB Database that hosts the Rya Instance.
      */
-    public String getMongoDBName() {
-        return this.get(MONGO_DB_NAME, "rya");
+    public @Nullable String getMongoUser() {
+        return get(MONGO_USER);
     }
 
     /**
-     * Sets name of MongoDB
-     * @param name - name of MongoDB to connect to
+     * @param password - The password used to connect to the MongoDB Database that hosts the Rya Instance.
      */
-    public void setMongoDBName(final String name) {
-        Preconditions.checkNotNull(name);
-        this.set(MONGO_DB_NAME, name);
+    public void setMongoPassword(final String password) {
+        requireNonNull(password);
+        set(MONGO_USER_PASSWORD, password);
     }
 
     /**
-     * Tells Rya to use an embedded Mongo instance as its backing
-     * if set to true.  By default this is set to false.
-     * @param useMock
+     * @return The password used to connect to the MongoDB Database that hosts the Rya Instance.
      */
-    public void setUseMock(final boolean useMock) {
-        this.setBoolean(USE_MOCK_MONGO, useMock);
+    public @Nullable String getMongoPassword() {
+        return get(MONGO_USER_PASSWORD);
     }
 
     /**
-     * Get whether an embedded Mongo is being used as the backing
-     * for Rya.
-     * @return true if embedded Mongo is being used, and false otherwise
+     * @return The name of the Rya instance to connect to. (default: rya)
      */
-    public boolean getUseMock() {
-        return getBoolean(USE_MOCK_MONGO, false);
+    public String getRyaInstance() {
+        return get(MONGO_COLLECTION_PREFIX, "rya");
     }
 
     /**
-     * @return name of NameSpace Mongo Collection
+     * @param name - The name of the Rya instance to connect to.
      */
-    public String getNameSpacesCollectionName() {
-        return this.get(MONGO_COLLECTION_PREFIX, "rya") + "_ns";
+    public void setRyaInstance(final String name) {
+        requireNonNull(name);
+        set(MONGO_COLLECTION_PREFIX, name);
     }
 
     /**
-     * Sets name of Mongo User
-     * @param user - name of Mongo user to connect to
+     * @return The name of the MongoDB Collection that contains Rya statements. (default: rya_triples)
      */
-    public void setMongoUser(final String user) {
-        Preconditions.checkNotNull(user);
-        set(MONGO_USER, user);
+    public String getTriplesCollectionName() {
+        return getRyaInstance() + "_triples";
     }
 
     /**
-     * @return name of Mongo user
+     * @return The name of the MongoDB Collection that contains the Rya namespace. (default: rya_ns)
      */
-    public String getMongoUser() {
-        return get(MONGO_USER);
+    public String getNameSpacesCollectionName() {
+        return getRyaInstance() + "_ns";
     }
 
     /**
-     * Sets Mongo password
-     * @param password - password to connect to Mongo
+     * @return The authorizations that will be used when accessing data. (default: empty)
      */
-    public void setMongoPassword(final String password) {
-        Preconditions.checkNotNull(password);
-        set(MONGO_USER_PASSWORD, password);
+    public Authorizations getAuthorizations() {
+        final String[] auths = getAuths();
+        if (auths == null || auths.length == 0) {
+            return MongoDbRdfConstants.ALL_AUTHORIZATIONS;
+        }
+        return new Authorizations(auths);
     }
 
     /**
-     * @return Mongo password
+     * Indicates whether each statement added to the batch writer should be flushed and written
+     * right away to the datastore or not. If this is turned off, then the statements will be
+     * queued and written to the datastore when the queue is full or after enough time has
+     * passed without a write.
+     *
+     * @return {@code true} if flushing after each updated is enabled; otherwise {@code false}. (default: true)
      */
-    public String getMongoPassword() {
-        return get(MONGO_USER_PASSWORD);
-    }
-
-    public void setAdditionalIndexers(final Class<? extends MongoSecondaryIndex>... indexers) {
-        final List<String> strs = Lists.newArrayList();
-        for (final Class<?> ai : indexers){
-            strs.add(ai.getName());
-        }
-
-        setStrings(CONF_ADDITIONAL_INDEXERS, strs.toArray(new String[]{}));
-    }
-
-    public List<MongoSecondaryIndex> getAdditionalIndexers() {
-        return getInstances(CONF_ADDITIONAL_INDEXERS, MongoSecondaryIndex.class);
-    }
-
-    public void setMongoClient(final MongoClient client) {
-        Preconditions.checkNotNull(client);
-        this.mongoClient = client;
+    public boolean flushEachUpdate(){
+        return getBoolean(CONF_FLUSH_EACH_UPDATE, true);
     }
 
-    public MongoClient getMongoClient() {
-        return mongoClient;
+    /**
+     * Set whether each statement added to the batch writer should be flushed and written
+     * right away to the datastore or not. If this is turned off, then the statements will be
+     * queued and written to the datastore when the queue is full or after enough time has
+     * passed without a write.
+     *
+     * @param flush - {@code true} if flushing after each updated is enabled; otherwise {@code false}.
+     */
+    public void setFlush(final boolean flush){
+        setBoolean(CONF_FLUSH_EACH_UPDATE, flush);
     }
-
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRyaDAO.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRyaDAO.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRyaDAO.java
index d263b9c..01bbee7 100644
--- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRyaDAO.java
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRyaDAO.java
@@ -1,6 +1,4 @@
-package org.apache.rya.mongodb;
-
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -18,10 +16,11 @@ package org.apache.rya.mongodb;
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.rya.mongodb;
 
+import static java.util.Objects.requireNonNull;
 
 import java.io.IOException;
-import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -57,13 +56,13 @@ import com.mongodb.MongoClient;
 /**
  * Default DAO for mongo backed RYA allowing for CRUD operations.
  */
-public final class MongoDBRyaDAO implements RyaDAO<MongoDBRdfConfiguration>{
+public final class MongoDBRyaDAO implements RyaDAO<StatefulMongoDBRdfConfiguration>{
     private static final Logger log = Logger.getLogger(MongoDBRyaDAO.class);
 
     private boolean isInitialized = false;
     private boolean flushEachUpdate = true;
-    private MongoDBRdfConfiguration conf;
-    private final MongoClient mongoClient;
+    private StatefulMongoDBRdfConfiguration conf;
+    private MongoClient mongoClient;
     private DB db;
     private DBCollection coll;
     private MongoDBQueryEngine queryEngine;
@@ -75,51 +74,24 @@ public final class MongoDBRyaDAO implements RyaDAO<MongoDBRdfConfiguration>{
 
     private MongoDbBatchWriter<DBObject> mongoDbBatchWriter;
 
-    /**
-     * Creates a new instance of {@link MongoDBRyaDAO}.
-     * @param conf the {@link MongoDBRdfConfiguration}.
-     * @throws RyaDAOException
-     */
-    public MongoDBRyaDAO(final MongoDBRdfConfiguration conf) throws RyaDAOException, NumberFormatException, UnknownHostException {
-        this(conf, MongoConnectorFactory.getMongoClient(conf));
-    }
-
-    /**
-     * Creates a new instance of {@link MongoDBRyaDAO}.
-     * @param conf the {@link MongoDBRdfConfiguration}.
-     * @param mongoClient the {@link MongoClient}.
-     * @throws RyaDAOException
-     */
-    public MongoDBRyaDAO(final MongoDBRdfConfiguration conf, final MongoClient mongoClient) throws RyaDAOException {
-        this.conf = conf;
-        this.mongoClient = mongoClient;
-        conf.setMongoClient(mongoClient);
-        auths = conf.getAuthorizations();
-        flushEachUpdate = conf.flushEachUpdate();
-        init();
-    }
-
     @Override
-    public void setConf(final MongoDBRdfConfiguration conf) {
-        this.conf = conf;
+    public void setConf(final StatefulMongoDBRdfConfiguration conf) {
+        this.conf = requireNonNull(conf);
+        mongoClient = this.conf.getMongoClient();
         auths = conf.getAuthorizations();
-    }
-
-    public MongoClient getMongoClient(){
-        return mongoClient;
+        flushEachUpdate = conf.flushEachUpdate();
     }
 
     public void setDB(final DB db) {
         this.db = db;
     }
 
-
     public void setDBCollection(final DBCollection coll) {
         this.coll = coll;
     }
 
     @Override
-    public MongoDBRdfConfiguration getConf() {
+    public StatefulMongoDBRdfConfiguration getConf() {
         return conf;
     }
 
@@ -131,13 +103,14 @@ public final class MongoDBRyaDAO implements RyaDAO<MongoDBRdfConfiguration>{
         secondaryIndexers = conf.getAdditionalIndexers();
         for(final MongoSecondaryIndex index: secondaryIndexers) {
             index.setConf(conf);
-            index.setClient(mongoClient);
+            index.setClient(conf.getMongoClient());
         }
 
         db = mongoClient.getDB(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
         coll = db.getCollection(conf.getTriplesCollectionName());
         nameSpaceManager = new SimpleMongoDBNamespaceManager(db.getCollection(conf.getNameSpacesCollectionName()));
-        queryEngine = new MongoDBQueryEngine(conf, mongoClient);
+        queryEngine = new MongoDBQueryEngine();
+        queryEngine.setConf(conf);
         storageStrategy = new SimpleMongoDBStorageStrategy();
         storageStrategy.createIndices(coll);
         for(final MongoSecondaryIndex index: secondaryIndexers) {
@@ -145,7 +118,7 @@ public final class MongoDBRyaDAO implements RyaDAO<MongoDBRdfConfiguration>{
         }
 
         final MongoDbBatchWriterConfig mongoDbBatchWriterConfig = MongoDbBatchWriterUtils.getMongoDbBatchWriterConfig(conf);
-        mongoDbBatchWriter = new MongoDbBatchWriter<DBObject>(new DbCollectionType(coll), mongoDbBatchWriterConfig);
+        mongoDbBatchWriter = new MongoDbBatchWriter<>(new DbCollectionType(coll), mongoDbBatchWriterConfig);
         try {
             mongoDbBatchWriter.start();
         } catch (final MongoDbBatchWriterException e) {
@@ -217,7 +190,7 @@ public final class MongoDBRyaDAO implements RyaDAO<MongoDBRdfConfiguration>{
 
     @Override
     public void add(final Iterator<RyaStatement> statementIter) throws RyaDAOException {
-        final List<DBObject> dbInserts = new ArrayList<DBObject>();
+        final List<DBObject> dbInserts = new ArrayList<>();
         while (statementIter.hasNext()){
             final RyaStatement ryaStatement = statementIter.next();
             final boolean canAdd = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility());
@@ -247,7 +220,7 @@ public final class MongoDBRyaDAO implements RyaDAO<MongoDBRdfConfiguration>{
     }
 
     @Override
-    public void delete(final RyaStatement statement, final MongoDBRdfConfiguration conf)
+    public void delete(final RyaStatement statement, final StatefulMongoDBRdfConfiguration conf)
             throws RyaDAOException {
         final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, statement.getColumnVisibility());
         if (canDelete) {
@@ -266,14 +239,14 @@ public final class MongoDBRyaDAO implements RyaDAO<MongoDBRdfConfiguration>{
     }
 
     @Override
-    public void dropGraph(final MongoDBRdfConfiguration conf, final RyaURI... graphs)
+    public void dropGraph(final StatefulMongoDBRdfConfiguration conf, final RyaURI... graphs)
             throws RyaDAOException {
 
     }
 
     @Override
     public void delete(final Iterator<RyaStatement> statements,
-            final MongoDBRdfConfiguration conf) throws RyaDAOException {
+            final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException {
         while (statements.hasNext()){
             final RyaStatement ryaStatement = statements.next();
             final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility());
@@ -298,12 +271,12 @@ public final class MongoDBRyaDAO implements RyaDAO<MongoDBRdfConfiguration>{
     }
 
     @Override
-    public RyaQueryEngine<MongoDBRdfConfiguration> getQueryEngine() {
+    public RyaQueryEngine<StatefulMongoDBRdfConfiguration> getQueryEngine() {
         return queryEngine;
     }
 
     @Override
-    public RyaNamespaceManager<MongoDBRdfConfiguration> getNamespaceManager() {
+    public RyaNamespaceManager<StatefulMongoDBRdfConfiguration> getNamespaceManager() {
         return nameSpaceManager;
     }
 
@@ -336,4 +309,4 @@ public final class MongoDBRyaDAO implements RyaDAO<MongoDBRdfConfiguration>{
             }
         }
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/StatefulMongoDBRdfConfiguration.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/StatefulMongoDBRdfConfiguration.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/StatefulMongoDBRdfConfiguration.java
new file mode 100644
index 0000000..1263166
--- /dev/null
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/StatefulMongoDBRdfConfiguration.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rya.mongodb;
+
+import static java.util.Objects.requireNonNull;
+
+import java.util.List;
+
+import org.apache.hadoop.conf.Configuration;
+
+import com.mongodb.MongoClient;
+
+import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
+import edu.umd.cs.findbugs.annotations.NonNull;
+
+/**
+ * A {@link MongoDBRdfConfiguration} that is used to hold onto state that is pass into Rya components that accept
+ * {@link Configuration} objects.
+ * </p>
+ * HACK:
+ * This class is part of a hack to get around how Rya uses reflection to initialize indexers, optimizers, etc.
+ * Those classes have empty constructors, so they are not able to receive Mongo specific components at construction
+ * time. However, they all receive a {@link Configuration} prior to initialization. If an object of this class
+ * is that configuration object, then shared objects may be passed into the constructed components.
+ */
+@DefaultAnnotation(NonNull.class)
+public class StatefulMongoDBRdfConfiguration extends MongoDBRdfConfiguration {
+
+    private final MongoClient mongoClient;
+    private final List<MongoSecondaryIndex> indexers;
+    // TODO optimizers? They're causing problems because they aren't getting this configuration object
+    //      like the indexers do.
+
+    /**
+     * Constructs an instance of {@link StatefulMongoDBRdfConfiguration} pre-loaded with values.
+     *
+     * @param other - The values that will be cloned into the constructed object. (not null)
+     * @param mongoClient - The {@link MongoClient} that Rya will use. (not null)
+     * @param indexers - The {@link MongoSecondaryIndex}s that Rya will use. (not null)
+     */
+    public StatefulMongoDBRdfConfiguration(
+            final Configuration other,
+            final MongoClient mongoClient,
+            final List<MongoSecondaryIndex> indexers) {
+        super(other);
+        this.mongoClient = requireNonNull(mongoClient);
+        this.indexers = requireNonNull(indexers);
+    }
+
+    /**
+     * @return The {@link MongoClient} that Rya will use.
+     */
+    public MongoClient getMongoClient() {
+        return mongoClient;
+    }
+
+    /**
+     * @return The {@link MongoSecondaryIndex}s that Rya will use.
+     */
+    public List<MongoSecondaryIndex> getAdditionalIndexers() {
+        return indexers;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/MongoDBNamespaceManager.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/MongoDBNamespaceManager.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/MongoDBNamespaceManager.java
index 1d86ce4..24d47ee 100644
--- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/MongoDBNamespaceManager.java
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/MongoDBNamespaceManager.java
@@ -1,6 +1,4 @@
-package org.apache.rya.mongodb.dao;
-
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -8,9 +6,9 @@ package org.apache.rya.mongodb.dao;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,18 +16,14 @@ package org.apache.rya.mongodb.dao;
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.rya.mongodb.dao;
 
-
-import org.apache.rya.api.domain.RyaStatement;
 import org.apache.rya.api.persist.RyaNamespaceManager;
-import org.apache.rya.api.persist.query.RyaQuery;
-import org.apache.rya.mongodb.MongoDBRdfConfiguration;
+import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration;
 
 import com.mongodb.DBCollection;
-import com.mongodb.DBObject;
 
-public interface MongoDBNamespaceManager extends RyaNamespaceManager<MongoDBRdfConfiguration>{
+public interface MongoDBNamespaceManager extends RyaNamespaceManager<StatefulMongoDBRdfConfiguration>{
 
 	public void createIndices(DBCollection coll);
-
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
index 6956f49..88fa2b5 100644
--- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
@@ -25,7 +25,7 @@ import java.util.Map;
 
 import org.apache.commons.codec.binary.Hex;
 import org.apache.rya.api.persist.RyaDAOException;
-import org.apache.rya.mongodb.MongoDBRdfConfiguration;
+import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration;
 import org.openrdf.model.Namespace;
 
 import com.mongodb.BasicDBObject;
@@ -109,7 +109,7 @@ public class SimpleMongoDBNamespaceManager implements MongoDBNamespaceManager {
 	private static final String ID = "_id";
 	private static final String PREFIX = "prefix";
 	private static final String NAMESPACE = "namespace";
-	private MongoDBRdfConfiguration conf;
+	private StatefulMongoDBRdfConfiguration conf;
 	private final DBCollection nsColl;
 
 
@@ -123,15 +123,13 @@ public class SimpleMongoDBNamespaceManager implements MongoDBNamespaceManager {
 		coll.createIndex(NAMESPACE);
 	}
 
-
 	@Override
-	public void setConf(final MongoDBRdfConfiguration paramC) {
-		this.conf = paramC;
+	public void setConf(final StatefulMongoDBRdfConfiguration conf) {
+		this.conf = conf;
 	}
 
 	@Override
-	public MongoDBRdfConfiguration getConf() {
-		// TODO Auto-generated method stub
+	public StatefulMongoDBRdfConfiguration getConf() {
 		return conf;
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java
index e068405..a481ccf 100644
--- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java
@@ -19,11 +19,15 @@
 package org.apache.rya.mongodb;
 
 import java.io.IOException;
+import java.net.UnknownHostException;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.mongodb.MongoClient;
+import com.mongodb.MongoException;
+
+import de.flapdoodle.embed.mongo.config.IMongodConfig;
 
 /**
  * To be used for tests. Creates a singleton {@link MongoClient} to be used
@@ -31,8 +35,27 @@ import com.mongodb.MongoClient;
  * embedded mongo factory ends up orphaning processes, consuming resources.
  */
 public class EmbeddedMongoSingleton {
-    public static MongoClient getInstance() {
-        return InstanceHolder.SINGLETON.instance;
+
+    public static MongoClient getNewMongoClient() throws UnknownHostException, MongoException {
+    	final MongoClient client = InstanceHolder.SINGLETON.factory.newMongoClient();
+
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            @Override
+            public void run() {
+                try {
+                    client.close();
+                } catch (final Throwable t) {
+                    // logging frameworks will likely be shut down
+                    t.printStackTrace(System.err);
+                }
+            }
+        });
+
+        return client;
+    }
+
+    public static IMongodConfig getMongodConfig() {
+        return InstanceHolder.SINGLETON.mongodConfig;
     }
 
     private EmbeddedMongoSingleton() {
@@ -44,32 +67,14 @@ public class EmbeddedMongoSingleton {
         SINGLETON;
 
         private final Logger log;
-        private MongoClient instance;
+        private IMongodConfig mongodConfig;
+        private EmbeddedMongoFactory factory;
 
         InstanceHolder() {
             log = LoggerFactory.getLogger(EmbeddedMongoSingleton.class);
-            instance = null;
             try {
-                instance = EmbeddedMongoFactory.newFactory().newMongoClient();
-                // JUnit does not have an overall lifecycle event for tearing down
-                // this kind of resource, but shutdown hooks work alright in practice
-                // since this should only be used during testing
-
-                // The only other alternative for lifecycle management is to use a
-                // suite lifecycle to enclose the tests that need this resource.
-                // In practice this becomes unwieldy.
-                Runtime.getRuntime().addShutdownHook(new Thread() {
-                    @Override
-                    public void run() {
-                        try {
-                            instance.close();
-                        } catch (final Throwable t) {
-                            // logging frameworks will likely be shut down
-                            t.printStackTrace(System.err);
-                        }
-                    }
-                });
-
+            	factory = EmbeddedMongoFactory.newFactory();
+                mongodConfig = factory.getMongoServerDetails();
             } catch (final IOException e) {
                 log.error("Unexpected error while starting mongo client", e);
             } catch (final Throwable e) {
@@ -79,4 +84,4 @@ public class EmbeddedMongoSingleton {
             }
         }
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java
index a8f2d88..f7235a6 100644
--- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java
@@ -1,5 +1,25 @@
+/*
+* * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.rya.mongodb;
 
+import static org.junit.Assert.assertEquals;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -27,38 +47,18 @@ import org.apache.rya.api.RdfCloudTripleStoreUtils;
 import org.apache.rya.api.domain.RyaStatement;
 import org.apache.rya.api.domain.RyaStatement.RyaStatementBuilder;
 import org.apache.rya.api.domain.RyaURI;
-import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 import org.openrdf.model.impl.URIImpl;
 import org.openrdf.query.BindingSet;
 import org.openrdf.query.impl.MapBindingSet;
 
 import com.google.common.collect.Lists;
-import com.mongodb.MongoClient;
 
 import info.aduna.iteration.CloseableIteration;
-
+/**
+ * Integration tests the methods of {@link MongoDBQueryEngine}.
+ */
 public class MongoDBQueryEngineTest extends MongoTestBase {
-    private MongoClient client;
-    private MongoDBRyaDAO dao;
-
-    private MongoDBQueryEngine engine;
-
-    private static final String DB_NAME = "testInstance";
-
-    @Before
-    public void setUp() throws Exception {
-        client = super.getMongoClient();
-        conf.setAuths("A", "B", "C");
-
-        engine = new MongoDBQueryEngine(conf, client);
-
-        // Add Data
-        final MongoDBRyaDAO dao = new MongoDBRyaDAO(conf, client);
-        dao.add(getStatement("u:a", "u:tt", "u:b"));
-        dao.add(getStatement("u:a", "u:tt", "u:c"));
-    }
 
     private RyaStatement getStatement(final String s, final String p, final String o) {
         final RyaStatementBuilder builder = new RyaStatementBuilder();
@@ -85,59 +85,101 @@ public class MongoDBQueryEngineTest extends MongoTestBase {
 
     @Test
     public void statementQuery() throws Exception {
-        final RyaStatement s = getStatement("u:a", null, null);
-        Assert.assertEquals(2, size(engine.query(s, conf)));
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try(final MongoDBQueryEngine engine =new MongoDBQueryEngine()) {
+            engine.setConf(conf);
+
+            // Add data.
+            dao.setConf(conf);
+            dao.init();
+            dao.add(getStatement("u:a", "u:tt", "u:b"));
+            dao.add(getStatement("u:a", "u:tt", "u:c"));
+
+            final RyaStatement s = getStatement("u:a", null, null);
+            assertEquals(2, size(engine.query(s, conf)));
+        } finally {
+            dao.destroy();
+        }
     }
 
     @SuppressWarnings("unchecked")
     @Test
     public void batchbindingSetsQuery() throws Exception {
-        final RyaStatement s1 = getStatement(null, null, "u:b");
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try(final MongoDBQueryEngine engine =new MongoDBQueryEngine()) {
+            engine.setConf(conf);
 
-        final MapBindingSet bs1 = new MapBindingSet();
-        bs1.addBinding("foo", new URIImpl("u:x"));
+            // Add data.
+            dao.setConf(conf);
+            dao.init();
+            dao.add(getStatement("u:a", "u:tt", "u:b"));
+            dao.add(getStatement("u:a", "u:tt", "u:c"));
 
-        final Map.Entry<RyaStatement, BindingSet> e1 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s1, bs1);
-        final Collection<Entry<RyaStatement, BindingSet>> stmts1 = Lists.newArrayList(e1);
-        Assert.assertEquals(1, size(engine.queryWithBindingSet(stmts1, conf)));
+            // Run the test.
+            final RyaStatement s1 = getStatement(null, null, "u:b");
 
+            final MapBindingSet bs1 = new MapBindingSet();
+            bs1.addBinding("foo", new URIImpl("u:x"));
 
-        final MapBindingSet bs2 = new MapBindingSet();
-        bs2.addBinding("foo", new URIImpl("u:y"));
+            final Map.Entry<RyaStatement, BindingSet> e1 = new RdfCloudTripleStoreUtils.CustomEntry<>(s1, bs1);
+            final Collection<Entry<RyaStatement, BindingSet>> stmts1 = Lists.newArrayList(e1);
+            assertEquals(1, size(engine.queryWithBindingSet(stmts1, conf)));
 
-        final RyaStatement s2 = getStatement(null, null, "u:c");
 
-        final Map.Entry<RyaStatement, BindingSet> e2 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s2, bs2);
+            final MapBindingSet bs2 = new MapBindingSet();
+            bs2.addBinding("foo", new URIImpl("u:y"));
 
-        final Collection<Entry<RyaStatement, BindingSet>> stmts2 = Lists.newArrayList(e1, e2);
-        Assert.assertEquals(2, size(engine.queryWithBindingSet(stmts2, conf)));
+            final RyaStatement s2 = getStatement(null, null, "u:c");
 
+            final Map.Entry<RyaStatement, BindingSet> e2 = new RdfCloudTripleStoreUtils.CustomEntry<>(s2, bs2);
 
-        final Map.Entry<RyaStatement, BindingSet> e3 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s2, bs1);
-        final Map.Entry<RyaStatement, BindingSet> e4 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s1, bs2);
+            final Collection<Entry<RyaStatement, BindingSet>> stmts2 = Lists.newArrayList(e1, e2);
+            assertEquals(2, size(engine.queryWithBindingSet(stmts2, conf)));
+
+
+            final Map.Entry<RyaStatement, BindingSet> e3 = new RdfCloudTripleStoreUtils.CustomEntry<>(s2, bs1);
+            final Map.Entry<RyaStatement, BindingSet> e4 = new RdfCloudTripleStoreUtils.CustomEntry<>(s1, bs2);
+
+            final Collection<Entry<RyaStatement, BindingSet>> stmts3 = Lists.newArrayList(e1, e2, e3, e4);
+            assertEquals(4, size(engine.queryWithBindingSet(stmts3, conf)));
+        } finally {
+            dao.destroy();
+        }
+    }
 
-        final Collection<Entry<RyaStatement, BindingSet>> stmts3 = Lists.newArrayList(e1, e2, e3, e4);
-        Assert.assertEquals(4, size(engine.queryWithBindingSet(stmts3, conf)));
-}
     @SuppressWarnings("unchecked")
     @Test
     public void bindingSetsQuery() throws Exception {
-        final RyaStatement s = getStatement("u:a", null, null);
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try(final MongoDBQueryEngine engine =new MongoDBQueryEngine()) {
+            engine.setConf(conf);
 
-        final MapBindingSet bs1 = new MapBindingSet();
-        bs1.addBinding("foo", new URIImpl("u:x"));
+            // Add data.
+            dao.setConf(conf);
+            dao.init();
+            dao.add(getStatement("u:a", "u:tt", "u:b"));
+            dao.add(getStatement("u:a", "u:tt", "u:c"));
 
-        final Map.Entry<RyaStatement, BindingSet> e1 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s, bs1);
-        final Collection<Entry<RyaStatement, BindingSet>> stmts1 = Lists.newArrayList(e1);
-        Assert.assertEquals(2, size(engine.queryWithBindingSet(stmts1, conf)));
+            // Run the test.
+            final RyaStatement s = getStatement("u:a", null, null);
 
+            final MapBindingSet bs1 = new MapBindingSet();
+            bs1.addBinding("foo", new URIImpl("u:x"));
 
-        final MapBindingSet bs2 = new MapBindingSet();
-        bs2.addBinding("foo", new URIImpl("u:y"));
+            final Map.Entry<RyaStatement, BindingSet> e1 = new RdfCloudTripleStoreUtils.CustomEntry<>(s, bs1);
+            final Collection<Entry<RyaStatement, BindingSet>> stmts1 = Lists.newArrayList(e1);
+            assertEquals(2, size(engine.queryWithBindingSet(stmts1, conf)));
 
-        final Map.Entry<RyaStatement, BindingSet> e2 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s, bs2);
 
-        final Collection<Entry<RyaStatement, BindingSet>> stmts2 = Lists.newArrayList(e1, e2);
-        Assert.assertEquals(4, size(engine.queryWithBindingSet(stmts2, conf)));
-}
-}
+            final MapBindingSet bs2 = new MapBindingSet();
+            bs2.addBinding("foo", new URIImpl("u:y"));
+
+            final Map.Entry<RyaStatement, BindingSet> e2 = new RdfCloudTripleStoreUtils.CustomEntry<>(s, bs2);
+
+            final Collection<Entry<RyaStatement, BindingSet>> stmts2 = Lists.newArrayList(e1, e2);
+            assertEquals(4, size(engine.queryWithBindingSet(stmts2, conf)));
+        } finally {
+            dao.destroy();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRdfConfigurationTest.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRdfConfigurationTest.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRdfConfigurationTest.java
index c047fde..2d28bb5 100644
--- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRdfConfigurationTest.java
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRdfConfigurationTest.java
@@ -33,16 +33,16 @@ public class MongoDBRdfConfigurationTest {
 
     @Test
     public void testBuilder() {
-        String prefix = "prefix_";
-        String auth = "U,V,W";
-        String visibility = "U,W";
-        String user = "user";
-        String password = "password";
-        boolean useMock = true;
-        boolean useInference = true;
-        boolean displayPlan = false;
+        final String prefix = "prefix_";
+        final String auth = "U,V,W";
+        final String visibility = "U,W";
+        final String user = "user";
+        final String password = "password";
+        final boolean useMock = true;
+        final boolean useInference = true;
+        final boolean displayPlan = false;
 
-        MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration().getBuilder()
+        final MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration().getBuilder()
                 .setVisibilities(visibility)
                 .setUseInference(useInference)
                 .setDisplayQueryPlan(displayPlan)
@@ -60,11 +60,11 @@ public class MongoDBRdfConfigurationTest {
         assertEquals(conf.getCv(), visibility);
         assertEquals(conf.isInfer(), useInference);
         assertEquals(conf.isDisplayQueryPlan(), displayPlan);
-        assertEquals(conf.getMongoInstance(), "host");
+        assertEquals(conf.getMongoHostname(), "host");
         assertEquals(conf.getBoolean(".useMockInstance", false), useMock);
         assertEquals(conf.getMongoPort(), "1000");
         assertEquals(conf.getMongoDBName(), "dbname");
-        assertEquals(conf.getCollectionName(), "prefix_");
+        assertEquals(conf.getRyaInstance(), "prefix_");
         assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER), user);
         assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER_PASSWORD), password);
 
@@ -72,32 +72,31 @@ public class MongoDBRdfConfigurationTest {
 
     @Test
     public void testBuilderFromProperties() throws FileNotFoundException, IOException {
-        String prefix = "prefix_";
-        String auth = "U";
-        String visibility = "U";
-        String user = "user";
-        String password = "password";
-        boolean useMock = true;
-        boolean useInference = true;
-        boolean displayPlan = false;
+        final String prefix = "prefix_";
+        final String auth = "U";
+        final String visibility = "U";
+        final String user = "user";
+        final String password = "password";
+        final boolean useMock = true;
+        final boolean useInference = true;
+        final boolean displayPlan = false;
 
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.load(new FileInputStream("src/test/resources/rya.properties"));
 
-        MongoDBRdfConfiguration conf = MongoDBRdfConfiguration.fromProperties(props);
+        final MongoDBRdfConfiguration conf = MongoDBRdfConfiguration.fromProperties(props);
 
         assertEquals(conf.getTablePrefix(), prefix);
         assertTrue(Arrays.equals(conf.getAuths(), new String[] { auth }));
         assertEquals(conf.getCv(), visibility);
         assertEquals(conf.isInfer(), useInference);
         assertEquals(conf.isDisplayQueryPlan(), displayPlan);
-        assertEquals(conf.getMongoInstance(), "host");
+        assertEquals(conf.getMongoHostname(), "host");
         assertEquals(conf.getBoolean(".useMockInstance", false), useMock);
         assertEquals(conf.getMongoPort(), "1000");
         assertEquals(conf.getMongoDBName(), "dbname");
-        assertEquals(conf.getCollectionName(), "prefix_");
+        assertEquals(conf.getRyaInstance(), "prefix_");
         assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER), user);
         assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER_PASSWORD), password);
     }
-
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java
index 68bbc27..afd7308 100644
--- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java
@@ -18,6 +18,8 @@
  */
 package org.apache.rya.mongodb;
 
+import static org.junit.Assert.assertEquals;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -33,20 +35,16 @@ import org.apache.rya.mongodb.batch.collection.MongoCollectionType;
 import org.apache.rya.mongodb.dao.MongoDBStorageStrategy;
 import org.apache.rya.mongodb.dao.SimpleMongoDBStorageStrategy;
 import org.bson.Document;
-import org.junit.Assert;
-import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 import com.google.common.collect.Lists;
 import com.mongodb.DBObject;
-import com.mongodb.MongoClient;
 
 /**
  * Integration tests for the {@link MongoDbBatchWriter}.
  */
 public class MongoDBRyaBatchWriterIT extends MongoTestBase {
-    private MongoDBRyaDAO dao;
 
     private static void setupLogging() {
         BasicConfigurator.configure();
@@ -57,14 +55,11 @@ public class MongoDBRyaBatchWriterIT extends MongoTestBase {
         setupLogging();
     }
 
-    @Before
-    public void setUp() throws Exception {
+    @Override
+    protected void updateConfiguration(final MongoDBRdfConfiguration conf) {
         conf.setBoolean("rya.mongodb.dao.flusheachupdate", false);
         conf.setInt("rya.mongodb.dao.batchwriter.size", 50_000);
         conf.setLong("rya.mongodb.dao.batchwriter.flushtime", 100L);
-
-        final MongoClient client = super.getMongoClient();
-        dao = new MongoDBRyaDAO(conf, client);
     }
 
     @Test
@@ -81,11 +76,18 @@ public class MongoDBRyaBatchWriterIT extends MongoTestBase {
         statements.add(statement(1));
         statements.add(statement(6));
 
-        dao.add(statements.iterator());
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try {
+            dao.setConf(conf);
+            dao.init();
 
-        dao.flush();
+            dao.add(statements.iterator());
+            dao.flush();
 
-        Assert.assertEquals(6, getRyaCollection().count());
+            assertEquals(6, getRyaCollection().count());
+        } finally {
+            dao.destroy();
+        }
     }
 
     @Test
@@ -104,7 +106,7 @@ public class MongoDBRyaBatchWriterIT extends MongoTestBase {
 
         final DbCollectionType collectionType = new DbCollectionType(getRyaDbCollection());
         final MongoDbBatchWriterConfig mongoDbBatchWriterConfig = MongoDbBatchWriterUtils.getMongoDbBatchWriterConfig(conf);
-        final MongoDbBatchWriter<DBObject> mongoDbBatchWriter = new MongoDbBatchWriter<DBObject>(collectionType, mongoDbBatchWriterConfig);
+        final MongoDbBatchWriter<DBObject> mongoDbBatchWriter = new MongoDbBatchWriter<>(collectionType, mongoDbBatchWriterConfig);
 
         mongoDbBatchWriter.start();
         mongoDbBatchWriter.addObjectsToQueue(objects);
@@ -114,7 +116,7 @@ public class MongoDBRyaBatchWriterIT extends MongoTestBase {
         mongoDbBatchWriter.flush();
         Thread.sleep(1_000);
         mongoDbBatchWriter.shutdown();
-        Assert.assertEquals(4, getRyaDbCollection().count());
+        assertEquals(4, getRyaDbCollection().count());
     }
 
     @Test
@@ -133,7 +135,7 @@ public class MongoDBRyaBatchWriterIT extends MongoTestBase {
 
         final MongoCollectionType mongoCollectionType = new MongoCollectionType(getRyaCollection());
         final MongoDbBatchWriterConfig mongoDbBatchWriterConfig = MongoDbBatchWriterUtils.getMongoDbBatchWriterConfig(conf);
-        final MongoDbBatchWriter<Document> mongoDbBatchWriter = new MongoDbBatchWriter<Document>(mongoCollectionType, mongoDbBatchWriterConfig);
+        final MongoDbBatchWriter<Document> mongoDbBatchWriter = new MongoDbBatchWriter<>(mongoCollectionType, mongoDbBatchWriterConfig);
 
         mongoDbBatchWriter.start();
         mongoDbBatchWriter.addObjectsToQueue(documents);
@@ -143,7 +145,7 @@ public class MongoDBRyaBatchWriterIT extends MongoTestBase {
         mongoDbBatchWriter.flush();
         Thread.sleep(1_000);
         mongoDbBatchWriter.shutdown();
-        Assert.assertEquals(4, getRyaCollection().count());
+        assertEquals(4, getRyaCollection().count());
     }
 
     private static Document toDocument(final DBObject dbObject) {