You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2011/04/07 14:32:24 UTC
svn commit: r1089855 - in
/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr:
./ impl/ impl/install/
Author: rwesten
Date: Thu Apr 7 12:32:23 2011
New Revision: 1089855
URL: http://svn.apache.org/viewvc?rev=1089855&view=rev
Log:
The SolrYard now can uses the DataFileProvider service for initialising new Solr Indexes
Modified:
incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/SolrDirectoryManager.java
incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/ConfigUtils.java
incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/DefaultSolrDirectoryManager.java
incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java
incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java
incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallTask.java
incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallerConstants.java
incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/SolrIndexInstaller.java
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/SolrDirectoryManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/SolrDirectoryManager.java?rev=1089855&r1=1089854&r2=1089855&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/SolrDirectoryManager.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/SolrDirectoryManager.java Thu Apr 7 12:32:23 2011
@@ -23,6 +23,7 @@ import java.util.Map;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.core.CoreContainer;
+import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProvider;
import org.apache.stanbol.entityhub.yard.solr.SolrServerProvider.Type;
import org.apache.stanbol.entityhub.yard.solr.impl.ConfigUtils;
import org.osgi.framework.BundleContext;
@@ -121,7 +122,7 @@ public interface SolrDirectoryManager {
*/
File getSolrDirectory(final String solrIndexName,boolean create) throws IllegalArgumentException;
/**
- *
+ * Creates a new Solr Index based on the data in the provided {@link ArchiveInputStream}
* @param solrIndexName the name of the index to create
* @param ais the stream providing the data for the new index
* @return the directory (instanceDir) of the index.
@@ -129,7 +130,20 @@ public interface SolrDirectoryManager {
* @throws IllegalArgumentException if the parsed solrIndexName is
* <code>null</code> or empty
*/
- File createSolrDirectory(final String solrIndexName, ArchiveInputStream ais) throws IllegalArgumentException, IOException;
+ File createSolrIndex(final String solrIndexName, ArchiveInputStream ais) throws IllegalArgumentException, IOException;
+
+ /**
+ * Creates a new Solr Index based on looking up the Index data via the
+ * {@link DataFileProvider} service
+ * @param solrIndexName The name of the solrIndex to create
+ * @param indexPath the name of the dataFile looked up via the {@link DataFileProvider}
+ * @param comments The comments describing the data on how to get the index
+ * @return the directory (instanceDir) of the index or null if the index
+ * data could not be found
+ * @throws IllegalArgumentException
+ * @throws IOException
+ */
+ File createSolrDirectory(final String solrIndexName, String indexPath,Map<String,String> comments) throws IllegalArgumentException, IOException;
/**
* Getter for the managed Solr Directory.
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/ConfigUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/ConfigUtils.java?rev=1089855&r1=1089854&r2=1089855&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/ConfigUtils.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/ConfigUtils.java Thu Apr 7 12:32:23 2011
@@ -24,15 +24,24 @@ import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.GZIPInputStream;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.stanbol.entityhub.yard.solr.impl.install.IndexInstallerConstants;
import org.osgi.framework.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,6 +59,48 @@ import org.slf4j.LoggerFactory;
*/
public final class ConfigUtils {
private ConfigUtils(){}
+
+ /**
+ * Supported archive types.
+ */
+ public static final Map<String,String> SUPPORTED_SOLR_ARCHIVE_FORMAT;
+ static {
+ Map<String,String> cfm = new HashMap<String,String>();
+ cfm.put("SOLR_INDEX_ARCHIVE_EXTENSION", "zip"); //the default if not specified
+ cfm.put("gz", "gz");
+ cfm.put("bz2", "bz2");
+ cfm.put("zip", "zip");
+ cfm.put("jar", "zip");
+ cfm.put("ref", "properties"); //reference
+ SUPPORTED_SOLR_ARCHIVE_FORMAT = Collections.unmodifiableMap(cfm);
+ }
+
+ public static ArchiveInputStream getArchiveInputStream(String solrArchiveName,InputStream is) throws IOException {
+ String archiveFormat;
+ String solrArchiveExtension = FilenameUtils.getExtension(solrArchiveName);
+ if(solrArchiveExtension == null || solrArchiveExtension.isEmpty()){
+ archiveFormat = solrArchiveName; //assume that the archiveExtension was parsed
+ } else {
+ archiveFormat = SUPPORTED_SOLR_ARCHIVE_FORMAT.get(solrArchiveExtension);
+ }
+ ArchiveInputStream ais;
+ if("zip".equals(archiveFormat)){
+ ais = new ZipArchiveInputStream(is);
+ } else {
+ if ("gz".equals(archiveFormat)) {
+ is = new GZIPInputStream(is);
+ } else if ("bz2".equals(archiveFormat)) {
+ is = new BZip2CompressorInputStream(is);
+ } else {
+ throw new IllegalStateException("Unsupported compression format "+archiveFormat+" " +
+ "(implementation out of sync with Constants defined in "+IndexInstallerConstants.class.getName()+"). " +
+ "Please report this to stanbol-dev mailing list!");
+ }
+ ais = new TarArchiveInputStream(is);
+ }
+ return ais;
+ }
+
/**
* The logger
*/
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/DefaultSolrDirectoryManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/DefaultSolrDirectoryManager.java?rev=1089855&r1=1089854&r2=1089855&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/DefaultSolrDirectoryManager.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/DefaultSolrDirectoryManager.java Thu Apr 7 12:32:23 2011
@@ -18,6 +18,7 @@ package org.apache.stanbol.entityhub.yar
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -30,7 +31,9 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProvider;
import org.apache.stanbol.entityhub.yard.solr.SolrDirectoryManager;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
@@ -51,7 +54,16 @@ import org.slf4j.LoggerFactory;
@Property(name=SolrDirectoryManager.MANAGED_SOLR_DIR_PROPERTY,value=SolrDirectoryManager.DEFAULT_SOLR_DATA_DIR)
})
public class DefaultSolrDirectoryManager implements SolrDirectoryManager {
+ /**
+ * The logger
+ */
private final Logger log = LoggerFactory.getLogger(DefaultSolrDirectoryManager.class);
+
+ /**
+ * The dataFileProvider used to lookup index data
+ */
+ @Reference
+ private DataFileProvider dataFileProvider;
/**
* The directory used by the internally managed embedded solr server.
* Use {@link #lookupManagedSolrDir()} instead of using this member, because
@@ -119,9 +131,22 @@ public class DefaultSolrDirectoryManager
public final File getSolrDirectory(final String solrIndexName,boolean create) throws IllegalArgumentException {
return initSolrDirectory(solrIndexName,null,create,componentContext);
}
- public final File createSolrDirectory(final String solrIndexName, ArchiveInputStream ais){
+ public final File createSolrIndex(final String solrIndexName, ArchiveInputStream ais){
return initSolrDirectory(solrIndexName,ais,true,componentContext);
}
+ @Override
+ public final File createSolrDirectory(String solrIndexName, String indexPath, Map<String,String> comments) throws IllegalArgumentException,IOException {
+ ComponentContext context = componentContext;
+ if(componentContext == null){
+ throw new IllegalStateException("Creating an Index by using the DataFileProvider does only work when running within an OSGI");
+ }
+ //TODO add the comments how to download the index!
+ InputStream is = dataFileProvider.getInputStream(context.getBundleContext().getBundle().getSymbolicName(), indexPath, comments);
+ if(is == null){
+ throw new IllegalStateException("SolrServer arvive "+indexPath+" is currently not available via the "+DataFileProvider.class.getSimpleName()+" service");
+ }
+ return createSolrIndex(solrIndexName,ConfigUtils.getArchiveInputStream(indexPath, is));
+ }
/**
* Internally used to get/init the Solr directory of a SolrCore or the root
* Solr directory (if <code>null</code> is parsed)
@@ -136,8 +161,9 @@ public class DefaultSolrDirectoryManager
* running outside an OSGI container. This is needed to avoid that
* {@link #deactivate(ComponentContext)} sets the context to <code>null</code>
* during this method does its initialisation work.
- * @return the Solr directory or <code>null</code> in case this component is
- * deactivated
+ * @return the Solr directory or <code>null</code> if the requested index
+ * could not be created (e.g. because of <code>false</code> was parsed as
+ * create) orin case this component is deactivated
* @throws IllegalStateException in case this method is called when this
* component is running within an OSGI environment and it is deactivated or
* the initialisation for the parsed index failed.
@@ -156,7 +182,10 @@ public class DefaultSolrDirectoryManager
return managedCoreContainerDirectory;
}
File coreDir = new File(managedCoreContainerDirectory,solrIndexName);
- if(create && !coreDir.exists()){
+ if(!coreDir.exists()){
+ if(!create){ //we are not allowed to create it
+ return null; //return null
+ }
synchronized (initCores) {
log.info(" > start initializing SolrIndex "+solrIndexName);
initCores.add(solrIndexName);
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java?rev=1089855&r1=1089854&r2=1089855&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java Thu Apr 7 12:32:23 2011
@@ -177,6 +177,11 @@ public class SolrYard extends AbstractYa
*/
public static final String SOLR_SERVER_TYPE = "org.apache.stanbol.entityhub.yard.solr.solrServerType";
/**
+ * Key used to to enable/disable the use of the default configuration when
+ * initialising the SolrYard. The default value MUST BE <code>true</code>
+ */
+ public static final String SOLR_INDEX_DEFAULT_CONFIG = "org.apache.stanbol.entityhub.yard.solr.allowDefaultConfig";
+ /**
* The default value for the maxBooleanClauses of SolrQueries. Set to
* {@value #defaultMaxBooleanClauses} the default of Slor 1.4
*/
@@ -339,10 +344,13 @@ public class SolrYard extends AbstractYa
File indexDirectory = ConfigUtils.toFile(config.getSolrServerLocation());
if(!indexDirectory.isAbsolute()){ //relative paths
// need to be resolved based on the internally managed Solr directory
- //TODO: for now parse TRUE to allow automatic creation if the index
- // does not already exist. We might add this as an additional
- // parameter to the SolrIndexConfig
- indexDirectory = solrDirectoryManager.getSolrDirectory(indexDirectory.toString(),true);
+ indexDirectory = solrDirectoryManager.getSolrDirectory(
+ indexDirectory.toString(),config.isDefaultInitialisation());
+ if(indexDirectory == null){
+ throw new ConfigurationException(SolrYard.SOLR_SERVER_LOCATION,
+ "SolrIndex "+config.getSolrServerLocation()+" is not available"+
+ (config.isDefaultInitialisation()?" and could not be initialised!":". The necessary Index is not yet installed."));
+ }
}
solrIndexLocation = indexDirectory.toString();
} else {
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java?rev=1089855&r1=1089854&r2=1089855&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java Thu Apr 7 12:32:23 2011
@@ -21,6 +21,7 @@ import java.util.Map;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.stanbol.entityhub.core.yard.AbstractYard.YardConfig;
+import org.apache.stanbol.entityhub.yard.solr.SolrDirectoryManager;
import org.apache.stanbol.entityhub.yard.solr.SolrServerProvider.Type;
import org.osgi.service.cm.ConfigurationException;
@@ -164,6 +165,44 @@ public final class SolrYardConfig extend
}
}
/**
+ * Getter for the state if this SolrYard can be initialised by using the
+ * default configuration or if it is required to use a provided configuration.
+ * The default is set to <code>true</code>.<p>
+ * If this property is set to <code>false</code> than the SolrYard can only
+ * be initialised if the Index is already available or the initial
+ * configuration is provided to the {@link SolrDirectoryManager}.
+ * @return the state or <code>true</code> as default
+ */
+ public boolean isDefaultInitialisation() {
+ Object value = config.get(SolrYard.SOLR_INDEX_DEFAULT_CONFIG);
+ if(value != null){
+ if(value instanceof Boolean){
+ return (Boolean) value;
+ } else {
+ return Boolean.parseBoolean(value.toString());
+ }
+ } else {
+ return true;
+ }
+ }
+ /**
+ * Setter for the state if this SolrYard can be initialised by using the
+ * default configuration or if it is required to use a provided configuration.
+ * The default is set to <code>true</code>.<p>
+ * If this property is set to <code>false</code> than the SolrYard can only
+ * be initialised if the Index is already available or the initial
+ * configuration is provided to the {@link SolrDirectoryManager}.
+ * @param defaultInitialisationState the state or <code>null</code> to
+ * remove the current configuration. The default state is <code>true</code>.
+ */
+ public void setDefaultInitialisation(Boolean defaultInitialisationState){
+ if(defaultInitialisationState != null){
+ config.put(SolrYard.SOLR_INDEX_DEFAULT_CONFIG, defaultInitialisationState);
+ } else {
+ config.remove(SolrYard.SOLR_INDEX_DEFAULT_CONFIG);
+ }
+ }
+ /**
* Getter for the maximum number of boolean clauses allowed for queries
* @return The configured number of <code>null</code> if not configured or
* the configured value is not an valid Integer.
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallTask.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallTask.java?rev=1089855&r1=1089854&r2=1089855&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallTask.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallTask.java Thu Apr 7 12:32:23 2011
@@ -21,7 +21,11 @@ import static org.apache.stanbol.entityh
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
+import java.util.Map.Entry;
import java.util.zip.GZIPInputStream;
import org.apache.commons.compress.archivers.ArchiveInputStream;
@@ -34,8 +38,13 @@ import org.apache.sling.installer.api.ta
import org.apache.sling.installer.api.tasks.ResourceState;
import org.apache.sling.installer.api.tasks.TaskResourceGroup;
import org.apache.stanbol.entityhub.yard.solr.SolrDirectoryManager;
+import org.apache.stanbol.entityhub.yard.solr.impl.ConfigUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class IndexInstallTask extends InstallTask {
+
+ private static final Logger log = LoggerFactory.getLogger(IndexInstallTask.class);
/**
* use 19 because the config install uses 20 and the files MUST be installed
* before the config triggering the initialisation of the services.
@@ -60,38 +69,47 @@ public class IndexInstallTask extends In
} else { //this index does not exist
String archiveFormat = (String)getResource().getAttribute(PROPERTY_ARCHIVE_FORMAT);
InputStream is = null;
- ArchiveInputStream ais = null;
try {
is = getResource().getInputStream();
- ais = null;
- if("zip".equals(archiveFormat)){
- ais = new ZipArchiveInputStream(is);
+ if("properties".equals(archiveFormat)){
+ Map<String,String> properties = new HashMap<String,String>();
+ InputStreamReader reader = new InputStreamReader(is,"UTF-8");
+ try {
+ Properties props = new Properties();
+ props.load(reader);
+ for(Entry<Object,Object> config : props.entrySet()){
+ properties.put(config.getKey().toString(),config.getValue()!= null?config.getValue().toString():null);
+ }
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ String indexPath = properties.get(PROPERTY_INDEX_ARCHIVE);
+ if(indexPath == null){
+ indexPath = indexName+'.'+IndexInstallerConstants.SOLR_INDEX_ARCHIVE_EXTENSION;
+ log.info("Property \""+PROPERTY_INDEX_ARCHIVE+"\" not present within the SolrIndex references file. Will use the default name \""+indexPath+"\"");
+ }
+ solrDirectoryManager.createSolrDirectory(indexName,indexPath,properties);
+ setFinishedState(ResourceState.INSTALLED);
} else {
- if ("gz".equals(archiveFormat)) {
- is = new GZIPInputStream(is);
- } else if ("bz2".equals(archiveFormat)) {
- is = new BZip2CompressorInputStream(is);
- } else {
- throw new IllegalStateException("Unsupported compression format "+archiveFormat+" " +
- "(implementation out of sync with Constants defined in "+IndexInstallerConstants.class.getName()+"). " +
- "Please report this to stanbol-dev mailing list!");
+ ArchiveInputStream ais = null;
+ try {
+ ais = ConfigUtils.getArchiveInputStream(archiveFormat, is);
+ solrDirectoryManager.createSolrIndex(indexName, ais);
+ //we are done ... set the state to installed!
+ setFinishedState(ResourceState.INSTALLED);
+ } finally {
+ IOUtils.closeQuietly(ais);
}
- ais = new TarArchiveInputStream(is);
}
//now we can copy the core!
- solrDirectoryManager.createSolrDirectory(indexName, ais);
- //we are done ... set the state to installed!
- setFinishedState(ResourceState.INSTALLED);
- }catch (IOException e) {
- ctx.log("Unable to open SolrIndexArchive for index name \"%s\"! (resource=%s, arviceFormat=%s)",
+ }catch (Exception e) {
+ String message = String.format("Unable to install SolrIndexArchive for index name \"%s\"! (resource=%s, arviceFormat=%s)",
indexName,getResource().getURL(),archiveFormat);
+ log.error(message,e);
+ ctx.log("%s! Reason: %s",message,e.getMessage());
setFinishedState(ResourceState.IGNORED);
} finally {
- if(ais != null){ //close the top most stream
- IOUtils.closeQuietly(ais);
- } else if(is != null){
- IOUtils.closeQuietly(is);
- }
+ IOUtils.closeQuietly(is);
}
}
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallerConstants.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallerConstants.java?rev=1089855&r1=1089854&r2=1089855&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallerConstants.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/IndexInstallerConstants.java Thu Apr 7 12:32:23 2011
@@ -29,19 +29,6 @@ public final class IndexInstallerConstan
private IndexInstallerConstants(){ /* do not create instances*/ }
/**
- * Supported archive types.
- */
- public static final Map<String,String> SUPPORTED_COMPRESSION_FORMAT;
- static {
- Map<String,String> cfm = new HashMap<String,String>();
- cfm.put("SOLR_INDEX_ARCHIVE_EXTENSION", "zip"); //the default if not specified
- cfm.put("gz", "gz");
- cfm.put("bz2", "bz2");
- cfm.put("zip", "zip");
- cfm.put("jar", "zip");
- SUPPORTED_COMPRESSION_FORMAT = Collections.unmodifiableMap(cfm);
- }
- /**
* Use <indexName>.solrindex[.<archiveType>] as file name
*/
public static final String SOLR_INDEX_ARCHIVE_EXTENSION = "solrindex";
@@ -61,4 +48,9 @@ public final class IndexInstallerConstan
*/
public static final String PROPERTY_ARCHIVE_FORMAT = PROPERTY_PREFIX+"archive.format";
+ /**
+ * The key used to configure the name of the Index-Archive
+ * The default name is \"<indexName>.solrarchive\".
+ */
+ public static final String PROPERTY_INDEX_ARCHIVE = "Index-Archive";
}
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/SolrIndexInstaller.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/SolrIndexInstaller.java?rev=1089855&r1=1089854&r2=1089855&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/SolrIndexInstaller.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/install/SolrIndexInstaller.java Thu Apr 7 12:32:23 2011
@@ -20,7 +20,7 @@ import static org.apache.stanbol.entityh
import static org.apache.stanbol.entityhub.yard.solr.impl.install.IndexInstallerConstants.PROPERTY_INDEX_NAME;
import static org.apache.stanbol.entityhub.yard.solr.impl.install.IndexInstallerConstants.SOLR_INDEX_ARCHIVE_EXTENSION;
import static org.apache.stanbol.entityhub.yard.solr.impl.install.IndexInstallerConstants.SOLR_INDEX_ARCHIVE_RESOURCE_TYPE;
-import static org.apache.stanbol.entityhub.yard.solr.impl.install.IndexInstallerConstants.SUPPORTED_COMPRESSION_FORMAT;
+import static org.apache.stanbol.entityhub.yard.solr.impl.ConfigUtils.SUPPORTED_SOLR_ARCHIVE_FORMAT;
import java.util.HashMap;
import java.util.Map;
@@ -99,7 +99,7 @@ public class SolrIndexInstaller implemen
*/
@Reference
private SolrDirectoryManager solrDirectoryManager;
-
+
public InstallTask createTask(TaskResourceGroup taskResourceGroup) {
TaskResource toActivate = taskResourceGroup.getActiveResource();
if(SOLR_INDEX_ARCHIVE_RESOURCE_TYPE.equals(toActivate.getType())){
@@ -145,10 +145,10 @@ public class SolrIndexInstaller implemen
return null; // -> can not transform
}
String extension = FilenameUtils.getExtension(filePath);
- String archiveFormat = SUPPORTED_COMPRESSION_FORMAT.get(extension);
+ String archiveFormat = SUPPORTED_SOLR_ARCHIVE_FORMAT.get(extension);
if(archiveFormat == null){
log.error("Unable to process Solr Index Archive from Resource "+registeredResource.getURL()+
- "because of unsupported archive format \""+extension+"\" (supported are "+SUPPORTED_COMPRESSION_FORMAT.keySet()+")");
+ "because of unsupported archive format \""+extension+"\" (supported are "+SUPPORTED_SOLR_ARCHIVE_FORMAT.keySet()+")");
return null;
} else {
properties.put(PROPERTY_ARCHIVE_FORMAT, archiveFormat);