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/07/23 08:26:38 UTC
svn commit: r1150054 - in
/incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr:
./ impl/ impl/install/
Author: rwesten
Date: Sat Jul 23 06:26:37 2011
New Revision: 1150054
URL: http://svn.apache.org/viewvc?rev=1150054&view=rev
Log:
should solve the issues encountered with build 345 [1]
The committed classes of the SolrYard had already dependencies to the SolrServerTypeEnum I refactored out of the SolrServerProvider interface.
This changes to commons.solr are related to STANBOL-287
sorry for breaking the build
[1] https://builds.apache.org/job/stanbol-trunk-1.6/org.apache.stanbol$org.apache.stanbol.entityhub.yard.solr/345/
Added:
incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerTypeEnum.java (with props)
Modified:
incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrDirectoryManager.java
incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProvider.java
incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProviderManager.java
incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java
incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/EmbeddedSolrPorovider.java
incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/install/IndexRemoveTask.java
Modified: incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrDirectoryManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrDirectoryManager.java?rev=1150054&r1=1150053&r2=1150054&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrDirectoryManager.java (original)
+++ incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrDirectoryManager.java Sat Jul 23 06:26:37 2011
@@ -24,7 +24,6 @@ import java.util.Properties;
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.solr.SolrServerProvider.Type;
import org.apache.stanbol.commons.solr.utils.ConfigUtils;
import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProvider;
import org.osgi.framework.BundleContext;
@@ -35,7 +34,7 @@ import org.osgi.service.component.Compon
* (configuration and data) needed to create a Solr Server.
* <p>
* Note that is only refers to the Files and not the Solr server (or EmbeddedSolrServer). Users need to use
- * the {@link SolrServerProvider#getSolrServer(Type, String, String...)} to get an {@link SolrServer} instance
+ * the {@link SolrServerProvider#getSolrServer(SolrServerTypeEnum, String, String...)} to get an {@link SolrServer} instance
* based on the directory provided by this Interface.
* <p>
* The {@link #MANAGED_SOLR_DIR_PROPERTY} property can be used to define the location of the internally
@@ -126,7 +125,7 @@ public interface SolrDirectoryManager {
* are valid Solr indices (or Solr Cores)
* <p>
* Directories returned by this method are typically used as second parameter of
- * {@link SolrServerProvider#getSolrServer(Type, String, String...)} to create an {@link SolrServer}
+ * {@link SolrServerProvider#getSolrServer(SolrServerTypeEnum, String, String...)} to create an {@link SolrServer}
* instance.
* <p>
* If the requested Index is currently initialising, than this method MUST
Modified: incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProvider.java?rev=1150054&r1=1150053&r2=1150054&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProvider.java (original)
+++ incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProvider.java Sat Jul 23 06:26:37 2011
@@ -38,36 +38,11 @@ import org.apache.solr.client.solrj.Solr
public interface SolrServerProvider {
/**
- * SolrServer types defined here to avoid java dependencies to the according java classes
- *
- * @author Rupert Westenthaler
- *
- */
- enum Type {
- /**
- * Uses an embedded SolrServer that runs within the same virtual machine
- */
- EMBEDDED,
- /**
- * The default type that can be used for query and updates
- */
- HTTP,
- /**
- * This server is preferable used for updates
- */
- STREAMING,
- /**
- * This allows to use load balancing on multiple SolrServers via a round robin algorithm.
- */
- LOAD_BALANCE
- }
-
- /**
* Getter for the supported types of this Provider
*
* @return the Types supported by this Provider
*/
- Set<Type> supportedTypes();
+ Set<SolrServerTypeEnum> supportedTypes();
/**
* Getter for the {@link SolrServer} instance for the provided URI or path (in case of an embedded server)
@@ -84,7 +59,7 @@ public interface SolrServerProvider {
* @throws NullPointerException
* @throws IllegalArgumentException
* if <code>null</code> is parsed as uriOrPath or if the parsed URI or path is not valid for
- * the requested {@link Type} or the parsed type is not supported by this provider
+ * the requested {@link SolrServerTypeEnum} or the parsed type is not supported by this provider
*/
- SolrServer getSolrServer(Type type, String uriOrPath, String... additional) throws IllegalArgumentException;
+ SolrServer getSolrServer(SolrServerTypeEnum type, String uriOrPath, String... additional) throws IllegalArgumentException;
}
Modified: incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProviderManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProviderManager.java?rev=1150054&r1=1150053&r2=1150054&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProviderManager.java (original)
+++ incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerProviderManager.java Sat Jul 23 06:26:37 2011
@@ -33,7 +33,6 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.ReferenceStrategy;
import org.apache.felix.scr.annotations.Service;
import org.apache.solr.client.solrj.SolrServer;
-import org.apache.stanbol.commons.solr.SolrServerProvider.Type;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,9 +62,9 @@ public final class SolrServerProviderMan
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
bind = "addSolrProvider",
unbind = "removeSolrProvider")
- private Map<Type,List<SolrServerProvider>> solrServerProviders = Collections
- .synchronizedMap(new EnumMap<Type,List<SolrServerProvider>>(Type.class));
-
+ private Map<SolrServerTypeEnum,List<SolrServerProvider>> solrServerProviders = Collections
+ .synchronizedMap(new EnumMap<SolrServerTypeEnum,List<SolrServerProvider>>(SolrServerTypeEnum.class));
+
public static SolrServerProviderManager getInstance() {
if (solrServerProviderManager == null) {
SolrServerProviderManager manager = new SolrServerProviderManager();
@@ -95,7 +94,7 @@ public final class SolrServerProviderMan
solrServerProviderManager = null;
}
- public SolrServer getSolrServer(Type type, String uriOrPath, String... additionalServerLocations) {
+ public SolrServer getSolrServer(SolrServerTypeEnum type, String uriOrPath, String... additionalServerLocations) {
List<SolrServerProvider> providers = solrServerProviders.get(type);
if (providers == null) {
throw new IllegalArgumentException("No Provider for type " + type + " available");
@@ -113,7 +112,7 @@ public final class SolrServerProviderMan
protected void addSolrProvider(SolrServerProvider provider) {
log.info("add SolrProvider " + provider + " types " + provider.supportedTypes());
- for (Type type : provider.supportedTypes()) {
+ for (SolrServerTypeEnum type : provider.supportedTypes()) {
List<SolrServerProvider> providers = solrServerProviders.get(type);
if (providers == null) {
providers = new CopyOnWriteArrayList<SolrServerProvider>();
@@ -125,7 +124,7 @@ public final class SolrServerProviderMan
protected void removeSolrProvider(SolrServerProvider provider) {
log.info("remove SolrProvider " + provider + " types " + provider.supportedTypes());
- for (Type type : provider.supportedTypes()) {
+ for (SolrServerTypeEnum type : provider.supportedTypes()) {
List<SolrServerProvider> providers = solrServerProviders.get(type);
if (providers != null) {
if (providers.remove(provider) && providers.isEmpty()) {
Added: incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerTypeEnum.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerTypeEnum.java?rev=1150054&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerTypeEnum.java (added)
+++ incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerTypeEnum.java Sat Jul 23 06:26:37 2011
@@ -0,0 +1,26 @@
+package org.apache.stanbol.commons.solr;
+
+/**
+ * SolrServer types defined here to avoid java dependencies to the according java classes
+ *
+ * @author Rupert Westenthaler
+ *
+ */
+public enum SolrServerTypeEnum {
+ /**
+ * Uses an embedded SolrServer that runs within the same virtual machine
+ */
+ EMBEDDED,
+ /**
+ * The default type that can be used for query and updates
+ */
+ HTTP,
+ /**
+ * This server is preferable used for updates
+ */
+ STREAMING,
+ /**
+ * This allows to use load balancing on multiple SolrServers via a round robin algorithm.
+ */
+ LOAD_BALANCE
+}
\ No newline at end of file
Propchange: incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/SolrServerTypeEnum.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java?rev=1150054&r1=1150053&r2=1150054&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java (original)
+++ incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java Sat Jul 23 06:26:37 2011
@@ -31,6 +31,7 @@ import org.apache.solr.client.solrj.impl
import org.apache.solr.client.solrj.impl.LBHttpSolrServer;
import org.apache.solr.client.solrj.impl.StreamingUpdateSolrServer;
import org.apache.stanbol.commons.solr.SolrServerProvider;
+import org.apache.stanbol.commons.solr.SolrServerTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,14 +51,14 @@ public class DefaultSolrServerProvider i
private final Logger log = LoggerFactory.getLogger(DefaultSolrServerProvider.class);
@Override
- public SolrServer getSolrServer(Type type, String uriOrPath, String... additional) throws NullPointerException,
+ public SolrServer getSolrServer(SolrServerTypeEnum type, String uriOrPath, String... additional) throws NullPointerException,
IllegalArgumentException {
if (uriOrPath == null) {
throw new IllegalArgumentException("The parsed SolrServer URI MUST NOT be NULL!");
}
if (type == null) {
- type = Type.HTTP;
- } else if (type == Type.EMBEDDED) {
+ type = SolrServerTypeEnum.HTTP;
+ } else if (type == SolrServerTypeEnum.EMBEDDED) {
throw new IllegalArgumentException(
String.format(
"The EmbeddedSolrServer (type=%s) is not supported by this SolrServerProvider implementation",
@@ -69,7 +70,7 @@ public class DefaultSolrServerProvider i
} catch (MalformedURLException e) {
throw new IllegalArgumentException("The parsed SolrServer location is not a valid URL", e);
}
- if (type != Type.LOAD_BALANCE && additional != null && additional.length > 0) {
+ if (type != SolrServerTypeEnum.LOAD_BALANCE && additional != null && additional.length > 0) {
log.warn(String.format(
"The parsed SolrServer type \"%s\" does not support multiple SolrServer instaces."
+ "The %s additional SolrServer locations parsed are ignored! (ignored Servers: %s)",
@@ -120,8 +121,8 @@ public class DefaultSolrServerProvider i
}
@Override
- public Set<Type> supportedTypes() {
- return EnumSet.of(Type.HTTP, Type.LOAD_BALANCE, Type.STREAMING);
+ public Set<SolrServerTypeEnum> supportedTypes() {
+ return EnumSet.of(SolrServerTypeEnum.HTTP, SolrServerTypeEnum.LOAD_BALANCE, SolrServerTypeEnum.STREAMING);
}
}
Modified: incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/EmbeddedSolrPorovider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/EmbeddedSolrPorovider.java?rev=1150054&r1=1150053&r2=1150054&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/EmbeddedSolrPorovider.java (original)
+++ incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/EmbeddedSolrPorovider.java Sat Jul 23 06:26:37 2011
@@ -36,7 +36,7 @@ import org.apache.solr.core.CoreContaine
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.SolrCore;
import org.apache.stanbol.commons.solr.SolrServerProvider;
-import org.apache.stanbol.commons.solr.SolrServerProvider.Type;
+import org.apache.stanbol.commons.solr.SolrServerTypeEnum;
import org.apache.stanbol.commons.solr.utils.ConfigUtils;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
@@ -45,7 +45,7 @@ import org.xml.sax.SAXException;
/**
* Support for the use of {@link EmbeddedSolrPorovider} in combination with the SolrYard implementation. This
- * implements the {@link SolrServerProvider} interface for the {@link Type#EMBEDDED}.
+ * implements the {@link SolrServerProvider} interface for the {@link SolrServerTypeEnum#EMBEDDED}.
* <p>
*
* TODO: add functionality to lookup the internally managed {@link CoreContainer}. Maybe this requires to add
@@ -69,10 +69,27 @@ public class EmbeddedSolrPorovider imple
@SuppressWarnings("unchecked")
private Map<String,CoreContainer> coreContainers = new ReferenceMap();
+// @Reference(cardinality=ReferenceCardinality.OPTIONAL_UNARY,
+// policy=ReferencePolicy.DYNAMIC,
+// strategy=ReferenceStrategy.EVENT,
+// bind="bindSolrDirectoryManager",
+// unbind="unbindSolrDirectoryManager")
+// private SolrDirectoryManager solrDirectoryManager;
+
public EmbeddedSolrPorovider() {}
+// protected void bindSolrDirectoryManager(SolrDirectoryManager solrDirectoryManager){
+// this.solrDirectoryManager = solrDirectoryManager;
+// }
+// protected void unbindSolrDirectoryManager(SolrDirectoryManager solrDirectoryManager) {
+// this.solrDirectoryManager = null;
+// }
+// protected SolrDirectoryManager getSolrDirectoryManager(){
+// return this.solrDirectoryManager;
+// }
+
@Override
- public SolrServer getSolrServer(Type type, String uriOrPath, String... additional) throws NullPointerException,
+ public SolrServer getSolrServer(SolrServerTypeEnum type, String uriOrPath, String... additional) throws NullPointerException,
IllegalArgumentException {
log.debug(String.format("getSolrServer Request for %s and path %s", type, uriOrPath));
if (uriOrPath == null) {
@@ -184,8 +201,8 @@ public class EmbeddedSolrPorovider imple
}
@Override
- public Set<Type> supportedTypes() {
- return Collections.singleton(Type.EMBEDDED);
+ public Set<SolrServerTypeEnum> supportedTypes() {
+ return Collections.singleton(SolrServerTypeEnum.EMBEDDED);
}
@Activate
Modified: incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/install/IndexRemoveTask.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/install/IndexRemoveTask.java?rev=1150054&r1=1150053&r2=1150054&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/install/IndexRemoveTask.java (original)
+++ incubator/stanbol/trunk/commons/solr/src/main/java/org/apache/stanbol/commons/solr/impl/install/IndexRemoveTask.java Sat Jul 23 06:26:37 2011
@@ -16,6 +16,10 @@
*/
package org.apache.stanbol.commons.solr.impl.install;
+import static org.apache.stanbol.commons.solr.impl.install.IndexInstallerConstants.PROPERTY_INDEX_NAME;
+
+import java.io.File;
+
import org.apache.sling.installer.api.tasks.InstallTask;
import org.apache.sling.installer.api.tasks.InstallationContext;
import org.apache.sling.installer.api.tasks.ResourceState;
@@ -49,15 +53,31 @@ public class IndexRemoveTask extends Ins
* the services are shut down.
*/
private static final String CONFIG_INSTALL_ORDER = "11-";
+
+ private final SolrDirectoryManager solrDirectoryManager;
public IndexRemoveTask(TaskResourceGroup trg, SolrDirectoryManager solrDirectoryManager) {
super(trg);
+ if(solrDirectoryManager == null){
+ throw new IllegalArgumentException("The parsed SolrDirectoryManager MUST NOT be NULL");
+ }
+ this.solrDirectoryManager = solrDirectoryManager;
}
@Override
public void execute(InstallationContext ctx) {
- log.warn("Uninstalling of SolrIndexes not yet Implemented -> marking as uninstalled (see STANBOL-287)");
- setFinishedState(ResourceState.UNINSTALLED);
+ String indexName = (String) getResource().getAttribute(PROPERTY_INDEX_NAME);
+ File solrIndexDir = solrDirectoryManager.getSolrIndexDirectory(indexName);
+ if (solrIndexDir == null) {
+ // no index with that name installed -> nothing to do
+ ctx.log(String.format("SolrIndex '%s' not installed. Nothing to uninstall",
+ indexName));
+ setFinishedState(ResourceState.IGNORED);
+ } else { // this index does not exist
+ //solrDirectoryManager.removeSolrIndex()
+ log.warn("Uninstalling of SolrIndexes not yet Implemented -> marking as uninstalled (see STANBOL-287)");
+ setFinishedState(ResourceState.UNINSTALLED);
+ }
}
@Override