diff --git a/backend/solr/src/main/java/com/rbmhtechnology/vind/solr/backend/SolrSearchServer.java b/backend/solr/src/main/java/com/rbmhtechnology/vind/solr/backend/SolrSearchServer.java index d888dddf..53ae2901 100644 --- a/backend/solr/src/main/java/com/rbmhtechnology/vind/solr/backend/SolrSearchServer.java +++ b/backend/solr/src/main/java/com/rbmhtechnology/vind/solr/backend/SolrSearchServer.java @@ -152,21 +152,11 @@ public Object getBackend() { @Override public StatusResult getBackendStatus() { - int statusCode = -1; - try { - if(SearchConfiguration.get(SearchConfiguration.SERVER_SOLR_CLOUD, false)) { - CollectionAdminRequest request = new CollectionAdminRequest.ClusterStatus(); - SolrResponse response = request.process(this.solrClient); - statusCode = Integer.valueOf(((NamedList)response.getResponse().get("responseHeader")).get("status").toString()); + try { + SolrPingResponse ping = solrClient.ping(); - } - else { - CoreAdminRequest request = new CoreAdminRequest(); - request.setAction(CoreAdminParams.CoreAdminAction.STATUS); - CoreAdminResponse response = request.process(this.solrClient); - statusCode = response.getStatus(); - } + int statusCode = ping.getStatus(); if(statusCode != 0) { return StatusResult.down().setDetail("status", statusCode); diff --git a/test/src/main/java/com/rbmhtechnology/vind/test/TestSearchServer.java b/test/src/main/java/com/rbmhtechnology/vind/test/TestSearchServer.java index 2aaab9cb..82e2851a 100644 --- a/test/src/main/java/com/rbmhtechnology/vind/test/TestSearchServer.java +++ b/test/src/main/java/com/rbmhtechnology/vind/test/TestSearchServer.java @@ -14,19 +14,16 @@ public class TestSearchServer extends ExternalResource { private Logger log = LoggerFactory.getLogger(getClass()); + private ServerType serverType = ServerType.Embedded; + private SearchServer searchServer; @Override protected void before() throws Throwable { super.before(); - SearchConfiguration.set(SearchConfiguration.SERVER_PROVIDER, "com.rbmhtechnology.vind.solr.backend.EmbeddedSolrServerProvider"); - //SearchConfiguration.set(SearchConfiguration.SERVER_PROVIDER, "com.rbmhtechnology.vind.solr.backend.RemoteSolrServerProvider"); - //SearchConfiguration.set(SearchConfiguration.SERVER_HOST, "localhost:9983"); - //SearchConfiguration.set(SearchConfiguration.SERVER_COLLECTION, "dam_assets"); - //SearchConfiguration.set(SearchConfiguration.SERVER_SOLR_CLOUD, true); + serverType.prepareConfig(); - System.setProperty("runtimeLib", "false"); searchServer = SearchServer.getInstance(); } @@ -47,4 +44,39 @@ public SearchServer getSearchServer() { return searchServer; } + private enum ServerType { + + Embedded("com.rbmhtechnology.vind.solr.backend.EmbeddedSolrServerProvider", null, null, false), + + //setup: + // * docker run --name vind-solr-2.1.0 -p 8983:8983 redlinkgmbh/vind-solr-server:2.1.0 + RemoteStandalone("com.rbmhtechnology.vind.solr.backend.RemoteSolrServerProvider", "http://localhost:8983/solr", "vind", false), + + //setup: + // * ./bin/solr start c + // * download exec jar for collection mgtm tool, e.g. http://central.maven.org/maven2/com/rbmhtechnology/vind/collection-managment-tool/2.1.0/ + // * java -jar collection-managment-tool-2.1.0-exec.jar -cc vind -from com.rbmhtechnology.vind:backend-solr:2.1.0 --in localhost:9983 + RemoteCloud("com.rbmhtechnology.vind.solr.backend.RemoteSolrServerProvider", "localhost:9983", "vind", true); + + private String provider; + private String host; + private String collection; + private boolean cloud; + + ServerType(String provider, String host, String collection, boolean cloud) { + this.provider = provider; + this.host = host; + this.collection = collection; + this.cloud = cloud; + } + + void prepareConfig() { + SearchConfiguration.set(SearchConfiguration.SERVER_PROVIDER, provider); + if(host != null) SearchConfiguration.set(SearchConfiguration.SERVER_HOST, host); + if(collection != null) SearchConfiguration.set(SearchConfiguration.SERVER_COLLECTION, collection); + SearchConfiguration.set(SearchConfiguration.SERVER_SOLR_CLOUD, cloud); + System.setProperty("runtimeLib", String.valueOf(cloud)); + } + } + }