diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 747b0b94d9e..19300d66e18 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -554,6 +554,9 @@ Other Changes * SOLR-6885: Add core name to RecoveryThread name. (Christine Poerschke via shalin) +* SOLR-6855: bin/solr -e dih launches, but has some path cruft issues preventing some of the + imports don't work (Hossman, Timothy Potter) + ================== 4.10.3 ================== Bug Fixes diff --git a/solr/core/src/java/org/apache/solr/rest/ManagedResource.java b/solr/core/src/java/org/apache/solr/rest/ManagedResource.java index 76ced76822e..d1d3d8b04cc 100644 --- a/solr/core/src/java/org/apache/solr/rest/ManagedResource.java +++ b/solr/core/src/java/org/apache/solr/rest/ManagedResource.java @@ -185,10 +185,22 @@ public abstract class ManagedResource { "Failed to load stored data for "+resourceId+" due to: "+ioExc, ioExc); } - Object managedData = null; + Object managedData = processStoredData(data); + + if (managedInitArgs == null) + managedInitArgs = new NamedList<>(); + + onManagedDataLoadedFromStorage(managedInitArgs, managedData); + } + + /** + * Processes the stored data. + */ + protected Object processStoredData(Object data) throws SolrException { + Object managedData = null; if (data != null) { if (!(data instanceof Map)) { - throw new SolrException(ErrorCode.SERVER_ERROR, + throw new SolrException(ErrorCode.SERVER_ERROR, "Stored data for "+resourceId+" is not a valid JSON object!"); } @@ -196,37 +208,32 @@ public abstract class ManagedResource { Map initArgsMap = (Map)jsonMap.get(INIT_ARGS_JSON_FIELD); managedInitArgs = new NamedList<>(initArgsMap); log.info("Loaded initArgs {} for {}", managedInitArgs, resourceId); - + if (jsonMap.containsKey(MANAGED_JSON_LIST_FIELD)) { Object jsonList = jsonMap.get(MANAGED_JSON_LIST_FIELD); if (!(jsonList instanceof List)) { - String errMsg = + String errMsg = String.format(Locale.ROOT, "Expected JSON array as value for %s but client sent a %s instead!", MANAGED_JSON_LIST_FIELD, jsonList.getClass().getName()); throw new SolrException(ErrorCode.SERVER_ERROR, errMsg); } - + managedData = jsonList; } else if (jsonMap.containsKey(MANAGED_JSON_MAP_FIELD)) { Object jsonObj = jsonMap.get(MANAGED_JSON_MAP_FIELD); if (!(jsonObj instanceof Map)) { - String errMsg = + String errMsg = String.format(Locale.ROOT, "Expected JSON map as value for %s but client sent a %s instead!", MANAGED_JSON_MAP_FIELD, jsonObj.getClass().getName()); throw new SolrException(ErrorCode.SERVER_ERROR, errMsg); } - + managedData = jsonObj; - } + } } - - if (managedInitArgs == null) { - managedInitArgs = new NamedList<>(); - } - - onManagedDataLoadedFromStorage(managedInitArgs, managedData); + return managedData; } /** diff --git a/solr/core/src/java/org/apache/solr/rest/RestManager.java b/solr/core/src/java/org/apache/solr/rest/RestManager.java index 05ed51b057c..f8a70afdd59 100644 --- a/solr/core/src/java/org/apache/solr/rest/RestManager.java +++ b/solr/core/src/java/org/apache/solr/rest/RestManager.java @@ -16,6 +16,7 @@ package org.apache.solr.rest; * limitations under the License. */ +import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.Constructor; import java.util.ArrayList; @@ -449,6 +450,31 @@ public class RestManager { this.restManager = restManager; } + /** + * Overrides the parent impl to handle FileNotFoundException better + */ + @Override + protected synchronized void reloadFromStorage() throws SolrException { + String resourceId = getResourceId(); + Object data = null; + try { + data = storage.load(resourceId); + } catch (FileNotFoundException fnf) { + // this is ok - simply means there are no managed components added yet + } catch (IOException ioExc) { + throw new SolrException(ErrorCode.SERVER_ERROR, + "Failed to load stored data for "+resourceId+" due to: "+ioExc, ioExc); + } + + Object managedData = processStoredData(data); + + if (managedInitArgs == null) + managedInitArgs = new NamedList<>(); + + if (managedData != null) + onManagedDataLoadedFromStorage(managedInitArgs, managedData); + } + /** * Loads and initializes any ManagedResources that have been created but * are not associated with any Solr components. @@ -457,12 +483,9 @@ public class RestManager { @Override protected void onManagedDataLoadedFromStorage(NamedList managedInitArgs, Object managedData) throws SolrException { - + if (managedData == null) { - // this is OK, just means there are no stored registrations - // storing an empty list is safe and avoid future warnings about - // the data not existing - storeManagedData(new ArrayList>(0)); + // this is ok - just means no managed components have been added yet return; } diff --git a/solr/example/example-DIH/README.txt b/solr/example/example-DIH/README.txt index 5139bf87e39..0926bb657bc 100644 --- a/solr/example/example-DIH/README.txt +++ b/solr/example/example-DIH/README.txt @@ -16,12 +16,11 @@ Solr DataImportHandler example configuration -------------------------------------------- -Change to the parent (example) directory. Start solr by executing the following command +To run this example, use the "-e" option of the bin/solr script: -> cd .. -> java -Dsolr.solr.home="./example-DIH/solr/" -jar start.jar +> bin/solr -e dih -in this directory, and when Solr is started connect to: +When Solr is started connect to: http://localhost:8983/solr/ diff --git a/solr/example/example-DIH/hsqldb/ex.log b/solr/example/example-DIH/hsqldb/ex.log deleted file mode 100644 index 26a8be8759b..00000000000 --- a/solr/example/example-DIH/hsqldb/ex.log +++ /dev/null @@ -1,16 +0,0 @@ -/*C2*/SET SCHEMA PUBLIC -CONNECT USER SA -SET AUTOCOMMIT FALSE -/*C3*/SET SCHEMA PUBLIC -CONNECT USER SA -SET AUTOCOMMIT FALSE -/*C4*/SET SCHEMA PUBLIC -CONNECT USER SA -SET AUTOCOMMIT FALSE -/*C5*/SET SCHEMA PUBLIC -CONNECT USER SA -SET AUTOCOMMIT FALSE -/*C2*/DISCONNECT -/*C3*/DISCONNECT -/*C4*/DISCONNECT -/*C5*/DISCONNECT diff --git a/solr/example/example-DIH/hsqldb/ex.properties b/solr/example/example-DIH/hsqldb/ex.properties deleted file mode 100644 index 78ba896cce1..00000000000 --- a/solr/example/example-DIH/hsqldb/ex.properties +++ /dev/null @@ -1,17 +0,0 @@ -#HSQL Database Engine 1.8.0.10 -#Tue Aug 19 10:31:19 EDT 2014 -hsqldb.script_format=0 -runtime.gc_interval=0 -sql.enforce_strict_size=false -hsqldb.cache_size_scale=8 -readonly=false -hsqldb.nio_data_file=true -hsqldb.cache_scale=14 -version=1.8.0 -hsqldb.default_table_type=memory -hsqldb.cache_file_scale=1 -hsqldb.log_size=200 -modified=yes -hsqldb.cache_version=1.7.0 -hsqldb.original_version=1.8.0 -hsqldb.compatible_version=1.8.0 diff --git a/solr/example/example-DIH/solr/db/conf/db-data-config.xml b/solr/example/example-DIH/solr/db/conf/db-data-config.xml index 21f17a0b878..4a7dba955be 100644 --- a/solr/example/example-DIH/solr/db/conf/db-data-config.xml +++ b/solr/example/example-DIH/solr/db/conf/db-data-config.xml @@ -1,5 +1,5 @@ - + diff --git a/solr/example/example-DIH/solr/db/conf/schema.xml b/solr/example/example-DIH/solr/db/conf/schema.xml index ee04f7c00b3..d0611fb3f1f 100755 --- a/solr/example/example-DIH/solr/db/conf/schema.xml +++ b/solr/example/example-DIH/solr/db/conf/schema.xml @@ -432,15 +432,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/solr/example/example-DIH/solr/tika/conf/tika-data-config.xml b/solr/example/example-DIH/solr/tika/conf/tika-data-config.xml index 70f75790b09..0d9e7685c44 100644 --- a/solr/example/example-DIH/solr/tika/conf/tika-data-config.xml +++ b/solr/example/example-DIH/solr/tika/conf/tika-data-config.xml @@ -2,7 +2,7 @@ + url="${solr.install.dir}/example/exampledocs/solr-word.pdf" format="text">