You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2020/09/22 01:46:41 UTC

[lucene-solr] branch branch_8x updated (dbae83a -> 1a01810)

This is an automated email from the ASF dual-hosted git repository.

noble pushed a change to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from dbae83a  Fix bad merge
     new 3d03a1b  SOLR-14884: TestContainerPlugin.testApiFromPackage jenkins failures
     new 1a01810  SOLR-14884: TestContainerPlugin.testApiFromPackage jenkins failures

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/solr/api/CustomContainerPlugins.java    | 24 +++++++----
 .../src/java/org/apache/solr/pkg/PackageAPI.java   | 46 +++++++++++-----------
 .../java/org/apache/solr/pkg/PackageLoader.java    |  8 ++++
 3 files changed, 47 insertions(+), 31 deletions(-)


[lucene-solr] 01/02: SOLR-14884: TestContainerPlugin.testApiFromPackage jenkins failures

Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 3d03a1b88c88aa5664499b59a59c477f7ff5c3e7
Author: noblepaul <no...@gmail.com>
AuthorDate: Tue Sep 22 11:20:49 2020 +1000

    SOLR-14884: TestContainerPlugin.testApiFromPackage jenkins failures
---
 .../apache/solr/api/CustomContainerPlugins.java    | 24 +++++++----
 .../src/java/org/apache/solr/pkg/PackageAPI.java   | 46 +++++++++++-----------
 .../java/org/apache/solr/pkg/PackageLoader.java    |  8 ++++
 3 files changed, 47 insertions(+), 31 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java b/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java
index f24626b..ef33c3e 100644
--- a/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java
+++ b/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.lucene.analysis.util.ResourceLoaderAware;
@@ -228,16 +229,23 @@ public class CustomContainerPlugins implements ClusterPropertiesListener, MapWri
       PluginInfo.ClassName klassInfo = new PluginInfo.ClassName(info.klass);
       pkg = klassInfo.pkg;
       if (pkg != null) {
-        PackageLoader.Package p = coreContainer.getPackageLoader().getPackage(pkg);
-        if (p == null) {
-          errs.add("Invalid package " + klassInfo.pkg);
-          return;
+        Optional<PackageLoader.Package.Version> ver = coreContainer.getPackageLoader().getPackageVersion(pkg, info.version);
+        if (ver.isEmpty()) {
+          //may be we are a bit early. Do a refresh and try again
+         coreContainer.getPackageLoader().getPackageAPI().refreshPackages(null);
+         ver = coreContainer.getPackageLoader().getPackageVersion(pkg, info.version);
         }
-        this.pkgVersion = p.getVersion(info.version);
-        if (pkgVersion == null) {
-          errs.add("No such package version:" + pkg + ":" + info.version + " . available versions :" + p.allVersions());
-          return;
+        if (ver.isEmpty()) {
+          PackageLoader.Package p = coreContainer.getPackageLoader().getPackage(pkg);
+          if (p == null) {
+            errs.add("Invalid package " + klassInfo.pkg);
+            return;
+          } else {
+            errs.add("No such package version:" + pkg + ":" + info.version + " . available versions :" + p.allVersions());
+            return;
+          }
         }
+        this.pkgVersion = ver.get();
         try {
           klas = pkgVersion.getLoader().findClass(klassInfo.className, Object.class);
         } catch (Exception e) {
diff --git a/solr/core/src/java/org/apache/solr/pkg/PackageAPI.java b/solr/core/src/java/org/apache/solr/pkg/PackageAPI.java
index c65dd0d..6461b76 100644
--- a/solr/core/src/java/org/apache/solr/pkg/PackageAPI.java
+++ b/solr/core/src/java/org/apache/solr/pkg/PackageAPI.java
@@ -93,8 +93,7 @@ public class PackageAPI {
 
   private void registerListener(SolrZkClient zkClient)
       throws KeeperException, InterruptedException {
-    String path = SOLR_PKGS_PATH;
-    zkClient.exists(path,
+    zkClient.exists(SOLR_PKGS_PATH,
         new Watcher() {
 
           @Override
@@ -103,32 +102,33 @@ public class PackageAPI {
             if (Event.EventType.None.equals(event.getType())) {
               return;
             }
-            try {
-              synchronized (this) {
-                log.debug("Updating [{}] ... ", path);
-
-                // remake watch
-                final Watcher thisWatch = this;
-                final Stat stat = new Stat();
-                final byte[] data = zkClient.getData(path, thisWatch, stat, true);
-                pkgs = readPkgsFromZk(data, stat);
-                packageLoader.refreshPackageConf();
-              }
-            } catch (KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e) {
-              log.warn("ZooKeeper watch triggered, but Solr cannot talk to ZK: ", e);
-            } catch (KeeperException e) {
-              log.error("A ZK error has occurred", e);
-              throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
-            } catch (InterruptedException e) {
-              // Restore the interrupted status
-              Thread.currentThread().interrupt();
-              log.warn("Interrupted", e);
+            synchronized (this) {
+              log.debug("Updating [{}] ... ", SOLR_PKGS_PATH);
+              // remake watch
+              final Watcher thisWatch = this;
+              refreshPackages(thisWatch);
             }
           }
-
         }, true);
   }
 
+  public void refreshPackages(Watcher watcher)  {
+    final Stat stat = new Stat();
+    try {
+      final byte[] data = coreContainer.getZkController().getZkClient().getData(SOLR_PKGS_PATH, watcher, stat, true);
+      pkgs = readPkgsFromZk(data, stat);
+      packageLoader.refreshPackageConf();
+    } catch (KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e) {
+      log.warn("ZooKeeper watch triggered, but Solr cannot talk to ZK: ", e);
+    } catch (KeeperException e) {
+      log.error("A ZK error has occurred", e);
+      throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
+    } catch (InterruptedException e) {
+      // Restore the interrupted status
+      Thread.currentThread().interrupt();
+      log.warn("Interrupted", e);
+    }
+  }
 
   private Packages readPkgsFromZk(byte[] data, Stat stat) throws KeeperException, InterruptedException {
 
diff --git a/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java b/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java
index 1e2fc57..e3ad675 100644
--- a/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java
+++ b/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java
@@ -31,6 +31,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -61,6 +62,12 @@ public class PackageLoader implements Closeable {
   private PackageAPI packageAPI;
 
 
+  public Optional<Package.Version> getPackageVersion(String pkg, String version) {
+    Package p = packageClassLoaders.get(pkg);
+    if(p == null) return Optional.empty();
+    return Optional.ofNullable(p.getVersion(version));
+  }
+
   public PackageLoader(CoreContainer coreContainer) {
     this.coreContainer = coreContainer;
     packageAPI = new PackageAPI(coreContainer, this);
@@ -227,6 +234,7 @@ public class PackageLoader implements Closeable {
     }
 
     public Version getVersion(String version) {
+      if(version == null) return getLatest();
       return myVersions.get(version);
     }
 


[lucene-solr] 02/02: SOLR-14884: TestContainerPlugin.testApiFromPackage jenkins failures

Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 1a018105b41e260bc3aaaf760fb9f2dab98ff53c
Author: noblepaul <no...@gmail.com>
AuthorDate: Tue Sep 22 11:30:05 2020 +1000

    SOLR-14884: TestContainerPlugin.testApiFromPackage jenkins failures
---
 solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java b/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java
index ef33c3e..218fff1 100644
--- a/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java
+++ b/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java
@@ -230,12 +230,12 @@ public class CustomContainerPlugins implements ClusterPropertiesListener, MapWri
       pkg = klassInfo.pkg;
       if (pkg != null) {
         Optional<PackageLoader.Package.Version> ver = coreContainer.getPackageLoader().getPackageVersion(pkg, info.version);
-        if (ver.isEmpty()) {
+        if (!ver.isPresent()) {
           //may be we are a bit early. Do a refresh and try again
          coreContainer.getPackageLoader().getPackageAPI().refreshPackages(null);
          ver = coreContainer.getPackageLoader().getPackageVersion(pkg, info.version);
         }
-        if (ver.isEmpty()) {
+        if (!ver.isPresent()) {
           PackageLoader.Package p = coreContainer.getPackageLoader().getPackage(pkg);
           if (p == null) {
             errs.add("Invalid package " + klassInfo.pkg);