SOLR-8969: Fix static cloud check

This commit is contained in:
Kevin Risden 2016-10-11 14:48:25 -05:00
parent b00f10916b
commit 7660dde458
1 changed files with 6 additions and 9 deletions

View File

@ -78,25 +78,22 @@ import com.facebook.presto.sql.parser.SqlParser;
public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , PermissionNameProvider { public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , PermissionNameProvider {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static String defaultZkhost = null; private static String defaultZkhost = null;
private static String defaultWorkerCollection = null; private static String defaultWorkerCollection = null;
private static List<String> remove;
static {
remove = new ArrayList();
remove.add("count(*)");
}
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
static final String sqlNonCloudErrorMsg = "/sql handler only works in Solr Cloud mode"; static final String sqlNonCloudErrorMsg = "/sql handler only works in Solr Cloud mode";
public void inform(SolrCore core) { private boolean isCloud = false;
public void inform(SolrCore core) {
CoreContainer coreContainer = core.getCoreDescriptor().getCoreContainer(); CoreContainer coreContainer = core.getCoreDescriptor().getCoreContainer();
if(coreContainer.isZooKeeperAware()) { if(coreContainer.isZooKeeperAware()) {
defaultZkhost = core.getCoreDescriptor().getCoreContainer().getZkController().getZkServerAddress(); defaultZkhost = core.getCoreDescriptor().getCoreContainer().getZkController().getZkServerAddress();
defaultWorkerCollection = core.getCoreDescriptor().getCollectionName(); defaultWorkerCollection = core.getCoreDescriptor().getCollectionName();
isCloud = true;
} }
} }
@ -121,7 +118,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , Pe
try { try {
if(workerZkhost == null) { if(!isCloud) {
throw new IllegalStateException(sqlNonCloudErrorMsg); throw new IllegalStateException(sqlNonCloudErrorMsg);
} }