Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #92 from RBMHTechnology/#91-Ping_on_Solr_in_non-cl…
Browse files Browse the repository at this point in the history
…oud_mode_fails

Ping is simplified and now works on both cloud and non-cloud mode.
  • Loading branch information
Alfonso Noriega authored Feb 26, 2019
2 parents 53d8439 + a10fddb commit 154219e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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));
}
}

}

0 comments on commit 154219e

Please sign in to comment.