mirror of https://github.com/apache/lucene.git
SOLR-14087: disable package store API if -Denable.packages not set to true
This commit is contained in:
parent
2f051a4bfe
commit
d64c5c20b6
|
@ -47,6 +47,7 @@ import org.apache.solr.common.util.Utils;
|
|||
import org.apache.solr.core.BlobRepository;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.pkg.PackageAPI;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.security.PermissionNameProvider;
|
||||
|
@ -64,7 +65,7 @@ import static org.apache.solr.handler.ReplicationHandler.FILE_STREAM;
|
|||
|
||||
public class PackageStoreAPI {
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
public static final String PACKAGESTORE_DIRECTORY = "filestore";
|
||||
public static final String PACKAGESTORE_DIRECTORY = "$filestore";
|
||||
|
||||
|
||||
private final CoreContainer coreContainer;
|
||||
|
@ -135,6 +136,9 @@ public class PackageStoreAPI {
|
|||
|
||||
@Command
|
||||
public void upload(SolrQueryRequest req, SolrQueryResponse rsp) {
|
||||
if(!coreContainer.getPackageLoader().getPackageAPI().isEnabled()) {
|
||||
throw new RuntimeException(PackageAPI.ERR_MSG);
|
||||
}
|
||||
try {
|
||||
coreContainer.getZkController().getZkClient().create(TMP_ZK_NODE, "true".getBytes(UTF_8),
|
||||
CreateMode.EPHEMERAL, true);
|
||||
|
|
|
@ -64,6 +64,8 @@ public class PackageAPI {
|
|||
public final boolean enablePackages = Boolean.parseBoolean(System.getProperty("enable.packages", "false"));
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
public static final String ERR_MSG = "Package loading is not enabled , Start your nodes with -Denable.packages=true";
|
||||
|
||||
final CoreContainer coreContainer;
|
||||
private final ObjectMapper mapper = SolrJacksonAnnotationInspector.createObjectMapper();
|
||||
private final PackageLoader packageLoader;
|
||||
|
@ -341,9 +343,13 @@ public class PackageAPI {
|
|||
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enablePackages;
|
||||
}
|
||||
|
||||
private boolean checkEnabled(CommandOperation payload) {
|
||||
if (!enablePackages) {
|
||||
payload.addError("Package loading is not enabled , Start your nodes with -Denable.packages=true");
|
||||
payload.addError(ERR_MSG);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
|
||||
package org.apache.solr.filestore;
|
||||
|
||||
import static org.apache.solr.common.util.Utils.JAVABINCONSUMER;
|
||||
import static org.apache.solr.core.TestDynamicLoading.getFileContent;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -30,6 +27,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
|
@ -50,12 +48,14 @@ import org.apache.solr.util.LogLevel;
|
|||
import org.apache.zookeeper.CreateMode;
|
||||
import org.apache.zookeeper.server.ByteBufferInputStream;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import static org.apache.solr.common.util.Utils.JAVABINCONSUMER;
|
||||
import static org.apache.solr.core.TestDynamicLoading.getFileContent;
|
||||
|
||||
@LogLevel("org.apache.solr.filestore.PackageStoreAPI=DEBUG;org.apache.solr.filestore.DistribPackageStore=DEBUG")
|
||||
public class TestDistribPackageStore extends SolrCloudTestCase {
|
||||
|
||||
public void testPackageStoreManagement() throws Exception {
|
||||
System.setProperty("enable.packages", "true");
|
||||
MiniSolrCloudCluster cluster =
|
||||
configureCluster(4)
|
||||
.withJettyConfig(jetty -> jetty.enableV2(true))
|
||||
|
|
Loading…
Reference in New Issue