@Test public void slaveReplicationHandlerDefinedButDisabled_thenContentStoreIsInReadWriteMode() throws Exception { prepare("solrconfig_slave_disabled_replication_handler.xml"); assertFalse("If a slave replication handler is defined but disabled, then we expect to run a RW content store.", listener.isSlaveModeEnabledFor(core)); }
@SuppressWarnings("rawtypes") boolean isSlaveModeEnabledFor(SolrCore core) { Predicate<PluginInfo> onlyReplicationHandler = plugin -> "/replication".equals(plugin.name) || plugin.className.endsWith(ReplicationHandler.class.getSimpleName()); Function<NamedList, Boolean> isSlaveModeEnabled = params -> ofNullable(params) .map(configuration -> { Object enable = configuration.get("enable"); return enable == null || (enable instanceof String ? StrUtils.parseBool((String)enable) : Boolean.TRUE.equals(enable));}) .orElse(false); return core.getSolrConfig().getPluginInfos(SolrRequestHandler.class.getName()) .stream() .filter(PluginInfo::isEnabled) .filter(onlyReplicationHandler) .findFirst() .map(plugin -> plugin.initArgs) .map(params -> params.get("slave")) .map(NamedList.class::cast) .map(isSlaveModeEnabled) .orElse(false); }
SolrCoreLoadListener extends AbstractSolrEventListener { @SuppressWarnings("rawtypes") boolean isSlaveModeEnabledFor(SolrCore core) { Predicate<PluginInfo> onlyReplicationHandler = plugin -> "/replication".equals(plugin.name) || plugin.className.endsWith(ReplicationHandler.class.getSimpleName()); Function<NamedList, Boolean> isSlaveModeEnabled = params -> ofNullable(params) .map(configuration -> { Object enable = configuration.get("enable"); return enable == null || (enable instanceof String ? StrUtils.parseBool((String)enable) : Boolean.TRUE.equals(enable));}) .orElse(false); return core.getSolrConfig().getPluginInfos(SolrRequestHandler.class.getName()) .stream() .filter(PluginInfo::isEnabled) .filter(onlyReplicationHandler) .findFirst() .map(plugin -> plugin.initArgs) .map(params -> params.get("slave")) .map(NamedList.class::cast) .map(isSlaveModeEnabled) .orElse(false); } }
SolrCoreLoadListener extends AbstractSolrEventListener { @SuppressWarnings("rawtypes") boolean isSlaveModeEnabledFor(SolrCore core) { Predicate<PluginInfo> onlyReplicationHandler = plugin -> "/replication".equals(plugin.name) || plugin.className.endsWith(ReplicationHandler.class.getSimpleName()); Function<NamedList, Boolean> isSlaveModeEnabled = params -> ofNullable(params) .map(configuration -> { Object enable = configuration.get("enable"); return enable == null || (enable instanceof String ? StrUtils.parseBool((String)enable) : Boolean.TRUE.equals(enable));}) .orElse(false); return core.getSolrConfig().getPluginInfos(SolrRequestHandler.class.getName()) .stream() .filter(PluginInfo::isEnabled) .filter(onlyReplicationHandler) .findFirst() .map(plugin -> plugin.initArgs) .map(params -> params.get("slave")) .map(NamedList.class::cast) .map(isSlaveModeEnabled) .orElse(false); } SolrCoreLoadListener(SolrCore core); }
SolrCoreLoadListener extends AbstractSolrEventListener { @SuppressWarnings("rawtypes") boolean isSlaveModeEnabledFor(SolrCore core) { Predicate<PluginInfo> onlyReplicationHandler = plugin -> "/replication".equals(plugin.name) || plugin.className.endsWith(ReplicationHandler.class.getSimpleName()); Function<NamedList, Boolean> isSlaveModeEnabled = params -> ofNullable(params) .map(configuration -> { Object enable = configuration.get("enable"); return enable == null || (enable instanceof String ? StrUtils.parseBool((String)enable) : Boolean.TRUE.equals(enable));}) .orElse(false); return core.getSolrConfig().getPluginInfos(SolrRequestHandler.class.getName()) .stream() .filter(PluginInfo::isEnabled) .filter(onlyReplicationHandler) .findFirst() .map(plugin -> plugin.initArgs) .map(params -> params.get("slave")) .map(NamedList.class::cast) .map(isSlaveModeEnabled) .orElse(false); } SolrCoreLoadListener(SolrCore core); @Override void newSearcher(SolrIndexSearcher newSearcher, SolrIndexSearcher currentSearcher); }
SolrCoreLoadListener extends AbstractSolrEventListener { @SuppressWarnings("rawtypes") boolean isSlaveModeEnabledFor(SolrCore core) { Predicate<PluginInfo> onlyReplicationHandler = plugin -> "/replication".equals(plugin.name) || plugin.className.endsWith(ReplicationHandler.class.getSimpleName()); Function<NamedList, Boolean> isSlaveModeEnabled = params -> ofNullable(params) .map(configuration -> { Object enable = configuration.get("enable"); return enable == null || (enable instanceof String ? StrUtils.parseBool((String)enable) : Boolean.TRUE.equals(enable));}) .orElse(false); return core.getSolrConfig().getPluginInfos(SolrRequestHandler.class.getName()) .stream() .filter(PluginInfo::isEnabled) .filter(onlyReplicationHandler) .findFirst() .map(plugin -> plugin.initArgs) .map(params -> params.get("slave")) .map(NamedList.class::cast) .map(isSlaveModeEnabled) .orElse(false); } SolrCoreLoadListener(SolrCore core); @Override void newSearcher(SolrIndexSearcher newSearcher, SolrIndexSearcher currentSearcher);  }