You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by Ryan McKinley <ry...@gmail.com> on 2008/12/18 19:05:05 UTC

getDirectoryFactory() initalized after it is used!

I'm messing with the tests for SOLR-680.  For some reason, the test  
for ChacheHeaderTest and NoCacheHeaderTest fail.

When I dig into it, it looks like it fails because the  
DirectoryFactory returns null.  If I add some code to make sure the  
directory is not null, then everything works fine.

Obviously it works somehow, because the tests work.  But I don't  
understand it and am not sure why we keep using the deprecated calls:

SolrCore#initIndex()
{
   if(  index exist ) {
     directory = SolrIndexWriter.getDirectory(getIndexDir(),...
   }
   stuff

  THEN:
  initDirectoryFactory();
}

1. Why are we using the deprecated calls?
2. Why isn't the directory factory initialized first?


Here is where things fail:
	at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:363)
	at org.apache.solr.core.SolrCore.<init>(SolrCore.java:527)
	at org.apache.solr.core.CoreContainer 
$Initializer.initialize(CoreContainer.java:120)
	at  
org 
.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:69)


Index: src/java/org/apache/solr/core/SolrCore.java
===================================================================
--- src/java/org/apache/solr/core/SolrCore.java (revision 727778)
+++ src/java/org/apache/solr/core/SolrCore.java (working copy)
@@ -358,9 +358,17 @@
        boolean firstTime = dirs.add(dirFile.getCanonicalPath());
        boolean removeLocks = solrConfig.getBool("mainIndex/ 
unlockOnStartup", false);
        if (indexExists && firstTime && removeLocks) {
+        DirectoryFactory f = getDirectoryFactory();
+        if( f == null ) {
+          Throwable t = new Throwable();
+          t.printStackTrace();
+
+          initDirectoryFactory();
+          f = getDirectoryFactory();
+        }
          // to remove locks, the directory must already exist... so  
we create it
          // if it didn't exist already...
-        Directory dir = SolrIndexWriter.getDirectory(getIndexDir(),  
getDirectoryFactory(), solrConfig.mainIndexConfig);
+        Directory dir = SolrIndexWriter.getDirectory(getIndexDir(),  
f, solrConfig.mainIndexConfig);
          if (dir != null)  {
            if (IndexWriter.isLocked(dir)) {
              log.warn(logid+"WARNING: Solr index directory '" +  
getIndexDir() + "' is locked.  Unlocking...");


Re: getDirectoryFactory() initalized after it is used!

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
I just committed a fix 5 minutes ago :)

Sorry my bad.

On Thu, Dec 18, 2008 at 11:35 PM, Ryan McKinley <ry...@gmail.com> wrote:

> I'm messing with the tests for SOLR-680.  For some reason, the test for
> ChacheHeaderTest and NoCacheHeaderTest fail.
>
> When I dig into it, it looks like it fails because the DirectoryFactory
> returns null.  If I add some code to make sure the directory is not null,
> then everything works fine.
>
> Obviously it works somehow, because the tests work.  But I don't understand
> it and am not sure why we keep using the deprecated calls:
>
> SolrCore#initIndex()
> {
>  if(  index exist ) {
>    directory = SolrIndexWriter.getDirectory(getIndexDir(),...
>  }
>  stuff
>
>  THEN:
>  initDirectoryFactory();
> }
>
> 1. Why are we using the deprecated calls?
> 2. Why isn't the directory factory initialized first?
>
>
> Here is where things fail:
>        at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:363)
>        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:527)
>        at
> org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:120)
>        at
> org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:69)
>
>
> Index: src/java/org/apache/solr/core/SolrCore.java
> ===================================================================
> --- src/java/org/apache/solr/core/SolrCore.java (revision 727778)
> +++ src/java/org/apache/solr/core/SolrCore.java (working copy)
> @@ -358,9 +358,17 @@
>       boolean firstTime = dirs.add(dirFile.getCanonicalPath());
>       boolean removeLocks = solrConfig.getBool("mainIndex/unlockOnStartup",
> false);
>       if (indexExists && firstTime && removeLocks) {
> +        DirectoryFactory f = getDirectoryFactory();
> +        if( f == null ) {
> +          Throwable t = new Throwable();
> +          t.printStackTrace();
> +
> +          initDirectoryFactory();
> +          f = getDirectoryFactory();
> +        }
>         // to remove locks, the directory must already exist... so we
> create it
>         // if it didn't exist already...
> -        Directory dir = SolrIndexWriter.getDirectory(getIndexDir(),
> getDirectoryFactory(), solrConfig.mainIndexConfig);
> +        Directory dir = SolrIndexWriter.getDirectory(getIndexDir(), f,
> solrConfig.mainIndexConfig);
>         if (dir != null)  {
>           if (IndexWriter.isLocked(dir)) {
>             log.warn(logid+"WARNING: Solr index directory '" +
> getIndexDir() + "' is locked.  Unlocking...");
>
>


-- 
Regards,
Shalin Shekhar Mangar.

Re: getDirectoryFactory() initalized after it is used!

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
The call I see in trunk is:
Directory dir = SolrIndexWriter.getDirectory(getIndexDir(),
getDirectoryFactory(), solrConfig.mainIndexConfig);

Whee is the deprecated call you are seeing?

On Thu, Dec 18, 2008 at 11:37 PM, Ryan McKinley <ry...@gmail.com> wrote:

> just saw:
>  http://svn.apache.org/viewvc?rev=727779&view=rev
>
> answers one question... but I still wonder why we are using the deprecated
> call?
>
>
>
> On Dec 18, 2008, at 1:05 PM, Ryan McKinley wrote:
>
>  I'm messing with the tests for SOLR-680.  For some reason, the test for
>> ChacheHeaderTest and NoCacheHeaderTest fail.
>>
>> When I dig into it, it looks like it fails because the DirectoryFactory
>> returns null.  If I add some code to make sure the directory is not null,
>> then everything works fine.
>>
>> Obviously it works somehow, because the tests work.  But I don't
>> understand it and am not sure why we keep using the deprecated calls:
>>
>> SolrCore#initIndex()
>> {
>>  if(  index exist ) {
>>    directory = SolrIndexWriter.getDirectory(getIndexDir(),...
>>  }
>>  stuff
>>
>>  THEN:
>>  initDirectoryFactory();
>> }
>>
>> 1. Why are we using the deprecated calls?
>> 2. Why isn't the directory factory initialized first?
>>
>>
>> Here is where things fail:
>>        at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:363)
>>        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:527)
>>        at
>> org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:120)
>>        at
>> org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:69)
>>
>>
>> Index: src/java/org/apache/solr/core/SolrCore.java
>> ===================================================================
>> --- src/java/org/apache/solr/core/SolrCore.java (revision 727778)
>> +++ src/java/org/apache/solr/core/SolrCore.java (working copy)
>> @@ -358,9 +358,17 @@
>>       boolean firstTime = dirs.add(dirFile.getCanonicalPath());
>>       boolean removeLocks =
>> solrConfig.getBool("mainIndex/unlockOnStartup", false);
>>       if (indexExists && firstTime && removeLocks) {
>> +        DirectoryFactory f = getDirectoryFactory();
>> +        if( f == null ) {
>> +          Throwable t = new Throwable();
>> +          t.printStackTrace();
>> +
>> +          initDirectoryFactory();
>> +          f = getDirectoryFactory();
>> +        }
>>         // to remove locks, the directory must already exist... so we
>> create it
>>         // if it didn't exist already...
>> -        Directory dir = SolrIndexWriter.getDirectory(getIndexDir(),
>> getDirectoryFactory(), solrConfig.mainIndexConfig);
>> +        Directory dir = SolrIndexWriter.getDirectory(getIndexDir(), f,
>> solrConfig.mainIndexConfig);
>>         if (dir != null)  {
>>           if (IndexWriter.isLocked(dir)) {
>>             log.warn(logid+"WARNING: Solr index directory '" +
>> getIndexDir() + "' is locked.  Unlocking...");
>>
>>
>


-- 
Regards,
Shalin Shekhar Mangar.

Re: getDirectoryFactory() initalized after it is used!

Posted by Ryan McKinley <ry...@gmail.com>.
just saw:
  http://svn.apache.org/viewvc?rev=727779&view=rev

answers one question... but I still wonder why we are using the  
deprecated call?


On Dec 18, 2008, at 1:05 PM, Ryan McKinley wrote:

> I'm messing with the tests for SOLR-680.  For some reason, the test  
> for ChacheHeaderTest and NoCacheHeaderTest fail.
>
> When I dig into it, it looks like it fails because the  
> DirectoryFactory returns null.  If I add some code to make sure the  
> directory is not null, then everything works fine.
>
> Obviously it works somehow, because the tests work.  But I don't  
> understand it and am not sure why we keep using the deprecated calls:
>
> SolrCore#initIndex()
> {
>   if(  index exist ) {
>     directory = SolrIndexWriter.getDirectory(getIndexDir(),...
>   }
>   stuff
>
>  THEN:
>  initDirectoryFactory();
> }
>
> 1. Why are we using the deprecated calls?
> 2. Why isn't the directory factory initialized first?
>
>
> Here is where things fail:
> 	at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:363)
> 	at org.apache.solr.core.SolrCore.<init>(SolrCore.java:527)
> 	at org.apache.solr.core.CoreContainer 
> $Initializer.initialize(CoreContainer.java:120)
> 	at  
> org 
> .apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java: 
> 69)
>
>
> Index: src/java/org/apache/solr/core/SolrCore.java
> ===================================================================
> --- src/java/org/apache/solr/core/SolrCore.java (revision 727778)
> +++ src/java/org/apache/solr/core/SolrCore.java (working copy)
> @@ -358,9 +358,17 @@
>        boolean firstTime = dirs.add(dirFile.getCanonicalPath());
>        boolean removeLocks = solrConfig.getBool("mainIndex/ 
> unlockOnStartup", false);
>        if (indexExists && firstTime && removeLocks) {
> +        DirectoryFactory f = getDirectoryFactory();
> +        if( f == null ) {
> +          Throwable t = new Throwable();
> +          t.printStackTrace();
> +
> +          initDirectoryFactory();
> +          f = getDirectoryFactory();
> +        }
>          // to remove locks, the directory must already exist... so  
> we create it
>          // if it didn't exist already...
> -        Directory dir = SolrIndexWriter.getDirectory(getIndexDir(),  
> getDirectoryFactory(), solrConfig.mainIndexConfig);
> +        Directory dir = SolrIndexWriter.getDirectory(getIndexDir(),  
> f, solrConfig.mainIndexConfig);
>          if (dir != null)  {
>            if (IndexWriter.isLocked(dir)) {
>              log.warn(logid+"WARNING: Solr index directory '" +  
> getIndexDir() + "' is locked.  Unlocking...");
>