lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpg...@apache.org
Subject lucene-solr:branch_6x: SOLR-3990: Moves getIndexSize() from ReplicationHandler to SolrCore
Date Wed, 04 Jan 2017 23:48:21 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 94dad5b68 -> 973a48e3e


SOLR-3990: Moves getIndexSize() from ReplicationHandler to SolrCore


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

Branch: refs/heads/branch_6x
Commit: 973a48e3e7fddef2ee3a21864783423974d6c6b7
Parents: 94dad5b
Author: Dennis Gove <dpgove@gmail.com>
Authored: Wed Jan 4 18:46:05 2017 -0500
Committer: Dennis Gove <dpgove@gmail.com>
Committed: Wed Jan 4 18:46:05 2017 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 ++
 .../src/java/org/apache/solr/core/SolrCore.java | 20 ++++++++++++++++++++
 .../apache/solr/handler/ReplicationHandler.java | 20 ++------------------
 3 files changed, 24 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/973a48e3/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 912a17c..29256b6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -328,6 +328,8 @@ Other Changes
 * SOLR-9899: StandardDirectoryFactory should use optimizations for all FilterDirectorys not
just NRTCachingDirectory.
   (Mark Miller)
 
+* SOLR-3990: Moves getIndexSize() from ReplicationHandler to SolrCore (Shawn Heisey)
+
 ==================  6.3.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/973a48e3/solr/core/src/java/org/apache/solr/core/SolrCore.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index cd47225..fcd9707 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -146,6 +146,7 @@ import org.apache.solr.update.processor.UpdateRequestProcessorChain;
 import org.apache.solr.update.processor.UpdateRequestProcessorChain.ProcessorInfo;
 import org.apache.solr.update.processor.UpdateRequestProcessorFactory;
 import org.apache.solr.util.DefaultSolrThreadFactory;
+import org.apache.solr.util.NumberUtils;
 import org.apache.solr.util.PropertiesInputStream;
 import org.apache.solr.util.RefCounted;
 import org.apache.solr.util.plugin.NamedListInitializedPlugin;
@@ -391,6 +392,22 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
   public IndexReaderFactory getIndexReaderFactory() {
     return indexReaderFactory;
   }
+  
+  public long getIndexSize() {
+    Directory dir;
+    long size = 0;
+    try {
+      dir = directoryFactory.get(getIndexDir(), DirContext.DEFAULT, solrConfig.indexConfig.lockType);
+      try {
+        size = DirectoryFactory.sizeOfDirectory(dir);
+      } finally {
+        directoryFactory.release(dir);
+      }
+    } catch (IOException e) {
+      SolrException.log(log, "IO error while trying to get the size of the Directory", e);
+    }
+    return size;
+  }
 
   @Override
   public String getName() {
@@ -2635,6 +2652,9 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
     lst.add("refCount", getOpenCount());
     lst.add("instanceDir", resourceLoader.getInstancePath());
     lst.add("indexDir", getIndexDir());
+    long size = getIndexSize();
+    lst.add("sizeInBytes", size);
+    lst.add("size", NumberUtils.readableSize(size));
 
     CoreDescriptor cd = getCoreDescriptor();
     if (cd != null) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/973a48e3/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
index d56d527..b436539 100644
--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@@ -806,22 +806,6 @@ public class ReplicationHandler extends RequestHandlerBase implements
SolrCoreAw
     numTimesReplicated++;
   }
 
-  long getIndexSize() {
-    Directory dir;
-    long size = 0;
-    try {
-      dir = core.getDirectoryFactory().get(core.getIndexDir(), DirContext.DEFAULT, core.getSolrConfig().indexConfig.lockType);
-      try {
-        size = core.getDirectoryFactory().size(dir);
-      } finally {
-        core.getDirectoryFactory().release(dir);
-      }
-    } catch (IOException e) {
-      SolrException.log(LOG, "IO error while trying to get the size of the Directory", e);
-    }
-    return size;
-  }
-
   @Override
   public String getDescription() {
     return "ReplicationHandler provides replication of index and configuration files from
Master to Slaves";
@@ -848,7 +832,7 @@ public class ReplicationHandler extends RequestHandlerBase implements
SolrCoreAw
   public NamedList getStatistics() {
     NamedList list = super.getStatistics();
     if (core != null) {
-      list.add("indexSize", NumberUtils.readableSize(getIndexSize()));
+      list.add("indexSize", NumberUtils.readableSize(core.getIndexSize()));
       CommitVersionInfo vInfo = (core != null && !core.isClosed()) ? getIndexVersion():
null;
       list.add("indexVersion", null == vInfo ? 0 : vInfo.version);
       list.add(GENERATION, null == vInfo ? 0 : vInfo.generation);
@@ -900,7 +884,7 @@ public class ReplicationHandler extends RequestHandlerBase implements
SolrCoreAw
     NamedList<Object> master = new SimpleOrderedMap<>();
     NamedList<Object> slave = new SimpleOrderedMap<>();
 
-    details.add("indexSize", NumberUtils.readableSize(getIndexSize()));
+    details.add("indexSize", NumberUtils.readableSize(core.getIndexSize()));
     details.add("indexPath", core.getIndexDir());
     details.add(CMD_SHOW_COMMITS, getCommits());
     details.add("isMaster", String.valueOf(isMaster));


Mime
View raw message