lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject lucene-solr:jira/solr-11702: SOLR-11702: Refactoring ZkShardTerms
Date Wed, 03 Jan 2018 13:13:10 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/jira/solr-11702 3e6afede4 -> b52186bf6


SOLR-11702: Refactoring ZkShardTerms


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/b52186bf
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/b52186bf
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/b52186bf

Branch: refs/heads/jira/solr-11702
Commit: b52186bf62cae36fa0d2f05c85721fe3e2616d71
Parents: 3e6afed
Author: Cao Manh Dat <datcm@apache.org>
Authored: Wed Jan 3 20:12:53 2018 +0700
Committer: Cao Manh Dat <datcm@apache.org>
Committed: Wed Jan 3 20:12:53 2018 +0700

----------------------------------------------------------------------
 .../src/java/org/apache/solr/cloud/ZkShardTerms.java  | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b52186bf/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java b/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java
index deadf2a..f61ed2c 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java
@@ -65,7 +65,7 @@ public class ZkShardTerms implements AutoCloseable{
     this.shard = shard;
     this.zkClient = zkClient;
     ensureTermNodeExist();
-    updateTerms();
+    refreshTerms();
     ObjectReleaseTracker.track(this);
   }
 
@@ -155,11 +155,11 @@ public class ZkShardTerms implements AutoCloseable{
     byte[] znodeData = Utils.toJSON(newTerms.values);
     try {
       Stat stat = zkClient.setData(znodePath, znodeData, newTerms.version, true);
-      updateTerms(new Terms(newTerms.values, stat.getVersion()));
+      setNewTerms(new Terms(newTerms.values, stat.getVersion()));
       return true;
     } catch (KeeperException.BadVersionException e) {
       log.info("Failed to save terms, version is not match, retrying");
-      updateTerms();
+      refreshTerms();
     } catch (KeeperException.NoNodeException e) {
       throw e;
     } catch (Exception e) {
@@ -196,20 +196,20 @@ public class ZkShardTerms implements AutoCloseable{
     }
   }
 
-  private void updateTerms() {
+  private void refreshTerms() {
     try {
       Watcher watcher = null;
       if (numWatcher.compareAndSet(0, 1)) {
         watcher = event -> {
           numWatcher.decrementAndGet();
-          updateTerms();
+          refreshTerms();
         };
       }
 
       Stat stat = new Stat();
       byte[] data = zkClient.getData(znodePath, watcher, stat, true);
       Terms newTerms = new Terms((Map<String, Long>) Utils.fromJSON(data), stat.getVersion());
-      updateTerms(newTerms);
+      setNewTerms(newTerms);
     } catch (InterruptedException e) {
       Thread.interrupted();
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error updating shard
term for collection:" + collection, e);
@@ -218,7 +218,7 @@ public class ZkShardTerms implements AutoCloseable{
     }
   }
 
-  private void updateTerms(Terms newTerms) {
+  private void setNewTerms(Terms newTerms) {
     boolean isChanged = false;
     synchronized (writingLock) {
       if (terms == null || newTerms.version > terms.version) {


Mime
View raw message