You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2017/03/16 08:12:23 UTC
[01/19] lucene-solr:feature/autoscaling: SOLR-10302: Solr's zkcli
scripts now able to find the metrics libraries
Repository: lucene-solr
Updated Branches:
refs/heads/feature/autoscaling 76de819c7 -> 1fe4cff22
SOLR-10302: Solr's zkcli scripts now able to find the metrics libraries
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1fe4cff2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1fe4cff2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1fe4cff2
Branch: refs/heads/feature/autoscaling
Commit: 1fe4cff22cec810a9035da5ad6dcc1b747ad48c4
Parents: 260159a
Author: Ishan Chattopadhyaya <is...@apache.org>
Authored: Thu Mar 16 05:32:27 2017 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
solr/server/scripts/cloud-scripts/zkcli.bat | 2 +-
solr/server/scripts/cloud-scripts/zkcli.sh | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1fe4cff2/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f1a12ea..5e2a518 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -258,6 +258,8 @@ Bug Fixes
* SOLR-9516: Admin UI (angular) now works with Kerberos, by excluding serving of /solr/libs/* through
SolrDispatchFilter. (Cassandra Targett, Amrit Sarkar via Ishan Chattopadhyaya)
+* SOLR-10302: Solr's zkcli scripts now able to find the metrics libraries, which it couldn't earlier (kiran, Ishan Chattopadhyaya)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1fe4cff2/solr/server/scripts/cloud-scripts/zkcli.bat
----------------------------------------------------------------------
diff --git a/solr/server/scripts/cloud-scripts/zkcli.bat b/solr/server/scripts/cloud-scripts/zkcli.bat
index c372685..c5d7b72 100644
--- a/solr/server/scripts/cloud-scripts/zkcli.bat
+++ b/solr/server/scripts/cloud-scripts/zkcli.bat
@@ -22,4 +22,4 @@ REM -DzkDigestUsername=admin-user -DzkDigestPassword=CHANGEME-ADMIN-PASSWORD ^
REM -DzkDigestReadonlyUsername=readonly-user -DzkDigestReadonlyPassword=CHANGEME-READONLY-PASSWORD
"%JVM%" %SOLR_ZK_CREDS_AND_ACLS% %ZKCLI_JVM_FLAGS% -Dlog4j.configuration="%LOG4J_CONFIG%" ^
--classpath "%SDIR%\..\..\solr-webapp\webapp\WEB-INF\lib\*;%SDIR%\..\..\lib\ext\*" org.apache.solr.cloud.ZkCLI %*
+-classpath "%SDIR%\..\..\solr-webapp\webapp\WEB-INF\lib\*;%SDIR%\..\..\lib\ext\*;%SDIR%\..\..\lib\*" org.apache.solr.cloud.ZkCLI %*
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1fe4cff2/solr/server/scripts/cloud-scripts/zkcli.sh
----------------------------------------------------------------------
diff --git a/solr/server/scripts/cloud-scripts/zkcli.sh b/solr/server/scripts/cloud-scripts/zkcli.sh
index df43265..bd971e9 100755
--- a/solr/server/scripts/cloud-scripts/zkcli.sh
+++ b/solr/server/scripts/cloud-scripts/zkcli.sh
@@ -22,5 +22,5 @@ fi
# -DzkDigestReadonlyUsername=readonly-user -DzkDigestReadonlyPassword=CHANGEME-READONLY-PASSWORD"
PATH=$JAVA_HOME/bin:$PATH $JVM $SOLR_ZK_CREDS_AND_ACLS $ZKCLI_JVM_FLAGS -Dlog4j.configuration=$log4j_config \
--classpath "$sdir/../../solr-webapp/webapp/WEB-INF/lib/*:$sdir/../../lib/ext/*" org.apache.solr.cloud.ZkCLI ${1+"$@"}
+-classpath "$sdir/../../solr-webapp/webapp/WEB-INF/lib/*:$sdir/../../lib/ext/*:$sdir/../../lib/*" org.apache.solr.cloud.ZkCLI ${1+"$@"}
[03/19] lucene-solr:feature/autoscaling: SOLR-9516: Fix: Admin UI
(angular) didn't work with Kerberos
Posted by sh...@apache.org.
SOLR-9516: Fix: Admin UI (angular) didn't work with Kerberos
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/cce7ba9b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/cce7ba9b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/cce7ba9b
Branch: refs/heads/feature/autoscaling
Commit: cce7ba9b2f1849930fc83cb5ede580f26c6d31f6
Parents: 10b7be5
Author: Ishan Chattopadhyaya <is...@apache.org>
Authored: Wed Mar 15 17:25:06 2017 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
solr/webapp/web/WEB-INF/web.xml | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cce7ba9b/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b3ce30c..0f1f488 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -253,6 +253,8 @@ Bug Fixes
* SOLR-10184: Fix bin/solr so it can run properly on java9 (hossman, Uwe Schindler)
+* SOLR-9516: Admin UI (angular) didn't work with Kerberos (Cassandra Targett, Amrit Sarkar via Ishan Chattopadhyaya)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cce7ba9b/solr/webapp/web/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/solr/webapp/web/WEB-INF/web.xml b/solr/webapp/web/WEB-INF/web.xml
index 5278ae5..5ebce10 100644
--- a/solr/webapp/web/WEB-INF/web.xml
+++ b/solr/webapp/web/WEB-INF/web.xml
@@ -56,7 +56,7 @@
-->
<init-param>
<param-name>excludePatterns</param-name>
- <param-value>/css/.+,/js/.+,/img/.+,/tpl/.+</param-value>
+ <param-value>/libs/.+,/css/.+,/js/.+,/img/.+,/tpl/.+</param-value>
</init-param>
</filter>
[13/19] lucene-solr:feature/autoscaling: SOLR-8045: SerachHandler to
override the registerV2() and remove registerPath from sample solrconfig.xml
Posted by sh...@apache.org.
SOLR-8045: SerachHandler to override the registerV2() and remove registerPath from sample solrconfig.xml
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e66924cc
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e66924cc
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e66924cc
Branch: refs/heads/feature/autoscaling
Commit: e66924cc5c58c24148236aa22858bf1aa9fd9240
Parents: 533f968
Author: Noble Paul <no...@apache.org>
Authored: Wed Mar 15 18:38:48 2017 +1030
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
.../java/org/apache/solr/handler/component/SearchHandler.java | 5 +++++
.../configsets/sample_techproducts_configs/conf/solrconfig.xml | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e66924cc/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
index ba581d4..c05c6c4 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
@@ -478,6 +478,11 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware ,
}
return sb.toString();
}
+
+ @Override
+ public Boolean registerV2() {
+ return Boolean.TRUE;
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e66924cc/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
----------------------------------------------------------------------
diff --git a/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml b/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
index 3ff89c0..23c2acd 100644
--- a/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
+++ b/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
@@ -850,7 +850,7 @@
</requestHandler>
<!-- A request handler that returns indented JSON by default -->
- <requestHandler name="/query" class="solr.SearchHandler" registerPath="/solr,/v2">
+ <requestHandler name="/query" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="wt">json</str>
[08/19] lucene-solr:feature/autoscaling: SOLR-9045: exclude static
methods from ConfigureRecoveryStrategyTest.testAlmostAllMethodsAreFinal
Posted by sh...@apache.org.
SOLR-9045: exclude static methods from ConfigureRecoveryStrategyTest.testAlmostAllMethodsAreFinal
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6163956a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6163956a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6163956a
Branch: refs/heads/feature/autoscaling
Commit: 6163956a1b303ca3690715f91ad737dab78b84ea
Parents: 52b3bc2
Author: Christine Poerschke <cp...@apache.org>
Authored: Tue Mar 14 13:05:55 2017 +0000
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
.../test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6163956a/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java b/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java
index 80032af..0a988f6 100644
--- a/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java
+++ b/solr/core/src/test/org/apache/solr/core/ConfigureRecoveryStrategyTest.java
@@ -66,6 +66,7 @@ public class ConfigureRecoveryStrategyTest extends SolrTestCaseJ4 {
public void testAlmostAllMethodsAreFinal() throws Exception {
for (Method m : RecoveryStrategy.class.getDeclaredMethods()) {
+ if (Modifier.isStatic(m.getModifiers())) continue;
final String methodName = m.getName();
if ("getReplicateLeaderUrl".equals(methodName)) {
assertFalse(m.toString(), Modifier.isFinal(m.getModifiers()));
[07/19] lucene-solr:feature/autoscaling: SOLR-10076: Hide keystore
and truststore passwords from /admin/info/* outputs.
Posted by sh...@apache.org.
SOLR-10076: Hide keystore and truststore passwords from /admin/info/* outputs.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/bb3d2e15
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/bb3d2e15
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/bb3d2e15
Branch: refs/heads/feature/autoscaling
Commit: bb3d2e15f6379f349e1552a078b82bd86cf71023
Parents: cab7e1a
Author: markrmiller <ma...@apache.org>
Authored: Tue Mar 14 06:13:34 2017 -0400
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 2 +
.../handler/admin/PropertiesRequestHandler.java | 27 ++++++--
.../solr/handler/admin/SystemInfoHandler.java | 20 +++++-
.../org/apache/solr/util/RedactionUtils.java | 51 ++++++++++++++
.../admin/PropertiesRequestHandlerTest.java | 73 ++++++++++++++++++++
5 files changed, 165 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bb3d2e15/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 280f165..4c987db 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -181,6 +181,8 @@ New Features
* SOLR-9045: Make RecoveryStrategy settings configurable. (Christine Poerschke)
+* SOLR-10076: Hide keystore and truststore passwords from /admin/info/* outputs. (Mano Kovacs via Mark Miller)
+
Bug Fixes
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bb3d2e15/solr/core/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
index c16cded..57a7492 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
@@ -17,12 +17,14 @@
package org.apache.solr.handler.admin;
import java.io.IOException;
+import java.util.Enumeration;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.util.RedactionUtils;
import static org.apache.solr.common.params.CommonParams.NAME;
@@ -32,23 +34,36 @@ import static org.apache.solr.common.params.CommonParams.NAME;
*/
public class PropertiesRequestHandler extends RequestHandlerBase
{
+
+ public static final String REDACT_STRING = RedactionUtils.getRedactString();
+
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException
{
- Object props = null;
+ NamedList<String> props = new SimpleOrderedMap<>();
String name = req.getParams().get(NAME);
if( name != null ) {
- NamedList<String> p = new SimpleOrderedMap<>();
- p.add( name, System.getProperty(name) );
- props = p;
+ String property = getSecuredPropertyValue(name);
+ props.add( name, property);
}
else {
- props = System.getProperties();
+ Enumeration<?> enumeration = System.getProperties().propertyNames();
+ while(enumeration.hasMoreElements()){
+ name = (String) enumeration.nextElement();
+ props.add(name, getSecuredPropertyValue(name));
+ }
}
rsp.add( "system.properties", props );
rsp.setHttpCaching(false);
}
-
+
+ private String getSecuredPropertyValue(String name) {
+ if(RedactionUtils.isSystemPropertySensitive(name)){
+ return REDACT_STRING;
+ }
+ return System.getProperty(name);
+ }
+
//////////////////////// SolrInfoMBeans methods //////////////////////
@Override
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bb3d2e15/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
index d031d69..94fb055 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
@@ -36,6 +36,8 @@ import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Arrays;
import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Locale;
import org.apache.commons.io.IOUtils;
@@ -50,7 +52,7 @@ import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.util.RTimer;
-
+import org.apache.solr.util.RedactionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,6 +68,8 @@ public class SystemInfoHandler extends RequestHandlerBase
{
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ public static String REDACT_STRING = RedactionUtils.getRedactString();
+
/**
* <p>
* Undocumented expert level system property to prevent doing a reverse lookup of our hostname.
@@ -373,7 +377,7 @@ public class SystemInfoHandler extends RequestHandlerBase
// the input arguments passed to the Java virtual machine
// which does not include the arguments to the main method.
- jmx.add( "commandLineArgs", mx.getInputArguments());
+ jmx.add( "commandLineArgs", getInputArgumentsRedacted(mx));
jmx.add( "startTime", new Date(mx.getStartTime()));
jmx.add( "upTimeMS", mx.getUptime() );
@@ -436,6 +440,18 @@ public class SystemInfoHandler extends RequestHandlerBase
return newSizeAndUnits;
}
+
+ private static List<String> getInputArgumentsRedacted(RuntimeMXBean mx) {
+ List<String> list = new LinkedList<>();
+ for (String arg : mx.getInputArguments()) {
+ if (arg.startsWith("-D") && arg.contains("=") && RedactionUtils.isSystemPropertySensitive(arg.substring(2, arg.indexOf("=")))) {
+ list.add(String.format("%s=%s", arg.substring(0, arg.indexOf("=")), REDACT_STRING));
+ } else {
+ list.add(arg);
+ }
+ }
+ return list;
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bb3d2e15/solr/core/src/java/org/apache/solr/util/RedactionUtils.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/RedactionUtils.java b/solr/core/src/java/org/apache/solr/util/RedactionUtils.java
new file mode 100644
index 0000000..afa2abf
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/util/RedactionUtils.java
@@ -0,0 +1,51 @@
+/*
+ * 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.util;
+
+import java.util.regex.Pattern;
+
+public class RedactionUtils {
+ public static final String SOLR_REDACTION_SYSTEM_PATTERN_PROP = "solr.redaction.system.pattern";
+ private static Pattern pattern = Pattern.compile(System.getProperty(SOLR_REDACTION_SYSTEM_PATTERN_PROP, ".*password.*"), Pattern.CASE_INSENSITIVE);
+ private static final String REDACT_STRING = "--REDACTED--";
+
+ private static boolean redactSystemProperty = Boolean.parseBoolean(System.getProperty("solr.redaction.system.enabled", "true"));
+
+ /**
+ * Returns if the given system property should be redacted.
+ *
+ * @param name The system property that is being checked.
+ * @return true if property should be redacted.
+ */
+ static public boolean isSystemPropertySensitive(String name) {
+ return redactSystemProperty && pattern.matcher(name).matches();
+ }
+
+ /**
+ * @return redaction string to be used instead of the value.
+ */
+ static public String getRedactString() {
+ return REDACT_STRING;
+ }
+
+ public static void setRedactSystemProperty(boolean redactSystemProperty) {
+ RedactionUtils.redactSystemProperty = redactSystemProperty;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bb3d2e15/solr/core/src/test/org/apache/solr/handler/admin/PropertiesRequestHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/PropertiesRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/PropertiesRequestHandlerTest.java
new file mode 100644
index 0000000..1a959a4
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/handler/admin/PropertiesRequestHandlerTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.handler.admin;
+
+import java.io.StringReader;
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.impl.XMLResponseParser;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.util.RedactionUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+public class PropertiesRequestHandlerTest extends SolrTestCaseJ4 {
+
+ public static final String PASSWORD = "secret123";
+ public static final String REDACT_STRING = RedactionUtils.getRedactString();
+
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
+
+ @Test
+ public void testRedaction() throws Exception {
+ RedactionUtils.setRedactSystemProperty(true);
+ for(String propName: new String[]{"some.password", "javax.net.ssl.trustStorePassword"}){
+ System.setProperty(propName, PASSWORD);
+ NamedList<NamedList<NamedList<Object>>> properties = readProperties();
+
+ assertEquals("Failed to redact "+propName, REDACT_STRING, properties.get(propName));
+ }
+ }
+
+ @Test
+ public void testDisabledRedaction() throws Exception {
+ RedactionUtils.setRedactSystemProperty(false);
+ for(String propName: new String[]{"some.password", "javax.net.ssl.trustStorePassword"}){
+ System.setProperty(propName, PASSWORD);
+ NamedList<NamedList<NamedList<Object>>> properties = readProperties();
+
+ assertEquals("Failed to *not* redact "+propName, PASSWORD, properties.get(propName));
+ }
+ }
+
+ private NamedList<NamedList<NamedList<Object>>> readProperties() throws Exception {
+ String xml = h.query(req(
+ CommonParams.QT, "/admin/properties",
+ CommonParams.WT, "xml"
+ ));
+
+ XMLResponseParser parser = new XMLResponseParser();
+ return (NamedList<NamedList<NamedList<Object>>>)
+ parser.processResponse(new StringReader(xml)).get("system.properties");
+ }
+}
\ No newline at end of file
[17/19] lucene-solr:feature/autoscaling: SOLR-9516: Updating
CHANGES.txt entry
Posted by sh...@apache.org.
SOLR-9516: Updating CHANGES.txt entry
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/482ec73a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/482ec73a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/482ec73a
Branch: refs/heads/feature/autoscaling
Commit: 482ec73ae5be7af0be8ec12bcbe86bc8dff6cccc
Parents: 0170df9
Author: Ishan Chattopadhyaya <is...@apache.org>
Authored: Thu Mar 16 02:03:09 2017 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/482ec73a/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6829cd1..f1a12ea 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -255,7 +255,8 @@ Bug Fixes
* SOLR-10184: Fix bin/solr so it can run properly on java9 (hossman, Uwe Schindler)
-* SOLR-9516: Admin UI (angular) didn't work with Kerberos (Cassandra Targett, Amrit Sarkar via Ishan Chattopadhyaya)
+* SOLR-9516: Admin UI (angular) now works with Kerberos, by excluding serving of /solr/libs/* through
+ SolrDispatchFilter. (Cassandra Targett, Amrit Sarkar via Ishan Chattopadhyaya)
Optimizations
----------------------
[10/19] lucene-solr:feature/autoscaling: SOLR-10266: fix implicit
test assumptions about doc order
Posted by sh...@apache.org.
SOLR-10266: fix implicit test assumptions about doc order
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/87569030
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/87569030
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/87569030
Branch: refs/heads/feature/autoscaling
Commit: 875690302c9d3be8aac81865685910d407588e1e
Parents: 6163956
Author: Chris Hostetter <ho...@apache.org>
Authored: Tue Mar 14 09:49:22 2017 -0700
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
.../org/apache/solr/schema/TestPointFields.java | 161 +++++++++++--------
1 file changed, 94 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/87569030/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
index 3c1f0b3..36e8c10 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
@@ -940,52 +940,59 @@ public class TestPointFields extends SolrTestCaseJ4 {
}
private void doTestIntPointFieldRangeQuery(String fieldName, String type, boolean testLong) throws Exception {
- for (int i = 0; i < 10; i++) {
+ for (int i = 9; i >= 0; i--) {
assertU(adoc("id", String.valueOf(i), fieldName, String.valueOf(i)));
}
assertU(commit());
- assertQ(req("q", fieldName + ":[0 TO 3]", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[0 TO 3]", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='4']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0']",
"//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='1']",
"//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='2']",
"//result/doc[4]/" + type + "[@name='" + fieldName + "'][.='3']");
- assertQ(req("q", fieldName + ":{0 TO 3]", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":{0 TO 3]", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='1']",
"//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='2']",
"//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='3']");
- assertQ(req("q", fieldName + ":[0 TO 3}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[0 TO 3}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0']",
"//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='1']",
"//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='2']");
- assertQ(req("q", fieldName + ":{0 TO 3}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":{0 TO 3}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='2']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='1']",
"//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='2']");
- assertQ(req("q", fieldName + ":{0 TO *}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":{0 TO *}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='9']",
+ "0=count(//result/doc/" + type + "[@name='" + fieldName + "'][.='0'])",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='1']");
- assertQ(req("q", fieldName + ":{* TO 3}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":{* TO 3}", "fl", "id, " + fieldName, "sort", "id desc"),
"//*[@numFound='3']",
- "//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0']");
+ "0=count(//result/doc/" + type + "[@name='" + fieldName + "'][.='3'])",
+ "//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='2']",
+ "//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='1']",
+ "//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='0']");
- assertQ(req("q", fieldName + ":[* TO 3}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[* TO 3}", "fl", "id, " + fieldName, "sort", "id desc"),
"//*[@numFound='3']",
- "//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0']");
+ "0=count(//result/doc/" + type + "[@name='" + fieldName + "'][.='3'])",
+ "//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='2']",
+ "//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='1']",
+ "//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='0']");
- assertQ(req("q", fieldName + ":[* TO *}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[* TO *}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0']",
"//result/doc[10]/" + type + "[@name='" + fieldName + "'][.='9']");
- assertQ(req("q", fieldName + ":[0 TO 1] OR " + fieldName + ":[8 TO 9]" , "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[0 TO 1] OR " + fieldName + ":[8 TO 9]" , "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='4']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0']",
"//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='1']",
@@ -1114,7 +1121,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
}
private void doTestIntPointFunctionQuery(String dvFieldName, String nonDvFieldName, String type) throws Exception {
- for (int i = 0; i < 10; i++) {
+ for (int i = 9; i >= 0; i--) {
assertU(adoc("id", String.valueOf(i), dvFieldName, String.valueOf(i), nonDvFieldName, String.valueOf(i)));
}
assertU(commit());
@@ -1127,14 +1134,14 @@ public class TestPointFields extends SolrTestCaseJ4 {
"//result/doc[3]/" + type + "[@name='" + dvFieldName + "'][.='7']",
"//result/doc[10]/" + type + "[@name='" + dvFieldName + "'][.='0']");
- assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", product(-1," + dvFieldName + ")"),
+ assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", product(-1," + dvFieldName + ")", "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/float[@name='product(-1," + dvFieldName + ")'][.='-0.0']",
"//result/doc[2]/float[@name='product(-1," + dvFieldName + ")'][.='-1.0']",
"//result/doc[3]/float[@name='product(-1," + dvFieldName + ")'][.='-2.0']",
"//result/doc[10]/float[@name='product(-1," + dvFieldName + ")'][.='-9.0']");
- assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", field(" + dvFieldName + ")"),
+ assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", field(" + dvFieldName + ")", "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/" + type + "[@name='field(" + dvFieldName + ")'][.='0']",
"//result/doc[2]/" + type + "[@name='field(" + dvFieldName + ")'][.='1']",
@@ -1210,7 +1217,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
assert numbers != null && numbers.length == 20;
assertTrue(h.getCore().getLatestSchema().getField(fieldName).multiValued());
assertTrue(h.getCore().getLatestSchema().getField(fieldName).getType() instanceof PointField);
- for (int i=0; i < 10; i++) {
+ for (int i=9; i >= 0; i--) {
assertU(adoc("id", String.valueOf(i), fieldName, numbers[i], fieldName, numbers[i+10]));
}
// Check using RTG before commit
@@ -1232,27 +1239,26 @@ public class TestPointFields extends SolrTestCaseJ4 {
"count(//doc/arr[@name='" + fieldName + "']/" + type + ")=2");
}
}
- String[] expected = new String[11];
- String[] expected2 = new String[11];
+ String[] expected = new String[21];
expected[0] = "//*[@numFound='10']";
- expected2[0] = "//*[@numFound='10']";
for (int i = 1; i <= 10; i++) {
+ // checks for each doc's two values aren't next to eachother in array, but that doesn't matter for correctness
expected[i] = "//result/doc[" + i + "]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[i-1] + "']";
- expected2[i] = "//result/doc[" + i + "]/arr[@name='" + fieldName + "']/" + type + "[2][.='" + numbers[i + 9] + "']";
+ expected[i+10] = "//result/doc[" + i + "]/arr[@name='" + fieldName + "']/" + type + "[2][.='" + numbers[i + 9] + "']";
}
- assertQ(req("q", "*:*", "fl", "id, " + fieldName), expected);
- assertQ(req("q", "*:*", "fl", "id, " + fieldName), expected2);
+ assertQ(req("q", "*:*", "fl", "id, " + fieldName, "sort","id asc"), expected);
}
private void testPointFieldMultiValuedRangeQuery(String fieldName, String type, String[] numbers) throws Exception {
assert numbers != null && numbers.length == 20;
assertTrue(h.getCore().getLatestSchema().getField(fieldName).multiValued());
assertTrue(h.getCore().getLatestSchema().getField(fieldName).getType() instanceof PointField);
- for (int i=0; i < 10; i++) {
+ for (int i=9; i >= 0; i--) {
assertU(adoc("id", String.valueOf(i), fieldName, numbers[i], fieldName, numbers[i+10]));
}
assertU(commit());
- assertQ(req("q", String.format(Locale.ROOT, "%s:[%s TO %s]", fieldName, numbers[0], numbers[3]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:[%s TO %s]", fieldName, numbers[0], numbers[3]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='4']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[0] + "']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[2][.='" + numbers[10] + "']",
@@ -1263,52 +1269,61 @@ public class TestPointFields extends SolrTestCaseJ4 {
"//result/doc[4]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[3] + "']",
"//result/doc[4]/arr[@name='" + fieldName + "']/" + type + "[2][.='" + numbers[13] + "']");
- assertQ(req("q", String.format(Locale.ROOT, "%s:{%s TO %s]", fieldName, numbers[0], numbers[3]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:{%s TO %s]", fieldName, numbers[0], numbers[3]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[1] + "']",
"//result/doc[2]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[2] + "']",
"//result/doc[3]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[3] + "']");
- assertQ(req("q", String.format(Locale.ROOT, "%s:[%s TO %s}", fieldName, numbers[0], numbers[3]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:[%s TO %s}", fieldName, numbers[0], numbers[3]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[0] + "']",
"//result/doc[2]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[1] + "']",
"//result/doc[3]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[2] + "']");
- assertQ(req("q", String.format(Locale.ROOT, "%s:{%s TO %s}", fieldName, numbers[0], numbers[3]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:{%s TO %s}", fieldName, numbers[0], numbers[3]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='2']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[1] + "']",
"//result/doc[2]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[2] + "']");
- assertQ(req("q", String.format(Locale.ROOT, "%s:{%s TO *}", fieldName, numbers[0]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:{%s TO *}", fieldName, numbers[0]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[0] + "']");
- assertQ(req("q", String.format(Locale.ROOT, "%s:{%s TO *}", fieldName, numbers[10]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:{%s TO *}", fieldName, numbers[10]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='9']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[1] + "']");
- assertQ(req("q", String.format(Locale.ROOT, "%s:{* TO %s}", fieldName, numbers[3]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:{* TO %s}", fieldName, numbers[3]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[0] + "']");
- assertQ(req("q", String.format(Locale.ROOT, "%s:[* TO %s}", fieldName, numbers[3]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:[* TO %s}", fieldName, numbers[3]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[0] + "']");
- assertQ(req("q", fieldName + ":[* TO *}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[* TO *}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[0] + "']",
"//result/doc[10]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[9] + "']");
- assertQ(req("q", String.format(Locale.ROOT, "%s:[%s TO %s] OR %s:[%s TO %s]", fieldName, numbers[0], numbers[1], fieldName, numbers[8], numbers[9]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:[%s TO %s] OR %s:[%s TO %s]", fieldName, numbers[0], numbers[1], fieldName, numbers[8], numbers[9]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='4']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[0] + "']",
"//result/doc[2]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[1] + "']",
"//result/doc[3]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[8] + "']",
"//result/doc[4]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[9] + "']");
- assertQ(req("q", String.format(Locale.ROOT, "%s:[%s TO %s] OR %s:[%s TO %s]", fieldName, numbers[0], numbers[0], fieldName, numbers[10], numbers[10]), "fl", "id, " + fieldName),
+ assertQ(req("q", String.format(Locale.ROOT, "%s:[%s TO %s] OR %s:[%s TO %s]", fieldName, numbers[0], numbers[0], fieldName, numbers[10], numbers[10]),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='1']",
"//result/doc[1]/arr[@name='" + fieldName + "']/" + type + "[1][.='" + numbers[0] + "']");
}
@@ -1621,7 +1636,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
private void doTestPointFieldSort(String field, String dvField, String[] arr) throws Exception {
assert arr != null && arr.length == 10;
- for (int i = 0; i < arr.length; i++) {
+ for (int i = arr.length-1; i >= 0; i--) {
assertU(adoc("id", String.valueOf(i), dvField, String.valueOf(arr[i]), field, String.valueOf(arr[i])));
}
assertU(commit());
@@ -1645,47 +1660,51 @@ public class TestPointFields extends SolrTestCaseJ4 {
}
private void doTestFloatPointFieldRangeQuery(String fieldName, String type, boolean testDouble) throws Exception {
- for (int i = 0; i < 10; i++) {
+ for (int i = 9; i >= 0; i--) {
assertU(adoc("id", String.valueOf(i), fieldName, String.valueOf(i)));
}
assertU(commit());
- assertQ(req("q", fieldName + ":[0 TO 3]", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[0 TO 3]", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='4']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0.0']",
"//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='1.0']",
"//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='2.0']",
"//result/doc[4]/" + type + "[@name='" + fieldName + "'][.='3.0']");
- assertQ(req("q", fieldName + ":{0 TO 3]", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":{0 TO 3]", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='1.0']",
"//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='2.0']",
"//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='3.0']");
- assertQ(req("q", fieldName + ":[0 TO 3}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[0 TO 3}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0.0']",
"//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='1.0']",
"//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='2.0']");
- assertQ(req("q", fieldName + ":{0 TO 3}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":{0 TO 3}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='2']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='1.0']",
"//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='2.0']");
- assertQ(req("q", fieldName + ":{0 TO *}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":{0 TO *}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='9']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='1.0']");
- assertQ(req("q", fieldName + ":{* TO 3}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":{* TO 3}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
- "//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0.0']");
+ "//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0.0']",
+ "//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='1.0']",
+ "//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='2.0']");
- assertQ(req("q", fieldName + ":[* TO 3}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[* TO 3}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
- "//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0.0']");
+ "//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0.0']",
+ "//result/doc[2]/" + type + "[@name='" + fieldName + "'][.='1.0']",
+ "//result/doc[3]/" + type + "[@name='" + fieldName + "'][.='2.0']");
- assertQ(req("q", fieldName + ":[* TO *}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[* TO *}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/" + type + "[@name='" + fieldName + "'][.='0.0']",
"//result/doc[10]/" + type + "[@name='" + fieldName + "'][.='9.0']");
@@ -1769,7 +1788,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
}
private void doTestFloatPointFunctionQuery(String dvFieldName, String nonDvFieldName, String type) throws Exception {
- for (int i = 0; i < 10; i++) {
+ for (int i = 9; i >= 0; i--) {
assertU(adoc("id", String.valueOf(i), dvFieldName, String.format(Locale.ROOT, "%f", (float)i*1.1), nonDvFieldName, String.format(Locale.ROOT, "%f", (float)i*1.1)));
}
assertU(commit());
@@ -1782,14 +1801,14 @@ public class TestPointFields extends SolrTestCaseJ4 {
"//result/doc[3]/" + type + "[@name='" + dvFieldName + "'][.='7.7']",
"//result/doc[10]/" + type + "[@name='" + dvFieldName + "'][.='0.0']");
- assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", product(-1," + dvFieldName + ")"),
+ assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", product(-1," + dvFieldName + ")", "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/float[@name='product(-1," + dvFieldName + ")'][.='-0.0']",
"//result/doc[2]/float[@name='product(-1," + dvFieldName + ")'][.='-1.1']",
"//result/doc[3]/float[@name='product(-1," + dvFieldName + ")'][.='-2.2']",
"//result/doc[10]/float[@name='product(-1," + dvFieldName + ")'][.='-9.9']");
- assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", field(" + dvFieldName + ")"),
+ assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", field(" + dvFieldName + ")", "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/" + type + "[@name='field(" + dvFieldName + ")'][.='0.0']",
"//result/doc[2]/" + type + "[@name='field(" + dvFieldName + ")'][.='1.1']",
@@ -2014,53 +2033,61 @@ public class TestPointFields extends SolrTestCaseJ4 {
private void doTestDatePointFieldRangeQuery(String fieldName) throws Exception {
String baseDate = "1995-12-31T10:59:59Z";
- for (int i = 0; i < 10; i++) {
+ for (int i = 9; i >= 0; i--) {
assertU(adoc("id", String.valueOf(i), fieldName, String.format(Locale.ROOT, "%s+%dHOURS", baseDate, i)));
}
assertU(commit());
- assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "[%s+0HOURS TO %s+3HOURS]", baseDate, baseDate), "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "[%s+0HOURS TO %s+3HOURS]", baseDate, baseDate),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='4']",
"//result/doc[1]/date[@name='" + fieldName + "'][.='1995-12-31T10:59:59Z']",
"//result/doc[2]/date[@name='" + fieldName + "'][.='1995-12-31T11:59:59Z']",
"//result/doc[3]/date[@name='" + fieldName + "'][.='1995-12-31T12:59:59Z']",
"//result/doc[4]/date[@name='" + fieldName + "'][.='1995-12-31T13:59:59Z']");
- assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "{%s+0HOURS TO %s+3HOURS]", baseDate, baseDate), "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "{%s+0HOURS TO %s+3HOURS]", baseDate, baseDate),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/date[@name='" + fieldName + "'][.='1995-12-31T11:59:59Z']",
"//result/doc[2]/date[@name='" + fieldName + "'][.='1995-12-31T12:59:59Z']",
"//result/doc[3]/date[@name='" + fieldName + "'][.='1995-12-31T13:59:59Z']");
- assertQ(req("q", fieldName + ":"+ String.format(Locale.ROOT, "[%s+0HOURS TO %s+3HOURS}",baseDate,baseDate), "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":"+ String.format(Locale.ROOT, "[%s+0HOURS TO %s+3HOURS}",baseDate,baseDate),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/date[@name='" + fieldName + "'][.='1995-12-31T10:59:59Z']",
"//result/doc[2]/date[@name='" + fieldName + "'][.='1995-12-31T11:59:59Z']",
"//result/doc[3]/date[@name='" + fieldName + "'][.='1995-12-31T12:59:59Z']");
- assertQ(req("q", fieldName + ":"+ String.format(Locale.ROOT, "{%s+0HOURS TO %s+3HOURS}",baseDate,baseDate), "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":"+ String.format(Locale.ROOT, "{%s+0HOURS TO %s+3HOURS}",baseDate,baseDate),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='2']",
"//result/doc[1]/date[@name='" + fieldName + "'][.='1995-12-31T11:59:59Z']",
"//result/doc[2]/date[@name='" + fieldName + "'][.='1995-12-31T12:59:59Z']");
- assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "{%s+0HOURS TO *}",baseDate), "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "{%s+0HOURS TO *}",baseDate),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='9']",
"//result/doc[1]/date[@name='" + fieldName + "'][.='1995-12-31T11:59:59Z']");
- assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "{* TO %s+3HOURS}",baseDate), "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "{* TO %s+3HOURS}",baseDate),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/date[@name='" + fieldName + "'][.='1995-12-31T10:59:59Z']");
- assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "[* TO %s+3HOURS}",baseDate), "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "[* TO %s+3HOURS}",baseDate),
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='3']",
"//result/doc[1]/date[@name='" + fieldName + "'][.='1995-12-31T10:59:59Z']");
- assertQ(req("q", fieldName + ":[* TO *}", "fl", "id, " + fieldName),
+ assertQ(req("q", fieldName + ":[* TO *}", "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/date[@name='" + fieldName + "'][.='1995-12-31T10:59:59Z']",
"//result/doc[10]/date[@name='" + fieldName + "'][.='1995-12-31T19:59:59Z']");
assertQ(req("q", fieldName + ":" + String.format(Locale.ROOT, "[%s+0HOURS TO %s+1HOURS]",baseDate,baseDate)
- +" OR " + fieldName + ":" + String.format(Locale.ROOT, "[%s+8HOURS TO %s+9HOURS]",baseDate,baseDate) , "fl", "id, " + fieldName),
+ + " OR " + fieldName + ":" + String.format(Locale.ROOT, "[%s+8HOURS TO %s+9HOURS]",baseDate,baseDate) ,
+ "fl", "id, " + fieldName, "sort", "id asc"),
"//*[@numFound='4']",
"//result/doc[1]/date[@name='" + fieldName + "'][.='1995-12-31T10:59:59Z']",
"//result/doc[2]/date[@name='" + fieldName + "'][.='1995-12-31T11:59:59Z']",
@@ -2218,28 +2245,28 @@ public class TestPointFields extends SolrTestCaseJ4 {
private void doTestDatePointFunctionQuery(String dvFieldName, String nonDvFieldName, String type) throws Exception {
String baseDate = "1995-01-10T10:59:10Z";
- for (int i = 0; i < 10; i++) {
+ for (int i = 9; i >= 0; i--) {
String date = String.format(Locale.ROOT, "%s+%dSECONDS", baseDate, i+1);
assertU(adoc("id", String.valueOf(i), dvFieldName, date, nonDvFieldName, date));
}
assertU(commit());
assertTrue(h.getCore().getLatestSchema().getField(dvFieldName).hasDocValues());
assertTrue(h.getCore().getLatestSchema().getField(dvFieldName).getType() instanceof PointField);
- assertQ(req("q", "*:*", "fl", "id, " + dvFieldName, "sort", "product(-1," + dvFieldName + ") asc"),
+ assertQ(req("q", "*:*", "fl", "id, " + dvFieldName, "sort", "product(-1,ms(" + dvFieldName + ")) asc"),
"//*[@numFound='10']",
- "//result/doc[1]/" + type + "[@name='" + dvFieldName + "'][.='1995-01-10T10:59:11Z']",
- "//result/doc[2]/" + type + "[@name='" + dvFieldName + "'][.='1995-01-10T10:59:12Z']",
- "//result/doc[3]/" + type + "[@name='" + dvFieldName + "'][.='1995-01-10T10:59:13Z']",
- "//result/doc[10]/" + type + "[@name='" + dvFieldName + "'][.='1995-01-10T10:59:20Z']");
+ "//result/doc[1]/" + type + "[@name='" + dvFieldName + "'][.='1995-01-10T10:59:20Z']",
+ "//result/doc[2]/" + type + "[@name='" + dvFieldName + "'][.='1995-01-10T10:59:19Z']",
+ "//result/doc[3]/" + type + "[@name='" + dvFieldName + "'][.='1995-01-10T10:59:18Z']",
+ "//result/doc[10]/" + type + "[@name='" + dvFieldName + "'][.='1995-01-10T10:59:11Z']");
- assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", ms(" + dvFieldName + ","+baseDate+")"),
+ assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", ms(" + dvFieldName + ","+baseDate+")", "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/float[@name='ms(" + dvFieldName + "," + baseDate + ")'][.='1000.0']",
"//result/doc[2]/float[@name='ms(" + dvFieldName + "," + baseDate + ")'][.='2000.0']",
"//result/doc[3]/float[@name='ms(" + dvFieldName + "," + baseDate + ")'][.='3000.0']",
"//result/doc[10]/float[@name='ms(" + dvFieldName + "," + baseDate + ")'][.='10000.0']");
- assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", field(" + dvFieldName + ")"),
+ assertQ(req("q", "*:*", "fl", "id, " + dvFieldName + ", field(" + dvFieldName + ")", "sort", "id asc"),
"//*[@numFound='10']",
"//result/doc[1]/" + type + "[@name='field(" + dvFieldName + ")'][.='1995-01-10T10:59:11Z']",
"//result/doc[2]/" + type + "[@name='field(" + dvFieldName + ")'][.='1995-01-10T10:59:12Z']",
[02/19] lucene-solr:feature/autoscaling: SOLR-10271: SQL aggregations
in map_reduce mode should use javabin transport
Posted by sh...@apache.org.
SOLR-10271: SQL aggregations in map_reduce mode should use javabin transport
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/da56db8b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/da56db8b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/da56db8b
Branch: refs/heads/feature/autoscaling
Commit: da56db8bf50c2f33ef407ebe18a957e6da64d388
Parents: 1e97cf8
Author: Joel Bernstein <jb...@apache.org>
Authored: Mon Mar 13 17:10:21 2017 -0400
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/da56db8b/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java b/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
index 37ed7d9..644ed97 100644
--- a/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
+++ b/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
@@ -453,6 +453,7 @@ class SolrTable extends AbstractQueryableTable implements TranslatableTable {
params.set(CommonParams.FL, fl);
params.set(CommonParams.Q, query);
+ params.set(CommonParams.WT, CommonParams.JAVABIN);
//Always use the /export handler for Group By Queries because it requires exporting full result sets.
params.set(CommonParams.QT, "/export");
@@ -691,6 +692,7 @@ class SolrTable extends AbstractQueryableTable implements TranslatableTable {
params.set(CommonParams.FL, fl);
params.set(CommonParams.Q, query);
+ params.set(CommonParams.WT, CommonParams.JAVABIN);
//Always use the /export handler for Distinct Queries because it requires exporting full result sets.
params.set(CommonParams.QT, "/export");
[05/19] lucene-solr:feature/autoscaling: SOLR-9835: Update CHANGES.txt
Posted by sh...@apache.org.
SOLR-9835: Update CHANGES.txt
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/83772c6f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/83772c6f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/83772c6f
Branch: refs/heads/feature/autoscaling
Commit: 83772c6f995604d854d3e6b0d9ff36c8eb2599c6
Parents: 76de819
Author: Cao Manh Dat <da...@apache.org>
Authored: Tue Mar 14 16:20:46 2017 +0700
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/83772c6f/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 80ecea8..6f6516f 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -56,6 +56,8 @@ New Features
----------------------
* SOLR-9857, SOLR-9858: Collect aggregated metrics from nodes and shard leaders in overseer. (ab)
+* SOLR-9835: Create another replication mode for SolrCloud
+
Bug Fixes
----------------------
* SOLR-9262: Connection and read timeouts are being ignored by UpdateShardHandler after SOLR-4509.
[06/19] lucene-solr:feature/autoscaling: SOLR-10279: The
autoAddReplica feature can result in SolrCores being assigned new shards when
using legacyCloud=false and will also fail on a state check when taking over
a core registration with a new core.
Posted by sh...@apache.org.
SOLR-10279: The autoAddReplica feature can result in SolrCores being assigned new shards when using legacyCloud=false and will also fail on a state check when taking over a core registration with a new core.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/cab7e1a3
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/cab7e1a3
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/cab7e1a3
Branch: refs/heads/feature/autoscaling
Commit: cab7e1a3d7027ba13f49aa69d4eb473609c42dc9
Parents: 83772c6
Author: markrmiller <ma...@apache.org>
Authored: Tue Mar 14 06:01:06 2017 -0400
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 4 +++
.../OverseerAutoReplicaFailoverThread.java | 6 ++--
.../org/apache/solr/cloud/ZkController.java | 8 +-----
.../cloud/SharedFSAutoReplicaFailoverTest.java | 29 ++++++++++++++++++++
4 files changed, 38 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cab7e1a3/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6f6516f..280f165 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -243,6 +243,10 @@ Bug Fixes
* SOLR-10269: MetricsHandler JSON output incorrect. (ab)
+* SOLR-10279: The autoAddReplica feature can result in SolrCores being assigned new shards when using
+ legacyCloud=false and will also fail on a state check when taking over a core registration with a new
+ core. (Mark Miller, Hrishikesh Gadre, Patrick Dvorack)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cab7e1a3/solr/core/src/java/org/apache/solr/cloud/OverseerAutoReplicaFailoverThread.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerAutoReplicaFailoverThread.java b/solr/core/src/java/org/apache/solr/cloud/OverseerAutoReplicaFailoverThread.java
index 10b4bf3..ea09eef 100644
--- a/solr/core/src/java/org/apache/solr/cloud/OverseerAutoReplicaFailoverThread.java
+++ b/solr/core/src/java/org/apache/solr/cloud/OverseerAutoReplicaFailoverThread.java
@@ -243,13 +243,14 @@ public class OverseerAutoReplicaFailoverThread implements Runnable, Closeable {
final String dataDir = badReplica.replica.getStr("dataDir");
final String ulogDir = badReplica.replica.getStr("ulogDir");
final String coreNodeName = badReplica.replica.getName();
+ final String shardId = badReplica.slice.getName();
if (dataDir != null) {
// need an async request - full shard goes down leader election
final String coreName = badReplica.replica.getStr(ZkStateReader.CORE_NAME_PROP);
log.debug("submit call to {}", createUrl);
MDC.put("OverseerAutoReplicaFailoverThread.createUrl", createUrl);
try {
- updateExecutor.submit(() -> createSolrCore(collection, createUrl, dataDir, ulogDir, coreNodeName, coreName));
+ updateExecutor.submit(() -> createSolrCore(collection, createUrl, dataDir, ulogDir, coreNodeName, coreName, shardId));
} finally {
MDC.remove("OverseerAutoReplicaFailoverThread.createUrl");
}
@@ -440,7 +441,7 @@ public class OverseerAutoReplicaFailoverThread implements Runnable, Closeable {
private boolean createSolrCore(final String collection,
final String createUrl, final String dataDir, final String ulogDir,
- final String coreNodeName, final String coreName) {
+ final String coreNodeName, final String coreName, final String shardId) {
try (HttpSolrClient client = new HttpSolrClient.Builder(createUrl).build()) {
log.debug("create url={}", createUrl);
@@ -451,6 +452,7 @@ public class OverseerAutoReplicaFailoverThread implements Runnable, Closeable {
createCmd.setCoreNodeName(coreNodeName);
// TODO: how do we ensure unique coreName
// for now, the collections API will use unique names
+ createCmd.setShardId(shardId);
createCmd.setCoreName(coreName);
createCmd.setDataDir(dataDir);
createCmd.setUlogDir(ulogDir.substring(0, ulogDir.length() - "/tlog".length()));
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cab7e1a3/solr/core/src/java/org/apache/solr/cloud/ZkController.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index a19b351..69a77f9 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -1449,13 +1449,7 @@ public class ZkController {
errorMessage.set("coreNodeName " + coreNodeName + " does not exist in shard " + cloudDesc.getShardId());
return false;
}
- String baseUrl = replica.getStr(BASE_URL_PROP);
- String coreName = replica.getStr(CORE_NAME_PROP);
- if (baseUrl.equals(this.baseURL) && coreName.equals(cd.getName())) {
- return true;
- }
- errorMessage.set("coreNodeName " + coreNodeName + " exists, but does not match expected node or core name");
- return false;
+ return true;
});
} catch (TimeoutException e) {
String error = errorMessage.get();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cab7e1a3/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java b/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
index 18503e7..9c345fd 100644
--- a/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
@@ -38,6 +38,7 @@ import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.CollectionAdminRequest.Create;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
@@ -103,6 +104,11 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa
public void setUp() throws Exception {
super.setUp();
collectionUlogDirMap.clear();
+ if (random().nextBoolean()) {
+ CollectionAdminRequest.setClusterProperty("legacyCloud", "false").process(cloudClient);
+ } else {
+ CollectionAdminRequest.setClusterProperty("legacyCloud", "true").process(cloudClient);
+ }
}
@Override
@@ -313,6 +319,29 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa
assertSliceAndReplicaCount(collection1);
assertUlogDir(collections);
+
+ // restart all to test core saved state
+
+ ChaosMonkey.stop(jettys);
+ ChaosMonkey.stop(controlJetty);
+
+ assertTrue("Timeout waiting for all not live", ClusterStateUtil.waitForAllReplicasNotLive(cloudClient.getZkStateReader(), 45000));
+
+ ChaosMonkey.start(jettys);
+ ChaosMonkey.start(controlJetty);
+
+ assertTrue("Timeout waiting for all live and active", ClusterStateUtil.waitForAllActiveAndLiveReplicas(cloudClient.getZkStateReader(), collection1, 120000));
+
+ assertSliceAndReplicaCount(collection1);
+
+ assertUlogDir(collections);
+
+ assertSliceAndReplicaCount(collection1);
+ assertSingleReplicationAndShardSize(collection3, 5);
+
+ // all docs should be queried
+ assertSingleReplicationAndShardSize(collection4, 5);
+ queryAndAssertResultSize(collection4, numDocs, 10000);
}
private void queryAndAssertResultSize(String collection, int expectedResultSize, int timeoutMS)
[14/19] lucene-solr:feature/autoscaling: LUCENE-7742: fix places
where we were unboxing and then re-boxing according to FindBugs
Posted by sh...@apache.org.
LUCENE-7742: fix places where we were unboxing and then re-boxing according to FindBugs
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/9f72056d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9f72056d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9f72056d
Branch: refs/heads/feature/autoscaling
Commit: 9f72056d94c47344dbba30b282b30f0e4b70256f
Parents: e66924c
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Mar 15 06:03:54 2017 -0400
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
lucene/CHANGES.txt | 3 +++
.../java/org/apache/lucene/document/LatLonDocValuesField.java | 2 +-
.../java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java | 2 +-
.../update/processor/TikaLanguageIdentifierUpdateProcessor.java | 5 +++--
solr/core/src/java/org/apache/solr/core/RequestParams.java | 2 +-
.../src/java/org/apache/solr/handler/sql/SolrEnumerator.java | 4 ++--
solr/core/src/java/org/apache/solr/schema/NumericFieldType.java | 4 ++--
solr/core/src/java/org/apache/solr/search/Grouping.java | 2 +-
.../core/src/java/org/apache/solr/search/SolrIndexSearcher.java | 2 +-
.../responseprocessor/SearchGroupShardResponseProcessor.java | 2 +-
.../org/apache/solr/security/AutorizationEditOperation.java | 2 +-
.../test/org/apache/solr/search/TestCollapseQParserPlugin.java | 2 +-
.../test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java | 2 +-
.../org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java | 2 +-
.../src/java/org/apache/solr/common/cloud/DocCollection.java | 2 +-
.../src/test/org/apache/solr/common/params/SolrParamTest.java | 4 ++--
16 files changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index e14ab53..62f4763 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -256,6 +256,9 @@ Optimizations
* LUCENE-7699: Query parsers now use span queries to produce more efficient
phrase queries for multi-token synonyms. (Matt Webber via Jim Ferenczi)
+* LUCENE-7742: Fix places where we were unboxing and then re-boxing
+ according to FindBugs (Daniel Jelinski via Mike McCandless)
+
Build
* LUCENE-7653: Update randomizedtesting to version 2.5.0. (Dawid Weiss)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java
index 08a7da7..10e90b4 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java
@@ -106,7 +106,7 @@ public class LatLonDocValuesField extends Field {
result.append(name);
result.append(':');
- long currentValue = Long.valueOf((Long)fieldsData);
+ long currentValue = (Long)fieldsData;
result.append(decodeLatitude((int)(currentValue >> 32)));
result.append(',');
result.append(decodeLongitude((int)(currentValue & 0xFFFFFFFF)));
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java
index 551fa5a..dc9df35 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java
@@ -305,7 +305,7 @@ public class Geo3DDocValuesField extends Field {
result.append(name);
result.append(':');
- long currentValue = Long.valueOf((Long)fieldsData);
+ long currentValue = (Long)fieldsData;
result.append(decodeXValue(currentValue));
result.append(',');
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/contrib/langid/src/java/org/apache/solr/update/processor/TikaLanguageIdentifierUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/contrib/langid/src/java/org/apache/solr/update/processor/TikaLanguageIdentifierUpdateProcessor.java b/solr/contrib/langid/src/java/org/apache/solr/update/processor/TikaLanguageIdentifierUpdateProcessor.java
index 3d3fa41..836a3bf 100644
--- a/solr/contrib/langid/src/java/org/apache/solr/update/processor/TikaLanguageIdentifierUpdateProcessor.java
+++ b/solr/contrib/langid/src/java/org/apache/solr/update/processor/TikaLanguageIdentifierUpdateProcessor.java
@@ -56,8 +56,9 @@ public class TikaLanguageIdentifierUpdateProcessor extends LanguageIdentifierUpd
// FIXME: Hack - we get the distance from toString and calculate our own certainty score
Double distance = Double.parseDouble(tikaSimilarityPattern.matcher(identifier.toString()).replaceFirst("$1"));
// This formula gives: 0.02 => 0.8, 0.1 => 0.5 which is a better sweetspot than isReasonablyCertain()
- Double certainty = 1 - (5 * distance);
- certainty = (certainty < 0) ? 0 : certainty;
+ Double certainty = 1 - (5 * distance);
+ if (certainty < 0)
+ certainty = 0d;
DetectedLanguage language = new DetectedLanguage(identifier.getLanguage(), certainty);
languages.add(language);
log.debug("Language detected as "+language+" with a certainty of "+language.getCertainty()+" (Tika distance="+identifier.toString()+")");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/core/src/java/org/apache/solr/core/RequestParams.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/RequestParams.java b/solr/core/src/java/org/apache/solr/core/RequestParams.java
index ff0d36c..fbb2555 100644
--- a/solr/core/src/java/org/apache/solr/core/RequestParams.java
+++ b/solr/core/src/java/org/apache/solr/core/RequestParams.java
@@ -222,7 +222,7 @@ public class RequestParams implements MapSerializable {
}
public Long getVersion() {
- return meta == null ? 0l : (Long) meta.get("v");
+ return meta == null ? Long.valueOf(0l) : (Long) meta.get("v");
}
@Override
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/core/src/java/org/apache/solr/handler/sql/SolrEnumerator.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/sql/SolrEnumerator.java b/solr/core/src/java/org/apache/solr/handler/sql/SolrEnumerator.java
index 6f9dddf..be6046c 100644
--- a/solr/core/src/java/org/apache/solr/handler/sql/SolrEnumerator.java
+++ b/solr/core/src/java/org/apache/solr/handler/sql/SolrEnumerator.java
@@ -103,10 +103,10 @@ class SolrEnumerator implements Enumerator<Object> {
private Object getRealVal(Object val) {
// Check if Double is really a Long
if(val instanceof Double) {
- Double doubleVal = (double) val;
+ double doubleVal = (double) val;
//make sure that double has no decimals and fits within Long
if(doubleVal % 1 == 0 && doubleVal >= Long.MIN_VALUE && doubleVal <= Long.MAX_VALUE) {
- return doubleVal.longValue();
+ return (long)doubleVal;
}
return doubleVal;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java b/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java
index 5801766..6cda9ca 100644
--- a/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java
+++ b/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java
@@ -114,10 +114,10 @@ public abstract class NumericFieldType extends PrimitiveFieldType {
if ((minVal == null || minVal.doubleValue() < 0d || minBits == minusZeroBits) &&
(maxVal != null && (maxVal.doubleValue() < 0d || maxBits == minusZeroBits))) {
query = numericDocValuesRangeQuery
- (fieldName, maxBits, (min == null ? negativeInfinityBits : minBits), maxInclusive, minInclusive, false);
+ (fieldName, maxBits, (min == null ? Long.valueOf(negativeInfinityBits) : minBits), maxInclusive, minInclusive, false);
} else { // If both max and min are positive, then issue range query
query = numericDocValuesRangeQuery
- (fieldName, minBits, (max == null ? positiveInfinityBits : maxBits), minInclusive, maxInclusive, false);
+ (fieldName, minBits, (max == null ? Long.valueOf(positiveInfinityBits) : maxBits), minInclusive, maxInclusive, false);
}
}
return query;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/core/src/java/org/apache/solr/search/Grouping.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/Grouping.java b/solr/core/src/java/org/apache/solr/search/Grouping.java
index 327e5bb..302383a 100644
--- a/solr/core/src/java/org/apache/solr/search/Grouping.java
+++ b/solr/core/src/java/org/apache/solr/search/Grouping.java
@@ -601,7 +601,7 @@ public class Grouping {
groupResult.add("matches", matches);
if (totalCount == TotalCount.grouped) {
Integer totalNrOfGroups = getNumberOfGroups();
- groupResult.add("ngroups", totalNrOfGroups == null ? 0 : totalNrOfGroups);
+ groupResult.add("ngroups", totalNrOfGroups == null ? Integer.valueOf(0) : totalNrOfGroups);
}
maxMatches = Math.max(maxMatches, matches);
return groupResult;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index a7ee433..19e47d0 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -847,7 +847,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
newVal = val.intValue();
break;
case LONG:
- newVal = val.longValue();
+ newVal = val;
break;
case FLOAT:
newVal = Float.intBitsToFloat(val.intValue());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java
index 1645b1e..a12cad1 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java
@@ -119,7 +119,7 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor
if (groupCount != null) {
Integer existingGroupCount = rb.mergedGroupCounts.get(field);
// Assuming groups don't cross shard boundary...
- rb.mergedGroupCounts.put(field, existingGroupCount != null ? existingGroupCount + groupCount : groupCount);
+ rb.mergedGroupCounts.put(field, existingGroupCount != null ? Integer.valueOf(existingGroupCount + groupCount) : groupCount);
}
final Collection<SearchGroup<BytesRef>> searchGroups = firstPhaseCommandResult.getSearchGroups();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/core/src/java/org/apache/solr/security/AutorizationEditOperation.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/security/AutorizationEditOperation.java b/solr/core/src/java/org/apache/solr/security/AutorizationEditOperation.java
index 88c7987..6a5230c 100644
--- a/solr/core/src/java/org/apache/solr/security/AutorizationEditOperation.java
+++ b/solr/core/src/java/org/apache/solr/security/AutorizationEditOperation.java
@@ -83,7 +83,7 @@ enum AutorizationEditOperation {
boolean indexSatisfied = index == null;
for (int i = 0; i < permissions.size(); i++) {
Map perm = permissions.get(i);
- Integer thisIdx = (int) perm.get("index");
+ Integer thisIdx = (Integer) perm.get("index");
if (thisIdx.equals(beforeIdx)) {
beforeSatisfied = true;
permissionsCopy.add(dataMap);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
index 2fca452..ea4114a 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
@@ -336,7 +336,7 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
if(boostedResults.size() == controlResults.size()) {
for(int i=0; i<boostedResults.size(); i++) {
- if(!boostedResults.get(i).equals(controlResults.get(i).intValue())) {
+ if(!boostedResults.get(i).equals(controlResults.get(i))) {
throw new Exception("boosted results do not match control results, boostedResults size:"+boostedResults.toString()+", controlResults size:"+controlResults.toString());
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
index 7a4fa86..4538e90 100644
--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
@@ -342,7 +342,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
SolrDocumentList results = LEADER.query(params).getResults();
assertEquals(numDocs, results.size());
for (SolrDocument doc : results) {
- luceneDocids.add((int) doc.get("[docid]"));
+ luceneDocids.add((Integer) doc.get("[docid]"));
valuesList.add((Float) doc.get("inplace_updatable_float"));
}
log.info("Initial results: "+results);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java
index 051a2de..c467a16 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java
@@ -86,7 +86,7 @@ public class EqualsEvaluator extends BooleanEvaluator {
return new BooleanChecker(){
@Override
public boolean test(Object left, Object right) {
- return (boolean)left.equals((boolean)right);
+ return (boolean)left == (boolean)right;
}
};
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java b/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
index bf0f04f..d89b2f6 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
@@ -85,7 +85,7 @@ public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
this.replicationFactor = (Integer) verifyProp(props, REPLICATION_FACTOR);
this.maxShardsPerNode = (Integer) verifyProp(props, MAX_SHARDS_PER_NODE);
Boolean autoAddReplicas = (Boolean) verifyProp(props, AUTO_ADD_REPLICAS);
- this.autoAddReplicas = autoAddReplicas == null ? false : autoAddReplicas;
+ this.autoAddReplicas = autoAddReplicas == null ? Boolean.FALSE : autoAddReplicas;
Integer realtimeReplicas = (Integer) verifyProp(props, REALTIME_REPLICAS);
this.realtimeReplicas = realtimeReplicas == null ? -1 : realtimeReplicas;
if (this.realtimeReplicas != -1 && this.realtimeReplicas != 1) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f72056d/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java b/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java
index 48237c5..80f9036 100644
--- a/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java
+++ b/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java
@@ -213,10 +213,10 @@ public class SolrParamTest extends LuceneTestCase {
// Get things with defaults
assertEquals( pstr , params.get( "xxx", pstr ) );
- assertEquals( pbool.booleanValue() , params.getBool( "xxx", pbool ) );
+ assertEquals( pbool , params.getBool( "xxx", pbool ) );
assertEquals( pint.intValue() , params.getInt( "xxx", pint ) );
assertEquals( pfloat.floatValue() , params.getFloat( "xxx", pfloat ), 0.1);
- assertEquals( pbool.booleanValue() , params.getFieldBool( "xxx", "bool", pbool ) );
+ assertEquals( pbool , params.getFieldBool( "xxx", "bool", pbool ) );
assertEquals( pint.intValue() , params.getFieldInt( "xxx", "int", pint ) );
assertEquals( pfloat.floatValue() , params.getFieldFloat("xxx", "float", pfloat ), 0.1);
assertEquals( pstr , params.getFieldParam("xxx", "str", pstr ) );
[15/19] lucene-solr:feature/autoscaling: SOLR-10046: Add
UninvertDocValuesMergePolicyFactory class. (Keith Laban, Christine Poerschke)
Posted by sh...@apache.org.
SOLR-10046: Add UninvertDocValuesMergePolicyFactory class. (Keith Laban, Christine Poerschke)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/0170df93
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/0170df93
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/0170df93
Branch: refs/heads/feature/autoscaling
Commit: 0170df93f3665c941cdd1b7c75d139bc1ed7af96
Parents: cce7ba9
Author: Christine Poerschke <cp...@apache.org>
Authored: Wed Mar 15 10:31:10 2017 +0000
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 2 +
.../UninvertDocValuesMergePolicyFactory.java | 218 +++++++++++++++++
.../solr/collection1/conf/schema-docValues.xml | 1 +
...nfig-uninvertdocvaluesmergepolicyfactory.xml | 38 +++
.../index/UninvertDocValuesMergePolicyTest.java | 243 +++++++++++++++++++
5 files changed, 502 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0170df93/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0f1f488..6829cd1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -185,6 +185,8 @@ New Features
* SOLR-10224: Add disk total and disk free metrics. (ab)
+* SOLR-10046: Add UninvertDocValuesMergePolicyFactory class. (Keith Laban, Christine Poerschke)
+
Bug Fixes
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0170df93/solr/core/src/java/org/apache/solr/index/UninvertDocValuesMergePolicyFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/index/UninvertDocValuesMergePolicyFactory.java b/solr/core/src/java/org/apache/solr/index/UninvertDocValuesMergePolicyFactory.java
new file mode 100644
index 0000000..b6bfbed
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/index/UninvertDocValuesMergePolicyFactory.java
@@ -0,0 +1,218 @@
+/*
+ * 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.index;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.lucene.codecs.DocValuesProducer;
+import org.apache.lucene.index.BinaryDocValues;
+import org.apache.lucene.index.CodecReader;
+import org.apache.lucene.index.DocValuesType;
+import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.FieldInfos;
+import org.apache.lucene.index.FilterCodecReader;
+import org.apache.lucene.index.IndexOptions;
+import org.apache.lucene.index.MergePolicy;
+import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.index.OneMergeWrappingMergePolicy;
+import org.apache.lucene.index.SegmentCommitInfo;
+import org.apache.lucene.index.SortedDocValues;
+import org.apache.lucene.index.SortedNumericDocValues;
+import org.apache.lucene.index.SortedSetDocValues;
+import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.schema.SchemaField;
+import org.apache.solr.uninverting.UninvertingReader;
+
+/**
+ * A merge policy that can detect schema changes and write docvalues into merging segments when a field has docvalues enabled
+ * Using UninvertingReader.
+ *
+ * This merge policy will delegate to the wrapped merge policy for selecting merge segments
+ *
+ */
+public class UninvertDocValuesMergePolicyFactory extends WrapperMergePolicyFactory {
+
+ final private boolean skipIntegrityCheck;
+
+ /**
+ * Whether or not the wrapped docValues producer should check consistency
+ */
+ public boolean getSkipIntegrityCheck() {
+ return skipIntegrityCheck;
+ }
+
+ public UninvertDocValuesMergePolicyFactory(SolrResourceLoader resourceLoader, MergePolicyFactoryArgs args, IndexSchema schema) {
+ super(resourceLoader, args, schema);
+ final Boolean sic = (Boolean)args.remove("skipIntegrityCheck");
+ if (sic != null) {
+ this.skipIntegrityCheck = sic.booleanValue();
+ } else {
+ this.skipIntegrityCheck = false;
+ }
+ if (!args.keys().isEmpty()) {
+ throw new IllegalArgumentException("Arguments were "+args+" but "+getClass().getSimpleName()+" takes no arguments.");
+ }
+ }
+
+ @Override
+ protected MergePolicy getMergePolicyInstance(MergePolicy wrappedMP) {
+ return new OneMergeWrappingMergePolicy(wrappedMP, (merge) -> new UninvertDocValuesOneMerge(merge.segments));
+ }
+
+ private UninvertingReader.Type getUninversionType(FieldInfo fi) {
+ SchemaField sf = schema.getFieldOrNull(fi.name);
+
+ if (null != sf &&
+ sf.hasDocValues() &&
+ fi.getDocValuesType() == DocValuesType.NONE &&
+ fi.getIndexOptions() != IndexOptions.NONE) {
+ return sf.getType().getUninversionType(sf);
+ } else {
+ return null;
+ }
+ }
+
+ private class UninvertDocValuesOneMerge extends MergePolicy.OneMerge {
+
+ public UninvertDocValuesOneMerge(List<SegmentCommitInfo> segments) {
+ super(segments);
+ }
+
+ @Override
+ public CodecReader wrapForMerge(CodecReader reader) throws IOException {
+ // Wrap the reader with an uninverting reader if any of the fields have no docvalues but the
+ // Schema says there should be
+
+
+ Map<String,UninvertingReader.Type> uninversionMap = null;
+
+ for(FieldInfo fi: reader.getFieldInfos()) {
+ final UninvertingReader.Type type = getUninversionType(fi);
+ if (type != null) {
+ if (uninversionMap == null) {
+ uninversionMap = new HashMap<>();
+ }
+ uninversionMap.put(fi.name, type);
+ }
+
+ }
+
+ if(uninversionMap == null) {
+ return reader; // Default to normal reader if nothing to uninvert
+ } else {
+ return new UninvertingFilterCodecReader(reader, uninversionMap);
+ }
+
+ }
+
+ }
+
+
+ /**
+ * Delegates to an Uninverting for fields with docvalues
+ *
+ * This is going to blow up FieldCache, look into an alternative implementation that uninverts without
+ * fieldcache
+ */
+ private class UninvertingFilterCodecReader extends FilterCodecReader {
+
+ private final UninvertingReader uninvertingReader;
+ private final DocValuesProducer docValuesProducer;
+
+ public UninvertingFilterCodecReader(CodecReader in, Map<String,UninvertingReader.Type> uninversionMap) {
+ super(in);
+
+ this.uninvertingReader = new UninvertingReader(in, uninversionMap);
+ this.docValuesProducer = new DocValuesProducer() {
+
+ @Override
+ public NumericDocValues getNumeric(FieldInfo field) throws IOException {
+ return uninvertingReader.getNumericDocValues(field.name);
+ }
+
+ @Override
+ public BinaryDocValues getBinary(FieldInfo field) throws IOException {
+ return uninvertingReader.getBinaryDocValues(field.name);
+ }
+
+ @Override
+ public SortedDocValues getSorted(FieldInfo field) throws IOException {
+ return uninvertingReader.getSortedDocValues(field.name);
+ }
+
+ @Override
+ public SortedNumericDocValues getSortedNumeric(FieldInfo field) throws IOException {
+ return uninvertingReader.getSortedNumericDocValues(field.name);
+ }
+
+ @Override
+ public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
+ return uninvertingReader.getSortedSetDocValues(field.name);
+ }
+
+ @Override
+ public void checkIntegrity() throws IOException {
+ if (!skipIntegrityCheck) {
+ uninvertingReader.checkIntegrity();
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ @Override
+ public long ramBytesUsed() {
+ return 0;
+ }
+ };
+ }
+
+ @Override
+ protected void doClose() throws IOException {
+ docValuesProducer.close();
+ uninvertingReader.close();
+ super.doClose();
+ }
+
+ @Override
+ public DocValuesProducer getDocValuesReader() {
+ return docValuesProducer;
+ }
+
+ @Override
+ public FieldInfos getFieldInfos() {
+ return uninvertingReader.getFieldInfos();
+ }
+
+ @Override
+ public CacheHelper getCoreCacheHelper() {
+ return in.getCoreCacheHelper();
+ }
+
+ @Override
+ public CacheHelper getReaderCacheHelper() {
+ return in.getReaderCacheHelper();
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0170df93/solr/core/src/test-files/solr/collection1/conf/schema-docValues.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-docValues.xml b/solr/core/src/test-files/solr/collection1/conf/schema-docValues.xml
index c7b7de8..9e4286d 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-docValues.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-docValues.xml
@@ -62,6 +62,7 @@
<field name="datedv" type="date" indexed="false" stored="false" docValues="true" default="1995-12-31T23:59:59.999Z"/>
<field name="stringdv" type="string" indexed="false" stored="false" docValues="true" default="solr" />
+ <field name="string_add_dv_later" type="string" indexed="true" stored="true" docValues="false"/>
<field name="booldv" type="boolean" indexed="false" stored="false" docValues="true" default="true" />
<field name="floatdvs" type="float" indexed="false" stored="false" docValues="true" default="1"/>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0170df93/solr/core/src/test-files/solr/collection1/conf/solrconfig-uninvertdocvaluesmergepolicyfactory.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-uninvertdocvaluesmergepolicyfactory.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-uninvertdocvaluesmergepolicyfactory.xml
new file mode 100644
index 0000000..613357b
--- /dev/null
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-uninvertdocvaluesmergepolicyfactory.xml
@@ -0,0 +1,38 @@
+<?xml version="1.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.
+-->
+
+<config>
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <indexConfig>
+ <useCompoundFile>${useCompoundFile:false}</useCompoundFile>
+ <mergePolicyFactory class="org.apache.solr.index.UninvertDocValuesMergePolicyFactory">
+ <str name="wrapped.prefix">inner</str>
+ <str name="inner.class">org.apache.solr.index.DefaultMergePolicyFactory</str>
+ <bool name="skipIntegrityCheck">${solr.tests.skipIntegrityCheck:false}</bool>
+ </mergePolicyFactory>
+
+ <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler"/>
+ </indexConfig>
+
+ <requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>
+
+</config>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0170df93/solr/core/src/test/org/apache/solr/index/UninvertDocValuesMergePolicyTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/index/UninvertDocValuesMergePolicyTest.java b/solr/core/src/test/org/apache/solr/index/UninvertDocValuesMergePolicyTest.java
new file mode 100644
index 0000000..17e6b3e
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/index/UninvertDocValuesMergePolicyTest.java
@@ -0,0 +1,243 @@
+/*
+ * 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.index;
+
+import java.util.Random;
+import java.util.function.IntUnaryOperator;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.DocValuesType;
+import org.apache.lucene.index.FieldInfos;
+import org.apache.lucene.index.LeafReader;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.SortedDocValues;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.schema.SchemaField;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.util.RefCounted;
+import org.apache.solr.util.TestHarness;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+public class UninvertDocValuesMergePolicyTest extends SolrTestCaseJ4 {
+
+ private static String SOLR_TESTS_SKIP_INTEGRITY_CHECK = "solr.tests.skipIntegrityCheck";
+ private static String ID_FIELD = "id";
+ private static String TEST_FIELD = "string_add_dv_later";
+
+ @BeforeClass
+ public static void beforeTests() throws Exception {
+ System.setProperty(SOLR_TESTS_SKIP_INTEGRITY_CHECK, (random().nextBoolean() ? "true" : "false"));
+ }
+
+ @AfterClass
+ public static void afterTests() {
+ System.clearProperty(SOLR_TESTS_SKIP_INTEGRITY_CHECK);
+ }
+
+ @After
+ public void after() throws Exception {
+ deleteCore();
+ }
+
+ @Before
+ public void before() throws Exception {
+ initCore("solrconfig-uninvertdocvaluesmergepolicyfactory.xml", "schema-docValues.xml");
+ }
+
+ public void testIndexAndAddDocValues() throws Exception {
+ Random rand = random();
+
+ for(int i=0; i < 100; i++) {
+ assertU(adoc(ID_FIELD, String.valueOf(i), TEST_FIELD, String.valueOf(i)));
+
+ if(rand.nextBoolean()) {
+ assertU(commit());
+ }
+ }
+
+ assertU(commit());
+
+ // Assert everything has been indexed and there are no docvalues
+ withNewRawReader(h, topReader -> {
+ assertEquals(100, topReader.numDocs());
+
+ final FieldInfos infos = MultiFields.getMergedFieldInfos(topReader);
+
+ // The global field type should not have docValues yet
+ assertEquals(DocValuesType.NONE, infos.fieldInfo(TEST_FIELD).getDocValuesType());
+ });
+
+
+ addDocValuesTo(h, TEST_FIELD);
+
+
+ // Add some more documents with doc values turned on including updating some
+ for(int i=90; i < 110; i++) {
+ assertU(adoc(ID_FIELD, String.valueOf(i), TEST_FIELD, String.valueOf(i)));
+
+ if(rand.nextBoolean()) {
+ assertU(commit());
+ }
+ }
+
+ assertU(commit());
+
+ withNewRawReader(h, topReader -> {
+ assertEquals(110, topReader.numDocs());
+
+ final FieldInfos infos = MultiFields.getMergedFieldInfos(topReader);
+ // The global field type should have docValues because a document with dvs was added
+ assertEquals(DocValuesType.SORTED, infos.fieldInfo(TEST_FIELD).getDocValuesType());
+ });
+
+ int optimizeSegments = 1;
+ assertU(optimize("maxSegments", String.valueOf(optimizeSegments)));
+
+
+ // Assert all docs have the right docvalues
+ withNewRawReader(h, topReader -> {
+ // Assert merged into one segment
+ assertEquals(110, topReader.numDocs());
+ assertEquals(optimizeSegments, topReader.leaves().size());
+
+
+ final FieldInfos infos = MultiFields.getMergedFieldInfos(topReader);
+ // The global field type should have docValues because a document with dvs was added
+ assertEquals(DocValuesType.SORTED, infos.fieldInfo(TEST_FIELD).getDocValuesType());
+
+
+ // Check that all segments have the right docvalues type with the correct value
+ // Also check that other fields (e.g. the id field) didn't mistakenly get docvalues added
+ for (LeafReaderContext ctx : topReader.leaves()) {
+ LeafReader r = ctx.reader();
+ SortedDocValues docvalues = r.getSortedDocValues(TEST_FIELD);
+ for(int i = 0; i < r.numDocs(); ++i) {
+ Document doc = r.document(i);
+ String v = doc.getField(TEST_FIELD).stringValue();
+ String id = doc.getField(ID_FIELD).stringValue();
+ assertEquals(DocValuesType.SORTED, r.getFieldInfos().fieldInfo(TEST_FIELD).getDocValuesType());
+ assertEquals(DocValuesType.NONE, r.getFieldInfos().fieldInfo(ID_FIELD).getDocValuesType());
+ assertEquals(v, id);
+
+ docvalues.nextDoc();
+ assertEquals(v, docvalues.binaryValue().utf8ToString());
+ }
+ }
+ });
+ }
+
+
+ // When an non-indexed field gets merged, it exhibit the old behavior
+ // The field will be merged, docvalues headers updated, but no docvalues for this field
+ public void testNonIndexedFieldDoesNonFail() throws Exception {
+ // Remove Indexed from fieldType
+ removeIndexFrom(h, TEST_FIELD);
+
+ assertU(adoc(ID_FIELD, String.valueOf(1), TEST_FIELD, String.valueOf(1)));
+ assertU(commit());
+
+ addDocValuesTo(h, TEST_FIELD);
+
+ assertU(adoc(ID_FIELD, String.valueOf(2), TEST_FIELD, String.valueOf(2)));
+ assertU(commit());
+
+ assertU(optimize("maxSegments", "1"));
+
+ withNewRawReader(h, topReader -> {
+ // Assert merged into one segment
+ assertEquals(2, topReader.numDocs());
+ assertEquals(1, topReader.leaves().size());
+
+
+ final FieldInfos infos = MultiFields.getMergedFieldInfos(topReader);
+ // The global field type should have docValues because a document with dvs was added
+ assertEquals(DocValuesType.SORTED, infos.fieldInfo(TEST_FIELD).getDocValuesType());
+
+ for (LeafReaderContext ctx : topReader.leaves()) {
+ LeafReader r = ctx.reader();
+ SortedDocValues docvalues = r.getSortedDocValues(TEST_FIELD);
+ for(int i = 0; i < r.numDocs(); ++i) {
+ Document doc = r.document(i);
+ String v = doc.getField(TEST_FIELD).stringValue();
+ String id = doc.getField(ID_FIELD).stringValue();
+ assertEquals(DocValuesType.SORTED, r.getFieldInfos().fieldInfo(TEST_FIELD).getDocValuesType());
+ assertEquals(DocValuesType.NONE, r.getFieldInfos().fieldInfo(ID_FIELD).getDocValuesType());
+
+
+ if(id.equals("2")) {
+ assertTrue(docvalues.advanceExact(i));
+ assertEquals(v, docvalues.binaryValue().utf8ToString());
+ } else {
+ assertFalse(docvalues.advanceExact(i));
+ }
+
+ }
+ }
+ });
+ }
+
+
+ private static void addDocValuesTo(TestHarness h, String fieldName) {
+ implUpdateSchemaField(h, fieldName, (p) -> (p | 0x00008000)); // FieldProperties.DOC_VALUES
+ }
+
+ private static void removeIndexFrom(TestHarness h, String fieldName) {
+ implUpdateSchemaField(h, fieldName, (p) -> (p ^ 0x00000001)); // FieldProperties.INDEXED
+ }
+
+ private static void implUpdateSchemaField(TestHarness h, String fieldName, IntUnaryOperator propertiesModifier) {
+ try (SolrCore core = h.getCoreInc()) {
+
+ // Add docvalues to the field type
+ IndexSchema schema = core.getLatestSchema();
+ SchemaField oldSchemaField = schema.getField(fieldName);
+ SchemaField newSchemaField = new SchemaField(
+ fieldName,
+ oldSchemaField.getType(),
+ propertiesModifier.applyAsInt(oldSchemaField.getProperties()),
+ oldSchemaField.getDefaultValue());
+ schema.getFields().put(fieldName, newSchemaField);
+ }
+ }
+
+ private interface DirectoryReaderConsumer {
+ public void accept(DirectoryReader consumer) throws Exception;
+ }
+
+ private static void withNewRawReader(TestHarness h, DirectoryReaderConsumer consumer) {
+ try (SolrCore core = h.getCoreInc()) {
+ final RefCounted<SolrIndexSearcher> searcherRef = core.openNewSearcher(true, true);
+ final SolrIndexSearcher searcher = searcherRef.get();
+ try {
+ try {
+ consumer.accept(searcher.getRawReader());
+ } catch (Exception e) {
+ fail(e.toString());
+ }
+ } finally {
+ searcherRef.decref();
+ }
+ }
+ }
+}
[16/19] lucene-solr:feature/autoscaling: LUCENE-7739: Fix places
where we unnecessarily boxed while parsing a numeric value according to
FindBugs
Posted by sh...@apache.org.
LUCENE-7739: Fix places where we unnecessarily boxed while parsing a numeric value according to FindBugs
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/10b7be59
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/10b7be59
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/10b7be59
Branch: refs/heads/feature/autoscaling
Commit: 10b7be59f71de5789e47eee60426018dc342e333
Parents: 9f72056
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Mar 15 06:08:10 2017 -0400
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
lucene/CHANGES.txt | 4 ++++
.../benchmark/byTask/feeds/EnwikiContentSource.java | 2 +-
.../benchmark/byTask/tasks/ForceMergeTask.java | 2 +-
.../test/org/apache/lucene/util/fst/TestFSTs.java | 4 ++--
.../apache/lucene/search/join/TestBlockJoin.java | 2 +-
.../search/TestDiversifiedTopDocsCollector.java | 2 +-
.../lucene/queries/function/TestValueSources.java | 6 +++---
.../lucene/queryparser/classic/QueryParserBase.java | 6 +++---
.../standard/parser/StandardSyntaxParser.java | 8 ++++----
.../standard/parser/StandardSyntaxParser.jj | 8 ++++----
.../queryparser/surround/parser/QueryParser.java | 2 +-
.../queryparser/surround/parser/QueryParser.jj | 2 +-
.../xml/builders/PointRangeQueryBuilder.java | 16 ++++++++--------
.../lucene/queryparser/classic/TestQueryParser.java | 2 +-
.../queryparser/xml/CoreParserTestIndexData.java | 2 +-
.../analytics/util/RangeEndpointCalculator.java | 8 ++++----
.../handler/dataimport/MailEntityProcessor.java | 2 +-
.../src/java/org/apache/solr/response/PageTool.java | 2 +-
.../java/org/apache/solr/handler/IndexFetcher.java | 6 +++---
.../org/apache/solr/handler/ReplicationHandler.java | 2 +-
.../solr/handler/component/RangeFacetRequest.java | 8 ++++----
.../org/apache/solr/parser/SolrQueryParserBase.java | 4 ++--
.../org/apache/solr/search/facet/FacetRange.java | 8 ++++----
.../processor/TolerantUpdateProcessorFactory.java | 2 +-
.../java/org/apache/solr/util/DateMathParser.java | 2 +-
.../java/org/apache/solr/util/SolrPluginUtils.java | 4 ++--
.../solr/core/snapshots/TestSolrCloudSnapshots.java | 2 +-
.../solr/core/snapshots/TestSolrCoreSnapshots.java | 2 +-
.../apache/solr/search/TestSolrFieldCacheMBean.java | 4 ++--
.../apache/solr/search/mlt/CloudMLTQParserTest.java | 14 +++++++-------
30 files changed, 71 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 62f4763..bd38f3f 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -259,6 +259,10 @@ Optimizations
* LUCENE-7742: Fix places where we were unboxing and then re-boxing
according to FindBugs (Daniel Jelinski via Mike McCandless)
+* LUCENE-7739: Fix places where we unnecessarily boxed while parsing
+ a numeric value according to FindBugs (Daniel Jelinski via Mike
+ McCandless)
+
Build
* LUCENE-7653: Update randomizedtesting to version 2.5.0. (Dawid Weiss)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSource.java
----------------------------------------------------------------------
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSource.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSource.java
index a933e56..7258476 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSource.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSource.java
@@ -101,7 +101,7 @@ public class EnwikiContentSource extends ContentSource {
buffer.append(original.substring(8, 10));
buffer.append('-');
- buffer.append(months[Integer.valueOf(original.substring(5, 7)).intValue() - 1]);
+ buffer.append(months[Integer.parseInt(original.substring(5, 7)) - 1]);
buffer.append('-');
buffer.append(original.substring(0, 4));
buffer.append(' ');
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ForceMergeTask.java
----------------------------------------------------------------------
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ForceMergeTask.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ForceMergeTask.java
index 40a3637..292642f 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ForceMergeTask.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ForceMergeTask.java
@@ -46,7 +46,7 @@ public class ForceMergeTask extends PerfTask {
@Override
public void setParams(String params) {
super.setParams(params);
- maxNumSegments = Double.valueOf(params).intValue();
+ maxNumSegments = (int)Double.parseDouble(params);
}
@Override
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java b/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
index dcce285..7a8e5f5 100644
--- a/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
+++ b/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
@@ -624,10 +624,10 @@ public class TestFSTs extends LuceneTestCase {
int idx = 0;
while (idx < args.length) {
if (args[idx].equals("-prune")) {
- prune = Integer.valueOf(args[1 + idx]);
+ prune = Integer.parseInt(args[1 + idx]);
idx++;
} else if (args[idx].equals("-limit")) {
- limit = Integer.valueOf(args[1 + idx]);
+ limit = Integer.parseInt(args[1 + idx]);
idx++;
} else if (args[idx].equals("-utf8")) {
inputMode = 0;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
----------------------------------------------------------------------
diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
index a13e66f..da3c20e 100644
--- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
@@ -1011,7 +1011,7 @@ public class TestBlockJoin extends LuceneTestCase {
TopDocs childHits = new TopDocs(0, new ScoreDoc[0], 0f);
for (ScoreDoc controlHit : controlHits.scoreDocs) {
Document controlDoc = r.document(controlHit.doc);
- int parentID = Integer.valueOf(controlDoc.get("parentID"));
+ int parentID = Integer.parseInt(controlDoc.get("parentID"));
if (parentID != currentParentID) {
assertEquals(childHitSlot, childHits.scoreDocs.length);
currentParentID = parentID;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java
----------------------------------------------------------------------
diff --git a/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java b/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java
index 043141a..f07793a 100644
--- a/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java
+++ b/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java
@@ -392,7 +392,7 @@ public class TestDiversifiedTopDocsCollector extends LuceneTestCase {
for (int i = 0; i < hitsOfThe60s.length; i++) {
String cols[] = hitsOfThe60s[i].split("\t");
Record record = new Record(String.valueOf(i), cols[0], cols[1], cols[2],
- Float.valueOf(cols[3]));
+ Float.parseFloat(cols[3]));
parsedRecords.put(record.id, record);
idField.setStringValue(record.id);
yearField.setStringValue(record.year);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java
----------------------------------------------------------------------
diff --git a/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java b/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java
index e008293..8008590 100644
--- a/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java
+++ b/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java
@@ -123,9 +123,9 @@ public class TestValueSources extends LuceneTestCase {
document.add(new StringField("id", doc[0], Field.Store.NO));
document.add(new SortedDocValuesField("id", new BytesRef(doc[0])));
document.add(new NumericDocValuesField("double", Double.doubleToRawLongBits(Double.parseDouble(doc[1]))));
- document.add(new NumericDocValuesField("float", Float.floatToRawIntBits(Float.valueOf(doc[2]))));
- document.add(new NumericDocValuesField("int", Integer.valueOf(doc[3])));
- document.add(new NumericDocValuesField("long", Long.valueOf(doc[4])));
+ document.add(new NumericDocValuesField("float", Float.floatToRawIntBits(Float.parseFloat(doc[2]))));
+ document.add(new NumericDocValuesField("int", Integer.parseInt(doc[3])));
+ document.add(new NumericDocValuesField("long", Long.parseLong(doc[4])));
document.add(new StringField("string", doc[5], Field.Store.NO));
document.add(new SortedDocValuesField("string", new BytesRef(doc[5])));
document.add(new TextField("text", doc[6], Field.Store.NO));
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java
index 3cfa7d0..cff9efa 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java
@@ -837,7 +837,7 @@ public abstract class QueryParserBase extends QueryBuilder implements CommonQuer
Query q;
float fms = fuzzyMinSim;
try {
- fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue();
+ fms = Float.parseFloat(fuzzySlop.image.substring(1));
} catch (Exception ignored) { }
if(fms < 0.0f){
throw new ParseException("Minimum similarity for a FuzzyQuery has to be between 0.0f and 1.0f !");
@@ -853,7 +853,7 @@ public abstract class QueryParserBase extends QueryBuilder implements CommonQuer
int s = phraseSlop; // default
if (fuzzySlop != null) {
try {
- s = Float.valueOf(fuzzySlop.image.substring(1)).intValue();
+ s = (int)Float.parseFloat(fuzzySlop.image.substring(1));
}
catch (Exception ignored) { }
}
@@ -865,7 +865,7 @@ public abstract class QueryParserBase extends QueryBuilder implements CommonQuer
if (boost != null) {
float f = (float) 1.0;
try {
- f = Float.valueOf(boost.image).floatValue();
+ f = Float.parseFloat(boost.image);
}
catch (Exception ignored) {
/* Should this be handled somehow? (defaults to "no boost", if
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
index ed0d67c..8ba34a6 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
@@ -466,7 +466,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
if (boost != null) {
float f = (float)1.0;
try {
- f = Float.valueOf(boost.image).floatValue();
+ f = Float.parseFloat(boost.image);
// avoid boosting null queries, such as those caused by stop words
if (q != null) {
q = new BoostQueryNode(q, f);
@@ -542,7 +542,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
if (fuzzy) {
float fms = defaultMinSimilarity;
try {
- fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue();
+ fms = Float.parseFloat(fuzzySlop.image.substring(1));
} catch (Exception ignored) { }
if(fms < 0.0f){
{if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));}
@@ -661,7 +661,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
if (fuzzySlop != null) {
try {
- phraseSlop = Float.valueOf(fuzzySlop.image.substring(1)).intValue();
+ phraseSlop = (int)Float.parseFloat(fuzzySlop.image.substring(1));
q = new SlopQueryNode(q, phraseSlop);
}
catch (Exception ignored) {
@@ -679,7 +679,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
if (boost != null) {
float f = (float)1.0;
try {
- f = Float.valueOf(boost.image).floatValue();
+ f = Float.parseFloat(boost.image);
// avoid boosting null queries, such as those caused by stop words
if (q != null) {
q = new BoostQueryNode(q, f);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj
index 868b257..b53bab3 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj
@@ -391,7 +391,7 @@ QueryNode Clause(CharSequence field) : {
if (boost != null) {
float f = (float)1.0;
try {
- f = Float.valueOf(boost.image).floatValue();
+ f = Float.parseFloat(boost.image);
// avoid boosting null queries, such as those caused by stop words
if (q != null) {
q = new BoostQueryNode(q, f);
@@ -431,7 +431,7 @@ QueryNode Term(CharSequence field) : {
if (fuzzy) {
float fms = defaultMinSimilarity;
try {
- fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue();
+ fms = Float.parseFloat(fuzzySlop.image.substring(1));
} catch (Exception ignored) { }
if(fms < 0.0f){
throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));
@@ -472,7 +472,7 @@ QueryNode Term(CharSequence field) : {
if (fuzzySlop != null) {
try {
- phraseSlop = Float.valueOf(fuzzySlop.image.substring(1)).intValue();
+ phraseSlop = (int)Float.parseFloat(fuzzySlop.image.substring(1));
q = new SlopQueryNode(q, phraseSlop);
}
catch (Exception ignored) {
@@ -488,7 +488,7 @@ QueryNode Term(CharSequence field) : {
if (boost != null) {
float f = (float)1.0;
try {
- f = Float.valueOf(boost.image).floatValue();
+ f = Float.parseFloat(boost.image);
// avoid boosting null queries, such as those caused by stop words
if (q != null) {
q = new BoostQueryNode(q, f);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
index bd91f04..f0f4b34 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
@@ -481,7 +481,7 @@ public class QueryParser implements QueryParserConstants {
weight = jj_consume_token(NUMBER);
float f;
try {
- f = Float.valueOf(weight.image).floatValue();
+ f = Float.parseFloat(weight.image);
} catch (Exception floatExc) {
{if (true) throw new ParseException(boostErrorMessage + weight.image + " (" + floatExc + ")");}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj
index d63189d..857cca1 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj
@@ -460,7 +460,7 @@ void OptionalWeights(SrndQuery q) : {
( <CARAT> weight=<NUMBER> {
float f;
try {
- f = Float.valueOf(weight.image).floatValue();
+ f = Float.parseFloat(weight.image);
} catch (Exception floatExc) {
throw new ParseException(boostErrorMessage + weight.image + " (" + floatExc + ")");
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/PointRangeQueryBuilder.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/PointRangeQueryBuilder.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/PointRangeQueryBuilder.java
index 82f7039..1297ad4 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/PointRangeQueryBuilder.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/PointRangeQueryBuilder.java
@@ -79,20 +79,20 @@ public class PointRangeQueryBuilder implements QueryBuilder {
try {
if (type.equalsIgnoreCase("int")) {
return IntPoint.newRangeQuery(field,
- (lowerTerm == null ? Integer.MIN_VALUE : Integer.valueOf(lowerTerm)),
- (upperTerm == null ? Integer.MAX_VALUE : Integer.valueOf(upperTerm)));
+ (lowerTerm == null ? Integer.MIN_VALUE : Integer.parseInt(lowerTerm)),
+ (upperTerm == null ? Integer.MAX_VALUE : Integer.parseInt(upperTerm)));
} else if (type.equalsIgnoreCase("long")) {
return LongPoint.newRangeQuery(field,
- (lowerTerm == null ? Long.MIN_VALUE : Long.valueOf(lowerTerm)),
- (upperTerm == null ? Long.MAX_VALUE : Long.valueOf(upperTerm)));
+ (lowerTerm == null ? Long.MIN_VALUE : Long.parseLong(lowerTerm)),
+ (upperTerm == null ? Long.MAX_VALUE : Long.parseLong(upperTerm)));
} else if (type.equalsIgnoreCase("double")) {
return DoublePoint.newRangeQuery(field,
- (lowerTerm == null ? Double.NEGATIVE_INFINITY : Double.valueOf(lowerTerm)),
- (upperTerm == null ? Double.POSITIVE_INFINITY : Double.valueOf(upperTerm)));
+ (lowerTerm == null ? Double.NEGATIVE_INFINITY : Double.parseDouble(lowerTerm)),
+ (upperTerm == null ? Double.POSITIVE_INFINITY : Double.parseDouble(upperTerm)));
} else if (type.equalsIgnoreCase("float")) {
return FloatPoint.newRangeQuery(field,
- (lowerTerm == null ? Float.NEGATIVE_INFINITY : Float.valueOf(lowerTerm)),
- (upperTerm == null ? Float.POSITIVE_INFINITY : Float.valueOf(upperTerm)));
+ (lowerTerm == null ? Float.NEGATIVE_INFINITY : Float.parseFloat(lowerTerm)),
+ (upperTerm == null ? Float.POSITIVE_INFINITY : Float.parseFloat(upperTerm)));
} else {
throw new ParserException("type attribute must be one of: [long, int, double, float]");
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java
index e8533e0..3450794 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java
@@ -193,7 +193,7 @@ public class TestQueryParser extends QueryParserTestBase {
if(fuzzySlop.image.endsWith("\u20ac")) {
float fms = fuzzyMinSim;
try {
- fms = Float.valueOf(fuzzySlop.image.substring(1, fuzzySlop.image.length()-1)).floatValue();
+ fms = Float.parseFloat(fuzzySlop.image.substring(1, fuzzySlop.image.length()-1));
} catch (Exception ignored) { }
float value = Float.parseFloat(termImage);
return getRangeQuery(qfield, Float.toString(value-fms/2.f), Float.toString(value+fms/2.f), true, true);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/CoreParserTestIndexData.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/CoreParserTestIndexData.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/CoreParserTestIndexData.java
index 5fa1523..4756888 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/CoreParserTestIndexData.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/CoreParserTestIndexData.java
@@ -52,7 +52,7 @@ class CoreParserTestIndexData implements Closeable {
Document doc = new Document();
doc.add(LuceneTestCase.newTextField("date", date, Field.Store.YES));
doc.add(LuceneTestCase.newTextField("contents", content, Field.Store.YES));
- doc.add(new IntPoint("date3", Integer.valueOf(date)));
+ doc.add(new IntPoint("date3", Integer.parseInt(date)));
writer.addDocument(doc);
line = d.readLine();
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java
index c3c2088..fa29022 100644
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java
+++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java
@@ -265,7 +265,7 @@ public abstract class RangeEndpointCalculator<T extends Comparable<T>> {
@Override
public Float parseAndAddGap(Float value, String gap) {
- return new Float(value.floatValue() + Float.valueOf(gap).floatValue());
+ return new Float(value.floatValue() + Float.parseFloat(gap));
}
}
@@ -281,7 +281,7 @@ public abstract class RangeEndpointCalculator<T extends Comparable<T>> {
@Override
public Double parseAndAddGap(Double value, String gap) {
- return new Double(value.doubleValue() + Double.valueOf(gap).doubleValue());
+ return new Double(value.doubleValue() + Double.parseDouble(gap));
}
}
@@ -297,7 +297,7 @@ public abstract class RangeEndpointCalculator<T extends Comparable<T>> {
@Override
public Integer parseAndAddGap(Integer value, String gap) {
- return new Integer(value.intValue() + Integer.valueOf(gap).intValue());
+ return new Integer(value.intValue() + Integer.parseInt(gap));
}
}
@@ -313,7 +313,7 @@ public abstract class RangeEndpointCalculator<T extends Comparable<T>> {
@Override
public Long parseAndAddGap(Long value, String gap) {
- return new Long(value.longValue() + Long.valueOf(gap).longValue());
+ return new Long(value.longValue() + Long.parseLong(gap));
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java
----------------------------------------------------------------------
diff --git a/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java b/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java
index 0258c33..7545eac 100644
--- a/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java
+++ b/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java
@@ -843,7 +843,7 @@ public class MailEntityProcessor extends EntityProcessorBase {
String val = context.getEntityAttribute(prop);
if (val != null) {
val = context.replaceTokens(val);
- v = Integer.valueOf(val);
+ v = Integer.parseInt(val);
}
} catch (NumberFormatException e) {
// do nothing
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java
----------------------------------------------------------------------
diff --git a/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java b/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java
index 1947f36..48dc826 100644
--- a/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java
+++ b/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java
@@ -38,7 +38,7 @@ public class PageTool {
String rows = request.getParams().get("rows");
if (rows != null) {
- results_per_page = new Integer(rows);
+ results_per_page = Integer.parseInt(rows);
}
//TODO: Handle group by results
Object docs = response.getResponse();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index a07496f..33e8091 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -697,7 +697,7 @@ public class IndexFetcher {
int indexCount = 1, confFilesCount = 1;
if (props.containsKey(TIMES_INDEX_REPLICATED)) {
- indexCount = Integer.valueOf(props.getProperty(TIMES_INDEX_REPLICATED)) + 1;
+ indexCount = Integer.parseInt(props.getProperty(TIMES_INDEX_REPLICATED)) + 1;
}
StringBuilder sb = readToStringBuilder(replicationTime, props.getProperty(INDEX_REPLICATED_AT_LIST));
props.setProperty(INDEX_REPLICATED_AT_LIST, sb.toString());
@@ -708,7 +708,7 @@ public class IndexFetcher {
props.setProperty(CONF_FILES_REPLICATED, confFiles.toString());
props.setProperty(CONF_FILES_REPLICATED_AT, String.valueOf(replicationTime));
if (props.containsKey(TIMES_CONFIG_REPLICATED)) {
- confFilesCount = Integer.valueOf(props.getProperty(TIMES_CONFIG_REPLICATED)) + 1;
+ confFilesCount = Integer.parseInt(props.getProperty(TIMES_CONFIG_REPLICATED)) + 1;
}
props.setProperty(TIMES_CONFIG_REPLICATED, String.valueOf(confFilesCount));
}
@@ -717,7 +717,7 @@ public class IndexFetcher {
if (!successfulInstall) {
int numFailures = 1;
if (props.containsKey(TIMES_FAILED)) {
- numFailures = Integer.valueOf(props.getProperty(TIMES_FAILED)) + 1;
+ numFailures = Integer.parseInt(props.getProperty(TIMES_FAILED)) + 1;
}
props.setProperty(TIMES_FAILED, String.valueOf(numFailures));
props.setProperty(REPLICATION_FAILED_AT, String.valueOf(replicationTime));
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/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 e40b2c3..4f6a408 100644
--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@@ -1075,7 +1075,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
String ss[] = s.split(",");
List<String> l = new ArrayList<>();
for (String s1 : ss) {
- l.add(new Date(Long.valueOf(s1)).toString());
+ l.add(new Date(Long.parseLong(s1)).toString());
}
nl.add(key, l);
} else {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/java/org/apache/solr/handler/component/RangeFacetRequest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RangeFacetRequest.java b/solr/core/src/java/org/apache/solr/handler/component/RangeFacetRequest.java
index 3ac7300..c234866 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RangeFacetRequest.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RangeFacetRequest.java
@@ -659,7 +659,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase {
@Override
public Float parseAndAddGap(Float value, String gap) {
- return new Float(value.floatValue() + Float.valueOf(gap).floatValue());
+ return new Float(value.floatValue() + Float.parseFloat(gap));
}
}
@@ -677,7 +677,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase {
@Override
public Double parseAndAddGap(Double value, String gap) {
- return new Double(value.doubleValue() + Double.valueOf(gap).doubleValue());
+ return new Double(value.doubleValue() + Double.parseDouble(gap));
}
}
@@ -695,7 +695,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase {
@Override
public Integer parseAndAddGap(Integer value, String gap) {
- return new Integer(value.intValue() + Integer.valueOf(gap).intValue());
+ return new Integer(value.intValue() + Integer.parseInt(gap));
}
}
@@ -713,7 +713,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase {
@Override
public Long parseAndAddGap(Long value, String gap) {
- return new Long(value.longValue() + Long.valueOf(gap).longValue());
+ return new Long(value.longValue() + Long.parseLong(gap));
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
index 84ffcb9..cb3b1ee 100644
--- a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
+++ b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
@@ -623,7 +623,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder {
} else if (fuzzy) {
float fms = fuzzyMinSim;
try {
- fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue();
+ fms = Float.parseFloat(fuzzySlop.image.substring(1));
} catch (Exception ignored) { }
if(fms < 0.0f){
throw new SyntaxError("Minimum similarity for a FuzzyQuery has to be between 0.0f and 1.0f !");
@@ -644,7 +644,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder {
int s = phraseSlop; // default
if (fuzzySlop != null) {
try {
- s = Float.valueOf(fuzzySlop.image.substring(1)).intValue();
+ s = (int)Float.parseFloat(fuzzySlop.image.substring(1));
}
catch (Exception ignored) { }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/java/org/apache/solr/search/facet/FacetRange.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetRange.java b/solr/core/src/java/org/apache/solr/search/facet/FacetRange.java
index 276af5f..a50fa2c 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/FacetRange.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/FacetRange.java
@@ -499,7 +499,7 @@ class FacetRangeProcessor extends FacetProcessor<FacetRange> {
}
@Override
public Float parseAndAddGap(Comparable value, String gap) {
- return new Float(((Number)value).floatValue() + Float.valueOf(gap).floatValue());
+ return new Float(((Number)value).floatValue() + Float.parseFloat(gap));
}
}
private static class DoubleCalc extends Calc {
@@ -520,7 +520,7 @@ class FacetRangeProcessor extends FacetProcessor<FacetRange> {
}
@Override
public Double parseAndAddGap(Comparable value, String gap) {
- return new Double(((Number)value).doubleValue() + Double.valueOf(gap).doubleValue());
+ return new Double(((Number)value).doubleValue() + Double.parseDouble(gap));
}
}
private static class IntCalc extends Calc {
@@ -532,7 +532,7 @@ class FacetRangeProcessor extends FacetProcessor<FacetRange> {
}
@Override
public Integer parseAndAddGap(Comparable value, String gap) {
- return new Integer(((Number)value).intValue() + Integer.valueOf(gap).intValue());
+ return new Integer(((Number)value).intValue() + Integer.parseInt(gap));
}
}
private static class LongCalc extends Calc {
@@ -544,7 +544,7 @@ class FacetRangeProcessor extends FacetProcessor<FacetRange> {
}
@Override
public Long parseAndAddGap(Comparable value, String gap) {
- return new Long(((Number)value).longValue() + Long.valueOf(gap).longValue());
+ return new Long(((Number)value).longValue() + Long.parseLong(gap));
}
}
private static class DateCalc extends Calc {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessorFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessorFactory.java
index b642d89..8ee5ff2 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessorFactory.java
@@ -99,7 +99,7 @@ public class TolerantUpdateProcessorFactory extends UpdateRequestProcessorFactor
Object maxErrorsObj = args.get(MAX_ERRORS_PARAM);
if (maxErrorsObj != null) {
try {
- defaultMaxErrors = Integer.valueOf(maxErrorsObj.toString());
+ defaultMaxErrors = Integer.parseInt(maxErrorsObj.toString());
} catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Unnable to parse maxErrors parameter: " + maxErrorsObj, e);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/java/org/apache/solr/util/DateMathParser.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/DateMathParser.java b/solr/core/src/java/org/apache/solr/util/DateMathParser.java
index 643fde8..2124d1d 100644
--- a/solr/core/src/java/org/apache/solr/util/DateMathParser.java
+++ b/solr/core/src/java/org/apache/solr/util/DateMathParser.java
@@ -381,7 +381,7 @@ public class DateMathParser {
}
int val = 0;
try {
- val = Integer.valueOf(ops[pos++]);
+ val = Integer.parseInt(ops[pos++]);
} catch (NumberFormatException e) {
throw new ParseException
("Not a Number: \"" + ops[pos-1] + "\"", pos-1);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
index 9386600..4445e07 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
@@ -583,8 +583,8 @@ public class SolrPluginUtils {
String[] fieldAndSlopVsBoost = caratPattern.split(s);
String[] fieldVsSlop = tildePattern.split(fieldAndSlopVsBoost[0]);
String field = fieldVsSlop[0];
- int slop = (2 == fieldVsSlop.length) ? Integer.valueOf(fieldVsSlop[1]) : defaultSlop;
- Float boost = (1 == fieldAndSlopVsBoost.length) ? 1 : Float.valueOf(fieldAndSlopVsBoost[1]);
+ int slop = (2 == fieldVsSlop.length) ? Integer.parseInt(fieldVsSlop[1]) : defaultSlop;
+ float boost = (1 == fieldAndSlopVsBoost.length) ? 1 : Float.parseFloat(fieldAndSlopVsBoost[1]);
FieldParams fp = new FieldParams(field,wordGrams,slop,boost);
out.add(fp);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java
index bb56a94..9503ee4 100644
--- a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java
+++ b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java
@@ -295,7 +295,7 @@ public class TestSolrCloudSnapshots extends SolrCloudTestCase {
for(int i = 0 ; i < apiResult.size(); i++) {
String commitName = apiResult.getName(i);
String indexDirPath = (String)((NamedList)apiResult.get(commitName)).get(SolrSnapshotManager.INDEX_DIR_PATH);
- long genNumber = Long.valueOf((String)((NamedList)apiResult.get(commitName)).get(SolrSnapshotManager.GENERATION_NUM));
+ long genNumber = Long.parseLong((String)((NamedList)apiResult.get(commitName)).get(SolrSnapshotManager.GENERATION_NUM));
result.add(new SnapshotMetaData(commitName, indexDirPath, genNumber));
}
return result;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
index da6dbac..7a9b0bb 100644
--- a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
+++ b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
@@ -293,7 +293,7 @@ public class TestSolrCoreSnapshots extends SolrCloudTestCase {
for(int i = 0 ; i < apiResult.size(); i++) {
String commitName = apiResult.getName(i);
String indexDirPath = (String)((NamedList)apiResult.get(commitName)).get("indexDirPath");
- long genNumber = Long.valueOf((String)((NamedList)apiResult.get(commitName)).get("generation"));
+ long genNumber = Long.parseLong((String)((NamedList)apiResult.get(commitName)).get("generation"));
result.add(new SnapshotMetaData(commitName, indexDirPath, genNumber));
}
return result;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/test/org/apache/solr/search/TestSolrFieldCacheMBean.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestSolrFieldCacheMBean.java b/solr/core/src/test/org/apache/solr/search/TestSolrFieldCacheMBean.java
index 35bdec6..d11c919 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSolrFieldCacheMBean.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSolrFieldCacheMBean.java
@@ -68,7 +68,7 @@ public class TestSolrFieldCacheMBean extends SolrTestCaseJ4 {
private void assertEntryListIncluded(boolean checkJmx) {
SolrFieldCacheMBean mbean = new SolrFieldCacheMBean();
NamedList stats = checkJmx ? mbean.getStatisticsForJmx() : mbean.getStatistics();
- assert(new Integer(stats.get("entries_count").toString()) > 0);
+ assert(Integer.parseInt(stats.get("entries_count").toString()) > 0);
assertNotNull(stats.get("total_size"));
assertNotNull(stats.get("entry#0"));
}
@@ -76,7 +76,7 @@ public class TestSolrFieldCacheMBean extends SolrTestCaseJ4 {
private void assertEntryListNotIncluded(boolean checkJmx) {
SolrFieldCacheMBean mbean = new SolrFieldCacheMBean();
NamedList stats = checkJmx ? mbean.getStatisticsForJmx() : mbean.getStatistics();
- assert(new Integer(stats.get("entries_count").toString()) > 0);
+ assert(Integer.parseInt(stats.get("entries_count").toString()) > 0);
assertNull(stats.get("total_size"));
assertNull(stats.get("entry#0"));
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10b7be59/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java b/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java
index e3a8d7b..f502f24 100644
--- a/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java
+++ b/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java
@@ -102,7 +102,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase {
int[] actualIds = new int[10];
int i = 0;
for (SolrDocument solrDocument : solrDocuments) {
- actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id")));
+ actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
}
assertArrayEquals(expectedIds, actualIds);
@@ -117,7 +117,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase {
int[] actualIds = new int[solrDocuments.size()];
int i = 0;
for (SolrDocument solrDocument : solrDocuments) {
- actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id")));
+ actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
}
assertArrayEquals(expectedIds, actualIds);
@@ -127,7 +127,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase {
actualIds = new int[solrDocuments.size()];
i = 0;
for (SolrDocument solrDocument : solrDocuments) {
- actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id")));
+ actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
}
System.out.println("DEBUG ACTUAL IDS 1: " + Arrays.toString(actualIds));
assertArrayEquals(expectedIds, actualIds);
@@ -138,7 +138,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase {
actualIds = new int[solrDocuments.size()];
i = 0;
for (SolrDocument solrDocument : solrDocuments) {
- actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id")));
+ actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
}
System.out.println("DEBUG ACTUAL IDS 2: " + Arrays.toString(actualIds));
assertArrayEquals(expectedIds, actualIds);
@@ -154,7 +154,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase {
int[] actualIds = new int[solrDocuments.size()];
int i = 0;
for (SolrDocument solrDocument : solrDocuments) {
- actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id")));
+ actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
}
assertArrayEquals(expectedIds, actualIds);
@@ -184,7 +184,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase {
int[] actualIds = new int[solrDocuments.size()];
int i = 0;
for (SolrDocument solrDocument : solrDocuments) {
- actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id")));
+ actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
}
assertArrayEquals(expectedIds, actualIds);
@@ -236,7 +236,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase {
int i = 0;
StringBuilder sb = new StringBuilder();
for (SolrDocument solrDocument : solrDocuments) {
- actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id")));
+ actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
sb.append(actualIds[i-1]).append(", ");
}
assertArrayEquals(expectedIds, actualIds);
[09/19] lucene-solr:feature/autoscaling: SOLR-10076:
'String.format(Locale.ROOT,
...' instead of (forbidden API) 'String.format(...)'
Posted by sh...@apache.org.
SOLR-10076: 'String.format(Locale.ROOT,...' instead of (forbidden API) 'String.format(...)'
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6083f370
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6083f370
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6083f370
Branch: refs/heads/feature/autoscaling
Commit: 6083f370a15329dd476d817039d28af3d43ba213
Parents: bb3d2e1
Author: Christine Poerschke <cp...@apache.org>
Authored: Tue Mar 14 10:46:25 2017 +0000
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
.../src/java/org/apache/solr/handler/admin/SystemInfoHandler.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6083f370/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
index 94fb055..fc1679f 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
@@ -445,7 +445,7 @@ public class SystemInfoHandler extends RequestHandlerBase
List<String> list = new LinkedList<>();
for (String arg : mx.getInputArguments()) {
if (arg.startsWith("-D") && arg.contains("=") && RedactionUtils.isSystemPropertySensitive(arg.substring(2, arg.indexOf("=")))) {
- list.add(String.format("%s=%s", arg.substring(0, arg.indexOf("=")), REDACT_STRING));
+ list.add(String.format(Locale.ROOT, "%s=%s", arg.substring(0, arg.indexOf("=")), REDACT_STRING));
} else {
list.add(arg);
}
[18/19] lucene-solr:feature/autoscaling: SOLR-10085: SQL result set
fields should be ordered by the field list
Posted by sh...@apache.org.
SOLR-10085: SQL result set fields should be ordered by the field list
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/260159a6
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/260159a6
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/260159a6
Branch: refs/heads/feature/autoscaling
Commit: 260159a634d96fe5153a54da4db6485295720ecc
Parents: da56db8
Author: Joel Bernstein <jb...@apache.org>
Authored: Wed Mar 15 18:31:14 2017 -0400
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
.../org/apache/solr/handler/SQLHandler.java | 37 +++++++++++++++-----
.../org/apache/solr/handler/TestSQLHandler.java | 31 ++++++++++++++++
.../org/apache/solr/client/solrj/io/Tuple.java | 21 +++++++----
3 files changed, 74 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/260159a6/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/SQLHandler.java b/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
index d65ea56..7563fe8 100644
--- a/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
@@ -34,7 +34,9 @@ import org.apache.solr.client.solrj.io.stream.ExceptionStream;
import org.apache.solr.client.solrj.io.stream.JDBCStream;
import org.apache.solr.client.solrj.io.stream.TupleStream;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.sql.CalciteSolrDriver;
@@ -74,6 +76,9 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware, Per
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
+ params = adjustParams(params);
+ req.setParams(params);
+
String sql = params.get("stmt");
// Set defaults for parameters
params.set("numWorkers", params.getInt("numWorkers", 1));
@@ -139,6 +144,8 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware, Per
private class SqlHandlerStream extends JDBCStream {
private final boolean includeMetadata;
private boolean firstTuple = true;
+ List<String> metadataFields = new ArrayList<>();
+ Map<String, String> metadataAliases = new HashMap<>();
SqlHandlerStream(String connectionUrl, String sqlQuery, StreamComparator definedSort,
Properties connectionProperties, String driverClassName, boolean includeMetadata)
@@ -151,7 +158,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware, Per
@Override
public Tuple read() throws IOException {
// Return a metadata tuple as the first tuple and then pass through to the JDBCStream.
- if(includeMetadata && firstTuple) {
+ if(firstTuple) {
try {
Map<String, Object> fields = new HashMap<>();
@@ -159,8 +166,6 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware, Per
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- List<String> metadataFields = new ArrayList<>();
- Map<String, String> metadataAliases = new HashMap<>();
for(int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
String columnName = resultSetMetaData.getColumnName(i);
String columnLabel = resultSetMetaData.getColumnLabel(i);
@@ -168,16 +173,30 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware, Per
metadataAliases.put(columnName, columnLabel);
}
- fields.put("isMetadata", true);
- fields.put("fields", metadataFields);
- fields.put("aliases", metadataAliases);
- return new Tuple(fields);
+ if(includeMetadata) {
+ fields.put("isMetadata", true);
+ fields.put("fields", metadataFields);
+ fields.put("aliases", metadataAliases);
+ return new Tuple(fields);
+ }
} catch (SQLException e) {
throw new IOException(e);
}
- } else {
- return super.read();
}
+
+ Tuple tuple = super.read();
+ if(!tuple.EOF) {
+ tuple.fieldNames = metadataFields;
+ tuple.fieldLabels = metadataAliases;
+ }
+ return tuple;
}
}
+
+ private ModifiableSolrParams adjustParams(SolrParams params) {
+ ModifiableSolrParams adjustedParams = new ModifiableSolrParams();
+ adjustedParams.add(params);
+ adjustedParams.add(CommonParams.OMIT_HEADER, "true");
+ return adjustedParams;
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/260159a6/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
index f222cee..cb16f03 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
@@ -16,21 +16,30 @@
*/
package org.apache.solr.handler;
+import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.InputStreamResponseParser;
import org.apache.solr.client.solrj.io.Tuple;
import org.apache.solr.client.solrj.io.stream.ExceptionStream;
import org.apache.solr.client.solrj.io.stream.SolrStream;
import org.apache.solr.client.solrj.io.stream.TupleStream;
+import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -161,6 +170,9 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
assert(tuple.getLong("field_i") == 7);
assert(tuple.get("str_s").equals("a"));
+ //Assert field order
+ assertResponseContains(clients.get(0), sParams, "{\"docs\":[{\"id\":8,\"field_i\":60,\"str_s\":\"c\"}");
+
//Test unlimited unsorted result. Should sort on _version_ desc
sParams = mapParams(CommonParams.QT, "/sql", "stmt", "select id, field_i, str_s from collection1 where text='XXXX'");
@@ -2362,4 +2374,23 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
return params;
}
+ public void assertResponseContains(SolrClient server, SolrParams requestParams, String json) throws IOException, SolrServerException {
+ String p = requestParams.get("qt");
+ if(p != null) {
+ ModifiableSolrParams modifiableSolrParams = (ModifiableSolrParams) requestParams;
+ modifiableSolrParams.remove("qt");
+ }
+
+ QueryRequest query = new QueryRequest( requestParams );
+ query.setPath(p);
+ query.setResponseParser(new InputStreamResponseParser("json"));
+ query.setMethod(SolrRequest.METHOD.POST);
+ NamedList<Object> genericResponse = server.request(query);
+ InputStream stream = (InputStream)genericResponse.get("stream");
+ InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
+ BufferedReader bufferedReader = new BufferedReader(reader);
+ String response = bufferedReader.readLine();
+ assertTrue(response.contains(json));
+ }
+
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/260159a6/solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java
index 58d948d..fdf44c9 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java
@@ -45,6 +45,8 @@ public class Tuple implements Cloneable, MapWriter {
public boolean EXCEPTION;
public Map fields = new HashMap();
+ public List<String> fieldNames;
+ public Map<String, String> fieldLabels;
public Tuple(Map fields) {
if(fields.containsKey("EOF")) {
@@ -198,12 +200,19 @@ public class Tuple implements Cloneable, MapWriter {
@Override
public void writeMap(EntryWriter ew) throws IOException {
- fields.forEach((k, v) -> {
- try {
- ew.put((String)k,v);
- } catch (IOException e) {
- throw new RuntimeException(e);
+ if(fieldNames == null) {
+ fields.forEach((k, v) -> {
+ try {
+ ew.put((String) k, v);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ } else {
+ for(String fieldName : fieldNames) {
+ String label = fieldLabels.get(fieldName);
+ ew.put(label, fields.get(label));
}
- });
+ }
}
}
[12/19] lucene-solr:feature/autoscaling: SOLR-10224: Add disk total
and disk free metrics.
Posted by sh...@apache.org.
SOLR-10224: Add disk total and disk free metrics.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/533f968f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/533f968f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/533f968f
Branch: refs/heads/feature/autoscaling
Commit: 533f968f812054252a8c20ff892d49418c4f219f
Parents: 40c5fd8
Author: Andrzej Bialecki <ab...@apache.org>
Authored: Tue Mar 14 19:57:57 2017 +0100
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
.../core/src/java/org/apache/solr/core/CoreContainer.java | 7 ++++++-
solr/core/src/java/org/apache/solr/core/SolrCore.java | 7 +++++++
.../solr/metrics/reporters/solr/SolrClusterReporter.java | 10 ++++++----
.../solr/metrics/reporters/solr/SolrShardReporter.java | 5 +++--
5 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/533f968f/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 5f94171..b3ce30c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -183,6 +183,8 @@ New Features
* SOLR-10076: Hide keystore and truststore passwords from /admin/info/* outputs. (Mano Kovacs via Mark Miller)
+* SOLR-10224: Add disk total and disk free metrics. (ab)
+
Bug Fixes
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/533f968f/solr/core/src/java/org/apache/solr/core/CoreContainer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 2da48b8..9e22f91 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -530,7 +530,8 @@ public class CoreContainer {
containerProperties.putAll(cfg.getSolrProperties());
- // initialize gauges for reporting the number of cores
+ // initialize gauges for reporting the number of cores and disk total/free
+
String registryName = SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node);
metricManager.registerGauge(registryName, () -> solrCores.getCores().size(),
true, "loaded", SolrInfoMBean.Category.CONTAINER.toString(), "cores");
@@ -538,6 +539,10 @@ public class CoreContainer {
true, "lazy",SolrInfoMBean.Category.CONTAINER.toString(), "cores");
metricManager.registerGauge(registryName, () -> solrCores.getAllCoreNames().size() - solrCores.getCoreNames().size(),
true, "unloaded",SolrInfoMBean.Category.CONTAINER.toString(), "cores");
+ metricManager.registerGauge(registryName, () -> cfg.getCoreRootDirectory().toFile().getTotalSpace(),
+ true, "totalSpace", SolrInfoMBean.Category.CONTAINER.toString(), "fs");
+ metricManager.registerGauge(registryName, () -> cfg.getCoreRootDirectory().toFile().getUsableSpace(),
+ true, "usableSpace", SolrInfoMBean.Category.CONTAINER.toString(), "fs");
if (isZooKeeperAware()) {
metricManager.loadClusterReporters(cfg.getMetricReporterPlugins(), this);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/533f968f/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 bc41b19..6e25280 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -30,6 +30,8 @@ import java.lang.reflect.Constructor;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.NoSuchFileException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -1137,6 +1139,11 @@ public final class SolrCore implements SolrInfoMBean, SolrMetricProducer, Closea
manager.registerGauge(registry, () -> getIndexSize(), true, "sizeInBytes", Category.INDEX.toString());
manager.registerGauge(registry, () -> NumberUtils.readableSize(getIndexSize()), true, "size", Category.INDEX.toString());
manager.registerGauge(registry, () -> coreDescriptor.getCoreContainer().getCoreNames(this), true, "aliases", Category.CORE.toString());
+ // initialize disk total / free metrics
+ Path dataDirPath = Paths.get(dataDir);
+ File dataDirFile = dataDirPath.toFile();
+ manager.registerGauge(registry, () -> dataDirFile.getTotalSpace(), true, "totalSpace", Category.CORE.toString(), "fs");
+ manager.registerGauge(registry, () -> dataDirFile.getUsableSpace(), true, "usableSpace", Category.CORE.toString(), "fs");
}
private Map<String,SolrInfoMBean> initInfoRegistry(String name, SolrConfig config) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/533f968f/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java
index 846e805..0c3b651 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java
@@ -106,10 +106,12 @@ public class SolrClusterReporter extends SolrMetricReporter {
add("os\\.FreeSwapSpaceSize");
add("os\\.OpenFileDescriptorCount");
add("threads\\.count");
- }})); // all metrics
- // XXX anything interesting here?
- //add(new SolrReporter.Specification(OVERSEER_GROUP, "node", SolrMetricManager.overridableRegistryName(SolrInfoMBean.Group.node.toString()),
- // Collections.emptySet())); // all metrics
+ }}));
+ add(new SolrReporter.Report(CLUSTER_GROUP, "node", SolrMetricManager.overridableRegistryName(SolrInfoMBean.Group.node.toString()),
+ new HashSet<String>() {{
+ add("CONTAINER\\.cores\\..*");
+ add("CONTAINER\\.fs\\..*");
+ }}));
add(new SolrReporter.Report(CLUSTER_GROUP, "leader.$1", "solr\\.collection\\.(.*)\\.leader",
new HashSet<String>(){{
add("UPDATE\\./update/.*");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/533f968f/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java
index 2b20274..8b36d3e 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java
@@ -61,9 +61,10 @@ public class SolrShardReporter extends SolrMetricReporter {
public static final List<String> DEFAULT_FILTERS = new ArrayList(){{
add("TLOG.*");
+ add("CORE\\.fs.*");
add("REPLICATION.*");
- add("INDEX.flush.*");
- add("INDEX.merge.major.*");
+ add("INDEX\\.flush.*");
+ add("INDEX\\.merge\\.major.*");
add("UPDATE\\./update/.*requests");
add("QUERY\\./select.*requests");
}};
[11/19] lucene-solr:feature/autoscaling: SOLR-10184: Fix bin/solr so
it can run properly on java9
Posted by sh...@apache.org.
SOLR-10184: Fix bin/solr so it can run properly on java9
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/40c5fd87
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/40c5fd87
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/40c5fd87
Branch: refs/heads/feature/autoscaling
Commit: 40c5fd87f3d6ca09c92c42447b338dda525d9eb7
Parents: 8756903
Author: Chris Hostetter <ho...@apache.org>
Authored: Tue Mar 14 10:23:49 2017 -0700
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
solr/bin/solr | 57 ++++++++++++++++++++++++++++++------------------
solr/bin/solr.in.sh | 11 ++++++++--
3 files changed, 47 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/40c5fd87/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 94e5257..5f94171 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -249,6 +249,8 @@ Bug Fixes
legacyCloud=false and will also fail on a state check when taking over a core registration with a new
core. (Mark Miller, Hrishikesh Gadre, Patrick Dvorack)
+* SOLR-10184: Fix bin/solr so it can run properly on java9 (hossman, Uwe Schindler)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/40c5fd87/solr/bin/solr
----------------------------------------------------------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index cd9db0f..9563bb2 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -50,7 +50,7 @@ verbose=false
THIS_OS=`uname -s`
# What version of Java is required to run this version of Solr.
-JAVA_VER_REQ="8" # For printing in echo
+JAVA_VER_REQ="1.8"
stop_all=false
@@ -130,27 +130,34 @@ if [[ $? -ne 0 ]] ; then
echo >&2 "Please install latest version of Java $JAVA_VER_REQ or set JAVA_HOME properly."
echo >&2 "Command that we tried: '${JAVA} -version', with response:"
echo >&2 "${JAVA_VER}"
- echo
+ echo >&2
echo >&2 "Debug information:"
echo >&2 "JAVA_HOME: ${JAVA_HOME:-N/A}"
echo >&2 "Active Path:"
echo >&2 "${PATH}"
exit 1
else
- JAVA_VER=$(echo $JAVA_VER | awk -F '"' '/version/ {print $2}')
- if [[ "$JAVA_VER" < "1.$JAVA_VER_REQ" ]] ; then
+ JAVA_VER_NUM=$(echo $JAVA_VER | head -1 | awk -F '"' '/version/ {print $2}')
+ if [[ "$JAVA_VER_NUM" < "$JAVA_VER_REQ" ]] ; then
echo >&2 "Your current version of Java is too old to run this version of Solr"
- echo >&2 "We found version $JAVA_VER, using command '${JAVA}'"
+ echo >&2 "We found version $JAVA_VER_NUM, using command '${JAVA} -version', with response:"
+ echo >&2 "${JAVA_VER}"
+ echo >&2
echo >&2 "Please install latest version of Java $JAVA_VER_REQ or set JAVA_HOME properly."
- echo
+ echo >&2
echo >&2 "Debug information:"
echo >&2 "JAVA_HOME: ${JAVA_HOME:-N/A}"
echo >&2 "Active Path:"
echo >&2 "${PATH}"
exit 1
fi
+ JAVA_VENDOR="Oracle"
+ if [ "`echo $JAVA_VER | grep -i "IBM J9"`" != "" ]; then
+ JAVA_VENDOR="IBM J9"
+ fi
fi
+
# Select HTTP OR HTTPS related configurations
SOLR_URL_SCHEME=http
SOLR_JETTY_CONFIG=()
@@ -1519,29 +1526,37 @@ if [ "${SOLR_LOG_PRESTART_ROTATION:=true}" == "true" ]; then
run_tool utils -s "$DEFAULT_SERVER_DIR" -l "$SOLR_LOGS_DIR" $q -rotate_solr_logs 9 || echo "Failed rotating old solr logs"
fi
-java_ver_out=`echo "$("$JAVA" -version 2>&1)"`
-JAVA_VERSION=`echo $java_ver_out | grep "java version" | awk '{ print substr($3, 2, length($3)-2); }'`
-JAVA_VENDOR="Oracle"
-if [ "`echo $java_ver_out | grep -i "IBM J9"`" != "" ]; then
- JAVA_VENDOR="IBM J9"
-fi
-
-# Establish default opts no env var set (otherwise init to empty)
+# Establish default GC logging opts if no env var set (otherwise init to sensible default)
if [ -z ${GC_LOG_OPTS+x} ]; then
- GC_LOG_OPTS=('-verbose:gc' '-XX:+PrintHeapAtGC' '-XX:+PrintGCDetails' \
- '-XX:+PrintGCDateStamps' '-XX:+PrintGCTimeStamps' '-XX:+PrintTenuringDistribution' \
- '-XX:+PrintGCApplicationStoppedTime')
+ if [[ "$JAVA_VER_NUM" < "9" ]] ; then
+ GC_LOG_OPTS=('-verbose:gc' '-XX:+PrintHeapAtGC' '-XX:+PrintGCDetails' \
+ '-XX:+PrintGCDateStamps' '-XX:+PrintGCTimeStamps' '-XX:+PrintTenuringDistribution' \
+ '-XX:+PrintGCApplicationStoppedTime')
+ else
+ GC_LOG_OPTS=('-Xlog:gc*')
+ fi
else
GC_LOG_OPTS=($GC_LOG_OPTS)
fi
# if verbose gc logging enabled, setup the location of the log file and rotation
if [ "$GC_LOG_OPTS" != "" ]; then
- gc_log_flag="-Xloggc"
- if [ "$JAVA_VENDOR" == "IBM J9" ]; then
- gc_log_flag="-Xverbosegclog"
+ if [[ "$JAVA_VER_NUM" < "9" ]] ; then
+ gc_log_flag="-Xloggc"
+ if [ "$JAVA_VENDOR" == "IBM J9" ]; then
+ gc_log_flag="-Xverbosegclog"
+ fi
+ GC_LOG_OPTS+=("$gc_log_flag:$SOLR_LOGS_DIR/solr_gc.log" '-XX:+UseGCLogFileRotation' '-XX:NumberOfGCLogFiles=9' '-XX:GCLogFileSize=20M')
+ else
+ # http://openjdk.java.net/jeps/158
+ for i in "${!GC_LOG_OPTS[@]}";
+ do
+ # for simplicity, we only look at the prefix '-Xlog:gc'
+ # (if 'all' or multiple tags are used starting with anything other then 'gc' the user is on their own)
+ # if a single additional ':' exists in param, then there is already an explicit output specifier
+ GC_LOG_OPTS[$i]=$(echo ${GC_LOG_OPTS[$i]} | sed "s|^\(-Xlog:gc[^:]*$\)|\1:file=$SOLR_LOGS_DIR/solr_gc.log:time,uptime:filecount=9,filesize=20000|")
+ done
fi
- GC_LOG_OPTS+=("$gc_log_flag:$SOLR_LOGS_DIR/solr_gc.log" -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=9 -XX:GCLogFileSize=20M)
fi
# If ZK_HOST is defined, the assume SolrCloud mode
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/40c5fd87/solr/bin/solr.in.sh
----------------------------------------------------------------------
diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.sh
index 878702f..67839f9 100644
--- a/solr/bin/solr.in.sh
+++ b/solr/bin/solr.in.sh
@@ -34,9 +34,16 @@
# Comment out SOLR_HEAP if you are using this though, that takes precedence
#SOLR_JAVA_MEM="-Xms512m -Xmx512m"
-# Enable verbose GC logging
+# Enable verbose GC logging...
+# * If this is unset, various default options will be selected depending on which JVM version is in use
+# * For java8 or lower: if this is set, additional params will be added to specify the log file & rotation
+# * For java9 or higher: each included opt param that starts with '-Xlog:gc', but does not include an output
+# specifier, will have a 'file' output specifier (as well as formatting & rollover options) appended,
+# using the effective value of the SOLR_LOGS_DIR.
+#
+#GC_LOG_OPTS='-Xlog:gc*' # (java9)
#GC_LOG_OPTS="-verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails \
-#-XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime"
+# -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime"
# These GC settings have shown to work well for a number of common Solr workloads
#GC_TUNE="-XX:NewRatio=3 -XX:SurvivorRatio=4 etc.
[04/19] lucene-solr:feature/autoscaling: SOLR-10247: Support
non-numeric metrics and a "compact" format of /admin/metrics.
Posted by sh...@apache.org.
SOLR-10247: Support non-numeric metrics and a "compact" format of /admin/metrics.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/52b3bc2f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/52b3bc2f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/52b3bc2f
Branch: refs/heads/feature/autoscaling
Commit: 52b3bc2f6d16515f7f1e85a3a2e499ac68391427
Parents: 6083f37
Author: Andrzej Bialecki <ab...@apache.org>
Authored: Tue Mar 14 11:17:56 2017 +0100
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 2 +
.../org/apache/solr/core/CoreContainer.java | 18 ++---
.../src/java/org/apache/solr/core/SolrCore.java | 36 +++++++---
.../solr/handler/admin/MetricsHandler.java | 6 +-
.../apache/solr/metrics/SolrMetricManager.java | 5 +-
.../metrics/reporters/solr/SolrReporter.java | 2 +-
.../solr/update/DirectUpdateHandler2.java | 22 ++----
.../org/apache/solr/update/SolrIndexWriter.java | 25 ++-----
.../java/org/apache/solr/update/UpdateLog.java | 14 ++--
...entedPoolingHttpClientConnectionManager.java | 38 ++--------
.../org/apache/solr/util/stats/MetricUtils.java | 76 ++++++++++++--------
.../solr/handler/admin/MetricsHandlerTest.java | 22 +++++-
.../solr/update/DirectUpdateHandlerTest.java | 18 ++---
.../solr/update/SolrIndexMetricsTest.java | 5 +-
.../apache/solr/util/stats/MetricUtilsTest.java | 53 +++++++++++++-
15 files changed, 195 insertions(+), 147 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 4c987db..94e5257 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -339,6 +339,8 @@ Other Changes
* SOLR-8876: change morphline test config files to work around 'importCommands' bug when using java9 (hossman)
+* SOLR-10247: Support non-numeric metrics and a "compact" format of /admin/metrics output. (ab)
+
================== 6.4.2 ==================
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/52b3bc2f/solr/core/src/java/org/apache/solr/core/CoreContainer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 0de671e..2da48b8 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -36,7 +36,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
-import com.codahale.metrics.Gauge;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.apache.http.auth.AuthSchemeProvider;
@@ -532,16 +531,13 @@ public class CoreContainer {
containerProperties.putAll(cfg.getSolrProperties());
// initialize gauges for reporting the number of cores
- Gauge<Integer> loadedCores = () -> solrCores.getCores().size();
- Gauge<Integer> lazyCores = () -> solrCores.getCoreNames().size() - solrCores.getCores().size();
- Gauge<Integer> unloadedCores = () -> solrCores.getAllCoreNames().size() - solrCores.getCoreNames().size();
-
- metricManager.register(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node),
- loadedCores, true, "loaded", SolrInfoMBean.Category.CONTAINER.toString(), "cores");
- metricManager.register(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node),
- lazyCores, true, "lazy",SolrInfoMBean.Category.CONTAINER.toString(), "cores");
- metricManager.register(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node),
- unloadedCores, true, "unloaded",SolrInfoMBean.Category.CONTAINER.toString(), "cores");
+ String registryName = SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node);
+ metricManager.registerGauge(registryName, () -> solrCores.getCores().size(),
+ true, "loaded", SolrInfoMBean.Category.CONTAINER.toString(), "cores");
+ metricManager.registerGauge(registryName, () -> solrCores.getCoreNames().size() - solrCores.getCores().size(),
+ true, "lazy",SolrInfoMBean.Category.CONTAINER.toString(), "cores");
+ metricManager.registerGauge(registryName, () -> solrCores.getAllCoreNames().size() - solrCores.getCoreNames().size(),
+ true, "unloaded",SolrInfoMBean.Category.CONTAINER.toString(), "cores");
if (isZooKeeperAware()) {
metricManager.loadClusterReporters(cfg.getMetricReporterPlugins(), this);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/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 70203d4..bc41b19 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -169,7 +169,7 @@ import static org.apache.solr.common.params.CommonParams.PATH;
/**
*
*/
-public final class SolrCore implements SolrInfoMBean, Closeable {
+public final class SolrCore implements SolrInfoMBean, SolrMetricProducer, Closeable {
public static final String version="1.0";
@@ -214,11 +214,11 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
private final ReentrantLock ruleExpiryLock;
private final ReentrantLock snapshotDelLock; // A lock instance to guard against concurrent deletions.
- private final Timer newSearcherTimer;
- private final Timer newSearcherWarmupTimer;
- private final Counter newSearcherCounter;
- private final Counter newSearcherMaxReachedCounter;
- private final Counter newSearcherOtherErrorsCounter;
+ private Timer newSearcherTimer;
+ private Timer newSearcherWarmupTimer;
+ private Counter newSearcherCounter;
+ private Counter newSearcherMaxReachedCounter;
+ private Counter newSearcherOtherErrorsCounter;
public Date getStartTimeStamp() { return startTime; }
@@ -901,11 +901,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
SolrMetricManager metricManager = this.coreDescriptor.getCoreContainer().getMetricManager();
// initialize searcher-related metrics
- newSearcherCounter = metricManager.counter(coreMetricManager.getRegistryName(), "new", Category.SEARCHER.toString());
- newSearcherTimer = metricManager.timer(coreMetricManager.getRegistryName(), "time", Category.SEARCHER.toString(), "new");
- newSearcherWarmupTimer = metricManager.timer(coreMetricManager.getRegistryName(), "warmup", Category.SEARCHER.toString(), "new");
- newSearcherMaxReachedCounter = metricManager.counter(coreMetricManager.getRegistryName(), "maxReached", Category.SEARCHER.toString(), "new");
- newSearcherOtherErrorsCounter = metricManager.counter(coreMetricManager.getRegistryName(), "errors", Category.SEARCHER.toString(), "new");
+ initializeMetrics(metricManager, coreMetricManager.getRegistryName(), null);
// Initialize JMX
this.infoRegistry = initInfoRegistry(name, config);
@@ -1125,6 +1121,24 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
return coreMetricManager;
}
+ @Override
+ public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
+ newSearcherCounter = manager.counter(registry, "new", Category.SEARCHER.toString());
+ newSearcherTimer = manager.timer(registry, "time", Category.SEARCHER.toString(), "new");
+ newSearcherWarmupTimer = manager.timer(registry, "warmup", Category.SEARCHER.toString(), "new");
+ newSearcherMaxReachedCounter = manager.counter(registry, "maxReached", Category.SEARCHER.toString(), "new");
+ newSearcherOtherErrorsCounter = manager.counter(registry, "errors", Category.SEARCHER.toString(), "new");
+
+ manager.registerGauge(registry, () -> name == null ? "(null)" : name, true, "coreName", Category.CORE.toString());
+ manager.registerGauge(registry, () -> startTime, true, "startTime", Category.CORE.toString());
+ manager.registerGauge(registry, () -> getOpenCount(), true, "refCount", Category.CORE.toString());
+ manager.registerGauge(registry, () -> resourceLoader.getInstancePath(), true, "instanceDir", Category.CORE.toString());
+ manager.registerGauge(registry, () -> getIndexDir(), true, "indexDir", Category.CORE.toString());
+ manager.registerGauge(registry, () -> getIndexSize(), true, "sizeInBytes", Category.INDEX.toString());
+ manager.registerGauge(registry, () -> NumberUtils.readableSize(getIndexSize()), true, "size", Category.INDEX.toString());
+ manager.registerGauge(registry, () -> coreDescriptor.getCoreContainer().getCoreNames(this), true, "aliases", Category.CORE.toString());
+ }
+
private Map<String,SolrInfoMBean> initInfoRegistry(String name, SolrConfig config) {
if (config.jmxConfig.enabled) {
return new JmxMonitoredMap<String, SolrInfoMBean>(name, coreMetricManager.getRegistryName(), String.valueOf(this.hashCode()), config.jmxConfig);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
index b53c818..25f317c 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
@@ -50,6 +50,8 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
final CoreContainer container;
final SolrMetricManager metricManager;
+ public static final String COMPACT_PARAM = "compact";
+
public MetricsHandler() {
this.container = null;
this.metricManager = null;
@@ -71,6 +73,7 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
throw new SolrException(SolrException.ErrorCode.INVALID_STATE, "Core container instance not initialized");
}
+ boolean compact = req.getParams().getBool(COMPACT_PARAM, false);
MetricFilter mustMatchFilter = parseMustMatchFilter(req);
List<MetricType> metricTypes = parseMetricTypes(req);
List<MetricFilter> metricFilters = metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList());
@@ -79,7 +82,8 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
NamedList response = new NamedList();
for (String registryName : requestedRegistries) {
MetricRegistry registry = metricManager.registry(registryName);
- response.add(registryName, MetricUtils.toNamedList(registry, metricFilters, mustMatchFilter, false, false, null));
+ response.add(registryName, MetricUtils.toNamedList(registry, metricFilters, mustMatchFilter, false,
+ false, compact, null));
}
rsp.getValues().add("metrics", response);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
index 3a4c3fe..f4abee0 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
@@ -38,6 +38,7 @@ import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import com.codahale.metrics.Counter;
+import com.codahale.metrics.Gauge;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.Metric;
@@ -520,7 +521,9 @@ public class SolrMetricManager {
}
}
-
+ public void registerGauge(String registry, Gauge<?> gauge, boolean force, String metricName, String... metricPath) {
+ register(registry, gauge, force, metricName, metricPath);
+ }
/**
* This method creates a hierarchical name with arbitrary levels of hierarchy
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java
index e9b8c3d..0bca68f 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java
@@ -361,7 +361,7 @@ public class SolrReporter extends ScheduledReporter {
}
final String effectiveGroup = group;
MetricUtils.toSolrInputDocuments(metricManager.registry(registryName), Collections.singletonList(report.filter), MetricFilter.ALL,
- skipHistograms, skipAggregateValues, metadata, doc -> {
+ skipHistograms, skipAggregateValues, false, metadata, doc -> {
doc.setField(REGISTRY_ID, registryName);
doc.setField(GROUP_ID, effectiveGroup);
if (effectiveLabel != null) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index abb5512..fdc9d22 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -26,7 +26,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.LongAdder;
-import com.codahale.metrics.Gauge;
import com.codahale.metrics.Meter;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -164,25 +163,18 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
@Override
public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
commitCommands = manager.meter(registry, "commits", getCategory().toString(), scope);
- Gauge<Integer> autoCommits = () -> commitTracker.getCommitCount();
- manager.register(registry, autoCommits, true, "autoCommits", getCategory().toString(), scope);
- Gauge<Integer> softAutoCommits = () -> softCommitTracker.getCommitCount();
- manager.register(registry, softAutoCommits, true, "softAutoCommits", getCategory().toString(), scope);
+ manager.registerGauge(registry, () -> commitTracker.getCommitCount(), true, "autoCommits", getCategory().toString(), scope);
+ manager.registerGauge(registry, () -> softCommitTracker.getCommitCount(), true, "softAutoCommits", getCategory().toString(), scope);
optimizeCommands = manager.meter(registry, "optimizes", getCategory().toString(), scope);
rollbackCommands = manager.meter(registry, "rollbacks", getCategory().toString(), scope);
splitCommands = manager.meter(registry, "splits", getCategory().toString(), scope);
mergeIndexesCommands = manager.meter(registry, "merges", getCategory().toString(), scope);
expungeDeleteCommands = manager.meter(registry, "expungeDeletes", getCategory().toString(), scope);
- Gauge<Long> docsPending = () -> numDocsPending.longValue();
- manager.register(registry, docsPending, true, "docsPending", getCategory().toString(), scope);
- Gauge<Long> adds = () -> addCommands.longValue();
- manager.register(registry, adds, true, "adds", getCategory().toString(), scope);
- Gauge<Long> deletesById = () -> deleteByIdCommands.longValue();
- manager.register(registry, deletesById, true, "deletesById", getCategory().toString(), scope);
- Gauge<Long> deletesByQuery = () -> deleteByQueryCommands.longValue();
- manager.register(registry, deletesByQuery, true, "deletesByQuery", getCategory().toString(), scope);
- Gauge<Long> errors = () -> numErrors.longValue();
- manager.register(registry, errors, true, "errors", getCategory().toString(), scope);
+ manager.registerGauge(registry, () -> numDocsPending.longValue(), true, "docsPending", getCategory().toString(), scope);
+ manager.registerGauge(registry, () -> addCommands.longValue(), true, "adds", getCategory().toString(), scope);
+ manager.registerGauge(registry, () -> deleteByIdCommands.longValue(), true, "deletesById", getCategory().toString(), scope);
+ manager.registerGauge(registry, () -> deleteByQueryCommands.longValue(), true, "deletesByQuery", getCategory().toString(), scope);
+ manager.registerGauge(registry, () -> numErrors.longValue(), true, "errors", getCategory().toString(), scope);
addCommandsCumulative = manager.meter(registry, "cumulativeAdds", getCategory().toString(), scope);
deleteByIdCommandsCumulative = manager.meter(registry, "cumulativeDeletesById", getCategory().toString(), scope);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
index 6a264f8..ed85604 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
@@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
import com.codahale.metrics.Meter;
import com.codahale.metrics.Timer;
import org.apache.lucene.codecs.Codec;
@@ -81,17 +80,11 @@ public class SolrIndexWriter extends IndexWriter {
private boolean mergeTotals = false;
private boolean mergeDetails = false;
private final AtomicInteger runningMajorMerges = new AtomicInteger();
- private Gauge<Integer> runningMajorMergesGauge;
private final AtomicInteger runningMinorMerges = new AtomicInteger();
- private Gauge<Integer> runningMinorMergesGauge;
private final AtomicInteger runningMajorMergesSegments = new AtomicInteger();
- private Gauge<Integer> runningMajorMergesSegmentsGauge;
private final AtomicInteger runningMinorMergesSegments = new AtomicInteger();
- private Gauge<Integer> runningMinorMergesSegmentsGauge;
private final AtomicLong runningMajorMergesDocs = new AtomicLong();
- private Gauge<Long> runningMajorMergesDocsGauge;
private final AtomicLong runningMinorMergesDocs = new AtomicLong();
- private Gauge<Long> runningMinorMergesDocsGauge;
public static SolrIndexWriter create(SolrCore core, String name, String path, DirectoryFactory directoryFactory, boolean create, IndexSchema schema, SolrIndexConfig config, IndexDeletionPolicy delPolicy, Codec codec) throws IOException {
@@ -165,18 +158,12 @@ public class SolrIndexWriter extends IndexWriter {
minorMerge = metricManager.timer(registry, "minor", SolrInfoMBean.Category.INDEX.toString(), "merge");
majorMerge = metricManager.timer(registry, "major", SolrInfoMBean.Category.INDEX.toString(), "merge");
mergeErrors = metricManager.counter(registry, "errors", SolrInfoMBean.Category.INDEX.toString(), "merge");
- runningMajorMergesGauge = () -> runningMajorMerges.get();
- runningMinorMergesGauge = () -> runningMinorMerges.get();
- runningMajorMergesDocsGauge = () -> runningMajorMergesDocs.get();
- runningMinorMergesDocsGauge = () -> runningMinorMergesDocs.get();
- runningMajorMergesSegmentsGauge = () -> runningMajorMergesSegments.get();
- runningMinorMergesSegmentsGauge = () -> runningMinorMergesSegments.get();
- metricManager.register(registry, runningMajorMergesGauge, true, "running", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
- metricManager.register(registry, runningMinorMergesGauge, true, "running", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
- metricManager.register(registry, runningMajorMergesDocsGauge, true, "running.docs", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
- metricManager.register(registry, runningMinorMergesDocsGauge, true, "running.docs", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
- metricManager.register(registry, runningMajorMergesSegmentsGauge, true, "running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
- metricManager.register(registry, runningMinorMergesSegmentsGauge, true, "running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
+ metricManager.registerGauge(registry, () -> runningMajorMerges.get(), true, "running", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
+ metricManager.registerGauge(registry, () -> runningMinorMerges.get(), true, "running", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
+ metricManager.registerGauge(registry, () -> runningMajorMergesDocs.get(), true, "running.docs", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
+ metricManager.registerGauge(registry, () -> runningMinorMergesDocs.get(), true, "running.docs", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
+ metricManager.registerGauge(registry, () -> runningMajorMergesSegments.get(), true, "running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
+ metricManager.registerGauge(registry, () -> runningMinorMergesSegments.get(), true, "running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
flushMeter = metricManager.meter(registry, "flush", SolrInfoMBean.Category.INDEX.toString());
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/java/org/apache/solr/update/UpdateLog.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index 6a5f407..bd0adbb 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -234,9 +234,6 @@ public static final int VERSION_IDX = 1;
// metrics
protected Gauge<Integer> bufferedOpsGauge;
- protected Gauge<Integer> replayLogsCountGauge;
- protected Gauge<Long> replayBytesGauge;
- protected Gauge<Integer> stateGauge;
protected Meter applyingBufferedOpsMeter;
protected Meter replayOpsMeter;
@@ -424,16 +421,13 @@ public static final int VERSION_IDX = 1;
return 0;
}
};
- replayLogsCountGauge = () -> logs.size();
- replayBytesGauge = () -> getTotalLogsSize();
- manager.register(registry, bufferedOpsGauge, true, "ops", scope, "buffered");
- manager.register(registry, replayLogsCountGauge, true, "logs", scope, "replay", "remaining");
- manager.register(registry, replayBytesGauge, true, "bytes", scope, "replay", "remaining");
+ manager.registerGauge(registry, bufferedOpsGauge, true, "ops", scope, "buffered");
+ manager.registerGauge(registry, () -> logs.size(), true, "logs", scope, "replay", "remaining");
+ manager.registerGauge(registry, () -> getTotalLogsSize(), true, "bytes", scope, "replay", "remaining");
applyingBufferedOpsMeter = manager.meter(registry, "ops", scope, "applyingBuffered");
replayOpsMeter = manager.meter(registry, "ops", scope, "replay");
- stateGauge = () -> state.getValue();
- manager.register(registry, stateGauge, true, "state", scope);
+ manager.registerGauge(registry, () -> state.getValue(), true, "state", scope);
}
/**
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java b/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
index 6c992fa..7bcabf8 100644
--- a/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
+++ b/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
@@ -17,8 +17,6 @@
package org.apache.solr.util.stats;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.MetricRegistry;
import org.apache.http.config.Registry;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
@@ -31,42 +29,16 @@ import org.apache.solr.metrics.SolrMetricProducer;
*/
public class InstrumentedPoolingHttpClientConnectionManager extends PoolingHttpClientConnectionManager implements SolrMetricProducer {
- protected MetricRegistry metricsRegistry;
-
public InstrumentedPoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry) {
super(socketFactoryRegistry);
}
- public MetricRegistry getMetricsRegistry() {
- return metricsRegistry;
- }
-
- public void setMetricsRegistry(MetricRegistry metricRegistry) {
- this.metricsRegistry = metricRegistry;
- }
-
@Override
public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
- this.metricsRegistry = manager.registry(registry);
- metricsRegistry.register(SolrMetricManager.mkName("availableConnections", scope),
- (Gauge<Integer>) () -> {
- // this acquires a lock on the connection pool; remove if contention sucks
- return getTotalStats().getAvailable();
- });
- metricsRegistry.register(SolrMetricManager.mkName("leasedConnections", scope),
- (Gauge<Integer>) () -> {
- // this acquires a lock on the connection pool; remove if contention sucks
- return getTotalStats().getLeased();
- });
- metricsRegistry.register(SolrMetricManager.mkName("maxConnections", scope),
- (Gauge<Integer>) () -> {
- // this acquires a lock on the connection pool; remove if contention sucks
- return getTotalStats().getMax();
- });
- metricsRegistry.register(SolrMetricManager.mkName("pendingConnections", scope),
- (Gauge<Integer>) () -> {
- // this acquires a lock on the connection pool; remove if contention sucks
- return getTotalStats().getPending();
- });
+ manager.registerGauge(registry, () -> getTotalStats().getAvailable(), true, SolrMetricManager.mkName("availableConnections", scope));
+ // this acquires a lock on the connection pool; remove if contention sucks
+ manager.registerGauge(registry, () -> getTotalStats().getLeased(), true, SolrMetricManager.mkName("leasedConnections", scope));
+ manager.registerGauge(registry, () -> getTotalStats().getMax(), true, SolrMetricManager.mkName("maxConnections", scope));
+ manager.registerGauge(registry, () -> getTotalStats().getPending(), true, SolrMetricManager.mkName("pendingConnections", scope));
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
index 70fd467..ba1284e 100644
--- a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
@@ -47,6 +47,7 @@ import org.apache.solr.metrics.AggregateMetric;
public class MetricUtils {
public static final String METRIC_NAME = "metric";
+ public static final String VALUE = "value";
public static final String VALUES = "values";
static final String MS = "_ms";
@@ -110,16 +111,17 @@ public class MetricUtils {
* @param mustMatchFilter a {@link MetricFilter}.
* A metric <em>must</em> match this filter to be included in the output.
* @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.
+ * @param compact use compact representation for counters and gauges.
* @param metadata optional metadata. If not null and not empty then this map will be added under a
* {@code _metadata_} key.
* @return a {@link NamedList}
*/
public static NamedList toNamedList(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,
MetricFilter mustMatchFilter, boolean skipHistograms,
- boolean skipAggregateValues,
+ boolean skipAggregateValues, boolean compact,
Map<String, Object> metadata) {
NamedList result = new SimpleOrderedMap();
- toNamedMaps(registry, shouldMatchFilters, mustMatchFilter, skipHistograms, skipAggregateValues, (k, v) -> {
+ toMaps(registry, shouldMatchFilters, mustMatchFilter, skipHistograms, skipAggregateValues, compact, (k, v) -> {
result.add(k, v);
});
if (metadata != null && !metadata.isEmpty()) {
@@ -140,17 +142,18 @@ public class MetricUtils {
* @param mustMatchFilter a {@link MetricFilter}.
* A metric <em>must</em> match this filter to be included in the output.
* @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.
+ * @param compact use compact representation for counters and gauges.
* @param metadata optional metadata. If not null and not empty then this map will be added under a
* {@code _metadata_} key.
* @return a list of {@link SolrInputDocument}-s
*/
public static List<SolrInputDocument> toSolrInputDocuments(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,
MetricFilter mustMatchFilter, boolean skipHistograms,
- boolean skipAggregateValues,
+ boolean skipAggregateValues, boolean compact,
Map<String, Object> metadata) {
List<SolrInputDocument> result = new LinkedList<>();
toSolrInputDocuments(registry, shouldMatchFilters, mustMatchFilter, skipHistograms,
- skipAggregateValues, metadata, doc -> {
+ skipAggregateValues, compact, metadata, doc -> {
result.add(doc);
});
return result;
@@ -158,10 +161,10 @@ public class MetricUtils {
public static void toSolrInputDocuments(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,
MetricFilter mustMatchFilter, boolean skipHistograms,
- boolean skipAggregateValues,
+ boolean skipAggregateValues, boolean compact,
Map<String, Object> metadata, Consumer<SolrInputDocument> consumer) {
boolean addMetadata = metadata != null && !metadata.isEmpty();
- toNamedMaps(registry, shouldMatchFilters, mustMatchFilter, skipHistograms, skipAggregateValues, (k, v) -> {
+ toMaps(registry, shouldMatchFilters, mustMatchFilter, skipHistograms, skipAggregateValues, compact, (k, v) -> {
SolrInputDocument doc = new SolrInputDocument();
doc.setField(METRIC_NAME, k);
toSolrInputDocument(null, doc, v);
@@ -172,10 +175,16 @@ public class MetricUtils {
});
}
- public static void toSolrInputDocument(String prefix, SolrInputDocument doc, Map<String, Object> map) {
+ public static void toSolrInputDocument(String prefix, SolrInputDocument doc, Object o) {
+ if (!(o instanceof Map)) {
+ String key = prefix != null ? prefix : VALUE;
+ doc.addField(key, o);
+ return;
+ }
+ Map<String, Object> map = (Map<String, Object>)o;
for (Map.Entry<String, Object> entry : map.entrySet()) {
if (entry.getValue() instanceof Map) { // flatten recursively
- toSolrInputDocument(entry.getKey(), doc, (Map<String, Object>)entry.getValue());
+ toSolrInputDocument(entry.getKey(), doc, entry.getValue());
} else {
String key = prefix != null ? prefix + "." + entry.getKey() : entry.getKey();
doc.addField(key, entry.getValue());
@@ -183,9 +192,10 @@ public class MetricUtils {
}
}
- public static void toNamedMaps(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,
- MetricFilter mustMatchFilter, boolean skipHistograms, boolean skipAggregateValues,
- BiConsumer<String, Map<String, Object>> consumer) {
+ public static void toMaps(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,
+ MetricFilter mustMatchFilter, boolean skipHistograms, boolean skipAggregateValues,
+ boolean compact,
+ BiConsumer<String, Object> consumer) {
Map<String, Metric> metrics = registry.getMetrics();
SortedSet<String> names = registry.getNames();
names.stream()
@@ -195,28 +205,28 @@ public class MetricUtils {
Metric metric = metrics.get(n);
if (metric instanceof Counter) {
Counter counter = (Counter) metric;
- consumer.accept(n, counterToMap(counter));
+ consumer.accept(n, convertCounter(counter, compact));
} else if (metric instanceof Gauge) {
Gauge gauge = (Gauge) metric;
- consumer.accept(n, gaugeToMap(gauge));
+ consumer.accept(n, convertGauge(gauge, compact));
} else if (metric instanceof Meter) {
Meter meter = (Meter) metric;
- consumer.accept(n, meterToMap(meter));
+ consumer.accept(n, convertMeter(meter));
} else if (metric instanceof Timer) {
Timer timer = (Timer) metric;
- consumer.accept(n, timerToMap(timer, skipHistograms));
+ consumer.accept(n, convertTimer(timer, skipHistograms));
} else if (metric instanceof Histogram) {
if (!skipHistograms) {
Histogram histogram = (Histogram) metric;
- consumer.accept(n, histogramToMap(histogram));
+ consumer.accept(n, convertHistogram(histogram));
}
} else if (metric instanceof AggregateMetric) {
- consumer.accept(n, aggregateMetricToMap((AggregateMetric)metric, skipAggregateValues));
+ consumer.accept(n, convertAggregateMetric((AggregateMetric)metric, skipAggregateValues));
}
});
}
- static Map<String, Object> aggregateMetricToMap(AggregateMetric metric, boolean skipAggregateValues) {
+ static Map<String, Object> convertAggregateMetric(AggregateMetric metric, boolean skipAggregateValues) {
Map<String, Object> response = new LinkedHashMap<>();
response.put("count", metric.size());
response.put(MAX, metric.getMax());
@@ -237,7 +247,7 @@ public class MetricUtils {
return response;
}
- static Map<String, Object> histogramToMap(Histogram histogram) {
+ static Map<String, Object> convertHistogram(Histogram histogram) {
Map<String, Object> response = new LinkedHashMap<>();
Snapshot snapshot = histogram.getSnapshot();
response.put("count", histogram.getCount());
@@ -268,7 +278,7 @@ public class MetricUtils {
response.put((ms ? P999_MS: P999), nsToMs(ms, snapshot.get999thPercentile()));
}
- static Map<String,Object> timerToMap(Timer timer, boolean skipHistograms) {
+ static Map<String,Object> convertTimer(Timer timer, boolean skipHistograms) {
Map<String, Object> response = new LinkedHashMap<>();
response.put("count", timer.getCount());
response.put("meanRate", timer.getMeanRate());
@@ -282,7 +292,7 @@ public class MetricUtils {
return response;
}
- static Map<String, Object> meterToMap(Meter meter) {
+ static Map<String, Object> convertMeter(Meter meter) {
Map<String, Object> response = new LinkedHashMap<>();
response.put("count", meter.getCount());
response.put("meanRate", meter.getMeanRate());
@@ -292,16 +302,24 @@ public class MetricUtils {
return response;
}
- static Map<String, Object> gaugeToMap(Gauge gauge) {
- Map<String, Object> response = new LinkedHashMap<>();
- response.put("value", gauge.getValue());
- return response;
+ static Object convertGauge(Gauge gauge, boolean compact) {
+ if (compact) {
+ return gauge.getValue();
+ } else {
+ Map<String, Object> response = new LinkedHashMap<>();
+ response.put("value", gauge.getValue());
+ return response;
+ }
}
- static Map<String, Object> counterToMap(Counter counter) {
- Map<String, Object> response = new LinkedHashMap<>();
- response.put("count", counter.getCount());
- return response;
+ static Object convertCounter(Counter counter, boolean compact) {
+ if (compact) {
+ return counter.getCount();
+ } else {
+ Map<String, Object> response = new LinkedHashMap<>();
+ response.put("count", counter.getCount());
+ return response;
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
index 2fd7e9c..81e14d9 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
@@ -49,9 +49,11 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
assertNotNull(values.get("solr.node"));
NamedList nl = (NamedList) values.get("solr.core.collection1");
assertNotNull(nl);
- assertNotNull(nl.get("SEARCHER.new.errors")); // counter type
- assertNotNull(((Map) nl.get("SEARCHER.new.errors")).get("count"));
+ Object o = nl.get("SEARCHER.new.errors");
+ assertNotNull(o); // counter type
+ assertTrue(o instanceof Map);
// response wasn't serialized so we get here whatever MetricUtils produced instead of NamedList
+ assertNotNull(((Map) o).get("count"));
assertEquals(0L, ((Map) nl.get("SEARCHER.new.errors")).get("count"));
nl = (NamedList) values.get("solr.node");
assertNotNull(nl.get("CONTAINER.cores.loaded")); // int gauge
@@ -149,4 +151,20 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
assertEquals(1, values.size());
assertEquals(0, ((NamedList)values.get("solr.node")).size());
}
+
+ @Test
+ public void testCompact() throws Exception {
+ MetricsHandler handler = new MetricsHandler(h.getCoreContainer());
+
+ SolrQueryResponse resp = new SolrQueryResponse();
+ handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json", MetricsHandler.COMPACT_PARAM, "true"), resp);
+ NamedList values = resp.getValues();
+ assertNotNull(values.get("metrics"));
+ values = (NamedList) values.get("metrics");
+ NamedList nl = (NamedList) values.get("solr.core.collection1");
+ assertNotNull(nl);
+ Object o = nl.get("SEARCHER.new.errors");
+ assertNotNull(o); // counter type
+ assertTrue(o instanceof Number);
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
index 2816354..462241a 100644
--- a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
@@ -119,7 +119,7 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
String delsQName = PREFIX + "deletesByQuery";
String cumulativeDelsQName = PREFIX + "cumulativeDeletesByQuery";
long commits = ((Meter) metrics.get(commitsName)).getCount();
- long adds = ((Gauge<Long>) metrics.get(addsName)).getValue();
+ long adds = ((Gauge<Number>) metrics.get(addsName)).getValue().longValue();
long cumulativeAdds = ((Meter) metrics.get(cumulativeAddsName)).getCount();
long cumulativeDelsI = ((Meter) metrics.get(cumulativeDelsIName)).getCount();
long cumulativeDelsQ = ((Meter) metrics.get(cumulativeDelsQName)).getCount();
@@ -137,7 +137,7 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
assertQ(req("q","id:5"), "//*[@numFound='0']");
assertQ(req("q","id:6"), "//*[@numFound='0']");
- long newAdds = ((Gauge<Long>) metrics.get(addsName)).getValue();
+ long newAdds = ((Gauge<Number>) metrics.get(addsName)).getValue().longValue();
long newCumulativeAdds = ((Meter) metrics.get(cumulativeAddsName)).getCount();
assertEquals("new adds", 2, newAdds - adds);
assertEquals("new cumulative adds", 2, newCumulativeAdds - cumulativeAdds);
@@ -147,7 +147,7 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
long newCommits = ((Meter) metrics.get(commitsName)).getCount();
assertEquals("new commits", 1, newCommits - commits);
- newAdds = ((Gauge<Long>) metrics.get(addsName)).getValue();
+ newAdds = ((Gauge<Number>) metrics.get(addsName)).getValue().longValue();
newCumulativeAdds = ((Meter) metrics.get(cumulativeAddsName)).getCount();
// adds should be reset to 0 after commit
assertEquals("new adds after commit", 0, newAdds);
@@ -161,7 +161,7 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
// now delete one
assertU(delI("5"));
- long newDelsI = ((Gauge<Long>) metrics.get(delsIName)).getValue();
+ long newDelsI = ((Gauge<Number>) metrics.get(delsIName)).getValue().longValue();
long newCumulativeDelsI = ((Meter) metrics.get(cumulativeDelsIName)).getCount();
assertEquals("new delsI", 1, newDelsI);
assertEquals("new cumulative delsI", 1, newCumulativeDelsI - cumulativeDelsI);
@@ -171,7 +171,7 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
assertU(commit());
// delsI should be reset to 0 after commit
- newDelsI = ((Gauge<Long>) metrics.get(delsIName)).getValue();
+ newDelsI = ((Gauge<Number>) metrics.get(delsIName)).getValue().longValue();
newCumulativeDelsI = ((Meter) metrics.get(cumulativeDelsIName)).getCount();
assertEquals("new delsI after commit", 0, newDelsI);
assertEquals("new cumulative delsI after commit", 1, newCumulativeDelsI - cumulativeDelsI);
@@ -183,7 +183,7 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
// now delete all
assertU(delQ("*:*"));
- long newDelsQ = ((Gauge<Long>) metrics.get(delsQName)).getValue();
+ long newDelsQ = ((Gauge<Number>) metrics.get(delsQName)).getValue().longValue();
long newCumulativeDelsQ = ((Meter) metrics.get(cumulativeDelsQName)).getCount();
assertEquals("new delsQ", 1, newDelsQ);
assertEquals("new cumulative delsQ", 1, newCumulativeDelsQ - cumulativeDelsQ);
@@ -193,7 +193,7 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
assertU(commit());
- newDelsQ = ((Gauge<Long>) metrics.get(delsQName)).getValue();
+ newDelsQ = ((Gauge<Number>) metrics.get(delsQName)).getValue().longValue();
newCumulativeDelsQ = ((Meter) metrics.get(cumulativeDelsQName)).getCount();
assertEquals("new delsQ after commit", 0, newDelsQ);
assertEquals("new cumulative delsQ after commit", 1, newCumulativeDelsQ - cumulativeDelsQ);
@@ -204,11 +204,11 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
// verify final metrics
newCommits = ((Meter) metrics.get(commitsName)).getCount();
assertEquals("new commits", 3, newCommits - commits);
- newAdds = ((Gauge<Long>) metrics.get(addsName)).getValue();
+ newAdds = ((Gauge<Number>) metrics.get(addsName)).getValue().longValue();
assertEquals("new adds", 0, newAdds);
newCumulativeAdds = ((Meter) metrics.get(cumulativeAddsName)).getCount();
assertEquals("new cumulative adds", 2, newCumulativeAdds - cumulativeAdds);
- newDelsI = ((Gauge<Long>) metrics.get(delsIName)).getValue();
+ newDelsI = ((Gauge<Number>) metrics.get(delsIName)).getValue().longValue();
assertEquals("new delsI", 0, newDelsI);
newCumulativeDelsI = ((Meter) metrics.get(cumulativeDelsIName)).getCount();
assertEquals("new cumulative delsI", 1, newCumulativeDelsI - cumulativeDelsI);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/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 c9935bb..9985937 100644
--- a/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java
+++ b/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java
@@ -67,7 +67,7 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {
Map<String, Metric> metrics = registry.getMetrics();
- assertEquals(10, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count());
+ assertEquals(12, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count());
// check basic index meters
Timer timer = (Timer)metrics.get("INDEX.merge.minor");
@@ -92,7 +92,8 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {
assertNotNull(registry);
Map<String, Metric> metrics = registry.getMetrics();
- assertEquals(0, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count());
+ // INDEX.size, INDEX.sizeInBytes
+ assertEquals(2, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count());
}
@Test
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52b3bc2f/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java b/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java
index 8717ad6..35caef8 100644
--- a/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java
+++ b/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java
@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import com.codahale.metrics.Counter;
+import com.codahale.metrics.Gauge;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricFilter;
@@ -44,7 +45,7 @@ public class MetricUtilsTest extends SolrTestCaseJ4 {
timer.update(Math.abs(random().nextInt()) + 1, TimeUnit.NANOSECONDS);
}
// obtain timer metrics
- NamedList lst = new NamedList(MetricUtils.timerToMap(timer, false));
+ NamedList lst = new NamedList(MetricUtils.convertTimer(timer, false));
// check that expected metrics were obtained
assertEquals(14, lst.size());
final Snapshot snapshot = timer.getSnapshot();
@@ -78,10 +79,15 @@ public class MetricUtilsTest extends SolrTestCaseJ4 {
am.set("foo", 10);
am.set("bar", 1);
am.set("bar", 2);
- MetricUtils.toNamedMaps(registry, Collections.singletonList(MetricFilter.ALL), MetricFilter.ALL,
- false, false, (k, v) -> {
+ Gauge<String> gauge = () -> "foobar";
+ registry.register("gauge", gauge);
+ MetricUtils.toMaps(registry, Collections.singletonList(MetricFilter.ALL), MetricFilter.ALL,
+ false, false, false, (k, o) -> {
+ Map v = (Map)o;
if (k.startsWith("counter")) {
assertEquals(1L, v.get("count"));
+ } else if (k.startsWith("gauge")) {
+ assertEquals("foobar", v.get("value"));
} else if (k.startsWith("timer")) {
assertEquals(1L, v.get("count"));
assertTrue(((Number)v.get("min_ms")).intValue() > 100);
@@ -102,6 +108,47 @@ public class MetricUtilsTest extends SolrTestCaseJ4 {
assertEquals(2, update.get("updateCount"));
}
});
+ // test compact format
+ MetricUtils.toMaps(registry, Collections.singletonList(MetricFilter.ALL), MetricFilter.ALL,
+ false, false, true, (k, o) -> {
+ if (k.startsWith("counter")) {
+ assertTrue(o instanceof Long);
+ assertEquals(1L, o);
+ } else if (k.startsWith("gauge")) {
+ assertTrue(o instanceof String);
+ assertEquals("foobar", o);
+ } else if (k.startsWith("timer")) {
+ assertTrue(o instanceof Map);
+ Map v = (Map)o;
+ assertEquals(1L, v.get("count"));
+ assertTrue(((Number)v.get("min_ms")).intValue() > 100);
+ } else if (k.startsWith("meter")) {
+ assertTrue(o instanceof Map);
+ Map v = (Map)o;
+ assertEquals(1L, v.get("count"));
+ } else if (k.startsWith("histogram")) {
+ assertTrue(o instanceof Map);
+ Map v = (Map)o;
+ assertEquals(1L, v.get("count"));
+ } else if (k.startsWith("aggregate")) {
+ assertTrue(o instanceof Map);
+ Map v = (Map)o;
+ assertEquals(2, v.get("count"));
+ Map<String, Object> values = (Map<String, Object>)v.get("values");
+ assertNotNull(values);
+ assertEquals(2, values.size());
+ Map<String, Object> update = (Map<String, Object>)values.get("foo");
+ assertEquals(10, update.get("value"));
+ assertEquals(1, update.get("updateCount"));
+ update = (Map<String, Object>)values.get("bar");
+ assertEquals(2, update.get("value"));
+ assertEquals(2, update.get("updateCount"));
+ } else {
+ Map v = (Map)o;
+ assertEquals(1L, v.get("count"));
+ }
+ });
+
}
}
[19/19] lucene-solr:feature/autoscaling: SOLR-10270: Stop exporting
_version_ during GROUP BY aggregations in map_reduce mode
Posted by sh...@apache.org.
SOLR-10270: Stop exporting _version_ during GROUP BY aggregations in map_reduce mode
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1e97cf82
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1e97cf82
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1e97cf82
Branch: refs/heads/feature/autoscaling
Commit: 1e97cf82d253f6d6f721889155caec62625a81e9
Parents: 482ec73
Author: Joel Bernstein <jb...@apache.org>
Authored: Mon Mar 13 12:50:17 2017 -0400
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 16 13:41:50 2017 +0530
----------------------------------------------------------------------
.../core/src/java/org/apache/solr/handler/sql/SolrTable.java | 8 --------
1 file changed, 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e97cf82/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java b/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
index 9375bc0..37ed7d9 100644
--- a/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
+++ b/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
@@ -330,24 +330,16 @@ class SolrTable extends AbstractQueryableTable implements TranslatableTable {
private String getFields(Set<String> fieldSet) {
StringBuilder buf = new StringBuilder();
- boolean appendVersion = true;
for(String field : fieldSet) {
if(buf.length() > 0) {
buf.append(",");
}
- if(field.equals("_version_")) {
- appendVersion = false;
- }
buf.append(field);
}
- if(appendVersion){
- buf.append(",_version_");
- }
-
return buf.toString();
}