[ 
https://issues.apache.org/jira/browse/RYA-414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16308749#comment-16308749
 ] 

ASF GitHub Bot commented on RYA-414:
------------------------------------

Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/256#discussion_r159311393
  
    --- Diff: 
dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java ---
    @@ -33,27 +34,43 @@
      */
     public class MongoTestBase {
     
    -    private static MongoClient mongoClient = null;
    -    protected static MongoDBRdfConfiguration conf;
    +    private MongoClient mongoClient = null;
    +    protected StatefulMongoDBRdfConfiguration conf;
     
         @Before
         public void setupTest() throws Exception {
    -        conf = new MongoDBRdfConfiguration( new Configuration() );
    +        // Setup the configuration that will be used within the test.
    +        final MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration( 
new Configuration() );
             conf.setBoolean("sc.useMongo", true);
             conf.setTablePrefix("test_");
             conf.setMongoDBName("testDB");
    -        mongoClient = EmbeddedMongoSingleton.getInstance();
    -        conf.setMongoClient(mongoClient);
    -    }
    +        
conf.setMongoHostname(EmbeddedMongoSingleton.getMongodConfig().net().getServerAddress().getHostAddress());
    +        
conf.setMongoPort(Integer.toString(EmbeddedMongoSingleton.getMongodConfig().net().getPort()));
    +
    +        // Let tests update the configuration.
    +        updateConfiguration(conf);
    +
    +        // Create the stateful configuration object.
    +        mongoClient = EmbeddedMongoSingleton.getNewMongoClient();
    +        final List<MongoSecondaryIndex> indexers = 
conf.getInstances("ac.additional.indexers", MongoSecondaryIndex.class);
    +        this.conf = new StatefulMongoDBRdfConfiguration(conf, mongoClient, 
indexers);
     
    -    @After
    -    public void cleanupTest() {
    -        // Remove any DBs that were created by the test.
    +        // Remove any DBs that were created by previous tests.
             for(final String dbName : mongoClient.listDatabaseNames()) {
                 mongoClient.dropDatabase(dbName);
             }
         }
     
    +    /**
    +     * Override this method if you would like to augment the configuration 
object that
    +     * will be used to initialize indexers and create the mongo client 
prior to running a test.
    +     *
    +     * @param conf - The configuration object that may be updated. (not 
null)
    +     */
    +    protected void updateConfiguration(final MongoDBRdfConfiguration conf) 
{
    --- End diff --
    
    Do any classes not override this? (I haven't looked to verify)  If most or 
all classes end up overriding this then this should be changed to an abstract 
method in an abstract class.


> Fix inconsistent method of using MongoClient within a Sail object
> -----------------------------------------------------------------
>
>                 Key: RYA-414
>                 URL: https://issues.apache.org/jira/browse/RYA-414
>             Project: Rya
>          Issue Type: Bug
>            Reporter: Andrew Smith
>            Assignee: Kevin Chilton
>            Priority: Blocker
>
> We've decided to introduce a stateful configuration object that is used to 
> hold onto objects that needs to be shared across components within a Sail 
> object in favor of having a static holder. The static holder limited our 
> ability to use more than a single Sail object within a single JVM because all 
> of those Sail objects would all have to access the same Mongo DB repository.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to