Author: rwesten
Date: Wed Oct 16 05:16:22 2013
New Revision: 1532640
URL: http://svn.apache.org/r1532640
Log:
STANBOL-1176: the 'data/index/write.lock' is now excluded from solrindex
archives
Modified:
stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java
stanbol/trunk/entityhub/indexing/destination/solryard/src/test/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestinationTest.java
Modified:
stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java
URL:
http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java?rev=1532640&r1=1532639&r2=1532640&view=diff
==============================================================================
---
stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java
(original)
+++
stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java
Wed Oct 16 05:16:22 2013
@@ -51,6 +51,7 @@ import org.apache.lucene.search.IndexSea
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.dataimport.SolrWriter;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.util.RefCounted;
@@ -82,6 +83,15 @@ public class SolrYardIndexingDestination
private static final Logger log =
LoggerFactory.getLogger(SolrYardIndexingDestination.class);
/**
+ * The relative path to the Solr 'write.lock' file (relative to the Solr
+ * instance dir). This file is excluded from the
+ * Solr Index archive built by {@link #writeSolrIndexArchive()} (see
+ * <a
href="https://issues.apache.org/jira/browse/STANBOL-1176">STANBOL-1176</a>
+ * for more details).
+ */
+ private static final String SOLR_WRITE_LOCK =
FilenameUtils.separatorsToSystem("data/index/write.lock");
+
+ /**
* Parameter used to refer to the name of the properties file containing
the
* field names as key and the {@link Float} boost factors as values. As
* default no boosts will be used for indexing.
@@ -767,8 +777,8 @@ public class SolrYardIndexingDestination
File solrArchiveFile = new
File(indexingConfig.getDistributionFolder(),solrArchive.getName());
ZipOutputStream out = new ZipOutputStream(new
FileOutputStream(solrArchiveFile));
for(File file :
(Collection<File>)FileUtils.listFiles(solrIndexLocation, null, true)){
- if(!file.isHidden()){
- String name =
file.getAbsolutePath().substring(parentPathLength);
+ String name = file.getAbsolutePath().substring(parentPathLength);
+ if(!file.isHidden() && !name.endsWith(SOLR_WRITE_LOCK)){
log.info("add "+name);
out.putNextEntry(new ZipEntry(name));
if(!file.isDirectory()){
@@ -777,6 +787,8 @@ public class SolrYardIndexingDestination
out.closeEntry();
IOUtils.closeQuietly(fileIn);
}
+ } else {
+ log.info("exclude "+name);
}
}
out.finish();
Modified:
stanbol/trunk/entityhub/indexing/destination/solryard/src/test/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestinationTest.java
URL:
http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/destination/solryard/src/test/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestinationTest.java?rev=1532640&r1=1532639&r2=1532640&view=diff
==============================================================================
---
stanbol/trunk/entityhub/indexing/destination/solryard/src/test/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestinationTest.java
(original)
+++
stanbol/trunk/entityhub/indexing/destination/solryard/src/test/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestinationTest.java
Wed Oct 16 05:16:22 2013
@@ -47,6 +47,7 @@ import org.apache.stanbol.entityhub.serv
import org.apache.stanbol.entityhub.yard.solr.impl.SolrYard;
import org.junit.After;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
@@ -76,6 +77,9 @@ public class SolrYardIndexingDestination
"solrconfig.xml",
"segments.gen");
+ public static final Collection<String> UNEXPECTED_INDEX_ARCHIVE_FILE_NAMES
=
+ Arrays.asList("write.lock"); //excluded with STANBOL1176
+
private static final Logger log =
LoggerFactory.getLogger(SolrYardIndexingDestinationTest.class);
private static final String CONFIG_ROOT = "testConfigs";
/**
@@ -211,9 +215,12 @@ public class SolrYardIndexingDestination
ZipEntry entry = entries.nextElement();
//the name of the index MUST be the root folder within the Archive!
assertTrue(entry.getName().startsWith(config.getName()));
- if(expected.remove(FilenameUtils.getName(entry.getName()))){
+ String name = FilenameUtils.getName(entry.getName());
+ if(expected.remove(name)){
log.info("found expected Entry '{}'",entry.getName());
}
+ Assert.assertFalse("found unexpected Entry '"+entry.getName()+"'
in "
+ + "SolrIndexArchive",
UNEXPECTED_INDEX_ARCHIVE_FILE_NAMES.contains(name));
}
assertTrue("missing Files in index archive:
"+expected,expected.isEmpty());