Apache Lucene open-source search software
SOLR-9242: Move license headers to the top + force refresh cluster propery before reading the 'location' param
Varun Thackereefdc62c997f
diff --git a/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java b/solr/core/src/java/org/apache/solr/core/backup/BackupManager.javaindex 0575bff95ac..51227e86a77 100644--- a/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java+++ b/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java@@ -1,3 +1,19 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */package org.apache.solr.core.backup;import java.io.IOException;@@ -31,23 +47,6 @@ import org.apache.zookeeper.KeeperException;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-/*** This class implements functionality to create a backup with extension points provided to integrate with different* types of file-systems.diff --git a/solr/core/src/java/org/apache/solr/core/backup/repository/BackupRepository.java b/solr/core/src/java/org/apache/solr/core/backup/repository/BackupRepository.javaindex 20d8628a50c..8950ce7fa00 100644--- a/solr/core/src/java/org/apache/solr/core/backup/repository/BackupRepository.java+++ b/solr/core/src/java/org/apache/solr/core/backup/repository/BackupRepository.java@@ -1,5 +1,3 @@-package org.apache.solr.core.backup.repository;-/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements. See the NOTICE file distributed with@@ -16,6 +14,7 @@ package org.apache.solr.core.backup.repository;* See the License for the specific language governing permissions and* limitations under the License.*/+package org.apache.solr.core.backup.repository;import java.io.Closeable;import java.io.IOException;diff --git a/solr/core/src/java/org/apache/solr/handler/SnapShooter.java b/solr/core/src/java/org/apache/solr/handler/SnapShooter.javaindex 4b39097770e..5ac324329a0 100644--- a/solr/core/src/java/org/apache/solr/handler/SnapShooter.java+++ b/solr/core/src/java/org/apache/solr/handler/SnapShooter.java@@ -28,6 +28,7 @@ import java.util.List;import java.util.Locale;import java.util.function.Consumer;+import com.google.common.base.Preconditions;import org.apache.lucene.index.IndexCommit;import org.apache.lucene.store.Directory;import org.apache.solr.common.SolrException;@@ -43,8 +44,6 @@ import org.apache.solr.util.RefCounted;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.google.common.base.Preconditions;-/*** <p> Provides functionality equivalent to the snapshooter script </p>* This is no longer used in standard replication.diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.javaindex 97fbd2d181d..874e68c4218 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java@@ -816,6 +816,9 @@ public class CollectionsHandler extends RequestHandlerBase implements PermissionString location = repository.getBackupLocation(req.getParams().get(CoreAdminParams.BACKUP_LOCATION));if (location == null) {+ //Refresh the cluster property file to make sure the value set for location is the latest+ h.coreContainer.getZkController().getZkStateReader().forceUpdateClusterProperties();+// Check if the location is specified in the cluster property.location = h.coreContainer.getZkController().getZkStateReader().getClusterProperty(CoreAdminParams.BACKUP_LOCATION, null);if (location == null) {@@ -857,6 +860,9 @@ public class CollectionsHandler extends RequestHandlerBase implements PermissionString location = repository.getBackupLocation(req.getParams().get(CoreAdminParams.BACKUP_LOCATION));if (location == null) {+ //Refresh the cluster property file to make sure the value set for location is the latest+ h.coreContainer.getZkController().getZkStateReader().forceUpdateClusterProperties();+// Check if the location is specified in the cluster property.location = h.coreContainer.getZkController().getZkStateReader().getClusterProperty("location", null);if (location == null) {diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.javaindex fa3beddac6d..33fe19adc24 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java@@ -860,7 +860,7 @@ enum CoreAdminOperation {BackupRepository repository = callInfo.handler.coreContainer.newBackupRepository(Optional.ofNullable(repoName));String location = repository.getBackupLocation(params.get(CoreAdminParams.BACKUP_LOCATION));- if(location == null) {+ if (location == null) {throw new SolrException(ErrorCode.BAD_REQUEST, "'location' is not specified as a query"+ " parameter or as a default repository property");}@@ -906,7 +906,7 @@ enum CoreAdminOperation {BackupRepository repository = callInfo.handler.coreContainer.newBackupRepository(Optional.ofNullable(repoName));String location = repository.getBackupLocation(params.get(CoreAdminParams.BACKUP_LOCATION));- if(location == null) {+ if (location == null) {throw new SolrException(ErrorCode.BAD_REQUEST, "'location' is not specified as a query"+ " parameter or as a default repository property");}diff --git a/solr/core/src/test/org/apache/solr/cloud/AbstractCloudBackupRestoreTestCase.java b/solr/core/src/test/org/apache/solr/cloud/AbstractCloudBackupRestoreTestCase.javaindex 96faf923922..fd74eaf06f7 100644--- a/solr/core/src/test/org/apache/solr/cloud/AbstractCloudBackupRestoreTestCase.java+++ b/solr/core/src/test/org/apache/solr/cloud/AbstractCloudBackupRestoreTestCase.java@@ -1,3 +1,19 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */package org.apache.solr.cloud;import java.io.IOException;@@ -30,23 +46,6 @@ import org.slf4j.LoggerFactory;import static org.apache.solr.common.params.ShardParams._ROUTE_;-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-/*** This class implements the logic required to test Solr cloud backup/restore capability.*/diff --git a/solr/core/src/test/org/apache/solr/cloud/TestHdfsCloudBackupRestore.java b/solr/core/src/test/org/apache/solr/cloud/TestHdfsCloudBackupRestore.javaindex a09fc2f5692..5fd7666d411 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestHdfsCloudBackupRestore.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestHdfsCloudBackupRestore.java@@ -1,3 +1,19 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */package org.apache.solr.cloud;import java.io.IOException;@@ -19,23 +35,6 @@ import org.junit.BeforeClass;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-/*** This class implements the tests for HDFS integration for Solr backup/restore capability.*/diff --git a/solr/core/src/test/org/apache/solr/cloud/TestLocalFSCloudBackupRestore.java b/solr/core/src/test/org/apache/solr/cloud/TestLocalFSCloudBackupRestore.javaindex 6f3e2bc8db0..db6891349f5 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestLocalFSCloudBackupRestore.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestLocalFSCloudBackupRestore.java@@ -1,7 +1,3 @@-package org.apache.solr.cloud;--import org.junit.BeforeClass;-/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements. See the NOTICE file distributed with@@ -18,6 +14,9 @@ import org.junit.BeforeClass;* See the License for the specific language governing permissions and* limitations under the License.*/+package org.apache.solr.cloud;++import org.junit.BeforeClass;/*** This class implements the tests for local file-system integration for Solr backup/restore capability.diff --git a/solr/core/src/test/org/apache/solr/core/TestBackupRepositoryFactory.java b/solr/core/src/test/org/apache/solr/core/TestBackupRepositoryFactory.javaindex a03d4c4d7bf..060cca157f3 100644--- a/solr/core/src/test/org/apache/solr/core/TestBackupRepositoryFactory.java+++ b/solr/core/src/test/org/apache/solr/core/TestBackupRepositoryFactory.java@@ -1,5 +1,3 @@-package org.apache.solr.core;-/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements. See the NOTICE file distributed with@@ -16,6 +14,7 @@ package org.apache.solr.core;* See the License for the specific language governing permissions and* limitations under the License.*/+package org.apache.solr.core;import java.io.File;import java.util.HashMap;diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.javaindex 3f422faa046..227a8b3d55d 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java@@ -845,6 +845,14 @@ public class ZkStateReader implements Closeable {loadClusterProperties();};+ /**+ * We should try keeping this to a minimum. Only in scenarios where the value being read is a user facing property+ * should we force update to make sure we are reading the latest value.+ */+ public void forceUpdateClusterProperties() {+ loadClusterProperties();+ }+@SuppressWarnings("unchecked")private void loadClusterProperties() {try {