mirror of https://github.com/apache/lucene.git
SOLR-13322 - let forbidden apis check for sysout in solr core
This commit is contained in:
parent
de13c8e79d
commit
2d690885e5
|
@ -551,7 +551,6 @@
|
||||||
</forbidden-apis>
|
</forbidden-apis>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="-check-forbidden-sysout"/>
|
|
||||||
|
|
||||||
<!-- hack for now to disable *all* Solr tests on Jenkins when "tests.disable-solr" property is set -->
|
<!-- hack for now to disable *all* Solr tests on Jenkins when "tests.disable-solr" property is set -->
|
||||||
<target name="test" unless="tests.disable-solr">
|
<target name="test" unless="tests.disable-solr">
|
||||||
|
|
|
@ -793,13 +793,9 @@ public class JettySolrRunner {
|
||||||
/**
|
/**
|
||||||
* A main class that starts jetty+solr This is useful for debugging
|
* A main class that starts jetty+solr This is useful for debugging
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) throws Exception {
|
||||||
try {
|
|
||||||
JettySolrRunner jetty = new JettySolrRunner(".", "/solr", 8983);
|
JettySolrRunner jetty = new JettySolrRunner(".", "/solr", 8983);
|
||||||
jetty.start();
|
jetty.start();
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.solr.common.cloud.ClusterProperties;
|
||||||
import org.apache.solr.common.cloud.SolrZkClient;
|
import org.apache.solr.common.cloud.SolrZkClient;
|
||||||
import org.apache.solr.common.cloud.ZkConfigManager;
|
import org.apache.solr.common.cloud.ZkConfigManager;
|
||||||
import org.apache.solr.core.CoreContainer;
|
import org.apache.solr.core.CoreContainer;
|
||||||
|
import org.apache.solr.util.CLIO;
|
||||||
import org.apache.zookeeper.CreateMode;
|
import org.apache.zookeeper.CreateMode;
|
||||||
import org.apache.zookeeper.KeeperException;
|
import org.apache.zookeeper.KeeperException;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
@ -50,7 +51,7 @@ import org.xml.sax.SAXException;
|
||||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||||
import static org.apache.solr.common.params.CommonParams.VALUE_LONG;
|
import static org.apache.solr.common.params.CommonParams.VALUE_LONG;
|
||||||
|
|
||||||
public class ZkCLI {
|
public class ZkCLI implements CLIO {
|
||||||
|
|
||||||
private static final String MAKEPATH = "makepath";
|
private static final String MAKEPATH = "makepath";
|
||||||
private static final String PUT = "put";
|
private static final String PUT = "put";
|
||||||
|
@ -84,7 +85,7 @@ public class ZkCLI {
|
||||||
ZkCLI.stdout = stdout;
|
ZkCLI.stdout = stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PrintStream stdout = System.out;
|
private static PrintStream stdout = CLIO.getOutStream();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to perform a variety of zookeeper related tasks, such as:
|
* Allows you to perform a variety of zookeeper related tasks, such as:
|
||||||
|
|
|
@ -1638,11 +1638,6 @@ public class ZkController implements Closeable {
|
||||||
overseerJobQueue.offer(Utils.toJSON(m));
|
overseerJobQueue.offer(Utils.toJSON(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
// convenience for testing
|
|
||||||
void printLayoutToStdOut() throws KeeperException, InterruptedException {
|
|
||||||
zkClient.printLayoutToStdOut();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZkStateReader getZkStateReader() {
|
public ZkStateReader getZkStateReader() {
|
||||||
return zkStateReader;
|
return zkStateReader;
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,8 +262,4 @@ public class ConfigOverlay implements MapSerializable {
|
||||||
public static final String ZNODEVER = "znodeVersion";
|
public static final String ZNODEVER = "znodeVersion";
|
||||||
public static final String NAME = "overlay";
|
public static final String NAME = "overlay";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println(Utils.toJSONString(editable_prop_map));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ import org.apache.solr.common.cloud.Slice;
|
||||||
import org.apache.solr.common.params.CollectionAdminParams;
|
import org.apache.solr.common.params.CollectionAdminParams;
|
||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
import org.apache.solr.core.snapshots.CollectionSnapshotMetaData.CoreSnapshotMetaData;
|
import org.apache.solr.core.snapshots.CollectionSnapshotMetaData.CoreSnapshotMetaData;
|
||||||
|
import org.apache.solr.util.CLIO;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ import com.google.common.base.Preconditions;
|
||||||
/**
|
/**
|
||||||
* This class provides utility functions required for Solr snapshots functionality.
|
* This class provides utility functions required for Solr snapshots functionality.
|
||||||
*/
|
*/
|
||||||
public class SolrSnapshotsTool implements Closeable {
|
public class SolrSnapshotsTool implements Closeable, CLIO {
|
||||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
private static final DateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.getDefault());
|
private static final DateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.getDefault());
|
||||||
|
|
||||||
|
@ -107,11 +108,11 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
try {
|
try {
|
||||||
resp = createSnap.process(solrClient);
|
resp = createSnap.process(solrClient);
|
||||||
Preconditions.checkState(resp.getStatus() == 0, "The CREATESNAPSHOT request failed. The status code is " + resp.getStatus());
|
Preconditions.checkState(resp.getStatus() == 0, "The CREATESNAPSHOT request failed. The status code is " + resp.getStatus());
|
||||||
System.out.println("Successfully created snapshot with name " + snapshotName + " for collection " + collectionName);
|
CLIO.out("Successfully created snapshot with name " + snapshotName + " for collection " + collectionName);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to create a snapshot with name " + snapshotName + " for collection " + collectionName, e);
|
log.error("Failed to create a snapshot with name " + snapshotName + " for collection " + collectionName, e);
|
||||||
System.out.println("Failed to create a snapshot with name " + snapshotName + " for collection " + collectionName
|
CLIO.out("Failed to create a snapshot with name " + snapshotName + " for collection " + collectionName
|
||||||
+" due to following error : "+e.getLocalizedMessage());
|
+" due to following error : "+e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,11 +123,11 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
try {
|
try {
|
||||||
resp = deleteSnap.process(solrClient);
|
resp = deleteSnap.process(solrClient);
|
||||||
Preconditions.checkState(resp.getStatus() == 0, "The DELETESNAPSHOT request failed. The status code is " + resp.getStatus());
|
Preconditions.checkState(resp.getStatus() == 0, "The DELETESNAPSHOT request failed. The status code is " + resp.getStatus());
|
||||||
System.out.println("Successfully deleted snapshot with name " + snapshotName + " for collection " + collectionName);
|
CLIO.out("Successfully deleted snapshot with name " + snapshotName + " for collection " + collectionName);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to delete a snapshot with name " + snapshotName + " for collection " + collectionName, e);
|
log.error("Failed to delete a snapshot with name " + snapshotName + " for collection " + collectionName, e);
|
||||||
System.out.println("Failed to delete a snapshot with name " + snapshotName + " for collection " + collectionName
|
CLIO.out("Failed to delete a snapshot with name " + snapshotName + " for collection " + collectionName
|
||||||
+" due to following error : "+e.getLocalizedMessage());
|
+" due to following error : "+e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,12 +142,12 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
|
|
||||||
NamedList apiResult = (NamedList) resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO);
|
NamedList apiResult = (NamedList) resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO);
|
||||||
for (int i = 0; i < apiResult.size(); i++) {
|
for (int i = 0; i < apiResult.size(); i++) {
|
||||||
System.out.println(apiResult.getName(i));
|
CLIO.out(apiResult.getName(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to list snapshots for collection " + collectionName, e);
|
log.error("Failed to list snapshots for collection " + collectionName, e);
|
||||||
System.out.println("Failed to list snapshots for collection " + collectionName
|
CLIO.out("Failed to list snapshots for collection " + collectionName
|
||||||
+" due to following error : "+e.getLocalizedMessage());
|
+" due to following error : "+e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,11 +157,11 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
Collection<CollectionSnapshotMetaData> snaps = listCollectionSnapshots(collectionName);
|
Collection<CollectionSnapshotMetaData> snaps = listCollectionSnapshots(collectionName);
|
||||||
for (CollectionSnapshotMetaData m : snaps) {
|
for (CollectionSnapshotMetaData m : snaps) {
|
||||||
if (snapshotName.equals(m.getName())) {
|
if (snapshotName.equals(m.getName())) {
|
||||||
System.out.println("Name: " + m.getName());
|
CLIO.out("Name: " + m.getName());
|
||||||
System.out.println("Status: " + m.getStatus());
|
CLIO.out("Status: " + m.getStatus());
|
||||||
System.out.println("Time of creation: " + dateFormat.format(m.getCreationDate()));
|
CLIO.out("Time of creation: " + dateFormat.format(m.getCreationDate()));
|
||||||
System.out.println("Total number of cores with snapshot: " + m.getReplicaSnapshots().size());
|
CLIO.out("Total number of cores with snapshot: " + m.getReplicaSnapshots().size());
|
||||||
System.out.println("-----------------------------------");
|
CLIO.out("-----------------------------------");
|
||||||
for (CoreSnapshotMetaData n : m.getReplicaSnapshots()) {
|
for (CoreSnapshotMetaData n : m.getReplicaSnapshots()) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("Core [name=");
|
builder.append("Core [name=");
|
||||||
|
@ -172,13 +173,13 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
builder.append(", indexDirPath=");
|
builder.append(", indexDirPath=");
|
||||||
builder.append(n.getIndexDirPath());
|
builder.append(n.getIndexDirPath());
|
||||||
builder.append("]\n");
|
builder.append("]\n");
|
||||||
System.out.println(builder.toString());
|
CLIO.out(builder.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to fetch snapshot details", e);
|
log.error("Failed to fetch snapshot details", e);
|
||||||
System.out.println("Failed to fetch snapshot details due to following error : " + e.getLocalizedMessage());
|
CLIO.out("Failed to fetch snapshot details due to following error : " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,21 +273,21 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
public void prepareForExport(String collectionName, String snapshotName, String localFsPath, Optional<String> pathPrefix, String destPath) {
|
public void prepareForExport(String collectionName, String snapshotName, String localFsPath, Optional<String> pathPrefix, String destPath) {
|
||||||
try {
|
try {
|
||||||
buildCopyListings(collectionName, snapshotName, localFsPath, pathPrefix);
|
buildCopyListings(collectionName, snapshotName, localFsPath, pathPrefix);
|
||||||
System.out.println("Successfully prepared copylisting for the snapshot export.");
|
CLIO.out("Successfully prepared copylisting for the snapshot export.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to prepare a copylisting for snapshot with name " + snapshotName + " for collection "
|
log.error("Failed to prepare a copylisting for snapshot with name " + snapshotName + " for collection "
|
||||||
+ collectionName, e);
|
+ collectionName, e);
|
||||||
System.out.println("Failed to prepare a copylisting for snapshot with name " + snapshotName + " for collection "
|
CLIO.out("Failed to prepare a copylisting for snapshot with name " + snapshotName + " for collection "
|
||||||
+ collectionName + " due to following error : " + e.getLocalizedMessage());
|
+ collectionName + " due to following error : " + e.getLocalizedMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
backupCollectionMetaData(collectionName, snapshotName, destPath);
|
backupCollectionMetaData(collectionName, snapshotName, destPath);
|
||||||
System.out.println("Successfully backed up collection meta-data");
|
CLIO.out("Successfully backed up collection meta-data");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to backup collection meta-data for collection " + collectionName, e);
|
log.error("Failed to backup collection meta-data for collection " + collectionName, e);
|
||||||
System.out.println("Failed to backup collection meta-data for collection " + collectionName
|
CLIO.out("Failed to backup collection meta-data for collection " + collectionName
|
||||||
+ " due to following error : " + e.getLocalizedMessage());
|
+ " due to following error : " + e.getLocalizedMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -306,7 +307,7 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
backup.processAsync(asyncReqId.orElse(null), solrClient);
|
backup.processAsync(asyncReqId.orElse(null), solrClient);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to backup collection meta-data for collection " + collectionName, e);
|
log.error("Failed to backup collection meta-data for collection " + collectionName, e);
|
||||||
System.out.println("Failed to backup collection meta-data for collection " + collectionName
|
CLIO.out("Failed to backup collection meta-data for collection " + collectionName
|
||||||
+ " due to following error : " + e.getLocalizedMessage());
|
+ " due to following error : " + e.getLocalizedMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -342,7 +343,7 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
try {
|
try {
|
||||||
cmd = parser.parse(options, args);
|
cmd = parser.parse(options, args);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
System.out.println(e.getLocalizedMessage());
|
CLIO.out(e.getLocalizedMessage());
|
||||||
printHelp(options);
|
printHelp(options);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -380,7 +381,7 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
try {
|
try {
|
||||||
new URI(pathPrefix.get());
|
new URI(pathPrefix.get());
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
System.out.println(
|
CLIO.out(
|
||||||
"The specified File system path prefix " + pathPrefix.get()
|
"The specified File system path prefix " + pathPrefix.get()
|
||||||
+ " is invalid. The error is " + e.getLocalizedMessage());
|
+ " is invalid. The error is " + e.getLocalizedMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
@ -401,14 +402,14 @@ public class SolrSnapshotsTool implements Closeable {
|
||||||
} else if (cmd.hasOption(HELP)) {
|
} else if (cmd.hasOption(HELP)) {
|
||||||
printHelp(options);
|
printHelp(options);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Unknown command specified.");
|
CLIO.out("Unknown command specified.");
|
||||||
printHelp(options);
|
printHelp(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String requiredArg(Options options, CommandLine cmd, String optVal) {
|
private static String requiredArg(Options options, CommandLine cmd, String optVal) {
|
||||||
if (!cmd.hasOption(optVal)) {
|
if (!cmd.hasOption(optVal)) {
|
||||||
System.out.println("Please specify the value for option " + optVal);
|
CLIO.out("Please specify the value for option " + optVal);
|
||||||
printHelp(options);
|
printHelp(options);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,6 @@ public class QueryParserTokenManager implements QueryParserConstants
|
||||||
{
|
{
|
||||||
int commentNestingDepth ;
|
int commentNestingDepth ;
|
||||||
|
|
||||||
/** Debug output. */
|
|
||||||
public java.io.PrintStream debugStream = System.out;
|
|
||||||
/** Set debug output. */
|
|
||||||
public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
|
|
||||||
private final int jjStopStringLiteralDfa_3(int pos, long active0)
|
private final int jjStopStringLiteralDfa_3(int pos, long active0)
|
||||||
{
|
{
|
||||||
switch (pos)
|
switch (pos)
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.solr.response;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -31,6 +32,8 @@ import org.apache.solr.common.util.XML;
|
||||||
import org.apache.solr.request.SolrQueryRequest;
|
import org.apache.solr.request.SolrQueryRequest;
|
||||||
import org.apache.solr.search.ReturnFields;
|
import org.apache.solr.search.ReturnFields;
|
||||||
import org.apache.solr.search.SolrReturnFields;
|
import org.apache.solr.search.SolrReturnFields;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||||
|
|
||||||
|
@ -39,6 +42,7 @@ import static org.apache.solr.common.params.CommonParams.NAME;
|
||||||
* @lucene.internal
|
* @lucene.internal
|
||||||
*/
|
*/
|
||||||
public class XMLWriter extends TextResponseWriter {
|
public class XMLWriter extends TextResponseWriter {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
|
|
||||||
public static float CURRENT_VERSION=2.2f;
|
public static float CURRENT_VERSION=2.2f;
|
||||||
|
|
||||||
|
@ -196,7 +200,7 @@ public class XMLWriter extends TextResponseWriter {
|
||||||
|
|
||||||
Object val = doc.getFieldValue(fname);
|
Object val = doc.getFieldValue(fname);
|
||||||
if( "_explain_".equals( fname ) ) {
|
if( "_explain_".equals( fname ) ) {
|
||||||
System.out.println( val );
|
log.debug(String.valueOf(val));
|
||||||
}
|
}
|
||||||
writeVal(fname, val);
|
writeVal(fname, val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,9 +107,8 @@ public class ExplainAugmenterFactory extends TransformerFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(SolrDocument doc, int docid) {
|
public void transform(SolrDocument doc, int docid) throws IOException {
|
||||||
if( context != null && context.getQuery() != null ) {
|
if( context != null && context.getQuery() != null ) {
|
||||||
try {
|
|
||||||
Explanation exp = context.getSearcher().explain(context.getQuery(), docid);
|
Explanation exp = context.getSearcher().explain(context.getQuery(), docid);
|
||||||
if( style == Style.nl ) {
|
if( style == Style.nl ) {
|
||||||
doc.setField( name, SolrPluginUtils.explanationToNamedList(exp) );
|
doc.setField( name, SolrPluginUtils.explanationToNamedList(exp) );
|
||||||
|
@ -121,10 +120,6 @@ public class ExplainAugmenterFactory extends TransformerFactory
|
||||||
doc.setField( name, exp.toString() );
|
doc.setField( name, exp.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,8 +172,7 @@ public class CloudMLTQParser extends QParser {
|
||||||
|
|
||||||
return realMLTQuery.build();
|
return realMLTQuery.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Bad Request", e);
|
||||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Bad Request");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* 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.io.PrintStream;
|
||||||
|
|
||||||
|
import org.apache.solr.common.util.SuppressForbidden;
|
||||||
|
|
||||||
|
@SuppressForbidden( reason = "For use in command line tools only")
|
||||||
|
public interface CLIO {
|
||||||
|
static void out(String s) {
|
||||||
|
System.out.println(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void err(String s) {
|
||||||
|
System.err.println(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PrintStream getOutStream() {
|
||||||
|
return System.out;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PrintStream getErrStream() {
|
||||||
|
return System.err;
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
|
||||||
/**A utility class to verify signatures
|
/**A utility class to verify signatures
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class CryptoKeys {
|
public final class CryptoKeys implements CLIO {
|
||||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
private final Map<String, PublicKey> keys;
|
private final Map<String, PublicKey> keys;
|
||||||
private Exception exception;
|
private Exception exception;
|
||||||
|
@ -342,14 +342,14 @@ public final class CryptoKeys {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
RSAKeyPair keyPair = new RSAKeyPair();
|
RSAKeyPair keyPair = new RSAKeyPair();
|
||||||
System.out.println(keyPair.getPublicKeyStr());
|
CLIO.out(keyPair.getPublicKeyStr());
|
||||||
PublicKey pk = deserializeX509PublicKey(keyPair.getPublicKeyStr());
|
PublicKey pk = deserializeX509PublicKey(keyPair.getPublicKeyStr());
|
||||||
byte[] payload = "Hello World!".getBytes(StandardCharsets.UTF_8);
|
byte[] payload = "Hello World!".getBytes(StandardCharsets.UTF_8);
|
||||||
byte[] encrypted = keyPair.encrypt(ByteBuffer.wrap(payload));
|
byte[] encrypted = keyPair.encrypt(ByteBuffer.wrap(payload));
|
||||||
String cipherBase64 = Base64.byteArrayToBase64(encrypted);
|
String cipherBase64 = Base64.byteArrayToBase64(encrypted);
|
||||||
System.out.println("encrypted: "+ cipherBase64);
|
CLIO.out("encrypted: "+ cipherBase64);
|
||||||
System.out.println("signed: "+ Base64.byteArrayToBase64(keyPair.signSha256(payload)));
|
CLIO.out("signed: "+ Base64.byteArrayToBase64(keyPair.signSha256(payload)));
|
||||||
System.out.println("decrypted "+ new String(decryptRSA(encrypted , pk), StandardCharsets.UTF_8));
|
CLIO.out("decrypted "+ new String(decryptRSA(encrypted , pk), StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,15 @@ package org.apache.solr.util;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
|
||||||
import org.noggit.JSONParser;
|
import org.noggit.JSONParser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class RecordingJSONParser extends JSONParser {
|
public class RecordingJSONParser extends JSONParser {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
|
|
||||||
static ThreadLocal<char[]> buf = new ThreadLocal<>();
|
static ThreadLocal<char[]> buf = new ThreadLocal<>();
|
||||||
private final char[] bufCopy;
|
private final char[] bufCopy;
|
||||||
//global position is the global position at the beginning of my buffer
|
//global position is the global position at the beginning of my buffer
|
||||||
|
@ -68,7 +73,7 @@ public class RecordingJSONParser extends JSONParser {
|
||||||
private void captureMissing() {
|
private void captureMissing() {
|
||||||
long currPosition = getPosition() - globalPosition;
|
long currPosition = getPosition() - globalPosition;
|
||||||
if(currPosition < 0){
|
if(currPosition < 0){
|
||||||
System.out.println("ERROR");
|
log.error("currPosition less than zero in captureMissing()?");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currPosition > lastMarkedPosition) {
|
if (currPosition > lastMarkedPosition) {
|
||||||
|
|
|
@ -204,7 +204,7 @@ public class SimplePostTool {
|
||||||
private void displayTiming(long millis) {
|
private void displayTiming(long millis) {
|
||||||
SimpleDateFormat df = new SimpleDateFormat("H:mm:ss.SSS", Locale.getDefault());
|
SimpleDateFormat df = new SimpleDateFormat("H:mm:ss.SSS", Locale.getDefault());
|
||||||
df.setTimeZone(TimeZone.getTimeZone("UTC"));
|
df.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
System.out.println("Time spent: "+df.format(new Date(millis)));
|
CLIO.out("Time spent: "+df.format(new Date(millis)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,7 +264,7 @@ public class SimplePostTool {
|
||||||
try {
|
try {
|
||||||
delay = Integer.parseInt(System.getProperty("delay", ""+delay));
|
delay = Integer.parseInt(System.getProperty("delay", ""+delay));
|
||||||
} catch(Exception e) { }
|
} catch(Exception e) { }
|
||||||
OutputStream out = isOn(System.getProperty("out", DEFAULT_OUT)) ? System.out : null;
|
OutputStream out = isOn(System.getProperty("out", DEFAULT_OUT)) ? CLIO.getOutStream() : null;
|
||||||
String fileTypes = System.getProperty("filetypes", DEFAULT_FILE_TYPES);
|
String fileTypes = System.getProperty("filetypes", DEFAULT_FILE_TYPES);
|
||||||
boolean commit = isOn(System.getProperty("commit",DEFAULT_COMMIT));
|
boolean commit = isOn(System.getProperty("commit",DEFAULT_COMMIT));
|
||||||
boolean optimize = isOn(System.getProperty("optimize",DEFAULT_OPTIMIZE));
|
boolean optimize = isOn(System.getProperty("optimize",DEFAULT_OPTIMIZE));
|
||||||
|
@ -385,12 +385,12 @@ public class SimplePostTool {
|
||||||
// USAGE
|
// USAGE
|
||||||
//
|
//
|
||||||
private static void usageShort() {
|
private static void usageShort() {
|
||||||
System.out.println(USAGE_STRING_SHORT+"\n"+
|
CLIO.out(USAGE_STRING_SHORT+"\n"+
|
||||||
" Please invoke with -h option for extended usage help.");
|
" Please invoke with -h option for extended usage help.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void usage() {
|
private static void usage() {
|
||||||
System.out.println
|
CLIO.out
|
||||||
(USAGE_STRING_SHORT+"\n\n" +
|
(USAGE_STRING_SHORT+"\n\n" +
|
||||||
"Supported System Properties and their defaults:\n"+
|
"Supported System Properties and their defaults:\n"+
|
||||||
" -Dc=<core/collection>\n"+
|
" -Dc=<core/collection>\n"+
|
||||||
|
@ -728,15 +728,15 @@ public class SimplePostTool {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void warn(String msg) {
|
static void warn(String msg) {
|
||||||
System.err.println("SimplePostTool: WARNING: " + msg);
|
CLIO.err("SimplePostTool: WARNING: " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void info(String msg) {
|
static void info(String msg) {
|
||||||
System.out.println(msg);
|
CLIO.out(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fatal(String msg) {
|
static void fatal(String msg) {
|
||||||
System.err.println("SimplePostTool: FATAL: " + msg);
|
CLIO.err("SimplePostTool: FATAL: " + msg);
|
||||||
System.exit(2);
|
System.exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,7 +814,6 @@ public class SimplePostTool {
|
||||||
is = new FileInputStream(file);
|
is = new FileInputStream(file);
|
||||||
postData(is, file.length(), output, type, url);
|
postData(is, file.length(), output, type, url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
|
||||||
warn("Can't open/read file: " + file);
|
warn("Can't open/read file: " + file);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -152,7 +152,7 @@ import static org.apache.solr.common.params.CommonParams.NAME;
|
||||||
/**
|
/**
|
||||||
* Command-line utility for working with Solr.
|
* Command-line utility for working with Solr.
|
||||||
*/
|
*/
|
||||||
public class SolrCLI {
|
public class SolrCLI implements CLIO {
|
||||||
private static final long MAX_WAIT_FOR_CORE_LOAD_NANOS = TimeUnit.NANOSECONDS.convert(1, TimeUnit.MINUTES);
|
private static final long MAX_WAIT_FOR_CORE_LOAD_NANOS = TimeUnit.NANOSECONDS.convert(1, TimeUnit.MINUTES);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,7 +169,7 @@ public class SolrCLI {
|
||||||
protected boolean verbose = false;
|
protected boolean verbose = false;
|
||||||
|
|
||||||
protected ToolBase() {
|
protected ToolBase() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToolBase(PrintStream stdout) {
|
protected ToolBase(PrintStream stdout) {
|
||||||
|
@ -196,7 +196,7 @@ public class SolrCLI {
|
||||||
// since this is a CLI, spare the user the stacktrace
|
// since this is a CLI, spare the user the stacktrace
|
||||||
String excMsg = exc.getMessage();
|
String excMsg = exc.getMessage();
|
||||||
if (excMsg != null) {
|
if (excMsg != null) {
|
||||||
System.err.println("\nERROR: " + excMsg + "\n");
|
CLIO.err("\nERROR: " + excMsg + "\n");
|
||||||
toolExitStatus = 1;
|
toolExitStatus = 1;
|
||||||
} else {
|
} else {
|
||||||
throw exc;
|
throw exc;
|
||||||
|
@ -281,7 +281,7 @@ public class SolrCLI {
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if (args == null || args.length == 0 || args[0] == null || args[0].trim().length() == 0) {
|
if (args == null || args.length == 0 || args[0] == null || args[0].trim().length() == 0) {
|
||||||
System.err.println("Invalid command-line args! Must pass the name of a tool to run.\n"
|
CLIO.err("Invalid command-line args! Must pass the name of a tool to run.\n"
|
||||||
+ "Supported tools:\n");
|
+ "Supported tools:\n");
|
||||||
displayToolOptions();
|
displayToolOptions();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -289,7 +289,7 @@ public class SolrCLI {
|
||||||
|
|
||||||
if (args.length == 1 && Arrays.asList("-v","-version","version").contains(args[0])) {
|
if (args.length == 1 && Arrays.asList("-v","-version","version").contains(args[0])) {
|
||||||
// Simple version tool, no need for its own class
|
// Simple version tool, no need for its own class
|
||||||
System.out.println(Version.LATEST);
|
CLIO.out(Version.LATEST.toString());
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ public class SolrCLI {
|
||||||
if (keyStoreFile.isFile()) {
|
if (keyStoreFile.isFile()) {
|
||||||
System.setProperty(sysProp, keyStoreFile.getAbsolutePath());
|
System.setProperty(sysProp, keyStoreFile.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
System.err.println("WARNING: "+sysProp+" file "+keyStore+
|
CLIO.err("WARNING: "+sysProp+" file "+keyStore+
|
||||||
" not found! https requests to Solr will likely fail; please update your "+
|
" not found! https requests to Solr will likely fail; please update your "+
|
||||||
sysProp+" setting to use an absolute path.");
|
sysProp+" setting to use an absolute path.");
|
||||||
}
|
}
|
||||||
|
@ -508,7 +508,7 @@ public class SolrCLI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasHelpArg) {
|
if (!hasHelpArg) {
|
||||||
System.err.println("Failed to parse command-line arguments due to: "
|
CLIO.err("Failed to parse command-line arguments due to: "
|
||||||
+ exp.getMessage());
|
+ exp.getMessage());
|
||||||
}
|
}
|
||||||
HelpFormatter formatter = new HelpFormatter();
|
HelpFormatter formatter = new HelpFormatter();
|
||||||
|
@ -857,7 +857,7 @@ public class SolrCLI {
|
||||||
static final String COLL_REDACTION_PREFIX = "COLL_";
|
static final String COLL_REDACTION_PREFIX = "COLL_";
|
||||||
|
|
||||||
public AutoscalingTool() {
|
public AutoscalingTool() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoscalingTool(PrintStream stdout) {
|
public AutoscalingTool(PrintStream stdout) {
|
||||||
|
@ -1138,7 +1138,7 @@ public class SolrCLI {
|
||||||
*/
|
*/
|
||||||
public static class StatusTool extends ToolBase {
|
public static class StatusTool extends ToolBase {
|
||||||
|
|
||||||
public StatusTool() { this(System.out); }
|
public StatusTool() { this(CLIO.getOutStream()); }
|
||||||
public StatusTool(PrintStream stdout) { super(stdout); }
|
public StatusTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -1186,7 +1186,7 @@ public class SolrCLI {
|
||||||
}
|
}
|
||||||
if (checkCommunicationError(exc)) {
|
if (checkCommunicationError(exc)) {
|
||||||
// this is not actually an error from the tool as it's ok if Solr is not online.
|
// this is not actually an error from the tool as it's ok if Solr is not online.
|
||||||
System.err.println("Solr at "+solrUrl+" not online.");
|
CLIO.err("Solr at "+solrUrl+" not online.");
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Failed to get system information from " + solrUrl + " due to: "+exc);
|
throw new Exception("Failed to get system information from " + solrUrl + " due to: "+exc);
|
||||||
}
|
}
|
||||||
|
@ -1288,7 +1288,7 @@ public class SolrCLI {
|
||||||
*/
|
*/
|
||||||
public static class ApiTool extends ToolBase {
|
public static class ApiTool extends ToolBase {
|
||||||
|
|
||||||
public ApiTool() { this(System.out); }
|
public ApiTool() { this(CLIO.getOutStream()); }
|
||||||
public ApiTool(PrintStream stdout) { super(stdout); }
|
public ApiTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -1474,7 +1474,7 @@ public class SolrCLI {
|
||||||
*/
|
*/
|
||||||
public static class HealthcheckTool extends SolrCloudTool {
|
public static class HealthcheckTool extends SolrCloudTool {
|
||||||
|
|
||||||
public HealthcheckTool() { this(System.out); }
|
public HealthcheckTool() { this(CLIO.getOutStream()); }
|
||||||
public HealthcheckTool(PrintStream stdout) { super(stdout); }
|
public HealthcheckTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1776,7 +1776,7 @@ public class SolrCLI {
|
||||||
public static class CreateCollectionTool extends ToolBase {
|
public static class CreateCollectionTool extends ToolBase {
|
||||||
|
|
||||||
public CreateCollectionTool() {
|
public CreateCollectionTool() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateCollectionTool(PrintStream stdout) {
|
public CreateCollectionTool(PrintStream stdout) {
|
||||||
|
@ -1909,7 +1909,7 @@ public class SolrCLI {
|
||||||
|
|
||||||
public static class CreateCoreTool extends ToolBase {
|
public static class CreateCoreTool extends ToolBase {
|
||||||
|
|
||||||
public CreateCoreTool() { this(System.out); }
|
public CreateCoreTool() { this(CLIO.getOutStream()); }
|
||||||
public CreateCoreTool(PrintStream stdout) { super(stdout); }
|
public CreateCoreTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -2049,7 +2049,7 @@ public class SolrCLI {
|
||||||
|
|
||||||
public static class CreateTool extends ToolBase {
|
public static class CreateTool extends ToolBase {
|
||||||
|
|
||||||
public CreateTool() { this(System.out); }
|
public CreateTool() { this(CLIO.getOutStream()); }
|
||||||
public CreateTool(PrintStream stdout) { super(stdout); }
|
public CreateTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -2089,7 +2089,7 @@ public class SolrCLI {
|
||||||
public static class ConfigSetUploadTool extends ToolBase {
|
public static class ConfigSetUploadTool extends ToolBase {
|
||||||
|
|
||||||
public ConfigSetUploadTool() {
|
public ConfigSetUploadTool() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigSetUploadTool(PrintStream stdout) {
|
public ConfigSetUploadTool(PrintStream stdout) {
|
||||||
|
@ -2162,7 +2162,7 @@ public class SolrCLI {
|
||||||
public static class ConfigSetDownloadTool extends ToolBase {
|
public static class ConfigSetDownloadTool extends ToolBase {
|
||||||
|
|
||||||
public ConfigSetDownloadTool() {
|
public ConfigSetDownloadTool() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigSetDownloadTool(PrintStream stdout) {
|
public ConfigSetDownloadTool(PrintStream stdout) {
|
||||||
|
@ -2238,7 +2238,7 @@ public class SolrCLI {
|
||||||
public static class ZkRmTool extends ToolBase {
|
public static class ZkRmTool extends ToolBase {
|
||||||
|
|
||||||
public ZkRmTool() {
|
public ZkRmTool() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZkRmTool(PrintStream stdout) {
|
public ZkRmTool(PrintStream stdout) {
|
||||||
|
@ -2315,7 +2315,7 @@ public class SolrCLI {
|
||||||
public static class ZkLsTool extends ToolBase {
|
public static class ZkLsTool extends ToolBase {
|
||||||
|
|
||||||
public ZkLsTool() {
|
public ZkLsTool() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZkLsTool(PrintStream stdout) {
|
public ZkLsTool(PrintStream stdout) {
|
||||||
|
@ -2383,7 +2383,7 @@ public class SolrCLI {
|
||||||
public static class ZkMkrootTool extends ToolBase {
|
public static class ZkMkrootTool extends ToolBase {
|
||||||
|
|
||||||
public ZkMkrootTool() {
|
public ZkMkrootTool() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZkMkrootTool(PrintStream stdout) {
|
public ZkMkrootTool(PrintStream stdout) {
|
||||||
|
@ -2445,7 +2445,7 @@ public class SolrCLI {
|
||||||
public static class ZkCpTool extends ToolBase {
|
public static class ZkCpTool extends ToolBase {
|
||||||
|
|
||||||
public ZkCpTool() {
|
public ZkCpTool() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZkCpTool(PrintStream stdout) {
|
public ZkCpTool(PrintStream stdout) {
|
||||||
|
@ -2535,7 +2535,7 @@ public class SolrCLI {
|
||||||
public static class ZkMvTool extends ToolBase {
|
public static class ZkMvTool extends ToolBase {
|
||||||
|
|
||||||
public ZkMvTool() {
|
public ZkMvTool() {
|
||||||
this(System.out);
|
this(CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZkMvTool(PrintStream stdout) {
|
public ZkMvTool(PrintStream stdout) {
|
||||||
|
@ -2615,7 +2615,7 @@ public class SolrCLI {
|
||||||
|
|
||||||
public static class DeleteTool extends ToolBase {
|
public static class DeleteTool extends ToolBase {
|
||||||
|
|
||||||
public DeleteTool() { this(System.out); }
|
public DeleteTool() { this(CLIO.getOutStream()); }
|
||||||
public DeleteTool(PrintStream stdout) { super(stdout); }
|
public DeleteTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -2797,7 +2797,7 @@ public class SolrCLI {
|
||||||
*/
|
*/
|
||||||
public static class ConfigTool extends ToolBase {
|
public static class ConfigTool extends ToolBase {
|
||||||
|
|
||||||
public ConfigTool() { this(System.out); }
|
public ConfigTool() { this(CLIO.getOutStream()); }
|
||||||
public ConfigTool(PrintStream stdout) { super(stdout); }
|
public ConfigTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -2932,7 +2932,7 @@ public class SolrCLI {
|
||||||
* Default constructor used by the framework when running as a command-line application.
|
* Default constructor used by the framework when running as a command-line application.
|
||||||
*/
|
*/
|
||||||
public RunExampleTool() {
|
public RunExampleTool() {
|
||||||
this(null, System.in, System.out);
|
this(null, System.in, CLIO.getOutStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public RunExampleTool(Executor executor, InputStream userInput, PrintStream stdout) {
|
public RunExampleTool(Executor executor, InputStream userInput, PrintStream stdout) {
|
||||||
|
@ -3286,7 +3286,7 @@ public class SolrCLI {
|
||||||
try {
|
try {
|
||||||
configTool.runTool(processCommandLineArgs(joinCommonAndToolOptions(configTool.getOptions()), configArgs));
|
configTool.runTool(processCommandLineArgs(joinCommonAndToolOptions(configTool.getOptions()), configArgs));
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
System.err.println("Failed to update '"+propName+"' property due to: "+exc);
|
CLIO.err("Failed to update '"+propName+"' property due to: "+exc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3316,7 +3316,7 @@ public class SolrCLI {
|
||||||
" seconds! Please check the solr.log for each node to look for errors.\n");
|
" seconds! Please check the solr.log for each node to look for errors.\n");
|
||||||
}
|
}
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
System.err.println("Failed to see if "+numNodes+" joined the SolrCloud cluster due to: "+exc);
|
CLIO.err("Failed to see if "+numNodes+" joined the SolrCloud cluster due to: "+exc);
|
||||||
} finally {
|
} finally {
|
||||||
if (cloudClient != null) {
|
if (cloudClient != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -3702,7 +3702,7 @@ public class SolrCLI {
|
||||||
private static boolean useExitCode = false;
|
private static boolean useExitCode = false;
|
||||||
private static Optional<Long> timeoutMs = Optional.empty();
|
private static Optional<Long> timeoutMs = Optional.empty();
|
||||||
|
|
||||||
public AssertTool() { this(System.out); }
|
public AssertTool() { this(CLIO.getOutStream()); }
|
||||||
public AssertTool(PrintStream stdout) { super(stdout); }
|
public AssertTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -3792,7 +3792,7 @@ public class SolrCLI {
|
||||||
// since this is a CLI, spare the user the stacktrace
|
// since this is a CLI, spare the user the stacktrace
|
||||||
String excMsg = exc.getMessage();
|
String excMsg = exc.getMessage();
|
||||||
if (excMsg != null) {
|
if (excMsg != null) {
|
||||||
System.err.println("\nERROR: " + excMsg + "\n");
|
CLIO.err("\nERROR: " + excMsg + "\n");
|
||||||
toolExitStatus = 100; // Exit >= 100 means error, else means number of tests that failed
|
toolExitStatus = 100; // Exit >= 100 means error, else means number of tests that failed
|
||||||
} else {
|
} else {
|
||||||
throw exc;
|
throw exc;
|
||||||
|
@ -4019,7 +4019,7 @@ public class SolrCLI {
|
||||||
|
|
||||||
// Authentication tool
|
// Authentication tool
|
||||||
public static class AuthTool extends ToolBase {
|
public static class AuthTool extends ToolBase {
|
||||||
public AuthTool() { this(System.out); }
|
public AuthTool() { this(CLIO.getOutStream()); }
|
||||||
public AuthTool(PrintStream stdout) { super(stdout); }
|
public AuthTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -4119,7 +4119,7 @@ public class SolrCLI {
|
||||||
case "kerberos":
|
case "kerberos":
|
||||||
return handleKerberos(cli);
|
return handleKerberos(cli);
|
||||||
default:
|
default:
|
||||||
System.out.println("Only type=basicAuth or kerberos supported at the moment.");
|
CLIO.out("Only type=basicAuth or kerberos supported at the moment.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -4144,13 +4144,13 @@ public class SolrCLI {
|
||||||
try {
|
try {
|
||||||
zkHost = getZkHost(cli);
|
zkHost = getZkHost(cli);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Unable to access ZooKeeper. Please add the following security.json to ZooKeeper (in case of SolrCloud):\n"
|
CLIO.out("Unable to access ZooKeeper. Please add the following security.json to ZooKeeper (in case of SolrCloud):\n"
|
||||||
+ securityJson + "\n");
|
+ securityJson + "\n");
|
||||||
zkInaccessible = true;
|
zkInaccessible = true;
|
||||||
}
|
}
|
||||||
if (zkHost == null) {
|
if (zkHost == null) {
|
||||||
if (zkInaccessible == false) {
|
if (zkInaccessible == false) {
|
||||||
System.out.println("Unable to access ZooKeeper. Please add the following security.json to ZooKeeper (in case of SolrCloud):\n"
|
CLIO.out("Unable to access ZooKeeper. Please add the following security.json to ZooKeeper (in case of SolrCloud):\n"
|
||||||
+ securityJson + "\n");
|
+ securityJson + "\n");
|
||||||
zkInaccessible = true;
|
zkInaccessible = true;
|
||||||
}
|
}
|
||||||
|
@ -4162,14 +4162,14 @@ public class SolrCLI {
|
||||||
if (zkClient.exists("/security.json", true)) {
|
if (zkClient.exists("/security.json", true)) {
|
||||||
byte oldSecurityBytes[] = zkClient.getData("/security.json", null, null, true);
|
byte oldSecurityBytes[] = zkClient.getData("/security.json", null, null, true);
|
||||||
if (!"{}".equals(new String(oldSecurityBytes, StandardCharsets.UTF_8).trim())) {
|
if (!"{}".equals(new String(oldSecurityBytes, StandardCharsets.UTF_8).trim())) {
|
||||||
System.out.println("Security is already enabled. You can disable it with 'bin/solr auth disable'. Existing security.json: \n"
|
CLIO.out("Security is already enabled. You can disable it with 'bin/solr auth disable'. Existing security.json: \n"
|
||||||
+ new String(oldSecurityBytes, StandardCharsets.UTF_8));
|
+ new String(oldSecurityBytes, StandardCharsets.UTF_8));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (zkInaccessible == false) {
|
if (zkInaccessible == false) {
|
||||||
System.out.println("Unable to access ZooKeeper. Please add the following security.json to ZooKeeper (in case of SolrCloud):\n"
|
CLIO.out("Unable to access ZooKeeper. Please add the following security.json to ZooKeeper (in case of SolrCloud):\n"
|
||||||
+ securityJson + "\n");
|
+ securityJson + "\n");
|
||||||
zkInaccessible = true;
|
zkInaccessible = true;
|
||||||
}
|
}
|
||||||
|
@ -4184,7 +4184,7 @@ public class SolrCLI {
|
||||||
zkClient.setData("/security.json", securityJson.getBytes(StandardCharsets.UTF_8), true);
|
zkClient.setData("/security.json", securityJson.getBytes(StandardCharsets.UTF_8), true);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (zkInaccessible == false) {
|
if (zkInaccessible == false) {
|
||||||
System.out.println("Unable to access ZooKeeper. Please add the following security.json to ZooKeeper (in case of SolrCloud):\n"
|
CLIO.out("Unable to access ZooKeeper. Please add the following security.json to ZooKeeper (in case of SolrCloud):\n"
|
||||||
+ securityJson);
|
+ securityJson);
|
||||||
zkInaccessible = true;
|
zkInaccessible = true;
|
||||||
}
|
}
|
||||||
|
@ -4201,7 +4201,7 @@ public class SolrCLI {
|
||||||
String solrIncludeFilename = cli.getOptionValue("solrIncludeFile");
|
String solrIncludeFilename = cli.getOptionValue("solrIncludeFile");
|
||||||
File includeFile = new File(solrIncludeFilename);
|
File includeFile = new File(solrIncludeFilename);
|
||||||
if (includeFile.exists() == false || includeFile.canWrite() == false) {
|
if (includeFile.exists() == false || includeFile.canWrite() == false) {
|
||||||
System.out.println("Solr include file " + solrIncludeFilename + " doesn't exist or is not writeable.");
|
CLIO.out("Solr include file " + solrIncludeFilename + " doesn't exist or is not writeable.");
|
||||||
printAuthEnablingInstructions(config);
|
printAuthEnablingInstructions(config);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
@ -4229,8 +4229,8 @@ public class SolrCLI {
|
||||||
solrIncludeFilename = cli.getOptionValue("solrIncludeFile");
|
solrIncludeFilename = cli.getOptionValue("solrIncludeFile");
|
||||||
includeFile = new File(solrIncludeFilename);
|
includeFile = new File(solrIncludeFilename);
|
||||||
if (!includeFile.exists() || !includeFile.canWrite()) {
|
if (!includeFile.exists() || !includeFile.canWrite()) {
|
||||||
System.out.println("Solr include file " + solrIncludeFilename + " doesn't exist or is not writeable.");
|
CLIO.out("Solr include file " + solrIncludeFilename + " doesn't exist or is not writeable.");
|
||||||
System.out.println("Security has been disabled. Please remove any SOLR_AUTH_TYPE or SOLR_AUTHENTICATION_OPTS configuration from solr.in.sh/solr.in.cmd.\n");
|
CLIO.out("Security has been disabled. Please remove any SOLR_AUTH_TYPE or SOLR_AUTHENTICATION_OPTS configuration from solr.in.sh/solr.in.cmd.\n");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4239,11 +4239,11 @@ public class SolrCLI {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
System.out.println("Valid auth commands are: enable, disable");
|
CLIO.out("Valid auth commands are: enable, disable");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Options not understood.");
|
CLIO.out("Options not understood.");
|
||||||
new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this));
|
new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -4254,11 +4254,11 @@ public class SolrCLI {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case "enable":
|
case "enable":
|
||||||
if (!prompt && !cli.hasOption("credentials")) {
|
if (!prompt && !cli.hasOption("credentials")) {
|
||||||
System.out.println("Option -credentials or -prompt is required with enable.");
|
CLIO.out("Option -credentials or -prompt is required with enable.");
|
||||||
new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this));
|
new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this));
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (!prompt && (cli.getOptionValue("credentials") == null || !cli.getOptionValue("credentials").contains(":"))) {
|
} else if (!prompt && (cli.getOptionValue("credentials") == null || !cli.getOptionValue("credentials").contains(":"))) {
|
||||||
System.out.println("Option -credentials is not in correct format.");
|
CLIO.out("Option -credentials is not in correct format.");
|
||||||
new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this));
|
new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -4270,17 +4270,17 @@ public class SolrCLI {
|
||||||
zkHost = getZkHost(cli);
|
zkHost = getZkHost(cli);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (cli.hasOption("zkHost")) {
|
if (cli.hasOption("zkHost")) {
|
||||||
System.out.println("Couldn't get ZooKeeper host. Please make sure that ZooKeeper is running and the correct zkHost has been passed in.");
|
CLIO.out("Couldn't get ZooKeeper host. Please make sure that ZooKeeper is running and the correct zkHost has been passed in.");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Couldn't get ZooKeeper host. Please make sure Solr is running in cloud mode, or a zkHost has been passed in.");
|
CLIO.out("Couldn't get ZooKeeper host. Please make sure Solr is running in cloud mode, or a zkHost has been passed in.");
|
||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (zkHost == null) {
|
if (zkHost == null) {
|
||||||
if (cli.hasOption("zkHost")) {
|
if (cli.hasOption("zkHost")) {
|
||||||
System.out.println("Couldn't get ZooKeeper host. Please make sure that ZooKeeper is running and the correct zkHost has been passed in.");
|
CLIO.out("Couldn't get ZooKeeper host. Please make sure that ZooKeeper is running and the correct zkHost has been passed in.");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Couldn't get ZooKeeper host. Please make sure Solr is running in cloud mode, or a zkHost has been passed in.");
|
CLIO.out("Couldn't get ZooKeeper host. Please make sure Solr is running in cloud mode, or a zkHost has been passed in.");
|
||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -4290,7 +4290,7 @@ public class SolrCLI {
|
||||||
if (zkClient.exists("/security.json", true)) {
|
if (zkClient.exists("/security.json", true)) {
|
||||||
byte oldSecurityBytes[] = zkClient.getData("/security.json", null, null, true);
|
byte oldSecurityBytes[] = zkClient.getData("/security.json", null, null, true);
|
||||||
if (!"{}".equals(new String(oldSecurityBytes, StandardCharsets.UTF_8).trim())) {
|
if (!"{}".equals(new String(oldSecurityBytes, StandardCharsets.UTF_8).trim())) {
|
||||||
System.out.println("Security is already enabled. You can disable it with 'bin/solr auth disable'. Existing security.json: \n"
|
CLIO.out("Security is already enabled. You can disable it with 'bin/solr auth disable'. Existing security.json: \n"
|
||||||
+ new String(oldSecurityBytes, StandardCharsets.UTF_8));
|
+ new String(oldSecurityBytes, StandardCharsets.UTF_8));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -4338,7 +4338,7 @@ public class SolrCLI {
|
||||||
String solrIncludeFilename = cli.getOptionValue("solrIncludeFile");
|
String solrIncludeFilename = cli.getOptionValue("solrIncludeFile");
|
||||||
File includeFile = new File(solrIncludeFilename);
|
File includeFile = new File(solrIncludeFilename);
|
||||||
if (includeFile.exists() == false || includeFile.canWrite() == false) {
|
if (includeFile.exists() == false || includeFile.canWrite() == false) {
|
||||||
System.out.println("Solr include file " + solrIncludeFilename + " doesn't exist or is not writeable.");
|
CLIO.out("Solr include file " + solrIncludeFilename + " doesn't exist or is not writeable.");
|
||||||
printAuthEnablingInstructions(username, password);
|
printAuthEnablingInstructions(username, password);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
@ -4346,7 +4346,7 @@ public class SolrCLI {
|
||||||
File basicAuthConfFile = new File(authConfDir + File.separator + "basicAuth.conf");
|
File basicAuthConfFile = new File(authConfDir + File.separator + "basicAuth.conf");
|
||||||
|
|
||||||
if (basicAuthConfFile.getParentFile().canWrite() == false) {
|
if (basicAuthConfFile.getParentFile().canWrite() == false) {
|
||||||
System.out.println("Cannot write to file: " + basicAuthConfFile.getAbsolutePath());
|
CLIO.out("Cannot write to file: " + basicAuthConfFile.getAbsolutePath());
|
||||||
printAuthEnablingInstructions(username, password);
|
printAuthEnablingInstructions(username, password);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
@ -4379,8 +4379,8 @@ public class SolrCLI {
|
||||||
solrIncludeFilename = cli.getOptionValue("solrIncludeFile");
|
solrIncludeFilename = cli.getOptionValue("solrIncludeFile");
|
||||||
includeFile = new File(solrIncludeFilename);
|
includeFile = new File(solrIncludeFilename);
|
||||||
if (!includeFile.exists() || !includeFile.canWrite()) {
|
if (!includeFile.exists() || !includeFile.canWrite()) {
|
||||||
System.out.println("Solr include file " + solrIncludeFilename + " doesn't exist or is not writeable.");
|
CLIO.out("Solr include file " + solrIncludeFilename + " doesn't exist or is not writeable.");
|
||||||
System.out.println("Security has been disabled. Please remove any SOLR_AUTH_TYPE or SOLR_AUTHENTICATION_OPTS configuration from solr.in.sh/solr.in.cmd.\n");
|
CLIO.out("Security has been disabled. Please remove any SOLR_AUTH_TYPE or SOLR_AUTHENTICATION_OPTS configuration from solr.in.sh/solr.in.cmd.\n");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4389,33 +4389,33 @@ public class SolrCLI {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
System.out.println("Valid auth commands are: enable, disable");
|
CLIO.out("Valid auth commands are: enable, disable");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Options not understood.");
|
CLIO.out("Options not understood.");
|
||||||
new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this));
|
new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
private void printAuthEnablingInstructions(String username, String password) {
|
private void printAuthEnablingInstructions(String username, String password) {
|
||||||
if (SystemUtils.IS_OS_WINDOWS) {
|
if (SystemUtils.IS_OS_WINDOWS) {
|
||||||
System.out.println("\nAdd the following lines to the solr.in.cmd file so that the solr.cmd script can use subsequently.\n");
|
CLIO.out("\nAdd the following lines to the solr.in.cmd file so that the solr.cmd script can use subsequently.\n");
|
||||||
System.out.println("set SOLR_AUTH_TYPE=basic\n"
|
CLIO.out("set SOLR_AUTH_TYPE=basic\n"
|
||||||
+ "set SOLR_AUTHENTICATION_OPTS=\"-Dbasicauth=" + username + ":" + password + "\"\n");
|
+ "set SOLR_AUTHENTICATION_OPTS=\"-Dbasicauth=" + username + ":" + password + "\"\n");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("\nAdd the following lines to the solr.in.sh file so that the ./solr script can use subsequently.\n");
|
CLIO.out("\nAdd the following lines to the solr.in.sh file so that the ./solr script can use subsequently.\n");
|
||||||
System.out.println("SOLR_AUTH_TYPE=\"basic\"\n"
|
CLIO.out("SOLR_AUTH_TYPE=\"basic\"\n"
|
||||||
+ "SOLR_AUTHENTICATION_OPTS=\"-Dbasicauth=" + username + ":" + password + "\"\n");
|
+ "SOLR_AUTHENTICATION_OPTS=\"-Dbasicauth=" + username + ":" + password + "\"\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void printAuthEnablingInstructions(String kerberosConfig) {
|
private void printAuthEnablingInstructions(String kerberosConfig) {
|
||||||
if (SystemUtils.IS_OS_WINDOWS) {
|
if (SystemUtils.IS_OS_WINDOWS) {
|
||||||
System.out.println("\nAdd the following lines to the solr.in.cmd file so that the solr.cmd script can use subsequently.\n");
|
CLIO.out("\nAdd the following lines to the solr.in.cmd file so that the solr.cmd script can use subsequently.\n");
|
||||||
System.out.println("set SOLR_AUTH_TYPE=kerberos\n"
|
CLIO.out("set SOLR_AUTH_TYPE=kerberos\n"
|
||||||
+ "set SOLR_AUTHENTICATION_OPTS=\"" + kerberosConfig + "\"\n");
|
+ "set SOLR_AUTHENTICATION_OPTS=\"" + kerberosConfig + "\"\n");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("\nAdd the following lines to the solr.in.sh file so that the ./solr script can use subsequently.\n");
|
CLIO.out("\nAdd the following lines to the solr.in.sh file so that the ./solr script can use subsequently.\n");
|
||||||
System.out.println("SOLR_AUTH_TYPE=\"kerberos\"\n"
|
CLIO.out("SOLR_AUTH_TYPE=\"kerberos\"\n"
|
||||||
+ "SOLR_AUTHENTICATION_OPTS=\"" + kerberosConfig + "\"\n");
|
+ "SOLR_AUTHENTICATION_OPTS=\"" + kerberosConfig + "\"\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4499,7 +4499,7 @@ public class SolrCLI {
|
||||||
private Path logsPath;
|
private Path logsPath;
|
||||||
private boolean beQuiet;
|
private boolean beQuiet;
|
||||||
|
|
||||||
public UtilsTool() { this(System.out); }
|
public UtilsTool() { this(CLIO.getOutStream()); }
|
||||||
public UtilsTool(PrintStream stdout) { super(stdout); }
|
public UtilsTool(PrintStream stdout) { super(stdout); }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class CleanupOldIndexTest extends SolrCloudTestCase {
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
|
|
||||||
if (suiteFailureMarker.wasSuccessful()) {
|
if (suiteFailureMarker.wasSuccessful()) {
|
||||||
zkClient().printLayoutToStdOut();
|
zkClient().printLayoutToStream(System.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class LeaderElectionIntegrationTest extends SolrCloudTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jetty == getRunner(leader)) {
|
if (jetty == getRunner(leader)) {
|
||||||
cluster.getZkClient().printLayoutToStdOut();
|
cluster.getZkClient().printLayoutToStream(System.out);
|
||||||
fail("We didn't find a new leader! " + jetty + " was close, but it's still showing as the leader");
|
fail("We didn't find a new leader! " + jetty + " was close, but it's still showing as the leader");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zkClient.printLayoutToStdOut();
|
zkClient.printLayoutToStream(System.out);
|
||||||
throw new RuntimeException("Could not get leader props for " + collection + " " + slice);
|
throw new RuntimeException("Could not get leader props for " + collection + " " + slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,6 +547,6 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printLayout() throws Exception {
|
private void printLayout() throws Exception {
|
||||||
zkClient.printLayoutToStdOut();
|
zkClient.printLayoutToStream(System.out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,7 +305,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
if (null != zkClient) {
|
if (null != zkClient) {
|
||||||
zkClient.printLayoutToStdOut();
|
zkClient.printLayoutToStream(System.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.clearProperty("solr.zkclienttimeout");
|
System.clearProperty("solr.zkclienttimeout");
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class RollingRestartTest extends AbstractFullDistribZkTestBase {
|
||||||
assertNotNull(leader);
|
assertNotNull(leader);
|
||||||
log.info("Current overseer leader = {}", leader);
|
log.info("Current overseer leader = {}", leader);
|
||||||
|
|
||||||
cloudClient.getZkStateReader().getZkClient().printLayoutToStdOut();
|
cloudClient.getZkStateReader().getZkClient().printLayoutToStream(System.out);
|
||||||
|
|
||||||
int numDesignateOverseers = TEST_NIGHTLY ? 16 : 2;
|
int numDesignateOverseers = TEST_NIGHTLY ? 16 : 2;
|
||||||
numDesignateOverseers = Math.max(getShardCount(), numDesignateOverseers);
|
numDesignateOverseers = Math.max(getShardCount(), numDesignateOverseers);
|
||||||
|
@ -78,7 +78,7 @@ public class RollingRestartTest extends AbstractFullDistribZkTestBase {
|
||||||
|
|
||||||
waitUntilOverseerDesignateIsLeader(cloudClient.getZkStateReader().getZkClient(), designates, MAX_WAIT_TIME);
|
waitUntilOverseerDesignateIsLeader(cloudClient.getZkStateReader().getZkClient(), designates, MAX_WAIT_TIME);
|
||||||
|
|
||||||
cloudClient.getZkStateReader().getZkClient().printLayoutToStdOut();
|
cloudClient.getZkStateReader().getZkClient().printLayoutToStream(System.out);
|
||||||
|
|
||||||
boolean sawLiveDesignate = false;
|
boolean sawLiveDesignate = false;
|
||||||
int numRestarts = 1 + random().nextInt(TEST_NIGHTLY ? 12 : 2);
|
int numRestarts = 1 + random().nextInt(TEST_NIGHTLY ? 12 : 2);
|
||||||
|
@ -124,7 +124,7 @@ public class RollingRestartTest extends AbstractFullDistribZkTestBase {
|
||||||
assertNotNull(leader);
|
assertNotNull(leader);
|
||||||
log.info("Current overseer leader (after restart) = {}", leader);
|
log.info("Current overseer leader (after restart) = {}", leader);
|
||||||
|
|
||||||
cloudClient.getZkStateReader().getZkClient().printLayoutToStdOut();
|
cloudClient.getZkStateReader().getZkClient().printLayoutToStream(System.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean waitUntilOverseerDesignateIsLeader(SolrZkClient testZkClient, List<String> overseerDesignates, long timeoutInNanos) throws KeeperException, InterruptedException {
|
static boolean waitUntilOverseerDesignateIsLeader(SolrZkClient testZkClient, List<String> overseerDesignates, long timeoutInNanos) throws KeeperException, InterruptedException {
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class TestPullReplica extends SolrCloudTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
zkClient().printLayoutToStdOut();
|
zkClient().printLayoutToStream(System.out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ public class TestPullReplica extends SolrCloudTestCase {
|
||||||
});
|
});
|
||||||
CollectionAdminRequest.addReplicaToShard(collectionName, "shard1", Replica.Type.PULL).process(cluster.getSolrClient());
|
CollectionAdminRequest.addReplicaToShard(collectionName, "shard1", Replica.Type.PULL).process(cluster.getSolrClient());
|
||||||
waitForState("Replica not added", collectionName, activeReplicaCount(1, 0, 1));
|
waitForState("Replica not added", collectionName, activeReplicaCount(1, 0, 1));
|
||||||
zkClient().printLayoutToStdOut();
|
zkClient().printLayoutToStream(System.out);
|
||||||
log.info("Saw states: " + Arrays.toString(statesSeen.toArray()));
|
log.info("Saw states: " + Arrays.toString(statesSeen.toArray()));
|
||||||
assertEquals("Expecting DOWN->RECOVERING->ACTIVE but saw: " + Arrays.toString(statesSeen.toArray()), 3, statesSeen.size());
|
assertEquals("Expecting DOWN->RECOVERING->ACTIVE but saw: " + Arrays.toString(statesSeen.toArray()), 3, statesSeen.size());
|
||||||
assertEquals("Expecting DOWN->RECOVERING->ACTIVE but saw: " + Arrays.toString(statesSeen.toArray()), Replica.State.DOWN, statesSeen.get(0));
|
assertEquals("Expecting DOWN->RECOVERING->ACTIVE but saw: " + Arrays.toString(statesSeen.toArray()), Replica.State.DOWN, statesSeen.get(0));
|
||||||
|
|
|
@ -222,7 +222,7 @@ public class TestTlogReplica extends SolrCloudTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
zkClient().printLayoutToStdOut();
|
zkClient().printLayoutToStream(System.out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -388,7 +388,7 @@ public class ZkCLITest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
private void printLayout(String zkHost) throws Exception {
|
private void printLayout(String zkHost) throws Exception {
|
||||||
SolrZkClient zkClient = new SolrZkClient(zkHost, AbstractZkTestCase.TIMEOUT);
|
SolrZkClient zkClient = new SolrZkClient(zkHost, AbstractZkTestCase.TIMEOUT);
|
||||||
zkClient.printLayoutToStdOut();
|
zkClient.printLayoutToStream(System.out);
|
||||||
zkClient.close();
|
zkClient.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,15 +407,11 @@ public class SocketProxy {
|
||||||
private URI target;
|
private URI target;
|
||||||
private AtomicReference<CountDownLatch> pause = new AtomicReference<CountDownLatch>();
|
private AtomicReference<CountDownLatch> pause = new AtomicReference<CountDownLatch>();
|
||||||
|
|
||||||
public Acceptor(ServerSocket serverSocket, URI uri) {
|
public Acceptor(ServerSocket serverSocket, URI uri) throws SocketException {
|
||||||
socket = serverSocket;
|
socket = serverSocket;
|
||||||
target = uri;
|
target = uri;
|
||||||
pause.set(new CountDownLatch(0));
|
pause.set(new CountDownLatch(0));
|
||||||
try {
|
|
||||||
socket.setSoTimeout(ACCEPT_TIMEOUT_MILLIS);
|
socket.setSoTimeout(ACCEPT_TIMEOUT_MILLIS);
|
||||||
} catch (SocketException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause() {
|
public void pause() {
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class XMLResponseParser extends ResponseParser
|
||||||
return new Date(Instant.parse(txt).toEpochMilli());
|
return new Date(Instant.parse(txt).toEpochMilli());
|
||||||
}
|
}
|
||||||
catch( Exception ex ) {
|
catch( Exception ex ) {
|
||||||
ex.printStackTrace();
|
log.info(ex.getMessage(),ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -453,8 +453,6 @@ public class XMLResponseParser extends ResponseParser
|
||||||
doc.addField( name, readNamedList( parser ) );
|
doc.addField( name, readNamedList( parser ) );
|
||||||
depth--;
|
depth--;
|
||||||
} else if( !type.isLeaf ) {
|
} else if( !type.isLeaf ) {
|
||||||
System.out.println("nbot leaf!:" + type);
|
|
||||||
|
|
||||||
throw new XMLStreamException( "must be value or array", parser.getLocation() );
|
throw new XMLStreamException( "must be value or array", parser.getLocation() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -239,7 +239,6 @@ public class ZplotStream extends TupleStream implements Expressible {
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
values.add((Long)it.next());
|
values.add((Long)it.next());
|
||||||
}
|
}
|
||||||
System.out.println(values);
|
|
||||||
int[] x = new int[values.size()];
|
int[] x = new int[values.size()];
|
||||||
double[] y = new double[values.size()];
|
double[] y = new double[values.size()];
|
||||||
for(int i=0; i<values.size(); i++) {
|
for(int i=0; i<values.size(); i++) {
|
||||||
|
|
|
@ -17,10 +17,13 @@
|
||||||
|
|
||||||
package org.apache.solr.client.solrj.response.json;
|
package org.apache.solr.client.solrj.response.json;
|
||||||
|
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the result of a "heatmap" JSON facet.
|
* Represents the result of a "heatmap" JSON facet.
|
||||||
|
@ -29,6 +32,8 @@ import org.apache.solr.common.util.NamedList;
|
||||||
* itself in one of two forms.
|
* itself in one of two forms.
|
||||||
*/
|
*/
|
||||||
public class HeatmapJsonFacet {
|
public class HeatmapJsonFacet {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
|
|
||||||
private int gridLevel;
|
private int gridLevel;
|
||||||
private int columns;
|
private int columns;
|
||||||
private int rows;
|
private int rows;
|
||||||
|
@ -47,9 +52,9 @@ public class HeatmapJsonFacet {
|
||||||
maxX = (double) heatmapNL.get("maxX");
|
maxX = (double) heatmapNL.get("maxX");
|
||||||
minY = (double) heatmapNL.get("minY");
|
minY = (double) heatmapNL.get("minY");
|
||||||
maxY = (double) heatmapNL.get("maxY");
|
maxY = (double) heatmapNL.get("maxY");
|
||||||
System.out.println("Rows is: " + rows);
|
log.debug("Rows is: {}", rows);
|
||||||
System.out.println("Cols is " + columns);
|
log.debug("Cols is {}", columns);
|
||||||
System.out.println("Whole deal is: " + heatmapNL);
|
log.debug("Whole deal is: {}", heatmapNL);
|
||||||
|
|
||||||
if (heatmapNL.get("counts_ints2D") == null) {
|
if (heatmapNL.get("counts_ints2D") == null) {
|
||||||
countEncodedAsBase64PNG = (String) heatmapNL.get("counts_png");
|
countEncodedAsBase64PNG = (String) heatmapNL.get("counts_png");
|
||||||
|
|
|
@ -647,13 +647,6 @@ public class SolrZkClient implements Closeable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints current ZooKeeper layout to stdout.
|
|
||||||
*/
|
|
||||||
public void printLayoutToStdOut() throws KeeperException,
|
|
||||||
InterruptedException {
|
|
||||||
printLayoutToStream(System.out);
|
|
||||||
}
|
|
||||||
public void printLayoutToStream(PrintStream out) throws KeeperException,
|
public void printLayoutToStream(PrintStream out) throws KeeperException,
|
||||||
InterruptedException {
|
InterruptedException {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
|
@ -776,15 +776,6 @@ public class FastJavaBinDecoder implements DataEntry.FastDecoder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
for (int i = 0; i < lower5BitTags.length; i++) {
|
|
||||||
Tag tag = lower5BitTags[i];
|
|
||||||
if (tag == null) continue;
|
|
||||||
System.out.println(tag.name() + " : " + tag.code + (tag.isLower5Bits ? " lower" : " upper"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static void addObj(DataEntry e) {
|
private static void addObj(DataEntry e) {
|
||||||
if (e.type().isContainer) {
|
if (e.type().isContainer) {
|
||||||
Object ctx = e.type() == DataEntry.Type.KEYVAL_ITER ?
|
Object ctx = e.type() == DataEntry.Type.KEYVAL_ITER ?
|
||||||
|
|
|
@ -116,5 +116,6 @@
|
||||||
</copy>
|
</copy>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="-check-forbidden-sysout"/>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes
|
||||||
});
|
});
|
||||||
} catch (TimeoutException | InterruptedException e) {
|
} catch (TimeoutException | InterruptedException e) {
|
||||||
Diagnostics.logThreadDumps("Gave up waiting for recovery to finish. THREAD DUMP:");
|
Diagnostics.logThreadDumps("Gave up waiting for recovery to finish. THREAD DUMP:");
|
||||||
zkStateReader.getZkClient().printLayoutToStdOut();
|
zkStateReader.getZkClient().printLayoutToStream(System.out);
|
||||||
fail("There are still nodes recoverying - waited for " + timeoutSeconds + " seconds");
|
fail("There are still nodes recoverying - waited for " + timeoutSeconds + " seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes
|
||||||
|
|
||||||
if (timeOut.hasTimedOut()) {
|
if (timeOut.hasTimedOut()) {
|
||||||
Diagnostics.logThreadDumps("Could not find new leader in specified timeout");
|
Diagnostics.logThreadDumps("Could not find new leader in specified timeout");
|
||||||
zkStateReader.getZkClient().printLayoutToStdOut();
|
zkStateReader.getZkClient().printLayoutToStream(System.out);
|
||||||
fail("Could not find new leader even after waiting for " + timeOut.timeElapsed(MILLISECONDS) + "ms");
|
fail("Could not find new leader even after waiting for " + timeOut.timeElapsed(MILLISECONDS) + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes
|
||||||
|
|
||||||
protected void printLayout() throws Exception {
|
protected void printLayout() throws Exception {
|
||||||
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT);
|
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT);
|
||||||
zkClient.printLayoutToStdOut();
|
zkClient.printLayoutToStream(System.out);
|
||||||
zkClient.close();
|
zkClient.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -861,7 +861,7 @@ public class ZkTestServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void printLayout() throws Exception {
|
protected void printLayout() throws Exception {
|
||||||
rootClient.printLayoutToStdOut();
|
rootClient.printLayoutToStream(System.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SolrZkClient getZkClient() {
|
public SolrZkClient getZkClient() {
|
||||||
|
|
Loading…
Reference in New Issue