lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject lucene-solr:branch_6_4: SOLR-10182 Remove metrics collection at Directory level.
Date Mon, 27 Feb 2017 12:40:57 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6_4 5af66d4da -> f622d0ef2


SOLR-10182 Remove metrics collection at Directory level.


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

Branch: refs/heads/branch_6_4
Commit: f622d0ef2bf66245cdf11f3abc67851d9ed73a44
Parents: 5af66d4
Author: Andrzej Bialecki <ab@apache.org>
Authored: Mon Feb 27 12:29:44 2017 +0100
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Mon Feb 27 13:08:27 2017 +0100

----------------------------------------------------------------------
 solr/CHANGES.txt                                |   5 +-
 .../solr/core/MetricsDirectoryFactory.java      | 537 -------------------
 .../src/java/org/apache/solr/core/SolrCore.java |   9 +-
 .../apache/solr/core/SolrDeletionPolicy.java    |   6 -
 .../conf/solrconfig-indexmetrics.xml            |   2 -
 .../solr/handler/TestReplicationHandler.java    |   9 +-
 .../admin/CoreMergeIndexesAdminHandlerTest.java |   8 +-
 .../solr/handler/admin/MBeansHandlerTest.java   |  14 +-
 .../solr/update/SolrIndexMetricsTest.java       |  44 --
 9 files changed, 19 insertions(+), 615 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f622d0ef/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0fcc64f..42942ef 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -34,9 +34,10 @@ Detailed Change List
 
 Bug Fixes
 ----------------------
-* SOLR-10130: Serious performance degradation in Solr 6.4.1 due to the new metrics collection.
+* SOLR-10130, SOLR-10182: Serious performance degradation in Solr 6.4.1 due to the new metrics
collection.
   Default settings in solrconfig.xml /config/indexConfig/metrics have been changed to turn
off
-  IndexWriter and Directory level metrics collection. (ab, ishan)
+  IndexWriter metrics collection. Directory level metrics collection has been completely
removed until
+  a better design is found. (ab, ishan)
 
 * SOLR-10138: Transaction log replay can hit an NPE due to new Metrics code. (ab)
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f622d0ef/solr/core/src/java/org/apache/solr/core/MetricsDirectoryFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/MetricsDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/MetricsDirectoryFactory.java
deleted file mode 100644
index b314ce7..0000000
--- a/solr/core/src/java/org/apache/solr/core/MetricsDirectoryFactory.java
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- * 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;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.Meter;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.FilterDirectory;
-import org.apache.lucene.store.IOContext;
-import org.apache.lucene.store.IndexInput;
-import org.apache.lucene.store.IndexOutput;
-import org.apache.lucene.store.LockFactory;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.metrics.SolrMetricManager;
-import org.apache.solr.util.plugin.SolrCoreAware;
-
-/**
- * An implementation of {@link DirectoryFactory} that decorates provided factory by
- * adding metrics for directory IO operations.
- */
-public class MetricsDirectoryFactory extends DirectoryFactory implements SolrCoreAware {
-  private final SolrMetricManager metricManager;
-  private final String registry;
-  private final DirectoryFactory in;
-  private boolean directoryDetails = false;
-  private boolean directoryTotals = false;
-
-  public MetricsDirectoryFactory(SolrMetricManager metricManager, String registry, DirectoryFactory
in) {
-    this.metricManager = metricManager;
-    this.registry = registry;
-    this.in = in;
-  }
-
-  public DirectoryFactory getDelegate() {
-    return in;
-  }
-
-  /**
-   * Currently the following arguments are supported:
-   * <ul>
-   *   <li><code>directory</code> - (optional bool, default false) when
true then coarse-grained metrics will be collected.</li>
-   *   <li><code>directoryDetails</code> - (optional bool, default false)
when true then additional detailed metrics
-   *   will be collected. These include eg. IO size histograms and per-file counters and
histograms</li>
-   * </ul>
-   * NOTE: please be aware that collecting even coarse-grained metrics can have significant
performance impact
-   * (see SOLR-10130).
-   * @param args init args
-   */
-  @Override
-  public void init(NamedList args) {
-    // should be already inited
-    // in.init(args);
-    if (args == null) {
-      return;
-    }
-    Boolean td = args.getBooleanArg("directory");
-    if (td != null) {
-      directoryTotals = td;
-    } else {
-      directoryTotals = false;
-    }
-    Boolean dd = args.getBooleanArg("directoryDetails");
-    if (dd != null) {
-      directoryDetails = dd;
-    } else {
-      directoryDetails = false;
-    }
-    if (directoryDetails) {
-      directoryTotals = true;
-    }
-  }
-
-  /**
-   * Unwrap just one level if the argument is a {@link MetricsDirectory}
-   * @param dir directory
-   * @return delegate if the instance was a {@link MetricsDirectory}, otherwise unchanged.
-   */
-  private static Directory unwrap(Directory dir) {
-    if (dir instanceof MetricsDirectory) {
-      return ((MetricsDirectory)dir).getDelegate();
-    } else {
-      return dir;
-    }
-  }
-
-  @Override
-  public void doneWithDirectory(Directory dir) throws IOException {
-    dir = unwrap(dir);
-    in.doneWithDirectory(dir);
-  }
-
-  @Override
-  public void addCloseListener(Directory dir, CachingDirectoryFactory.CloseListener closeListener)
{
-    dir = unwrap(dir);
-    in.addCloseListener(dir, closeListener);
-  }
-
-  @Override
-  public void close() throws IOException {
-    in.close();
-  }
-
-  @Override
-  protected Directory create(String path, LockFactory lockFactory, DirContext dirContext)
throws IOException {
-    Directory dir = in.create(path, lockFactory, dirContext);
-    return new MetricsDirectory(metricManager, registry, dir, directoryTotals, directoryDetails);
-  }
-
-  @Override
-  protected LockFactory createLockFactory(String rawLockType) throws IOException {
-    return in.createLockFactory(rawLockType);
-  }
-
-  @Override
-  public boolean exists(String path) throws IOException {
-    return in.exists(path);
-  }
-
-  @Override
-  public void remove(Directory dir) throws IOException {
-    dir = unwrap(dir);
-    in.remove(dir);
-  }
-
-  @Override
-  public void remove(Directory dir, boolean afterCoreClose) throws IOException {
-    dir = unwrap(dir);
-    in.remove(dir, afterCoreClose);
-  }
-
-  @Override
-  public boolean isSharedStorage() {
-    return in.isSharedStorage();
-  }
-
-  @Override
-  public boolean isAbsolute(String path) {
-    return in.isAbsolute(path);
-  }
-
-  @Override
-  public boolean searchersReserveCommitPoints() {
-    return in.searchersReserveCommitPoints();
-  }
-
-  @Override
-  public String getDataHome(CoreDescriptor cd) throws IOException {
-    return in.getDataHome(cd);
-  }
-
-  @Override
-  public long size(Directory dir) throws IOException {
-    dir = unwrap(dir);
-    return in.size(dir);
-  }
-
-  @Override
-  public long size(String path) throws IOException {
-    return in.size(path);
-  }
-
-  @Override
-  public Collection<SolrInfoMBean> offerMBeans() {
-    return in.offerMBeans();
-  }
-
-  @Override
-  public void cleanupOldIndexDirectories(String dataDirPath, String currentIndexDirPath)
{
-    in.cleanupOldIndexDirectories(dataDirPath, currentIndexDirPath);
-  }
-
-  @Override
-  public void remove(String path, boolean afterCoreClose) throws IOException {
-    in.remove(path, afterCoreClose);
-  }
-
-  @Override
-  public void remove(String path) throws IOException {
-    in.remove(path);
-  }
-
-  @Override
-  public void move(Directory fromDir, Directory toDir, String fileName, IOContext ioContext)
throws IOException {
-    fromDir = unwrap(fromDir);
-    toDir = unwrap(toDir);
-    in.move(fromDir, toDir, fileName, ioContext);
-  }
-
-  @Override
-  public void renameWithOverwrite(Directory dir, String fileName, String toName) throws IOException
{
-    dir = unwrap(dir);
-    in.renameWithOverwrite(dir, fileName, toName);
-  }
-
-  @Override
-  public Directory get(String path, DirContext dirContext, String rawLockType) throws IOException
{
-    Directory dir = in.get(path, dirContext, rawLockType);
-    if (dir instanceof MetricsDirectory) {
-      return dir;
-    } else {
-      return new MetricsDirectory(metricManager, registry, dir, directoryTotals, directoryDetails);
-    }
-  }
-
-  @Override
-  public String normalize(String path) throws IOException {
-    return in.normalize(path);
-  }
-
-  @Override
-  protected boolean deleteOldIndexDirectory(String oldDirPath) throws IOException {
-    return in.deleteOldIndexDirectory(oldDirPath);
-  }
-
-  @Override
-  public void initCoreContainer(CoreContainer cc) {
-    in.initCoreContainer(cc);
-  }
-
-  @Override
-  public void incRef(Directory dir) {
-    dir = unwrap(dir);
-    in.incRef(dir);
-  }
-
-  @Override
-  public boolean isPersistent() {
-    return in.isPersistent();
-  }
-
-  @Override
-  public void inform(SolrCore core) {
-    if (in instanceof  SolrCoreAware) {
-      ((SolrCoreAware)in).inform(core);
-    }
-  }
-
-  @Override
-  public void release(Directory dir) throws IOException {
-    dir = unwrap(dir);
-    in.release(dir);
-  }
-
-
-
-  private static final String SEGMENTS = "segments";
-  private static final String SEGMENTS_PREFIX = "segments_";
-  private static final String PENDING_SEGMENTS_PREFIX = "pending_segments_";
-  private static final String TEMP = "temp";
-  private static final String OTHER = "other";
-
-  public static class MetricsDirectory extends FilterDirectory {
-
-    private final Directory in;
-    private final String registry;
-    private final SolrMetricManager metricManager;
-    private final Meter totalReads;
-    private final Histogram totalReadSizes;
-    private final Meter totalWrites;
-    private final Histogram totalWriteSizes;
-    private final boolean directoryDetails;
-    private final boolean directoryTotals;
-
-    private final String PREFIX = SolrInfoMBean.Category.DIRECTORY.toString() + ".";
-
-    public MetricsDirectory(SolrMetricManager metricManager, String registry, Directory in,
boolean directoryTotals,
-                            boolean directoryDetails) throws IOException {
-      super(in);
-      this.metricManager = metricManager;
-      this.registry = registry;
-      this.in = in;
-      this.directoryDetails = directoryDetails;
-      this.directoryTotals = directoryTotals;
-      if (directoryTotals) {
-        this.totalReads = metricManager.meter(registry, "reads", SolrInfoMBean.Category.DIRECTORY.toString(),
"total");
-        this.totalWrites = metricManager.meter(registry, "writes", SolrInfoMBean.Category.DIRECTORY.toString(),
"total");
-        if (directoryDetails) {
-          this.totalReadSizes = metricManager.histogram(registry, "readSizes", SolrInfoMBean.Category.DIRECTORY.toString(),
"total");
-          this.totalWriteSizes = metricManager.histogram(registry, "writeSizes", SolrInfoMBean.Category.DIRECTORY.toString(),
"total");
-        } else {
-          this.totalReadSizes = null;
-          this.totalWriteSizes = null;
-        }
-      } else {
-        this.totalReads = null;
-        this.totalWrites = null;
-        this.totalReadSizes = null;
-        this.totalWriteSizes = null;
-      }
-    }
-
-    private String getMetricName(String name, boolean output) {
-      if (!directoryDetails) {
-        return null;
-      }
-      String lastName;
-      if (name.startsWith(SEGMENTS_PREFIX) || name.startsWith(PENDING_SEGMENTS_PREFIX)) {
-        lastName = SEGMENTS;
-      } else {
-        int pos = name.lastIndexOf('.');
-        if (pos != -1 && name.length() > pos + 1) {
-          lastName = name.substring(pos + 1);
-        } else {
-          lastName = OTHER;
-        }
-      }
-      StringBuilder sb = new StringBuilder(PREFIX);
-      sb.append(lastName);
-      sb.append('.');
-      if (output) {
-        sb.append("write");
-      } else {
-        sb.append("read");
-      }
-      return sb.toString();
-    }
-
-    @Override
-    public IndexOutput createOutput(String name, IOContext context) throws IOException {
-      IndexOutput output = in.createOutput(name, context);
-      if (!directoryTotals) {
-        return output;
-      }
-      if (output != null) {
-        return new MetricsOutput(totalWrites, totalWriteSizes, metricManager, registry, getMetricName(name,
true), output);
-      } else {
-        return null;
-      }
-    }
-
-    @Override
-    public IndexOutput createTempOutput(String prefix, String suffix, IOContext context)
throws IOException {
-      IndexOutput output = in.createTempOutput(prefix, suffix, context);
-      if (!directoryTotals) {
-        return output;
-      }
-      if (output != null) {
-        return new MetricsOutput(totalWrites, totalWriteSizes, metricManager, registry, getMetricName(TEMP,
true), output);
-      } else {
-        return null;
-      }
-    }
-
-    @Override
-    public IndexInput openInput(String name, IOContext context) throws IOException {
-      IndexInput input = in.openInput(name, context);
-      if (!directoryTotals) {
-        return input;
-      }
-      if (input != null) {
-        return new MetricsInput(totalReads, totalReadSizes, metricManager, registry, getMetricName(name,
false), input);
-      } else {
-        return null;
-      }
-    }
-  }
-
-  public static class MetricsOutput extends IndexOutput {
-    private final IndexOutput in;
-    private final Histogram histogram;
-    private final Meter meter;
-    private final Meter totalMeter;
-    private final Histogram totalHistogram;
-    private final boolean withDetails;
-
-    public MetricsOutput(Meter totalMeter, Histogram totalHistogram, SolrMetricManager metricManager,
-                         String registry, String metricName, IndexOutput in) {
-      super(in.toString(), in.getName());
-      this.in = in;
-      this.totalMeter = totalMeter;
-      this.totalHistogram = totalHistogram;
-      if (metricName != null && totalHistogram != null) {
-        withDetails = true;
-        String histName = metricName + "Sizes";
-        String meterName = metricName + "s";
-        this.histogram = metricManager.histogram(registry, histName);
-        this.meter = metricManager.meter(registry, meterName);
-      } else {
-        withDetails = false;
-        this.histogram = null;
-        this.meter = null;
-      }
-    }
-
-    @Override
-    public void writeByte(byte b) throws IOException {
-      in.writeByte(b);
-      totalMeter.mark();
-      if (withDetails) {
-        totalHistogram.update(1);
-        meter.mark();
-        histogram.update(1);
-      }
-    }
-
-    @Override
-    public void writeBytes(byte[] b, int offset, int length) throws IOException {
-      in.writeBytes(b, offset, length);
-      totalMeter.mark(length);
-      if (withDetails) {
-        totalHistogram.update(length);
-        meter.mark(length);
-        histogram.update(length);
-      }
-    }
-
-    @Override
-    public void close() throws IOException {
-      in.close();
-    }
-
-    @Override
-    public long getFilePointer() {
-      return in.getFilePointer();
-    }
-
-    @Override
-    public long getChecksum() throws IOException {
-      return in.getChecksum();
-    }
-  }
-
-  public static class MetricsInput extends IndexInput {
-    private final IndexInput in;
-    private final Meter totalMeter;
-    private final Histogram totalHistogram;
-    private final Histogram histogram;
-    private final Meter meter;
-    private final boolean withDetails;
-
-    public MetricsInput(Meter totalMeter, Histogram totalHistogram, SolrMetricManager metricManager,
String registry, String metricName, IndexInput in) {
-      super(in.toString());
-      this.in = in;
-      this.totalMeter = totalMeter;
-      this.totalHistogram = totalHistogram;
-      if (metricName != null && totalHistogram != null) {
-        withDetails = true;
-        String histName = metricName + "Sizes";
-        String meterName = metricName + "s";
-        this.histogram = metricManager.histogram(registry, histName);
-        this.meter = metricManager.meter(registry, meterName);
-      } else {
-        withDetails = false;
-        this.histogram = null;
-        this.meter = null;
-      }
-    }
-
-    public MetricsInput(Meter totalMeter, Histogram totalHistogram, Histogram histogram,
Meter meter, IndexInput in) {
-      super(in.toString());
-      this.in = in;
-      this.totalMeter = totalMeter;
-      this.totalHistogram  = totalHistogram;
-      this.histogram = histogram;
-      this.meter = meter;
-      if (totalHistogram != null && meter != null && histogram != null) {
-        withDetails = true;
-      } else {
-        withDetails = false;
-      }
-    }
-
-    @Override
-    public void close() throws IOException {
-      in.close();
-    }
-
-    @Override
-    public long getFilePointer() {
-      return in.getFilePointer();
-    }
-
-    @Override
-    public void seek(long pos) throws IOException {
-      in.seek(pos);
-    }
-
-    @Override
-    public long length() {
-      return in.length();
-    }
-
-    @Override
-    public IndexInput clone() {
-      return new MetricsInput(totalMeter, totalHistogram, histogram, meter, in.clone());
-    }
-
-    @Override
-    public IndexInput slice(String sliceDescription, long offset, long length) throws IOException
{
-      IndexInput slice = in.slice(sliceDescription, offset, length);
-      if (slice != null) {
-        return new MetricsInput(totalMeter, totalHistogram, histogram, meter, slice);
-      } else {
-        return null;
-      }
-    }
-
-    @Override
-    public byte readByte() throws IOException {
-      totalMeter.mark();
-      if (withDetails) {
-        totalHistogram.update(1);
-        meter.mark();
-        histogram.update(1);
-      }
-      return in.readByte();
-    }
-
-    @Override
-    public void readBytes(byte[] b, int offset, int len) throws IOException {
-      totalMeter.mark(len);
-      if (withDetails) {
-        totalHistogram.update(len);
-        meter.mark(len);
-        histogram.update(len);
-      }
-      in.readBytes(b, offset, len);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f622d0ef/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 ce72b58..c68f0ca 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -659,14 +659,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
       dirFactory = new NRTCachingDirectoryFactory();
       dirFactory.initCoreContainer(getCoreDescriptor().getCoreContainer());
     }
-    if (solrConfig.indexConfig.metricsInfo != null && solrConfig.indexConfig.metricsInfo.isEnabled())
{
-      final DirectoryFactory factory = new MetricsDirectoryFactory(coreDescriptor.getCoreContainer().getMetricManager(),
-          coreMetricManager.getRegistryName(), dirFactory);
-        factory.init(solrConfig.indexConfig.metricsInfo.initArgs);
-      return factory;
-    } else {
-      return dirFactory;
-    }
+    return dirFactory;
   }
 
   private void initIndexReaderFactory() {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f622d0ef/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java b/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java
index eba2964..34482cd 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java
@@ -114,9 +114,6 @@ public class SolrDeletionPolicy extends IndexDeletionPolicy implements
NamedList
 
     protected void appendDetails(StringBuilder sb, IndexCommit c) {
       Directory dir = c.getDirectory();
-      if (dir instanceof MetricsDirectoryFactory.MetricsDirectory) { // unwrap
-        dir = ((MetricsDirectoryFactory.MetricsDirectory) dir).getDelegate();
-      }
       if (dir instanceof FSDirectory) {
         FSDirectory fsd = (FSDirectory) dir;
         sb.append("dir=").append(fsd.getDirectory());
@@ -197,9 +194,6 @@ public class SolrDeletionPolicy extends IndexDeletionPolicy implements
NamedList
   private String getId(IndexCommit commit) {
     StringBuilder sb = new StringBuilder();
     Directory dir = commit.getDirectory();
-    if (dir instanceof MetricsDirectoryFactory.MetricsDirectory) { // unwrap
-      dir = ((MetricsDirectoryFactory.MetricsDirectory) dir).getDelegate();
-    }
 
     // For anything persistent, make something that will
     // be the same, regardless of the Directory instance.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f622d0ef/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexmetrics.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexmetrics.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexmetrics.xml
index 188340d..6cf54d5 100644
--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexmetrics.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexmetrics.xml
@@ -29,8 +29,6 @@
 
   <indexConfig>
     <metrics>
-      <bool name="directory">${solr.tests.metrics.directory:false}</bool>
-      <bool name="directoryDetails">${solr.tests.metrics.directoryDetails:false}</bool>
       <bool name="merge">${solr.tests.metrics.merge:false}</bool>
       <bool name="mergeDetails">${solr.tests.metrics.mergeDetails:false}</bool>
     </metrics>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f622d0ef/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
index a2178db..0f44280 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
@@ -66,8 +66,6 @@ import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.CachingDirectoryFactory;
 import org.apache.solr.core.CoreContainer;
-import org.apache.solr.core.DirectoryFactory;
-import org.apache.solr.core.MetricsDirectoryFactory;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.StandardDirectoryFactory;
 import org.apache.solr.core.snapshots.SolrSnapshotMetaDataManager;
@@ -900,12 +898,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
   }
 
   private CachingDirectoryFactory getCachingDirectoryFactory(SolrCore core) {
-    DirectoryFactory df = core.getDirectoryFactory();
-    if (df instanceof MetricsDirectoryFactory) {
-      return (CachingDirectoryFactory)((MetricsDirectoryFactory)df).getDelegate();
-    } else {
-      return (CachingDirectoryFactory)df;
-    }
+    return (CachingDirectoryFactory) core.getDirectoryFactory();
   }
 
   private void checkForSingleIndex(JettySolrRunner jetty) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f622d0ef/solr/core/src/test/org/apache/solr/handler/admin/CoreMergeIndexesAdminHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/CoreMergeIndexesAdminHandlerTest.java
b/solr/core/src/test/org/apache/solr/handler/admin/CoreMergeIndexesAdminHandlerTest.java
index 937cc86..d026ecd 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/CoreMergeIndexesAdminHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/CoreMergeIndexesAdminHandlerTest.java
@@ -25,7 +25,6 @@ import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.DirectoryFactory;
-import org.apache.solr.core.MetricsDirectoryFactory;
 import org.apache.solr.core.MockFSDirectoryFactory;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.response.SolrQueryResponse;
@@ -78,12 +77,7 @@ public class CoreMergeIndexesAdminHandlerTest extends SolrTestCaseJ4 {
 
     try (SolrCore core = cores.getCore("collection1")) {
       DirectoryFactory df = core.getDirectoryFactory();
-      FailingDirectoryFactory dirFactory;
-      if (df instanceof MetricsDirectoryFactory) {
-        dirFactory = (FailingDirectoryFactory)((MetricsDirectoryFactory)df).getDelegate();
-      } else {
-        dirFactory = (FailingDirectoryFactory)df;
-      }
+      FailingDirectoryFactory dirFactory = (FailingDirectoryFactory) df;
 
       try {
         dirFactory.fail = true;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f622d0ef/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
index a5e0a6c..1617b1e 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
@@ -18,6 +18,8 @@ package org.apache.solr.handler.admin;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.CommonParams;
@@ -60,7 +62,17 @@ public class MBeansHandlerTest extends SolrTestCaseJ4 {
     NamedList stats = (NamedList)diff.get("ADMIN").get("/admin/mbeans").get("stats");
     
     //System.out.println("stats:"+stats);
-    assertEquals("Was: 1, Now: 2, Delta: 1", stats.get("requests"));
+    Pattern p = Pattern.compile("Was: (?<was>[0-9]+), Now: (?<now>[0-9]+), Delta:
(?<delta>[0-9]+)");
+    String response = stats.get("requests").toString();
+    Matcher m = p.matcher(response);
+    if (!m.matches()) {
+      fail("Response did not match pattern: " + response);
+    }
+
+    assertEquals(1, Integer.parseInt(m.group("delta")));
+    int was = Integer.parseInt(m.group("was"));
+    int now = Integer.parseInt(m.group("now"));
+    assertEquals(1, now - was);
 
     xml = h.query(req(
         CommonParams.QT,"/admin/mbeans",

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f622d0ef/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java b/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java
index 48446e1..c9935bb 100644
--- a/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java
+++ b/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java
@@ -18,7 +18,6 @@ package org.apache.solr.update;
 
 import java.util.Map;
 
-import com.codahale.metrics.Histogram;
 import com.codahale.metrics.Meter;
 import com.codahale.metrics.Metric;
 import com.codahale.metrics.MetricRegistry;
@@ -59,8 +58,6 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {
   public void testIndexMetricsNoDetails() throws Exception {
     System.setProperty("solr.tests.metrics.merge", "true");
     System.setProperty("solr.tests.metrics.mergeDetails", "false");
-    System.setProperty("solr.tests.metrics.directory", "true");
-    System.setProperty("solr.tests.metrics.directoryDetails", "false");
     initCore("solrconfig-indexmetrics.xml", "schema.xml");
 
     addDocs();
@@ -71,7 +68,6 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {
     Map<String, Metric> metrics = registry.getMetrics();
 
     assertEquals(10, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count());
-    assertEquals(2, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("DIRECTORY")).count());
 
     // check basic index meters
     Timer timer = (Timer)metrics.get("INDEX.merge.minor");
@@ -82,30 +78,12 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {
     assertNull((Meter)metrics.get("INDEX.merge.major.docs"));
     Meter meter = (Meter)metrics.get("INDEX.flush");
     assertTrue("flush: " + meter.getCount(), meter.getCount() > 10);
-
-    // check basic directory meters
-    meter = (Meter)metrics.get("DIRECTORY.total.reads");
-    assertTrue("totalReads", meter.getCount() > 0);
-    meter = (Meter)metrics.get("DIRECTORY.total.writes");
-    assertTrue("totalWrites", meter.getCount() > 0);
-    // check detailed meters
-    Histogram histogram = (Histogram)metrics.get("DIRECTORY.total.readSizes");
-    assertNull("readSizes", histogram);
-    histogram = (Histogram)metrics.get("DIRECTORY.total.writeSizes");
-    assertNull("writeSizes", histogram);
-    meter = (Meter)metrics.get("DIRECTORY.segments.writes");
-    assertNull("segmentsWrites", meter);
-    histogram = (Histogram)metrics.get("DIRECTORY.segments.writeSizes");
-    assertNull("segmentsWriteSizes", histogram);
-
   }
 
   @Test
   public void testIndexNoMetrics() throws Exception {
     System.setProperty("solr.tests.metrics.merge", "false");
     System.setProperty("solr.tests.metrics.mergeDetails", "false");
-    System.setProperty("solr.tests.metrics.directory", "false");
-    System.setProperty("solr.tests.metrics.directoryDetails", "false");
     initCore("solrconfig-indexmetrics.xml", "schema.xml");
 
     addDocs();
@@ -115,16 +93,12 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {
 
     Map<String, Metric> metrics = registry.getMetrics();
     assertEquals(0, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count());
-    // this is variable, depending on the codec and the number of created files
-    assertEquals(0, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("DIRECTORY")).count());
   }
 
   @Test
   public void testIndexMetricsWithDetails() throws Exception {
     System.setProperty("solr.tests.metrics.merge", "false"); // test mergeDetails override
too
     System.setProperty("solr.tests.metrics.mergeDetails", "true");
-    System.setProperty("solr.tests.metrics.directory", "false");
-    System.setProperty("solr.tests.metrics.directoryDetails", "true");
     initCore("solrconfig-indexmetrics.xml", "schema.xml");
 
     addDocs();
@@ -135,8 +109,6 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {
     Map<String, Metric> metrics = registry.getMetrics();
 
     assertTrue(metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count()
>= 12);
-    // this is variable, depending on the codec and the number of created files
-    assertTrue(metrics.entrySet().stream().filter(e -> e.getKey().startsWith("DIRECTORY")).count()
> 50);
 
     // check basic index meters
     Timer timer = (Timer)metrics.get("INDEX.merge.minor");
@@ -149,21 +121,5 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {
 
     meter = (Meter)metrics.get("INDEX.flush");
     assertTrue("flush: " + meter.getCount(), meter.getCount() > 10);
-
-    // check basic directory meters
-    meter = (Meter)metrics.get("DIRECTORY.total.reads");
-    assertTrue("totalReads", meter.getCount() > 0);
-    meter = (Meter)metrics.get("DIRECTORY.total.writes");
-    assertTrue("totalWrites", meter.getCount() > 0);
-    // check detailed meters
-    Histogram histogram = (Histogram)metrics.get("DIRECTORY.total.readSizes");
-    assertTrue("readSizes", histogram.getCount() > 0);
-    histogram = (Histogram)metrics.get("DIRECTORY.total.writeSizes");
-    assertTrue("writeSizes", histogram.getCount() > 0);
-    meter = (Meter)metrics.get("DIRECTORY.segments.writes");
-    assertTrue("segmentsWrites", meter.getCount() > 0);
-    histogram = (Histogram)metrics.get("DIRECTORY.segments.writeSizes");
-    assertTrue("segmentsWriteSizes", histogram.getCount() > 0);
-
   }
 }


Mime
View raw message